Greetings!
On Wednesday 03 June 2009 06:14:26 pm Mats Ekberg wrote:
> I cant figure out why this grammar dont work (I have left out some
> not relevant stuff).
> This expression works:    [ LOOKUP( A1234567890, 9TN ) ] 93
> This dont:    [ LOOKUP( A1234567890, ATN ) ] 93
> Why?

Your lexer rules for TABLEID and UNIT overlap so I believe that the
lexer considers the "ATN" string in the second, non-working,
sentence to be a 3 letter TABLEID rather than a UNIT.

And of course your parser gets confused by seeing another TABLEID
after the first on in a LOOKUP construct.


> TABLEID       :       UCLETTER (ALPHANUM)* ;

> fragment DIGIT:               '0'..'9';
> fragment UCLETTER:    'A'..'Z';
> fragment LCLETTER:    'a'..'z';
> fragment USCORE:      '_';
> fragment CHAR:        UCLETTER | LCLETTER | DIGIT;
> fragment ALPHANUM:    DIGIT | UCLETTER;
> UNIT  : ALPHANUM ALPHANUM ALPHANUM


Remember that you lexer operates independently from the parser.

Your lexer has no knowledge of what your parser is trying to recognize.

maybe you could remove your lexer rule for UNIT, using TABLEID in
your parser instead and then add a semantic error checking actions
to ensure that those TABLEIDs (which are supposed to be UNITs)
are exactly 3 characters long.

Hope this helps.
------
  -jbb


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to