Parsing and Reflective Printing, Bidirectionally

被引:13
作者
Zhu, Zirun [1 ,2 ]
Zhang, Yongzhe [1 ,2 ]
Ko, Hsiang-Shang [2 ]
Martins, Pedro [3 ]
Saraiva, Joao [4 ]
Hu, Zhenjiang [1 ,2 ]
机构
[1] SOKENDAI Grad Univ Adv Studies, Hayama, Japan
[2] Natl Inst Informat, Tokyo, Japan
[3] Univ Calif Irvine, Irvine, CA 92717 USA
[4] Univ Minho, P-4719 Braga, Portugal
来源
PROCEEDINGS OF THE 2016 ACM SIGPLAN INTERNATIONAL CONFERENCE ON SOFTWARE LANGUAGE ENGINEERING (SLE'16) | 2016年
基金
日本学术振兴会;
关键词
parsing; reflective printing; bidirectional transformations; domain-specific languages; TRANSFORMATIONS;
D O I
10.1145/2997364.2997369
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Language designers usually need to implement parsers and printers. Despite being two intimately related programs, in practice they are often designed separately, and then need to be revised and kept consistent as the language evolves. It will be more convenient if the parser and printer can be unified and developed in one single program, with their consistency guaranteed automatically. Furthermore, in certain scenarios (like showing compiler optimisation results to the programmer), it is desirable to have a more powerful reflective printer that, when an abstract syntax tree corresponding to a piece of program text is modified, can reflect the modification to the program text while preserving layouts, comments, and syntactic sugar. To address these needs, we propose a domain-specific language BIYACC, whose programs denote both a parser and a reflective printer for an unambiguous context-free grammar. BIYACC is based on the theory of bidirectional transformations, which helps to guarantee by construction that the pairs of parsers and reflective printers generated by BIYACC are consistent. We show that BIYACC is capable of facilitating many tasks such as Pombrio and Krishnamurthi's "resugaring", simple refactoring, and language evolution.
引用
收藏
页码:2 / 14
页数:13
相关论文
共 27 条
  • [1] [Anonymous], 2007, PRACTICAL PROGRAMMIN
  • [2] Appel A. W., 1998, Modern Compiler Implementationin ML, V1
  • [3] Boulton R., 1966, 390 COMP LAB U CAMB
  • [4] Dual syntax for XML languages
    Brabrand, Claus
    Moller, Anders
    Schwartzbach, Michael I.
    [J]. INFORMATION SYSTEMS, 2008, 33 (4-5) : 385 - 406
  • [5] Czarnecki K, 2009, LECT NOTES COMPUT SC, V5563, P260, DOI 10.1007/978-3-642-02408-5_19
  • [6] de Jonge Maartje, 2012, Software Language Engineering. 4th International Conference, SLE 2011. Revised Selected Papers, P40, DOI 10.1007/978-3-642-28830-2_3
  • [7] Pretty-printing for software reengineering
    de Jonge, M
    [J]. INTERNATIONAL CONFERENCE ON SOFTWARE MAINTENANCE, PROCEEDINGS, 2002, : 550 - 559
  • [8] DIJKSTRA EW, 1975, COMMUN ACM, V18, P453, DOI [10.1145/360933.360975, 10.1145/390016.808417]
  • [9] Duregård J, 2011, HASKELL 11: PROCEEDINGS OF THE 2011 ACM SIGPLAN HASKELL SYMPOSIUM, P107
  • [10] The essence of bidirectional programming
    Fischer, Sebastian
    Hu ZhenJiang
    Pacheco, Hugo
    [J]. SCIENCE CHINA-INFORMATION SCIENCES, 2015, 58 (05) : 1 - 21