Is there a way to see where the Go lexer inserts semicolons?

42 Views Asked by At

In the Go spec, the section about semicolons says that semicolons are automatically inserted into the token stream if some rules are true.

When the input is broken into tokens, a semicolon is automatically inserted into the token stream immediately after a line's final token if that token is

an identifier
an integer, floating-point, imaginary, rune, or string literal
one of the keywords break, continue, fallthrough, or return
one of the operators and punctuation ++, --, ), ], or }

Is there a way to actually see what the code looks like after this step? Just curious how the lexing is done.

To me, it seems like semicolons would end up after if statements and functions?

package foo;

func bar() {
  a := 1;
  if a > 0 {
  };
};

I'd like to actually see what happens instead of guessing though.

0

There are 0 best solutions below