grammar LDB;
import LDBGeneratedLex;
start_parse returns [SelectListItem sli] :
select_list_item EOF
;
select_list_item returns [SelectListItem sli] :
ASTERISK
|
regular_ident
;
ASTERISK : '*' ;
//RI : [a-zA-Z]+ ; // it's this - uncomment to break
fragment HWS : [ \t] ; // horizontal whitespaces
fragment ALLWSes : [ \t\r\n]+ ;
SKIPWS : ALLWSes -> skip ;
lexer grammar MSSQLLexer;
regular_ident :
REGULAR_IDENT
;
REGULAR_IDENT :
'ddd'
;
ddd
i don't think parser rules contained within a Lexer grammar
included when you import the Lexer grammar.
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/antlr-discussion/91fa6196-7ecb-4c78-8fb3-8b48817dca8eo%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-di...@googlegroups.com.
Greetings!
Sorry for not fully reading your earlier question and just jumping to a conclusion...
I have very little experience with imported Lexers, so I am
probably off-base here, anyway...
when you un-comment RI, you have an ambiguous Lexer.
whenever 2 lexer rules match EXACTLY the same input sequence,
ANTLR will resolve this ambiguity by using the lexer rule that
appears first in the grammar definition. RI and REGULAR_IDENT
match "ddd" perfectly and (apparently) RI wins. Generally it is
best to put lexer rules with repetition last.
dump the type of the input tokens and not just their text in
order to check me on this. there should be a *.tokens file in the
same directory as the generated lexer that gives the type numbers,
and i think grun --tokens dumps the token stream with text and
type, afaicr... I don't know what the tt field is in your dump,
maybe Token Type? if so the *.tokens file will help.
One intuition might be that since the import statement appears first in the grammar then its rules would be "first" but evidently that is not the case...
Hope this helps
-jbb
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/antlr-discussion/c4968d33-510c-4927-8a21-59947a166c3ao%40googlegroups.com.