Skip to main content

Linear Parsing Expression Grammars

  • Conference paper
  • First Online:
Language and Automata Theory and Applications (LATA 2017)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 10168))

Abstract

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Aho, A.V., Ullman, J.D.: The Theory of Parsing, Translation, and Compiling. Prentice-Hall Inc., Upper Saddle River (1972)

    MATH  Google Scholar 

  2. Birman, A.: The TMG recognition schema. Ph.D. thesis aAI7101582, Princeton, NJ, USA (1970)

    Google Scholar 

  3. Birman, A., Ullman, J.D.: Parsing algorithms with backtrack. Inf. Control 23(1), 1–34 (1973). http://www.sciencedirect.com/science/article/pii/S0019995873908516

    Article  MathSciNet  MATH  Google Scholar 

  4. Brzozowski, J., Leiss, E.: On equations for regular languages, finite automata, and sequential networks. Theoret. Comput. Sci. 10(1), 19–35 (1980). http://www.sciencedirect.com/science/article/pii/0304397580900699

    Article  MathSciNet  MATH  Google Scholar 

  5. Chandra, A.K., Kozen, D.C., Stockmeyer, L.J.: Alternation. J. ACM 28(1), 114–133 (1981). http://doi.acm.org/10.1145/322234.322243

    Article  MathSciNet  MATH  Google Scholar 

  6. Fellah, A., Jürgensen, H., Yu, S.: Constructions for alternating finite automata. Int. J. Comput. Math. 35(1–4), 117–132 (1990). http://dx.doi.org/10.1080/00207169008803893

    Article  MATH  Google Scholar 

  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). http://doi.acm.org/10.1145/964001.964011

  8. Google: Re2. https://github.com/google/re2

  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)

    MATH  Google Scholar 

  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). http://doi.acm.org/10.1145/2986012.2986019

  11. Linz, P.: An Introduction to Formal Language and Automata. Jones and Bartlett Publishers Inc., USA (2006)

    MATH  Google Scholar 

  12. Medeiros, S., Mascarenhas, F., Ierusalimschy, R.: From regexes to parsing expression grammars. Sci. Comput. Program. Part A 93, 3–18 (2014). http://www.sciencedirect.com/science/article/pii/S0167642312002171

    Article  Google Scholar 

  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. Oikawa, M., Ierusalimschy, R., Moura, A.L.D.: Converting regexes to parsing expression grammars

    Google Scholar 

  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). http://doi.acm.org/10.1145/1993498.1993548

  16. Parr, T., Harwell, S., Fisher, K.: Adaptive ll(*) parsing: the power of dynamic analysis. SIGPLAN Not. 49(10), 579–598 (2014). http://doi.acm.org/10.1145/2714064.2660202

    Article  Google Scholar 

  17. Thompson, K.: Programming techniques: regular expression search algorithm. Commun. ACM 11(6), 419–422 (1968). http://doi.acm.org/10.1145/363347.363387

    Article  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Nariyoshi Chida .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Springer International Publishing AG

About this paper

Cite this paper

Chida, N., Kuramitsu, K. (2017). Linear Parsing Expression Grammars. In: Drewes, F., Martín-Vide, C., Truthe, B. (eds) Language and Automata Theory and Applications. LATA 2017. Lecture Notes in Computer Science(), vol 10168. Springer, Cham. https://doi.org/10.1007/978-3-319-53733-7_20

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-53733-7_20

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-53732-0

  • Online ISBN: 978-3-319-53733-7

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics