1. 13 Feb, 2018 37 commits
  2. 12 Feb, 2018 3 commits
    • Robert Griesemer's avatar
      cmd/compile/internal/syntax: added test cases for recent fixes · 945872e5
      Robert Griesemer authored
      R=go1.11.
      
      Now that we have a syntax error test harness, we can add the
      proper tests for the recent parser fixes.
      
      For #20800.
      For #20789.
      For #23385.
      For #23434.
      
      A test for #20789 already exists in test/fixedbugs, but this
      is the better location for that test. But leaving the existing
      one where it is as well.
      
      Change-Id: I5937b9b63bafd1efab467a00344302e717976171
      Reviewed-on: https://go-review.googlesource.com/88336Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      945872e5
    • Robert Griesemer's avatar
      cmd/compile/internal/syntax: implement regression test harness for syntax errors · 52fcac3b
      Robert Griesemer authored
      R=go1.11
      
      Fixes #20800.
      
      Change-Id: Ifea273521d42a543a43da2f655ace7c295650e30
      Reviewed-on: https://go-review.googlesource.com/88335Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      52fcac3b
    • Robert Griesemer's avatar
      cmd/compile/internal/syntax: implement comment reporting in scanner · b8906889
      Robert Griesemer authored
      R=go1.11
      
      In order to collect comments in the AST and for error testing purposes,
      the scanner needs to not only recognize and skip comments, but also be
      able to report them if so desired. This change adds a mode flag to the
      scanner's init function which controls the scanner behavior around
      comments.
      
      In the common case where comments are not needed, there must be no
      significant overhead. Thus, comments are reported via a handler upcall
      rather than being returned as a _Comment token (which the parser would
      have to filter out with every scanner.next() call).
      
      Because the handlers for error messages, directives, and comments all
      look the same (they take a position and text), and because directives
      look like comments, and errors never start with a '/', this change
      simplifies the scanner's init call to only take one (error) handler
      instead of 2 or 3 different handlers with identical signature. It is
      trivial in the handler to determine if we have an error, directive,
      or general comment.
      
      Finally, because directives are comments, when reporting directives
      the full comment text is returned now rather than just the directive
      text. This simplifies the implementation and makes the scanner API
      more regular. Furthermore, it provides important information about
      the comment style used by a directive, which may matter eventually
      when we fully implement /*line file:line:col*/ directives.
      
      Change-Id: I2adbfcebecd615e4237ed3a832b6ceb9518bf09c
      Reviewed-on: https://go-review.googlesource.com/88215Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      b8906889