From EBNF to PEG

  • Authors:
  • Roman R. Redziejowski

  • Affiliations:
  • Giraf's Research, roman@redz.se

  • Venue:
  • Fundamenta Informaticae - Concurrency, Specification and Programming
  • Year:
  • 2013

Quantified Score

Hi-index 0.00

Visualization

Abstract

Parsing Expression Grammar PEG encodes a recursive-descent parser with limited backtracking. The parser has many useful properties, and with the use of memoization, it works in a linear time. In its appearance, PEG is almost identical to a grammar in Extended Backus-Naur Form EBNF, but usually defines a different language. However, in some cases only minor typographical changes are sufficient to convert an EBNF grammar into its PEG parser. As recently shown by Medeiros, this is, in particular, true for LL1 grammars. But this is also true for many non-LL1 grammars, which is interesting because the backtracking of PEG is often a convenient way to circumvent just the LL1 restriction. We formulate a number of conditions for EBNF grammar to become its own PEG parser, and arrive at a condition that we call LL1p, meaning that a top-down parser can choose its next action by looking at the input within the reach of one parsing procedure rather than by looking at the next letter. An extension to LLkp for k 1 seems possible.