3 research outputs found

    Memoized zipper-based attribute grammars and their higher order extension

    Get PDF
    Attribute grammars are a powerfull, well-known formalism to implement and reason about programs which, by design, are conveniently modular. In this work we focus on a state of the art zipper-based embedding of classic attribute grammars and higher-order attribute grammars. We improve their execution performance through controlling attribute (re)evaluation by means of memoization techniques. We present the results of our optimizations by comparing their impact in various implementations of different, well-studied, attribute grammars and their Higher-Order extensions. (C) 2018 Elsevier B.V. All rights reserved.- (undefined

    Attribute grammars as tree transducers over cyclic representations of infinite trees and their descriptional composition

    No full text
    International audienceEvaluation of attributes w.r.t. an attribute grammar can be obtained by inductively computing a function expressing the dependencies of the synthesized attributes on inherited attributes. This higher-order functional approach to attribute evaluation can straightforwardly be implemented in a higher-order lazy functional language like Haskell. The resulting evaluation functions are, however, not easily amenable to optimization when we want to compose two attribute grammars. We present an alternative first-order functional interpretation of attribute grammars where the input tree is replaced by an extended cyclic tree each node of which is aware of its context viewed as an additional child tree. These cyclic representations of zippers (trees with their context) are natural generalizations of doubly-linked lists to trees over an arbitrary signature. Then we show that, up to that representation, descriptional composition of attribute grammars reduces to the composition of tree transducers.L'évaluation des attributs d'une grammaire attribuée peut s'obtenir inductivement à l'aide de fonctions exprimant les dépendances fonctionnelles entre attributs hérités et synthétisés d'un même noeud. Le codage de ce mécanisme d'évaluation se fait de manière directe dans un langage fonctionnel paresseux (comme Haskell). Néanmoins l'utilisation de fonctions d'ordres supérieurs rend difficile l'optimisation de ces fonctions lorsqu'il s'agit de composer de telles grammaires attribuées. Nous présentons une implémentation alternative de l'évaluation des attributs reposant uniquement sur des fonctions du premier ordre pour laquelle l'arbre d'entrée est néanmoins rendu cyclique en ajoutant un lien de chaque noeud vers son père permettant ainsi l'accès aux informations héritées. Ces représentations de zippers (arbres donnés avec leurs contextes) sont des généralisations naturelles des listes avec double chaînage pour une signature arbitraire. Nous montrons que par ce codage la composition descriptionnelle des grammaires attribuées se réduit à une composition de transducteurs d'arbres

    Embedding attribute grammars and their extensions using functional zippers

    Get PDF
    Attribute grammars are a suitable formalism to express complex software language analysis and manipulation algorithms, which rely on multiple traversals of the underlying syntax tree. Attribute grammars have been extended with mechanisms such as reference, higher order and circular attributes. Such extensions provide a powerful modular mechanism and allow the specification of complex computations. This paper studies an elegant and simple, zipper-based embedding of attribute grammars and their extensions as first class citizens. In this setting, language specifications are defined as a set of independent, off-the-shelf components that can easily be composed into a powerful, executable language processor. Techniques to describe automatic bidirectional transformations between grammars in this setting are also described. Several real examples of language specification and processing programs have been implemented. (C) 2016 Elsevier B.V. All rights reserved.This author is supported by ERDF - European Regional Development Fund through the COMPETE Programme (operational programme for competitiveness) and by National Funds through the FCT - Fundacao para a Ciencia e a Tecnologia (Portuguese Foundation for Science and Technology) within project ON.2 IC&DT Programa Integrado "BEST CASE - Better Science Through Cooperative Advanced Synergetic Efforts (Ref. BIM-2013_BestCase_RL3.2_UMINHO) and project FATBIT - Foundations, Applications and Tools for Bidirectional Transformation (Ref. FCOMP-01-0124-FEDER-020532).This author is partially supported by NSF Award #1047961
    corecore