On Thursday, May 20, 2004 Jonas Wolf said:
> 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.

You do not provide any examples of what you are trying to parse, which would 
help.  IMHO what you mean by the above paragraph is not clear so I don't know 
what you "want".

> 
> 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 ...'.

Perhaps:

conj      : term conjOp(?) conj | term

It might help if you followed the example given in the PR::D POD more closely.

> 
> Any help would be appreciated.
> 
> Thanks, Jonas.


--
 Intel, Corp.
 5000 W. Chandler Blvd.
 Chandler, AZ 85226

-- 
 Intel, Corp.
 5000 W. Chandler Blvd.
 Chandler, AZ  85226


Reply via email to