PEGs eliminate ambiguity by ordering the alternation:

  • If the first pattern matches, then use it
  • And don’t try to match the second one

This largely overlaps with Context Free Grammars except:

  • PEG’s can not represent ambiguity
  • PEG’s can count three things
  • CFG’s can have left-recursion

You use PEG’s to recognize languages like .