|Re: Parsing Expression Grammar email@example.com (Chris F Clark) (2005-09-25)|
|Predicates (was: Parsing Expression Grammar) firstname.lastname@example.org (Quinn Tyler Jackson) (2005-10-02)|
|Re: Predicates email@example.com (Sylvain Schmitz) (2005-10-04)|
|Re: Predicates cfc@shell01.TheWorld.com (Chris F Clark) (2005-10-05)|
|Re: Predicates firstname.lastname@example.org (Sylvain Schmitz) (2005-10-06)|
|From:||Quinn Tyler Jackson <email@example.com>|
|Date:||2 Oct 2005 02:55:06 -0400|
|Posted-Date:||02 Oct 2005 02:55:06 EDT|
Chris F Clark said:
> However, syntactic predicates can also be used to resolve conflicts
> (and ambiguities), which are a quite practical concern for compiler
> writers. For example, If one has a context sensitive special case,
> one can usually code the special case and the context up as a
> predicate which is then used to parse only the special case part.
> that way you tell the parser generator how much context and lookahead
> to use to idetify the special case and make the parser generator's job
Indeed, predicated grammars can accept a great number of fairly intricate
programming language constructions, as seen in this paper from Okhotin:
"On the existence of a Boolean grammar for a simple procedural language"
Except for the behavior of the conjunction operators | and /, conjunctive
grammars and PEGs are pretty much one and the same, formally.
I suppose one might be able to show a direct relation of the implied
predication of the ordering in PEGs and the explicit predicates found in
both formalisms, and this suspicion leads me to believe that one way to
address language equivalency with PEGs is not to examine their relation to
the CFLs, but to the conjunctive/Boolean languages, and work from there.
Now, it could be shown that there exists no algorithm for detecting such
cases as the P <- x P x / x situation noted in other posts, since x can be
replaced with any arbitrary production X, and the crux of finding such cases
would rest in proving that the LHS and RHS expressions of P accept the same
language, where that language might be a CSL. I haven't given this too much
formal thought, and so I freely admit I could be speaking out the top of my
That is to say, one could easily say that P <- X P X / X is not acceptable
(or potentially misleading), but what of P <- X P Y / Z where X, Y, and Z
generate the same strings?
Return to the
Search the comp.compilers archives again.