首页> 外文会议>International Symposium on Symbolic and Numeric Algorithms for Scientific Computing >Automating Abstract Syntax Tree Construction for Context Free Grammars
【24h】

Automating Abstract Syntax Tree Construction for Context Free Grammars

机译:上下文无关文法的自动化抽象语法树构造

获取原文

摘要

In most of the compilers or programming languages tools, parsers are used for transforming human readable code into Parse Trees or Abstract Syntax Trees (AST). A popular method to create parsers is to use a parser generator. Advanced parser generators (e.g. ANTLR, SDF) are able to generate directly ASTs if the grammar is annotated with AST generation rules. These annotations are typically done manually, by adding to each grammar rule a constructor and associating an AST component to each constructor. This might be inconvenient for people with little experience in writing grammars or for those who already have a grammar for their language. In this paper, we present a generic method for inferring such AST generation rules and a tool which automatically generates the annotated grammar. Assuming you have a grammar for a language, some input programs and their corresponding ASTs, the tool will infer the rules for constructing the AST. If the input programs cover the whole range of the language syntax constructs then the parser corresponding to the generated annotated grammar is able to parse and transform into an AST any program of the given language.
机译:在大多数编译器或编程语言工具中,解析器用于将人类可读的代码转换为解析树或抽象语法树(AST)。创建解析器的一种流行方法是使用解析器生成器。如果语法是用AST生成规则注释的,则高级解析器生成器(例如ANTLR,SDF)能够直接生成AST。这些批注通常是通过向每个语法规则添加一个构造函数并将AST组件与每个构造函数相关联来手动完成的。对于没有编写语法经验的人或已经对他们的语言有语法的人来说,这可能会带来不便。在本文中,我们提出了一种推断此类AST生成规则的通用方法以及一种自动生成带注释的语法的工具。假设您具有某种语言的语法,一些输入程序及其相应的AST,则该工具将推断出构造AST的规则。如果输入程序覆盖了语言语法结构的整个范围,则与生成的带注释的语法相对应的解析器将能够解析给定语言的任何程序并将其转换为AST。

著录项

相似文献

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

客服邮箱:kefu@zhangqiaokeyan.com

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

  • 服务号