Lightweight multi-language syntax transformation with parser parser combinators
Lightweight multi-language syntax transformation with parser parser combinators
复制标题
使用解析器解析器组合器进行轻量级多语言语法转换
DOI:
10.1145/3314221.3314589
复制
发表时间:
2019
期刊:
影响因子:
--
通讯作者:
Le Goues, Claire
中科院分区:
文献类型:
--
作者:
van Tonder, Rijnard;Le Goues, Claire
Automatically transforming programs is hard, yet critical for automated program refactoring, rewriting, and repair. Multi-language syntax transformation is especially hard due to heterogeneous representations in syntax, parse trees, and abstract syntax trees (ASTs). Our insight is that the problem can be decomposed such that (1) a common grammar expresses the central context-free language (CFL) properties shared by many contemporary languages and (2) open extension points in the grammar allow customizing syntax (e.g., for balanced delimiters) and hooks in smaller parsers to handle language-specific syntax (e.g., for comments). Our key contribution operationalizes this decomposition using a Parser Parser combinator (PPC), a mechanism that generates parsers for matching syntactic fragments in source code by parsing declarative user-supplied templates. This allows our approach to detach from translating input programs to any particular abstract syntax tree representation, and lifts syntax rewriting to a modularly-defined parsing problem. A notable effect is that we skirt the complexity and burden of defining additional translation layers between concrete user input templates and an underlying abstract syntax representation. We demonstrate that these ideas admit efficient and declarative rewrite templates across 12 languages, and validate effectiveness of our approach by producing correct and desirable lightweight transformations on popular real-world projects (over 50 syntactic changes produced by our approach have been merged into 40+). Our declarative rewrite patterns require an order of magnitude less code compared to analog implementations in existing, language-specific tools.
登录
查看更多内容
影响因子:
1.1
作者:
Graham Hutton
通讯作者:
Graham Hutton
DOI:
--
发表时间:
2017
期刊:
International Conference on Generative Programming: Concepts and Experiences
影响因子:
--
作者:
L. Parreaux;A. Shaikhha;Christoph E. Koch
通讯作者:
Christoph E. Koch
DOI:
--
发表时间:
1992
期刊:
IEEE Trans. Software Eng.
影响因子:
--
作者:
Ed Merks;J. Dyck;R. Cameron
通讯作者:
R. Cameron
DOI:
--
发表时间:
1992
期刊:
LISP and Symbolic Computation
影响因子:
--
作者:
R. Dybvig;Robert Hieb;Carl Bruggeman
通讯作者:
Carl Bruggeman
DOI:
--
发表时间:
2006
期刊:
ACM-SIGPLAN Symposium on Programming Language Design and Implementation
影响因子:
--
作者:
R. Grimm
通讯作者:
R. Grimm