4,636 research outputs found
CAN WE TRANSFORM LOGIC PROGRAMS INTO ATTRIBUTE GRAMMARS?
In this paper we study the relationship between Attribute Grammars and Logic Programs,
concentrating on transforming logic programs into attribute grammars. This
has potential applications in compilation techniques for logic programs. It does not
seem possible to transform arbitrary Logic Programs into Attribute Grammars, basically
because the same logic variables can sometimes be used as input and sometimes as
output. We introduce the notion of an Abstract Attribute Grammar, which is similar to
that of an Attribute Grammar with the exception that attributes are not classified into
inherited and synthesized, and that the semantic equations are replaced by restriction
sets. These sets represent a restriction on the values of attribute occurrences namely,
all elements within each set have to be equal. We give an effective translation schema
which produces an equivalent Abstract Attribute Grammar for a given Logic Program.
We provide a formal proof of this equivalence. We then proceed to classify a class
of Abstract Attribute Grammars that can be transformed into Attribute Grammars,
and show how to achieve this transformation. By composing both transformations one
can transform certain logic programs into attribute grammars. Complete proofs ar5e
given.Information Systems Working Papers Serie
One Parser to Rule Them All
Despite the long history of research in parsing, constructing parsers for real programming languages remains a difficult and painful task. In the last decades, different parser generators emerged to allow the construction of parsers from a BNF-like specification. However, still today, many parsers are handwritten, or are only partly generated, and include various hacks to deal with different peculiarities in programming languages. The main problem is that current declarative syntax definition techniques are based on pure context-free grammars, while many constructs found in programming languages require context information.
In this paper we propose a parsing framework that embraces context information in its core. Our framework is based on data-dependent grammars, which extend context-free grammars with arbitrary computation, variable binding and constraints. We present an implementation of our framework on top of the Generalized LL (GLL) parsing algorithm, and show how common idioms in syntax of programming languages such as (1) lexical disambiguation filters, (2) operator precedence, (3) indentation-sensitive rules, and (4) conditional preprocessor directives can be mapped to data-dependent grammars. We demonstrate the initial experience with our framework, by parsing more than 20000 Java, C#, Haskell, and OCaml source files
- …