6 research outputs found

    Yet Another Implementation of Attribute Evaluation

    Get PDF
    We introduce another item in the already large list of techniques for attribute evaluation. Our algorithm consists in computing attributes by reductions to normal forms using a transducer operating on tree encodings of a cyclic representation of zippers. A zipper is a data structure introduced by GĂ©rard Huet for representing a subtree together with its context, i.e. it is a tree with a focus that points to some node inside it. We mention some potential applications of this representation of attribute grammars as zipper transformers

    Attribute grammars as tree transducers and their descriptional composition

    No full text
    Attribute coupled grammars and their descriptional composition were advocated by Ganzinger and Giegerich as a modular variant of attribute grammars, a model of syntax-directed semantics orginally introduced by Knuth. Descriptional composition has been related to various techniques of program optimization, in particular to "deforestation", a technique for eliminating intermediate data structures in function composition, In this work, we present a higher-order functional approach to attribute evaluation w.r.t. an attribute grammar based on local dependencies of the synthezised attributes on inherited attributes described by functions. This higher-order functional approach leads to efficient implementations in a higher-order lazy functional language like Haskell, but it fails to achieve deforestation. We present an alternative first-order functional interpretation of attribute grammars where the input tree is replaced by an extended cyclic tree corresponding to cyclic representations of zippers (trees with their context). Then we show that, up to that representation, descriptional composition reduces to the composition of trees transducers.Les grammaires attribuées introduites à l'origine par Knuth pour décrire les sémantiques dirigées parla syntaxe ont été présentées de façon modulaire par Ganzinger et Giegerich sous la forme de grammaires couplées par attributs. La composition de ces grammaires, appelée composition descriptionnelle, s'apparente aux techniques d'optimisation des programmes fonctionnels, telles que la déforestation qui consiste à éliminer des structures de données intermédiaires lors de la composition des fonctions. Dans ce travail, nous présentons une approche fonctionnelle d'ordre supérieure pour l'évaluation des attributs basée sur les dépendances locales entre les attributs synthétisés et les attributs hérités. Cette traduction, de nature non syntaxique et à ce titre non compatible avec les techniques de déforestation, procure néanmoins une implémentation directe des grammaires attribuées dans un langage fonctionnel paresseux d'ordre supérieur. Nous présentons alternativement une traduction fonctionnelle du premier ordre dans laquelle l'arbre d'entrée et son contexte sont représentés simultanéement par un arbre sur une signature étendue. Nous montrons que la composition descriptionnelle des grammaires attribuées se ramène, par cette traduction, en une simple composition de transducteurs d'arbres.RENNES1-BU Sciences Philo (352382102) / SudocSudocFranceF

    Attribute Grammars as Recursion Schemes over Cyclic Representations of Zippers

    Get PDF
    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 grammars leads to a straightforward implementation using a higher-order lazy functional language like Haskell. The resulting evaluation functions are, however, not easily amenable to optimization rules. We present an alternative first-order functional interpretation of attribute grammars where the input tree is replaced with an extended cyclic tree each node of which is aware of its context viewed as an additional child tree. By the way, we demonstrate that these cyclic representations of zippers (trees with their context) are natural generalizations of doubly-linked lists to trees over an arbitrary signature

    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
    corecore