Prefix & Empty literals table
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, June 30, 2006 01:59 AM

I wonder why my grammar doesn't behave the way you describe it in the documentation or in these different threads. Here is my lexer : class MyLex extends Lexer; options { k=7; } STREET_DIRECTION : "North" | "South" | "N" | "S" ; ID : (('A'..'Z')|( 'a'..'z'))+ ; I just wonder why when I enter "Nblabla", it tries to match with a STREET_DIRECTION and then an ID, instead of an ID. I thought that it was reading 7 (k=7) characters and tried to match with the longest (which would be, here, t   More>>


I wonder why my grammar doesn't behave the way you describe it in the documentation or in these different threads. Here is my lexer :


class MyLex extends Lexer;

options {

k=7;

}


STREET_DIRECTION

: "North"

| "South"

| "N"

| "S"

;


ID

: (('A'..'Z')|( 'a'..'z'))+

;




I just wonder why when I enter "Nblabla", it tries to match with a STREET_DIRECTION and then an ID, instead of an ID. I thought that it was reading 7 (k=7) characters and tried to match with the longest (which would be, here, the ID "Nblabla").

May be because my literals table is definitly empty in the generated code (whereas I want the tokens gathered under the name STREET_DIRECTION to be put in this table...).



Although I read the documentation, I may have misunderstood the way antlr works for the lexer...

Thanks for your help...    <<Less
About | Sitemap | Contact