[antlr-interest] Grammar help
Brian Catlin
BrianC at sannas.org
Tue Mar 16 01:18:27 PDT 2010
(Brian slaps head again), "Duh!" Sigh. Sometimes, I really wonder whether
I'm overpaid ;-}
You fixed it!
Thank you very much for your help!!
-Brian
-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Bart Kiers
Sent: Tuesday, March 16, 2010 15:33
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Grammar help
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.
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list