[antlr-interest] JavaScript grammar
Johannes Luber
jaluber at gmx.de
Mon Mar 31 06:12:29 PDT 2008
Patrick Hulsmeijer schrieb:
> Chris,
>
> For the semicolon insertion issue I’ve taken the following approach.
> The line terminators are left on the hidden channel. In the parser the
> semicolon (e.g. in statements) is defined as a rule. In this rule I scan
> the token stream for line terminators and promote the first encountered
> to the default channel. Line terminator are also an alternative in this
> rule. Something like this:
>
> semic:
> @init
> {
> int marker = input.mark();
> promoteEOL();
> }
> : SEMIC
> | EOL
> | RBRACE { input.rewind(marker); }
> | EOF
> ;
>
Can you elaborate more on the function promoteEOL()?
Johannes
More information about the antlr-interest
mailing list