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
In reply to Converting BNF for use in Parse::RecDescent by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |