首页> 外文期刊>New Generation Computing >Unifying Parsing and Reflective Printing for Fully Disambiguated Grammars
【24h】

Unifying Parsing and Reflective Printing for Fully Disambiguated Grammars

机译:为完全消化歧义语法统一解析和反射印刷

获取原文
           

摘要

Language designers usually need to implement parsers and printers. Despite being two closely 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 a 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 propagate 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 a fully disambiguated context-free grammar. BiYacc is based on the theory of bidirectional transformations, which helps to guarantee by construction that the generated pairs of parsers and reflective printers are consistent. Handling grammatical ambiguity is particularly challenging: we propose an approach based on generalised parsing and disambiguation filters, which produce all the parse results and (try to) select the only correct one in the parsing direction; the filters are carefully bidirectionalised so that they also work in the printing direction and do not break the consistency between the parsers and reflective printers. We show that BiYacc is capable of facilitating many tasks such as Pombrio and Krishnamurthi’s ‘resugaring’, simple refactoring, and language evolution.
机译:语言设计人员通常需要实现解析器和打印机。尽管是两个密切相关的程序,但实际上它们通常是单独设计的,然后需要修改并保持一致随着语言的发展。如果解析器和打印机可以在单个程序中统一和开发,则将更方便,并自动保证其一致性。此外,在某些情况下(例如将编译器优化结果显示给程序员),希望具有更强大的反射打印​​机,当修改了与一段程序文本对应的抽象语法树时,可以将修改传播到程序保留布局,评论和句法糖时的文字。为满足这些需求,我们提出了一种特定于域的语言BIYACC,其程序表示解析器和用于完全消化不衰的上下文语法的反射打印​​机。 BiyACC基于双向变换的理论,有助于通过构造来保证所产生的解析器和反射式打印机是一致的。处理语法模糊性尤为具有挑战性:我们提出了一种基于广义解析和消歧滤波器的方法,它产生所有解析结果和(尝试)在解析方向上选择唯一正确的一个;滤镜经过精心双向化,以便它们在打印方向上工作,不会打破解析器和反射式打印机之间的一致性。我们表明BiyACC能够促进许多任务,如Pombrio和Krishnamurthi的“休假”,简单的重构和语言演化。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号