6 research outputs found

    On the performance of strategic attribute grammars

    Get PDF
    Dissertação de mestrado integrado em Engenharia InformáticaStrategic programming is a powerful technique used in language processing to define functions that traverse abstract syntax trees. With strategies, the programmer only indicates the nodes of the tree where the work has to be done, and the strategy used to traverse the whole tree and apply the function that works only on the defined nodes. In Haskell, there are two libraries that implement strategies: Strafunski and an equivalent library developed by DI: Ztrategic. Beyond that, we also have the Kiama library which is implemented in the Scala programming language. The Ztrategic library uses memorization in order to save work. Using memorization, the elimination of all occurrences of "bad smells" in an abstract tree of a program is done only once! In this thesis, we present a detailed study of the performance of the Kiama, Ztrategic, and memoized Ztrategic libraries, using different strategic problems and input languages.Programação estratégica é uma técnica poderosa usada em processamento de linguagens para definir funções que atravessam árvores de sintaxe abstracta. Com estratégias o programador apenas indica os nodos da árvore onde o trabalho tem de ser feito, e depois que estratégia é utilizada para atravessar toda a árvore e aplicar a função que faz trabalho apenas nos nodos definidos. Em Haskell existem duas bibliotecas de combinadores que implementam estratégias: Strafunski e uma biblioteca equivalente desenvolvida no DI: Ztrategic. Existe também outra biblioteca desenvolvida em Scala, Kiama. A biblioteca Ztrategic usa memorização de modo a poupar trabalho. Usando memorização, a eliminação de todas a ocorrências do "mau cheiro" numa árvore abstracta de um programa é feita apenas uma vez! Nesta tese faz-se um estudo detalhado da performance das bibliotecas Kiama, Ztrategic, e memoized Ztrategic, utilizando diferentes problemas de programação estratégica e diferentes linguagens de input

    Tools and libraries to model and manipulate circular programs

    Get PDF
    This paper presents techniques to model circular lazy programs in a strict, purely functional setting. Circular lazy programs model any algorithm based on multiple traversals over a recursive data structure as a single traversal function. Such elegant and concise circular programs are defined in a (strict or lazy) functional language and they are transformed into efficient strict and deforested, multiple traversal programs by using attribute grammars-based techniques. Moreover, we use standard slicing techniques to slice such circular lazy programs. We have expressed these transformations as an Haskell library and two tools have been constructed: the HaCirctool that refactors Haskell lazy circular programs into strict ones, and the OCirctool that extends Ocaml with circular definitions allowing programmers to write circular programs in Ocaml notation, which are transformed into strict Ocaml programs before they are executed. The first benchmarks of the different implementations are presented and show that for algorithms relying on a large number of traversals the resulting strict, deforested programs are more efficient than the lazy ones, both in terms of runtime and memory consumption.(undefined

    Multiple intermediate structure deforestation by shortcut fusion

    Get PDF
    Shortcut fusion is a well-known optimization technique for functional programs. Its aim is to transform multi-pass algorithms into single pass ones, achieving deforestation of the intermediate structures that multi-pass algorithms need to construct. Shortcut fusion has already been extended in several ways. It can be applied to monadic programs, maintaining the global effects, and also to obtain circular and higher-order programs. The techniques proposed so far, however, only consider programs defined as the composition of a single producer with a single consumer. In this paper, we analyse shortcut fusion laws to deal with programs consisting of an arbitrary number of function compositions. (C) 2016 Elsevier B.V. All rights reserved.We would like to thank the anonymous reviewers for their detailed and helpful comments. This work was partially funded 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 projects FCOMP-01-0124-FEDER-020532 and FCOMP-01-0124-FEDER-022701

    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

    Shortcut fusion rules for the derivation of circular and higher-order programs

    Get PDF
    Functional programs often combine separate parts using intermediate data structures for communicating results. Programs so defined are modular, easier to understand and maintain, but suffer from inefficiencies due to the generation of those gluing data structures. To eliminate such redundant data structures, some program transformation techniques have been proposed. One such technique is shortcut fusion, and has been studied in the context of both pure and monadic functional programs. In this paper, we study several shortcut fusion extensions, so that, alternatively, circular or higher-order programs are derived. These extensions are also provided for effect-free programs and monadic ones. Our work results in a set of generic calculation rules, that are widely applicable, and whose correctness is formally established.Fundação para a Ciência e a Tecnologi

    Typing Haskell with an Attribute Grammar (Part I)

    No full text
    corecore