Linear Parsing Expression Grammars

  • Nariyoshi ChidaEmail author
  • Kimio Kuramitsu
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10168)


PEGs were formalized by Ford in 2004, and have several pragmatic operators (such as ordered choice and unlimited lookahead) for better expressing modern programming language syntax. Since these operators are not explicitly defined in the classic formal language theory, it is significant and still challenging to argue PEGs’ expressiveness in the context of formal language theory. Since PEGs are relatively new, there are several unsolved problems. One of the problems is revealing a subclass of PEGs that is equivalent to DFAs. This allows application of some techniques from the theory of regular grammar to PEGs. In this paper, we define Linear PEGs (LPEGs), a subclass of PEGs that is equivalent to DFAs. Surprisingly, LPEGs are formalized by only excluding some patterns of recursive nonterminal in PEGs, and include the full set of ordered choice, unlimited lookahead, and greedy repetition, which are characteristic of PEGs. Although the conversion judgement of parsing expressions into DFAs is undecidable in general, the formalism of LPEGs allows for a syntactical judgement of parsing expressions.


Parsing expression grammars Boolean finite automata Packrat parsing 


  1. 1.
    Aho, A.V., Ullman, J.D.: The Theory of Parsing, Translation, and Compiling. Prentice-Hall Inc., Upper Saddle River (1972)zbMATHGoogle Scholar
  2. 2.
    Birman, A.: The TMG recognition schema. Ph.D. thesis aAI7101582, Princeton, NJ, USA (1970)Google Scholar
  3. 3.
    Birman, A., Ullman, J.D.: Parsing algorithms with backtrack. Inf. Control 23(1), 1–34 (1973). MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Brzozowski, J., Leiss, E.: On equations for regular languages, finite automata, and sequential networks. Theoret. Comput. Sci. 10(1), 19–35 (1980). MathSciNetCrossRefzbMATHGoogle Scholar
  5. 5.
    Chandra, A.K., Kozen, D.C., Stockmeyer, L.J.: Alternation. J. ACM 28(1), 114–133 (1981). MathSciNetCrossRefzbMATHGoogle Scholar
  6. 6.
    Fellah, A., Jürgensen, H., Yu, S.: Constructions for alternating finite automata. Int. J. Comput. Math. 35(1–4), 117–132 (1990). CrossRefzbMATHGoogle Scholar
  7. 7.
    Ford, B.: Parsing expression grammars: a recognition-based syntactic foundation. In: Proceedings of 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 111–122. ACM, New York (2004).
  8. 8.
  9. 9.
    Hopcroft, J.E., Motwani, R., Ullman, J.D.: Introduction to Automata Theory, Languages, and Computation, 3rd edn. Addison-Wesley Longman Publishing Co., Inc., Boston (2006)zbMATHGoogle Scholar
  10. 10.
    Kuramitsu, K.: Nez: practical open grammar language. In: Proceedings of 2016 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software, Onward! 2016, pp. 29–42. ACM, New York (2016).
  11. 11.
    Linz, P.: An Introduction to Formal Language and Automata. Jones and Bartlett Publishers Inc., USA (2006)zbMATHGoogle Scholar
  12. 12.
    Medeiros, S., Mascarenhas, F., Ierusalimschy, R.: From regexes to parsing expression grammars. Sci. Comput. Program. Part A 93, 3–18 (2014). CrossRefGoogle Scholar
  13. 13.
    Morihata, A.: Translation of regular expression with lookahead into finite state automaton. Comput. Softw. 29(1), 1_147–1_158 (2012)Google Scholar
  14. 14.
    Oikawa, M., Ierusalimschy, R., Moura, A.L.D.: Converting regexes to parsing expression grammarsGoogle Scholar
  15. 15.
    Parr, T., Fisher, K.: Ll(*): the foundation of the ANTLR parser generator. In: Proceedings of 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2011, pp. 425–436. ACM, New York (2011).
  16. 16.
    Parr, T., Harwell, S., Fisher, K.: Adaptive ll(*) parsing: the power of dynamic analysis. SIGPLAN Not. 49(10), 579–598 (2014). CrossRefGoogle Scholar
  17. 17.
    Thompson, K.: Programming techniques: regular expression search algorithm. Commun. ACM 11(6), 419–422 (1968). CrossRefzbMATHGoogle Scholar

Copyright information

© Springer International Publishing AG 2017

Authors and Affiliations

  1. 1.Yokohama National UniversityYokohamaJapan

Personalised recommendations