Hiya. I'm very new to the lexer/parser/compiler world, so my question may
well not be appropriate in this forum. If so, I apologize; any resource
suggestions would be helpful.
I'm working on a grammar for SQL where clauses. The aim is to be able to
parse and walk an AST tree of a user-supplied where clause in order to mark
it in in HTML and allow individual portions of the clause to be editable
using form widgets and such. I based my grammar subset on a BNF grammar for
SQL that I found here:
http://cui.unige.ch/db-research/Enseignement/analyseinfo/SQL7/BNFindex.html
Their grammar allows for [] and {} sections in productions (see
http://cui.unige.ch/db-research/Enseignement/analyseinfo/AboutBNF.html),
which sablecc does not (at least not the {} sections). I didn't think it
would be hard to rewrite them as recursive rules, but I apparently must
have done something wrong because sablecc will not process the grammar
included below. It does not like the first rule in this production:
logical_factor =
{compare} exp_simple compare exp_simple |
{condition} lparen condition rparen;
It says:
[java] -- Generating parser for grammar in
C:\cygwin\home\Dball\src\sqlparser\build\java
[java] Verifying identifiers.
[java] java.lang.RuntimeException: [39,38] Redefinition of
ACompareLogicalFactor.ExpSimple.
I can't figure out why sablecc does not like this grammar, perhaps someone
might offer some advice? Thanks in advance.