[antlr-interest] Problem removing warning
Gerald Rosenberg
gerald at certiv.net
Fri Mar 19 10:01:08 PDT 2010
Having a bit of difficulty in figuring out how to unambiguously parse
this into an AST.
Order of the elements is significant, the parens are significant, and
the leading dot is significant.
(.buf_unittest.complex_opt1).foo;
.buf_unittest.complex_opt1.fum;
(buf_unittest.complex_opt1).(.buf_unittest.quux);
(.buf_unittest.complex_opt1).(buf_unittest.corge).qux;
(complex_opt2).baz;
(complex_opt2).(grault);
(complex_opt2).bar.foo;
(complex_opt2).bar.(quux);
(complex_opt2).bar.(buf_unittest.corge).qux;
(complex_opt2).(garply).foo;
(complex_opt2).(garply).(.buf_unittest.quux);
(complex_opt2).(buf_unittest.garply).(corge).qux;
(ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo;
(complex_opt2).fred.waldo;
(buf_unittest.complex_opt3).qux;
(complex_opt3).complexoptiontype5.plugh;
(complexopt6).xyzzy;
The rule ident_parens following appears to work, but Antlr is
complaining "Decision can match input such as "'.' ID" using multiple
alternatives: 1, 2" on both identN and identO. I can see the
theoretical overlap, but cannot tell if the warning is actually
significant or how to fix the rules to avoid the warning.
ident_parens
: (identM | identN | identO ) ('.' ( identM | identO ) )*
;
identM
: '(' '.' ipd+=ID ( '.' ipd+=ID )* ')' -> ^( IDENT_PARENSDOT $ipd+ )
| '(' ip+=ID ( '.' ip+=ID )* ')' -> ^( IDENT_PARENS $ip+ )
;
identN
: '.' id+=ID ( '.' id+=ID )* -> ^( IDENT_DOT $id+ )
;
identO
: i+=ID ( '.' i+=ID )* -> ^( IDENT $i+ )
;
Thanks...
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: PBTest.g
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20100319/5e7fa597/attachment.pl
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pbtest.txt
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20100319/5e7fa597/attachment.txt
More information about the antlr-interest
mailing list