[antlr-interest] Re: help with literals
mzukowski at yci.com
mzukowski at yci.com
Thu Nov 13 11:19:16 PST 2003
No, you need a lexer rule something like
ID:
options {testLiterals=true;}
('a'..'z' | 'A'..'Z')+
;
Monty
-----Original Message-----
From: yahamkon [mailto:Vladimir.Konstantinov at rogers.com]
Sent: Thursday, November 13, 2003 11:16 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Re: help with literals
Thanks for the fast response!
>> See docs on literals and any example grammar with an ID rule.
I've looked in the docs, the "java.g" grammar, also searched the
archives but things aren't getting clearer.
> Yes, you need a rule that will test it's result against the defined
> literals.
Isn't "calc" such a rule? To put it defferently, if I had a grammar
that specifies a single rule recognising a single literal how would
that look like (that's what I had in mind sending the example anyway)?
>
> Monty
>
> -----Original Message-----
> From: VLADIMIR KONSTANTINOV [mailto:Vladimir.Konstantinov at r...]
> Sent: Thursday, November 13, 2003 11:03 AM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] help with literals
>
>
> I want to specify literals ("min", "max", "sum" etc) in my grammar.
>
> I am getting :
> line 1:1: unexpected char: 'm'
> line 1:2: unexpected char: 'i'
> line 1:3: unexpected char: 'n'
> when testing with the following expression: "min;"
>
> This a stripped down version of my grammar:
>
> ///
> class ExpressionParser extends Parser;
> options { importVocab=Expression; }
> calc: fun END;
> fun: "min";
>
> class ExpressionLexer extends Lexer ;
> options{ exportVocab=Expression;}
> END: ';'
> ///
>
> I am missing something very basic, but can't figure it out myself.
>
> Thanks in advance.
>
>
>
>
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list