...
首页> 外文期刊>Electronic Notes in Theoretical Computer Science >Visitor-based Attribute Grammars with Side Effect
【24h】

Visitor-based Attribute Grammars with Side Effect

机译:具有副作用的基于访问者的属性文法

获取原文
           

摘要

The visitor design pattern is often applied to program traversal algorithms over Abstract Syntax Trees (ASTs). It defines a visitor, an object with a visit method that is executed for each node in the AST. These visitors have the advantage that the order of traversal is explicitly under control of the programmer, which is essential to deal with side-effectful computations. Unfortunately, the exchange of results between traversals is error-prone. Attribute Grammars (AGs) are an alternative way to write multi-traversal algorithms. An attribute evaluator decorates the AST with attributes in one or more traversals. The attributes form a convenient mechanism to exchange results between traversals. Unfortunately, AGs discourage the use of side effect. In this paper, we present ruler-front, a language capturing the combination of the above approaches. A ruler-front grammar can be translated to traversal algorithms in multiple languages. In this paper, we translate to the imperative, dynamically-typed language JavaScript.
机译:访问者设计模式通常应用于抽象语法树(AST)上的程序遍历算法。它定义了一个访问者,一个具有访问方法的对象,该对象对AST中的每个节点执行。这些访问者的优点是遍历的顺序明确地受程序员控制,这对于处理副作用计算至关重要。不幸的是,遍历之间的结果交换容易出错。属性语法(AG)是编写多遍历算法的另一种方法。属性评估器使用一个或多个遍历中的属性来装饰AST。这些属性形成了在遍历之间交换结果的便捷机制。不幸的是,AG不鼓励使用副作用。在本文中,我们提出了一种统治者前线的语言,该语言捕获了上述方法的组合。可以将标尺前语法转换为多种语言的遍历算法。在本文中,我们将翻译成命令式,动态类型的语言JavaScript。

著录项

相似文献

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

客服邮箱:kefu@zhangqiaokeyan.com

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

  • 服务号