Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have the following BNF and am trying to get it to work with RecDescent. I'm evaluating the WHERE condition on a simplified SQL statement.
BNF
tabname and colname are identifiers which have at most 20 characters, start with a letter, and cannot end in an underscore. colname as seen above can take the forme tabname.colname.<cond> ::= <x> [ "OR" <cond> ] <x> ::= <y> [ "AND" <y> ] <y> ::= "(" <cond> ")" | <z> <op> <z> <z> ::= [tabname"."]colname | <value> <op> ::= "<" | ">" | "=" | "<>" | "<=" | ">="
This is my grammar as I've converted it:
It seems to check syntax okay put when I try to print @item after the y statement only the first part of a statement is printed. So if my string is: "ssn = 1234 and name = bob" only "ssn = 1234" gets put in @item.condition : x | x /OR/i condition x : y | y /AND/i y y : "(" condition ")" | z OP z z : TABCOLNAME | COLNAME | VALUE # Terminals TABCOLNAME : /([a-z]{1}[\w]{0,18}[^_])\.([a-z]{1}[\w]{0,18}[^_\ ])/i COLNAME : /([a-z]{1}[\w]{0,18}[^_\ ])/i VALUE : /(\w+)/ix OP : /(<>|<=|>=|=|<|>)/
Thanks for any help.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Converting BNF for use in Parse::RecDescent
by Abigail-II (Bishop) on Oct 31, 2003 at 17:47 UTC | |
|
Re: Converting BNF for use in Parse::RecDescent
by hanenkamp (Pilgrim) on Nov 01, 2003 at 17:23 UTC | |
|
Re: Converting BNF for use in Parse::RecDescent
by daveyh (Initiate) on Oct 31, 2003 at 18:26 UTC |