[antlr-interest] Problem with this antlr grammar.
doctlo-antlr at yahoo.com
doctlo-antlr at yahoo.com
Tue Mar 1 10:05:38 PST 2005
On Mon, 28 Feb 2005 23:38:20 -0800, you wrote:
>DIGIT, UPPER, LOWER, OPENB, and CLOSEB need to be "protected" so that they
>can be used inside other lexer rules. What your grammar encounters is OPENP
>SEMI UPPER.
>
>--Loring
>
Thanks. I have one more question.
If I use this as input:
(;GM[1-1])
I get the error message:
exception: line 1:7: expecting ']', found '-'
which if I interpret correctly means that - is not part of ~']'.
Basically I want to include any character that is not a ], but am
unsure how.
>> -----Original Message-----
>> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
>> bounces at antlr.org] On Behalf Of doctlo-antlr at yahoo.com
>> Sent: Monday, February 28, 2005 11:24 PM
>> To: ANTLR Interest
>> Subject: [antlr-interest] Problem with this antlr grammar.
>>
>> header {
>> }
>>
>> class MyLexer extends Lexer;
>> options
>> {
>> k=3;
>> }
>> WS : ('\n' | '\r')
>> { _ttype = Token.SKIP; };
>> DIGIT : '0'..'9';
>> UPPER : 'A'..'Z';
>> LOWER : 'a'..'z';
>> //NUMBER : ('+'|'-')(DIGIT)+;
>> //REAL : NUMBER '.' (DIGIT)*;
>> OPENP : '(';
>> CLOSEP : ')';
>> SEMI : ';';
>> OPENB : '[';
>> CLOSEB : ']';
>> COLON : ':';
>> PERIOD : '.';
>> ESC : '\\' ']';
>> PROP_VALUE : OPENB ( ESC | ~']')* CLOSEB;
>> PROP_IDENT : UPPER (UPPER|DIGIT)?;
>>
>> class MyParser extends Parser;
>> options
>> {
>> k=3;
>> }
>> collection : (game_tree)+;
>> game_tree : OPENP sequence (game_tree)* CLOSEP;
>> sequence : (node)+ ;
>> node : SEMI (property)*;
>> property : PROP_IDENT PROP_VALUE;
>>
>>
>> For some reason when I feed it the following:
>>
>> (;GM[1])
>>
>> line 1:3: expecting CLOSEP but found 'G'.
>>
>> I have no idea why.
>> Can someone help?
>>
>> Thanks
>> T.L.Olczyk
>> 2.7.4
More information about the antlr-interest
mailing list