Results 1 -
7 of
7
Attribute Grammars as a Functional Programming Paradigm
- Functional Programming Languages and Computer Architecture, volume 274 of LNCS
, 1987
"... The purpose of this paper is twofold. Firstly we show how attributes in an attribute grammar can be simply and efficiently evaluated using a lazy functional language. The class of attribute grammars we can deal with are the most general ones possible: attributes may depend on each other in an arbitr ..."
Abstract
-
Cited by 71 (2 self)
- Add to MetaCart
The purpose of this paper is twofold. Firstly we show how attributes in an attribute grammar can be simply and efficiently evaluated using a lazy functional language. The class of attribute grammars we can deal with are the most general ones possible: attributes may depend on each other in an arbitrary way, as long as there are no truly circular data dependencies. Secondly, we describe a methodology based on attribute grammars, where, in a fairly straightforward way, we can develop efficient functional programs where direct, conventional solutions yield less efficient programs. We review two examples from a paper by R. Bird (Using circular programs to eliminate multiple traversals of data, Acta Informatica, 21, 1984) where he transforms simple but inefficient multipass programs into more efficient single pass ones, but which on their own can be very hard to understand. We show how such efficient but tangled programs can have natural formulations as attribute grammars. We also propose a...
Reference Attributed Grammars
- SECOND WORKSHOP ON ATTRIBUTE GRAMMARS AND THEIR REFERENCE APPLICATIONS ATTRIBUTED – GRAMMARS WAGA99
, 1999
"... An extension to canonical attribute grammars is introduced, permitting attributes to be references to arbitrary nodes in the syntax tree, and attributes to be accessed via the reference attributes. Important practical problems such as name and type analysis for object-oriented languages can be expre ..."
Abstract
-
Cited by 56 (13 self)
- Add to MetaCart
An extension to canonical attribute grammars is introduced, permitting attributes to be references to arbitrary nodes in the syntax tree, and attributes to be accessed via the reference attributes. Important practical problems such as name and type analysis for object-oriented languages can be expressed concisely in these grammars, and an optimal evaluation algorithm is available. The proposed formalism and algorithm have been implemented in an interactive language development tool.
Programming Language Specification and Prototyping Using the MAX System
- Programming Language Implementation and Logic Programming
, 1993
"... The paper describes the MAX system, a tool for specification and prototyping of language processors. The MAX system is based on a first--order framework generalizing attribute grammar like frameworks. It allows to refer to syntax tree nodes and "distant" attribute occurrences. Attributes may have ..."
Abstract
-
Cited by 9 (2 self)
- Add to MetaCart
The paper describes the MAX system, a tool for specification and prototyping of language processors. The MAX system is based on a first--order framework generalizing attribute grammar like frameworks. It allows to refer to syntax tree nodes and "distant" attribute occurrences. Attributes may have tree nodes as values, so that global relations between distant tree nodes can be expressed. This enables more compact and readable specifications for a wide class of complex problems. Within the presented framework, context conditions can be globally formulated by first--order predicate formulae. The paper explains the fundamental semantical concepts of the system, shows its application to a small name analysis problem, and describes the main implementation issues. In particular, we present a powerful attribute evaluation algorithm that can handle attribute dependencies arising during evaluation time. Finally, we report on the experiences made by the system and compare it to other s...
Circular Reference Attributed Grammars - Their Evaluation and Applications
- Science of Computer Programming
, 2003
"... This paper presents a combination of Reference Attributed Grammars (RAGs) and Circular Attribute Grammars (CAGs). While RAGs allow the direct and easy specification of non-locally dependent information, CAGs allow iterative fixed-point computations to be expressed directly using recursive (circular) ..."
Abstract
-
Cited by 9 (2 self)
- Add to MetaCart
This paper presents a combination of Reference Attributed Grammars (RAGs) and Circular Attribute Grammars (CAGs). While RAGs allow the direct and easy specification of non-locally dependent information, CAGs allow iterative fixed-point computations to be expressed directly using recursive (circular) equations. We demonstrate how the combined formalism, Circular Reference Attributed Grammars (CRAGs), can take advantage of both these strengths, making it possible to express solutions to many problems in an easy way. We exemplify with the specification and computation of the nullable, first, andfollow sets used in parser construction, aproblemwhichishighly recursive and normally programmed by hand using an iterative algorithm. We also present a general demand-driven evaluation algorithm for CRAGs and some optimizations of it. The approach has been implemented and experimental results include computations on a series of grammars including that of Java 1.2. We also revisit some of the classical examples of CAGs and show how their solutions are facilitated by CRAGs. 1
JastAdd - a Java-based system for implementing frontends
- Electronic Notes in Theoretical Computer Science
, 2001
"... Abstract We describe JastAdd, a Java-based system for specifying and implementing the frontend parts of a compiler that follow parsing. The system is built on top of a traditional Java parser generator which is used for parsing and treebuilding. JastAdd adds facilities for specifying and generating ..."
Abstract
-
Cited by 8 (0 self)
- Add to MetaCart
Abstract We describe JastAdd, a Java-based system for specifying and implementing the frontend parts of a compiler that follow parsing. The system is built on top of a traditional Java parser generator which is used for parsing and treebuilding. JastAdd adds facilities for specifying and generating object-oriented abstract syntax trees with both declarative behavior (using Reference Attributed Grammars (RAGs)) and imperative behavior (using ordinary Java code). The behavior can be modularized into different aspects, e.g. name analysis, type checking, etc., that are woven together into classes. This combination of objectoriented ASTs and aspect-modularized behavior results in a system which is easier and safer to use than solutions based on, e.g., the Visitor pattern. We also describe the implementation of the RAG evaluator (optimal recursive evaluation) which is implemented very conveniently using Java classes, interfaces, and virtual methods. 1
JastAdd--an aspect-oriented compiler construction system
- Science of Computer Programming
, 2003
"... centered around an object-oriented representation of the abstract syntax tree where reference variables can be used to link together different parts of the tree. JastAdd supports the combination of declarative techniques (using Reference Attributed Grammars) and imperative techniques (using ordinary ..."
Abstract
-
Cited by 5 (0 self)
- Add to MetaCart
centered around an object-oriented representation of the abstract syntax tree where reference variables can be used to link together different parts of the tree. JastAdd supports the combination of declarative techniques (using Reference Attributed Grammars) and imperative techniques (using ordinary Java code) in implementing the compiler. The behavior can be modularized into different aspects, e.g. name analysis, type checking, code generation, etc., that are woven together into classes using aspect-oriented programming techniques, providing a safer and more powerful alternative to the Visitor pattern. The JastAdd system is independent of the underlying parsing technology and supports any non-circular dependencies between computations, thereby allowing general multi-pass compilation. The attribute evaluator (optimal recursive evaluation) is implemented very conveniently using Java classes, interfaces, and virtual methods. Key words: reference attributed grammars, aspect-oriented programming, compiler construction, visitor pattern, Java 1
An Introductory Tutorial on JastAdd Attribute Grammars
"... The final publication will be available at www.springerlink.com Abstract. JastAdd is an open-source system for generating compilers and other language-based tools. Its declarative specification language is based on reference attribute grammars and object-orientation. This allows tools to be implemen ..."
Abstract
- Add to MetaCart
The final publication will be available at www.springerlink.com Abstract. JastAdd is an open-source system for generating compilers and other language-based tools. Its declarative specification language is based on reference attribute grammars and object-orientation. This allows tools to be implemented as composable extensible modules, as exemplified by JastAddJ, a complete extensible Java compiler. This tutorial gives an introduction to JastAdd and its core attribute grammar mechanisms, and how to use them when solving key problems in building language-based tools. A simple state machine language is used as a running example, showing the essence of name analysis, adding graphs to the abstract syntax tree, and computing circular properties like reachability. Exercises are included, and code for the examples is available online.

