语言描述的语法方面
Grammatical Aspects for Language Descriptions
摘要:
为了工具开发的目的,计算机语言通常使用上下文无关文法来描述,并带有诸如语义动作或漂亮打印指令之类的注释。这些描述由自动构建软件的生成器处理,例如,解析器,漂亮的打印机和编辑支持。在许多情况下,注释使得语法不可读,并且当为支持相同语言的多个工具生成代码时,通常需要复制语法以便为不同的生成器提供不同的注释。我们提出了一种方法来描述语言,提高可读性的语法和减少重复。为了实现这一点,我们使用面向对象的编程原则。这种方法已经在一个名为Grammatic的开源工具中实现。我们将展示如何使用它来生成漂亮的打印机和语法高亮。
英文摘要:
For the purposes of tool development, computer languages are usually described using context-free grammars with annotations such as semantic actions or pretty-printing instructions. These descriptions are processed by generators which automatically build software, e.g., parsers, pretty-printers and editing support. In many cases the annotations make grammars unreadable, and when generating code for several tools supporting the same language, one usually needs to duplicate the grammar in order to provide different annotations for different generators. We present an approach to describing languages which improves readability of grammars and reduces the duplication. To achieve this we use Aspect-Oriented Programming principles. This approach has been implemented in an open-source tool named Grammatic. We show how it can be used to generate pretty-printers and syntax highlighters.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。