A Mixed Approach for Building Extensible Parsers

For languages whose syntax is fixed, parsers are usually built with a static structure. The implementation of features like macro mechanisms or extensible languages requires the use of parsers that may be dynamically extended. In this work, we discuss a mixed approach for building efficient top-down dynamically extensible parsers. Our view is based on the fact that a large part of the parser code can be statically compiled and only the parts that are dynamic should be interpreted for a more efficient processing. We propose the generation of code for the base parser, in which hooks are included to allow efficient extension of the underlying grammar and activation of a grammar interpreter whenever it is necessary to use an extended syntax. As a proof of concept, we present a prototype implementation of a parser generator using Adaptable Parsing Expression Grammars (APEG) as the underlying method for syntax definition. We show that APEG has features which allow an efficient implementation using the proposed mixed approach.

[1]  Eelco Visser,et al.  Parse Table Composition : Separate Compilation and Binary Extensibility of Grammars , 2008 .

[2]  Robert Wilson,et al.  Compiling Java just in time , 1997, IEEE Micro.

[3]  Gregory V. Wilson Extensible Programming for the 21st Century , 2004, ACM Queue.

[4]  Ole Lehrmann Madsen,et al.  Extended Attribute Grammars , 1981, Comput. J..

[5]  Masaru Tomita,et al.  Efficient Parsing for Natural Language: A Fast Algorithm for Practical Systems , 1985 .

[6]  Eelco Visser,et al.  Parse Table Composition , 2009, SLE.

[7]  J. L. Dawson Combining Interpretive Code with Machine Code , 1973, Comput. J..

[8]  David Walker,et al.  Semantics and algorithms for data-dependent grammars , 2010, POPL '10.

[9]  Ken Thompson,et al.  Programming Techniques: Regular expression search algorithm , 1968, Commun. ACM.

[10]  Alessandro Warth,et al.  OMeta: an object-oriented language for pattern matching , 2007, DLS '07.

[11]  Charles Consel,et al.  Harissa: A Flexible and Efficient Java Environment Mixing Bytecode and Compiled Code , 1997, COOTS.

[12]  Eelco Visser,et al.  Syntax definition for language prototyping , 1997 .

[13]  Eric Van Wyk,et al.  Verifiable composition of deterministic grammars , 2009, PLDI '09.

[14]  Ulrik Pagh Schultz,et al.  Harissa: A Hybrid Approach to Java Execution , 1999, IEEE Softw..

[15]  Donald E. Knuth,et al.  An empirical study of FORTRAN programs , 1971, Softw. Pract. Exp..

[16]  Murray Hill,et al.  Yacc: Yet Another Compiler-Compiler , 1978 .

[17]  Bryan Ford,et al.  Parsing expression grammars: a recognition-based syntactic foundation , 2004, POPL '04.

[18]  Michael P. Plezbert Continuous Compilation for Software Development and Mobile Computing , 1996 .

[19]  Roberto da Silva Bigonha,et al.  Defining the syntax of extensible languages , 2014, SAC.

[20]  Sebastian Erdweg,et al.  SugarJ: library-based syntactic language extensibility , 2011, OOPSLA '11.

[21]  Soo-Mook Moon,et al.  Hybrid compilation and optimization for java-based digital TV platforms , 2014, TECS.

[22]  Leonardo Vieira dos Santos Reis Adaptable parsing expression grammars , 2012, SBLP.

[23]  Peter C. Poole,et al.  A Mixed Code Approach , 1973, Comput. J..

[24]  Eric Van Wyk,et al.  Verifiable Parse Table Composition for Deterministic Parsing , 2009, SLE.

[25]  Toshiaki Yasue,et al.  Overview of the IBM Java Just-in-Time Compiler , 2000, IBM Syst. J..

[26]  Steven V. Earhart UNIX programmer's manual , 1986 .

[27]  Ron Cytron,et al.  Does “just in time” = “better late than never”? , 1997, POPL '97.

[28]  John Aycock,et al.  A brief history of just-in-time , 2003, CSUR.

[29]  Laurence Tratt,et al.  Eco: A Language Composition Editor , 2014, SLE.

[30]  Roberto da Silva Bigonha,et al.  The formalization and implementation of Adaptable Parsing Expression Grammars , 2014, Sci. Comput. Program..