Moved complex grammar from PLY to ANTLR: issues ...

67 views
Skip to first unread message

markmc....@gmail.com

unread,
Jul 15, 2016, 7:04:59 PM7/15/16
to antlr-discussion
I have a working LALR grammar in PLY that builds a parser for a subset of PL/1. I was asked to move it
to ANTLR4 by the management and have done so, but I'm having an issue.

One of the segments in the grammar is:

dclobject : idorlist dclattrs type optinit
    | maplist ';'
    ;
... and dclattrs, type and optinit are all optional, really should be specified as type* and init* ...

But with the original I'm getting an 'Extraneous input' error on a semicolon, and if I make changes I get '

   Problems calling org.antlr.v4.gui.TestRig.main(args)

and it won't run at all.

Any ideas for a general approach to this problem?



Gerald Rosenberg

unread,
Jul 15, 2016, 7:54:30 PM7/15/16
to antlr-discussion
Reduce the source text being parsed to the absolute minimum, with separate instances tailored to testing different rule series. Dump the tokens and print the parse tree to see what is actually being lex'd and parsed.

See SnippetsTest for a simple way of automating this. Can run as part of your Maven test phase.
Reply all
Reply to author
Forward
0 new messages