[antlr-interest] LR problem with SQL92 parsing?
Lubos Vnuk
lubos.vnuk at rts.at
Tue Jun 17 06:18:17 PDT 2003
Hi,
I am new to ANTLR, I have read most of the docs but got stuck trying
to parse SQL2:
//Example 1
class SQL2 extends Parser;
options {k = 4;}
id : REGULAR_ID;
char_set_name : (schema_name ".")? id;
schema_name : (id ".")? id;
So far so good. Using left factoring for <schema_name> I can even
reduce the lookahead to 3:
//Example 2
class SQL2 extends Parser;
options {k = 3;}
id : REGULAR_ID;
char_set_name : (schema_name ".")? id;
schema_name : id ("." id)?;
So far so good. But as I introduce the "_" for the <id>:
//Example 3 - THE PROBLEM
class SQL2 extends Parser;
options {k = 3;}
id : ("_" char_set_name)? REGULAR_ID;
char_set_name : (schema_name ".")? id;
schema_name : id ("." id)?;
I get two ambuguities. My question is: How can I best resolve the
issue? Is it:
-> by specifying greedy subrules for char_set_name and schema_name
subrules?
-> by using syntactic predicates?
-> or else?
TIA,
Lubos.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list