I was on the wrong track. I now found the source of the problem. It is
me not Antlr :-(( Unfortunately I am missing the words to express this
correctly - I am just trying to learn this.
The FILE_SELECTOR rule is causing the "problem". This rule is executed
on top level but should not. So it matches 'select' but 'select'
should be matched by another rule. How are those conflicts resolved?
What I want to say is that the FILE_SELECTOR rule should only fire in
its own context which is the 'from' part of the select statement?
I want to split the grammar in small pieces to be able to handle this.
How do I split the grammar in pieces without having every piece (sub-
rule) match on top level?
(the input file looks like "select a.b ;")
grammar LogAnalyser;
options {
output=AST;
ASTLabelType=CommonTree;
}
tokens {
SELECT; // tokens used for AST generation
FROM;
WHERE;
COLUMN;
}
prog : (select
';' {System.out.println($select.tree.toStringTree());} )+ ;
select : 'select' displayed_column (',' displayed_column)*
-> ^(COLUMN displayed_column)+ ;
displayed_column : id1=ID '.' id2=ID -> $id1 $id2;
ID : ('a'..'z')+ ;
WS : (' '|'\t'|'\n'|'\r')+ {skip();} ;
FILE_SELECTOR : ('a'..'z'|'A'..'Z'|'0'..'9'|'/'|'_'|'-'|'*'|'.')+ ;
Cheers,
Mark
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---