[antlr-interest] Grammar not detecting stray syntax after certain valid blocks

Bart Kiers bkiers at gmail.com
Tue Apr 5 11:31:45 PDT 2011


>
> This is enough to demonstrate the problem. When I create a program such as:
>
> state hello
> {
>
> }
> }
>
> The trailing close bracket is not detected as an error.
> <http://www.antlr.org/mailman/options/antlr-interest/your-email-address>


Try to "anchor" it by adding an EOF at the end of your entry-rule:

public prog
  :  globalStmt+ EOF
  ;


That way, you force the parser to go through the entire token stream, and
not stop prematurely.

Regards,

Bart.


More information about the antlr-interest mailing list