Treffer: Visitor-based Attribute Grammars with Side Effect

Title:
Visitor-based Attribute Grammars with Side Effect
Authors:
Middelkoop, Arie1 ariem@cs.uu.nl, Dijkstra, Atze1 atze@cs.uu.nl, Doaitse Swierstra, S.1 doaitse@cs.uu.nl
Source:
ENTCS: Electronic Notes in Theoretical Computer Science. Jul2011, Vol. 264 Issue 5, p47-69. 23p.
Database:
Supplemental Index

Weitere Informationen

Abstract: 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. [Copyright &y& Elsevier]