[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (probably very naive) question regarding production grammar



Hi Donald,

Have a look at the OQL 3.0 grammar, which is under "grammars" SableCC subproject. You may get some ideas from it. The "where"-clause should be similar, if not compatibile with SQL "where"-clause.

Hth,
Mariusz Nowostawski Research Fellow/PhD student
Information Science, University of Otago, Dunedin New Zealand, PO BOX 56
Phone Work: +64 3 479 8317 Home: +64 3 4 876543 Fax: +64 3 479 8311


Donald Ball wrote:
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.