Fast, Flexible, and Declarative Construction of Abstract Syntax Trees with PEGs

Kimio Kuramitsu
DOI: https://doi.org/10.48550/arXiv.1507.08610
2015-07-31
Abstract:We address a declarative construction of abstract syntax trees with Parsing Expression Grammars. AST operators (constructor, connector, and tagging) are newly defined to specify flexible AST constructions. A new challenge coming with PEGs is the consistency management of ASTs in backtracking and packrat parsing. We make the transaction AST machine in order to perform AST operations in the context of the speculative parsing of PEGs. All the consistency control is automated by the analysis of AST operators. The proposed approach is implemented in the Nez parser, written in Java. The performance study shows that the transactional AST machine requires 25\% approximately more time in CSV, XML, and C grammars.
Programming Languages
What problem does this paper attempt to address?