[antlr-interest] Grammar help
Bart Kiers
bkiers at gmail.com
Tue Mar 16 00:32:49 PDT 2010
On Tue, Mar 16, 2010 at 8:10 AM, Brian Catlin <BrianC at sannas.org> wrote:
> While that gets rid of those warnings (why don't the warnings print a
> reasonable line number? I would call that a BUG),
Note that the '!' is a valid operator inside your grammar, ANTLR just
assumes that you're building trees. So, you're not doing anything wrong.
But, yes, a warning with the line number of the improper use of rewrite
operators would be nice.
On Tue, Mar 16, 2010 at 8:10 AM, Brian Catlin <BrianC at sannas.org> wrote:
> the fundamental problem
> of being able to parse (or otherwise capture the file name) still exists.
>
> Any ideas?
>
The error message is telling that your FILE_NAME is ambiguous. When matching
one or more characters from:
~('|' | '<' | '>' | '*' | '?')+
then line breaks will also be matched, yet after that, the following could
be matched:
('\r'? '\n')
which has already been "eaten" by the previous part of your rule. You could
fix that by adding line breaks to that first part of your rule, like this:
FILE_NAME : ~('|' | '<' | '>' | '*' | '?'| '\r' | '\n')+ (('\r'? '\n') |
EOF);
Regards,
Bart.
More information about the antlr-interest
mailing list