Hello monks, hoping for some insight here.

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

<cond> ::= <x> [ "OR" <cond> ] <x> ::= <y> [ "AND" <y> ] <y> ::= "(" <cond> ")" | <z> <op> <z> <z> ::= [tabname"."]colname | <value> <op> ::= "<" | ">" | "=" | "<>" | "<=" | ">="
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.

This is my grammar as I've converted it:

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 : /(<>|<=|>=|=|<|>)/
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.

Thanks for any help.

Dave


In reply to Converting BNF for use in Parse::RecDescent by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.