OT: CFGs vs PEGs?

BCS ao at pathlink.com
Tue Jul 1 11:32:09 PDT 2008


Reply to Nick,

> As far as more technical differences, from what I've seen, it sounds
> like the main difference between the two is that a PEG is basically
> like a CFG except that (using a contrived example):
> 
> A <- B | C
> 
> With a CFG, if both B and C match, then that's considered an ambiguity
> error, whereas with a PEG, if both B and C match, then it's
> automatically disambiguated by automatically using B. As I understand
> it, that seems to be the primary difference and all the other
> differences are basically just consequences of that. Is that right, or
> is there more to it?
> 
> (Also, if that's the case, it sounds like there wouldn't be much of a
> performance difference between equivilent PEG-based and CFG-based
> compilers?)
> 

If that is th only differerence, than the only difference is the disambuguation 
rule. (IIRC yacc/Bison does some magic to disambiguate stuff as well)





More information about the Digitalmars-d mailing list