ABSTRACT
Adaptable Parsing Expression Grammars (APEG) are a formal model whose main purpose is to formally describe the syntax of extensible languages and their extension mechanisms. APEG extends Parsing Expression Grammar model with the notion of syntactic attributes, which are values passed through parse tree nodes and used during the parsing process. A grammar is a first-class value passed to every nonterminal, and the rules used during the parsing are fetched from this grammar. The ability to change and pass different grammars is the key to dynamically extend the original language grammar. The reported implementation of APEG attributes uses strings and ad hoc Java code to manipulate and build grammars during parsing time. This approach has at least three disadvantages: a grammar specification becomes dependent on the language in which the functions to manipulate and build new grammars were implemented; we may not assure that the grammars built are always syntactically correct; and it is virtually impossible to prove that the generated parser does not lead to a infinite loop. In this work, we formally define an attribute language for APEG containing operators to manipulate grammars. As a result, new rules and grammars built during parsing time are syntactically correct. In addition, we define a restriction on APEG rules that assures that any generated parser will terminate on all inputs.
- William J. Bowman. 2016. Growing a Proof Assistant. https://www.williamjbowman.com/resources/cur.pdfGoogle Scholar
- Martin Bravenboer, Karl T. Kalleberg, Rob Vermaas, and Eelco Visser. 2008. Stratego/XT 0.17. A language and toolset for program transformation. Science of Computer Programming 72, 1-2 (2008), 52--70. Google ScholarDigital Library
- Cristiano Calcagno, Walid Taha, Liwen Huang, and Xavier Leroy. 2003. Implementing Multi-stage Languages Using ASTs, Gensym, and Reflection. In Generative Programming and Component Engineering, Frank Pfenning and Yannis Smaragdakis (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 57--76. Google ScholarDigital Library
- Adam Carmi. 2010. Adaptive Multi-pass Parsing. Master's thesis. Israel Institute of Technology.Google Scholar
- Henning Christiansen. 1990. A survey of adaptable grammars. SIGPLAN Not. 25 (1990), 35--44. Issue 11. Google ScholarDigital Library
- Sebastian Erdweg, Stefan Fehrenbach, and Klaus Ostermann. 2014. Evolution of Software Systems with Extensible Languages and DSLs. IEEE Software 31, 5 (2014), 68--75.Google ScholarCross Ref
- Sebastian Erdweg, Tillmann Rendel, Christian Kästner, and Klaus Ostermann. 2011. SugarJ: library-based syntactic language extensibility. In Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applications (OOPSLA'11). ACM, New York, NY, USA, 391--406. Google ScholarDigital Library
- Bryan Ford. 2004. Parsing Expression Grammars: A Recognition-based Syntactic Foundation. In Proceedings of the 31st Symposium on Principles of Programming Languages (POPL'04). ACM, New York, NY, USA, 111--122. Google ScholarDigital Library
- J. Heering, P. R. H. Hendriks, P. Klint, and J. Rekers. 1989. The syntax definition formalism SDF reference manual. SIGPLAN Not. 24, 11 (1989), 43--75. Google ScholarDigital Library
- S. Shan Huang, David Zook, and Yannis Smaragdakis. 2008. Domain-specific Languages and Program Generation with meta-AspectJ. ACM Trans. Softw. Eng. Methodol. 18, 2, Article 6 (2008), 32 pages. Google ScholarDigital Library
- Shan S. Huang, David Zook, and Yannis Smaragdakis. 2011. Statically safe program generation with SafeGen. Science of Computer Programming 76, 5 (2011), 376 -- 391. Special Issue on GPCE 2004/2005. Google ScholarDigital Library
- Ted Kaminski and Eric Van Wyk. 2017. Ensuring Non-interference of Composable Language Extensions. In Proceedings of the 10th ACM SIGPLAN International Conference on Software Language Engineering (SLE 2017). ACM, New York, NY, USA, 163--174. Google ScholarDigital Library
- Lennart C.L. Kats and Eelco Visser. 2010. The Spoofax Language Workbench: Rules for Declarative Specification of Languages and IDEs. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA'10). ACM, New York, NY, USA, 444--463. Google ScholarDigital Library
- Florian Lorenzen and Sebastian Erdweg. 2016. Sound Type-dependent Syntactic Language Extension. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL'16). ACM, New York, NY, USA, 204--216. Google ScholarDigital Library
- Leonardo V.S. Reis, Roberto S. Bigonha, Vladimir O. Di Iorio, and Luis Eduardo S. Amorim. 2012. Adaptable Parsing Expression Grammars. In Programming Languages, Francisco Heron Carvalho Junior and Luis Soares Barbosa (Eds.). Lecture Notes in Computer Science, Vol. 7554. Springer Berlin Heidelberg, 72--86. Google ScholarDigital Library
- Leonardo V.S. Reis, Roberto S. Bigonha, Vladimir O. Di Iorio, and Luis Eduardo S. Amorim. 2014. The formalization and implementation of Adaptable Parsing Expression Grammars. Science of Computer Programming 96, Part 2 (2014), 191 -- 210. Selected and extended papers of the SBLP 2012. Google ScholarDigital Library
- Leonardo V. S. Reis, Vladimir O. Di Iorio, and Roberto S. Bigonha. 2014. Defining the Syntax of Extensible Languages. In Proceedings of the 29th Annual ACM Symposium on Applied Computing (SAC'14). ACM, New York, NY, USA, 1570--1576. Google ScholarDigital Library
- August C. Schwerdfeger and Eric Van Wyk. 2009. Verifiable Composition of Deterministic Grammars. In Proceedings of the 30th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI'09). ACM, New York, NY, USA, 199--210. Google ScholarDigital Library
- John N. Shutt. 1998. Recursive Adaptable Grammars. Master's thesis. Worchester Polytechnic Institute.Google Scholar
- Paul Stansifer and Mitchell Wand. 2011. Parsing Reflective Grammars. In Proceedings of the Eleventh Workshop on Language Descriptions, Tools and Applications (LDTA '11). ACM, New York, NY, USA, Article 10, 7 pages. Google ScholarDigital Library
- Sam Tobin-Hochstadt, Vincent St-Amour, Ryan Culpepper, Matthew Flatt, and Matthias Felleisen. 2011. Languages as libraries. In Proceedings of the 32nd ACM SIGPLAN conference on Programming language design and implementation (PLDI'11). ACM, New York, NY, USA, 132--141. Google ScholarDigital Library
- David A. Watt and Ole Lehrmann Madsen. 1983. Extended Attribute Grammars. Comput. J. 26, 2 (1983), 142--153.Google ScholarCross Ref
- Eric Van Wyk, Derek Bodin, Jimin Gao, and Lijesh Krishnan. 2010. Silver: An extensible attribute grammar system. Science of Computer Programming 75, 1 (2010), 39 -- 54. Special Issue on LDTA 06/07. Google ScholarDigital Library
Index Terms
- An attribute language definition for adaptable parsing expression grammars
Recommendations
Parsing expression grammars: a recognition-based syntactic foundation
POPL '04: Proceedings of the 31st ACM SIGPLAN-SIGACT symposium on Principles of programming languagesFor decades we have been using Chomsky's generative system of grammars, particularly context-free grammars (CFGs) and regular expressions (REs), to express the syntax of programming languages and protocols. The power of generative grammars to express ...
Parsing expression grammars: a recognition-based syntactic foundation
POPL '04For decades we have been using Chomsky's generative system of grammars, particularly context-free grammars (CFGs) and regular expressions (REs), to express the syntax of programming languages and protocols. The power of generative grammars to express ...
Left recursion in Parsing Expression Grammars
Parsing Expression Grammars (PEGs) are a formalism that can describe all deterministic context-free languages through a set of rules that specify a top-down parser for some language. PEGs are easy to use, and there are efficient implementations of PEG ...
Comments