Hello, I recently downloaded the Parse::RecDescent package to parse boolean queries. I have several questions, not necessarily about the package itself, but rather about my grammar.
I am currently using the following grammar: my $grammar = q { <autotree> disj : qualif(?) conj disjRec(s?) disjRec : disjOp conj conj : term conjRec(s?) conjRec : conjOp term term : brack | phrase | ident brack : '(' disj ')' phrase : '"' ident(s?) '"' ident : /[a-zA-Z0-9]+/i qualif : ident '=' conjOp : /AND/i disjOp : /OR/i }; I have several problems with this. Firstly, the precedence isn't quite what I want in 'qualif'. I would like 'ident' to bind tightly to whatever comes next to it. Currently it seems to associate it with the whole 'disj' that comes after. Secondly, I would like the 'conjOp' operator to be optional, and that the parser recognises this. This means a query for 'a b' would be interpreted as 'a AND b'. I tried replacing the conjOp rule with 'conjOp : /AND/i | ""', but this does not work, as now a query 'a AND b' is interpreted as 'a AND and ...'. Any help would be appreciated. Thanks, Jonas.