444 research outputs found
Fast and Tiny Structural Self-Indexes for XML
XML document markup is highly repetitive and therefore well compressible
using dictionary-based methods such as DAGs or grammars. In the context of
selectivity estimation, grammar-compressed trees were used before as synopsis
for structural XPath queries. Here a fully-fledged index over such grammars is
presented. The index allows to execute arbitrary tree algorithms with a
slow-down that is comparable to the space improvement. More interestingly,
certain algorithms execute much faster over the index (because no decompression
occurs). E.g., for structural XPath count queries, evaluating over the index is
faster than previous XPath implementations, often by two orders of magnitude.
The index also allows to serialize XML results (including texts) faster than
previous systems, by a factor of ca. 2-3. This is due to efficient copy
handling of grammar repetitions, and because materialization is totally
avoided. In order to compare with twig join implementations, we implemented a
materializer which writes out pre-order numbers of result nodes, and show its
competitiveness.Comment: 13 page
Memoized zipper-based attribute grammars and their higher order extension
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
Incremental Semantic Evaluation for Interactive Systems: Inertia, Pre-emption, and Relations
Although schemes for incremental semantic evaluation have been explored and refined for more than two decades, the demands of user interaction continue to outstrip the capabilities of these schemes. The feedback produced by a semantic evaluator must support the user's programming activities: it must be structured in a way that provides the user with meaningful insight into the program (directly, or via other tools in the environment) and it must be timely. In this paper we extend an incremental attribute evaluation scheme with three techniques to better meet these demands within the context of a modeless editing system with a flexible tool integration paradigm. Efficient evaluation in the presence of syntax errors (which arise often under modeless editing) is supported by giving semantic attributes inertia: a tendency to not change unless necessary. Pre-emptive evaluation helps to reduce the delays associated with a sequence of edits, allowing an evaluator to "keep pace" with the user. Relations provide a general means to capture semantic structure (for the user, other tools, and as attributes within an evaluation) and are treated efficiently using a form of differential propagation. The combination of these three techniques meets the demands of user interaction; leaving out any one does not
Recommended from our members
Experience with a Production Compiler Automatically Generated from an Attribute Grammar
This paper relates our experience implementing a production compiler from an attribute grammar. The compiler is Intel Corporation's Pascal-80 compiler. It runs on a microcomputer-based development system without virtual memory. An attribute grammar was written describing semantic analysis, storage allocation, and translation to intermediate code. Attribute evaluation is done in two alternating passes and the program tree is kept in intermediate files on disk. The first version of the compiler was manually implemented from the attribute grammar. Using what was learned from this experience, an automatic attribute evaluator-generator was then written and a new version or the compiler was mechanically created from the attribute grammar. Various techniques for optimizing the evaluator were tried. Their degree or success is reported and they are compared with other ideas from the literature. Complex attribute-values, such as sets, sequences and finite functions, were carefully implemented using applicative data structure in order to conserve memory. The attribute grammar was designed using the principles or data abstraction and information-hiding. The internal organization or many types or attributes is completely hidden from the attribute grammar author and the attribute evaluator. These values are manipulated only by specific out-of-line semantic functions that can be viewed as the operators or an abstract data type for this attribute. This also contributed to an efficient use of memory
Well-Formed and Scalable Invasive Software Composition
Software components provide essential means to structure and organize software effectively. However, frequently, required component abstractions are not available in a programming language or system, or are not adequately combinable with each other. Invasive software composition (ISC) is a general approach to software composition that unifies component-like abstractions such as templates, aspects and macros. ISC is based on fragment composition, and composes programs and other software artifacts at the level of syntax trees. Therefore, a unifying fragment component model is related to the context-free grammar of a language to identify extension and variation points in syntax trees as well as valid component types. By doing so, fragment components can be composed by transformations at respective extension and variation points so that always valid composition results regarding the underlying context-free grammar are yielded. However, given a language’s context-free grammar, the composition result may still be incorrect.
Context-sensitive constraints such as type constraints may be violated so that the program cannot be compiled and/or interpreted correctly. While a compiler can detect such errors after composition, it is difficult to relate them back to the original transformation step in the composition system, especially in the case of complex compositions with several hundreds of such steps. To tackle this problem, this thesis proposes well-formed ISC—an extension to ISC that uses reference attribute grammars (RAGs) to specify fragment component models and fragment contracts to guard compositions with context-sensitive constraints. Additionally, well-formed ISC provides composition strategies as a means to configure composition algorithms and handle interferences between composition steps.
Developing ISC systems for complex languages such as programming languages is a complex undertaking. Composition-system developers need to supply or develop adequate language and parser specifications that can be processed by an ISC composition engine. Moreover, the specifications may need to be extended with rules for the intended composition abstractions.
Current approaches to ISC require complete grammars to be able to compose fragments in the respective languages. Hence, the specifications need to be developed exhaustively before any component model can be supplied. To tackle this problem, this thesis introduces scalable ISC—a variant of ISC that uses island component models as a means to define component models for partially specified languages while still the whole language is supported. Additionally, a scalable workflow for agile composition-system development is proposed which supports a development of ISC systems in small increments using modular extensions.
All theoretical concepts introduced in this thesis are implemented in the Skeletons and Application Templates framework SkAT. It supports “classic”, well-formed and scalable ISC by leveraging RAGs as its main specification and implementation language. Moreover, several composition systems based on SkAT are discussed, e.g., a well-formed composition system for Java and a C preprocessor-like macro language. In turn, those composition systems are used as composers in several example applications such as a library of parallel algorithmic skeletons
Extending Attribute Grammars to Support Programming-in-the-Large
Attribute grammars add specification of static semantic properties to context-free grammars, which in turn describe the syntactic structure of program units. However, context-free grammars cannot express programming-in-the-large features common in modern programming languages, including unordered collections of units, included units and sharing of included units. We present extensions to context-free grammars, and corresponding extensions to attribute grammars, suitable for defining such features. We explain how batch and incremental attribute evaluation algorithms can be adapted to support these extensions, resulting in a uniform approach to intra-unit and inter-unit static semantic analysis and translation of multi-unit programs
Incremental Evaluation of Reference Attribute Grammars using Dynamic Dependency Tracking
Reference attribute grammars (RAGs) have proven practical for gen- erating production-quality compilers from declarative descriptions, as demonstrated by the JastAdd system. Recent results indicate their applicability also to generating semantic services in interactive editors. For use in editors, it is necessary to update the attribution after edit operations. Earlier algorithms based on statically scheduled incremental attribute evaluation are, however, not applicable to RAGs, as they do not account for the dynamic dependencies that reference attributes give rise to. In this report, we introduce a notion of consistency for RAG attributions, along with an algorithm for maintaining consistency after edit operations, based on dynamic dependency tracking. That is, we introduce a means to do incremental evaluation of RAGs using dynamic dependency tracking
Generating incremental attribute evaluators
In onze maatschappij wordt tegenwoordig veel met software, dat wil zeggen com-
puterprogramma's, gewerkt. Denk daarbij niet alleen aan tekstverwerkers, maar
ook aan software in geldautomaten, videorecorders en het administratiesysteem
van de scus.
Software moet geschreven worden. Programmeurs schrijven software in zoge-
heten hogere programmeertalen, waarvan Pascal, C, Basic, Cobol en Fortran de
bekenste zijn. Zulke programmeertalen nemen tijdrovende, saaie en administratieve
taken verbonden aan het programmeren, uit handen.
Echter, computers \begrijpen" hogere programmeertalen niet, zij moeten ge?n-
strueerd worden in een zogeheten machinetaal. Om een hogere programmeertaal
naar machinetaal te vertalen zijn er speciale computerprogramma's in omloop,
zogeheten compilers. Met andere woorden, compilers vormen een vitale schakel in
het productieproces van software.
Een compiler zet een zogeheten bronprogramma, geschreven in een specieke
hogere programmeertaal, om naar een zogeheten doel programma in een specieke
machinetaal. Men spreek dan bijvoorbeeld ook van een \Pascal compiler voor een
DOS computer". De kwaliteit van het doelprogramma is niet alleen afhankelijk van
de kwaliteit van het bronprogramma, maar ook van de kwaliteit van de gebruikte
compiler.
Compilers zijn grote, ingewikkelde programma's, die ook geschreven moeten
worden. Dit proces wordt ondersteund door compiler-generatoren. Tijdens mijn?192 Samenvatting
boter
melk 30
10 2,50
1,25
item aantal prijs a
b
c
d
1 23 4
b2 b3 x
c2 c3 x
b4+c4 b2+c2
boter
melk 30
10 2,50
1,25
25,00
52,50
item aantal prijs a
b
c
d
1 23 4
40 77,50
a. Invoer b. Uitvoer
Figuur 2. Een rekenblad voor de melkboer
vierjarig onderzoek heb ik een compiler-generator gemaakt. Een compiler-generator
is een computerprogramma dat, na invoer van een minutieuze beschrijving van
een hogere programmeertaal en de gewenste machinetaal, een compiler voor die
programmeertaal genereert.
De voordelen van een compiler-generator zijn legio. Elke verbetering aan de
generator heeft tot gevolg dat elke gegenereerde compiler verbetert. Bovendien
worden de produktiekosten en de produktietijd verbonden aan het maken van een
compiler, aanzienlijk verminderd. Immers, in plaats van een compiler voor een
hogere programmeertaal hoeft alleen nog maar een beschrijving van die hogere
programmeertaal geschreven te worden. Een student informatica kan in een paar
maanden tijd een compiler genereren, terwijl een groep beroeps programmeurs daar
eerder vele maanden tot jaren mee bezig is.
Incrementele berekeningen
De kracht van de compilers gegenereert door dedoor mij ontwikkelde generator is
voornamelijk gelegen in het feit dat ze incrementeel zijn. Dat betekent dat na een
kleine verandering in het bronprogramma, de compiler de corresponderende veran-
deringen in het doelprogramma aanbrengt|dit in tegenstelling tot het simpelweg
vertalen van het gehele (gewijzigde) bronprogramma. Dit laatste zou veel meer
tijd zou kosten.
Wat een incrementele berekening is wordt elegant ge?llustreerd aan de hand van
een compiler-verwante toepassing: een rekenblad of spreadsheet. Een rekenblad
bestaat uit cellen in een rechthoekig patroon, zie Figuur 2a. Elke cel wordt
aangeduid met een letter-cijfer combinatie. Zo wordt de cel links-boven aangeduid
met a1. Een cel kan tekst, getallen of formules bevatten: cel a1 bevat de tekst
`item', cel b2 bevat het getal 10 en cel b4 bevat de formule b2 b3.
Een rekenblad-evaluator berekent de waarde van de cellen waar formules in
staan. Dus, na invoer van het rekenblad in Figuur 2a wordt de uitvoer van Figuur 2b
geproduceerd.
Stel dat we een verandering aanbrengen in het rekenblad; we voeren een
zogeheten edit-operatie uit. We verlagen het getal in cel b2 van 10 naar 9, zie?Informele inleiding 193
boter
melk 30
2,50
1,25
item aantal prijs a
b
c
d
1 23 4
b2 b3 x
c2 c3 x
b4+c4 b2+c2
9 boter
melk 30
2,50
1,25 52,50
item aantal prijs a
b
c
d
1 23 4
9 22,50
75,00 39
a. Wijziging in de invoer b. Zuinige herberekening
Figuur 3. Wijziging aan een rekenblad
Figuur 3a. De rekenblad-evaluator zou alle cellen met formules opnieuw kunnen
uitrekenen. Een incrementele evaluator berekent alleen de grijze cellen in Figuur 3b.
In dit geval spaart dat de berekening van cel c4 uit.
Het is overigens niet eenvoudig om in te zien welke cellen herberekend moeten
worden. Om dat te bepalen stelt de rekenblad-evaluator een zogeheten graaf op
die de cel-afhankelijkheden weergeeft. Een knoop in de graaf representeert een cel.
Er loopt een pijl van knoop b2 naar knoopb4 omdat de formule van cel b4 refereert
aan cel b2. Zo'n pijl impliceert dat cel b4 na celb2 uitgerekend moet worden.
Bij een incrementele evaluatie moet elke cel wiens knoop in de graaf een
opvolger is van b2, herberekend worden, tenzij veranderingen eerder uitdoven.
Als voorbeeld van dat laatste, beschouwen we de volgende verandering: de prijs
van boter gaat naar 0,25 en de hoeveelheid boter naar 100. In dat geval blijft de
waarde van cel b4 25,00 zodat d4 niet herberekend hoeft te worden. Grafen spelen
b3
b2
c2
c3
c4
d2
b4
d4
bij incrementele berekeningen een belangrijke rol. Ze komen dan ook veelvuldig in
dit proefschrift voor.
Compilers worden ook vaak toegepast op slechts weinig veranderde invoer. Hoe
vaak wordt een computerprogramma niet gecompileerd om er vervolgens achter te
komen dat er een kleine fout in staat? Het is daarom jammer dat er nog zo weinig i:=1 had natuurlijk
i:=0 moeten zijn. incrementele compilers zijn.
Taal-specieke editors
Een editor is een computerprogramma waarmee gegevens in een computer in-
gevoerd kunnen worden. Bovendien kunnen met een editor bestaande gegevens
gewijzigd worden. Meestal verstaat men onder een editor een algemeen programma
waarmee gegevens voor uiteenlopende applicaties (toepassings programma's zoals
compilers, rekenbladen, tekstverwerkers) ingevoerd kunnen worden.
Een applicatie-specieke editor is een invoer-en-wijzig programma dat \kennis"
heeft van een applicatie. Alle huis-tuin-en-keuken applicaties zoals tekstverwerkers L a T E X is geen huis-tuin-
en-keuken applicatie. en rekenbladen zijn uitgerust met applicatie-specieke editors. Het grootste voor-
deel van zulke editors is dat ze de gebruiker kunnen sturen: er kan geen al te grote
onzin in worden gevoerd.?194 Samenvatting
Compilers zouden ook uitgerust kunnen worden met een brontaal-specieke
editor. Dat is met name interessant als er een incrementele compiler beschikbaar
is die tijdens het intypen van het bronprogramma voortdurend het bijbehorende
doelprogramma berekend. Zulke systemen zouden de arbeidsproduktiviteit van
programmeurs enorm verhogen. Immers, fouten in het bronprogramma worden
direct als zodanig herkend door het system, en meegedeeld aan de gebruiker. Het
grootste voordeel is echter dat de editor \ondervraagd" kan worden over bepaalde
kenmerken van het bronprogramma. Voor ingewijden: als de editor constateert dat
i:=1 incorrect is omdat i niet gedeclareerd is kan het een menu aanbieden met alle
integer variabelen in de huidige scoop en een optie om de declaratie i:integer
toe te voegen aan de declaraties.
Kort overzicht
Dit proefschrift beschrijft de generatie van incrementele compilers, met name als
onderdeel van een taal-specieke \language based" editor.
Omdat we uitgaan van een taal-specieke editor, kunnen we het ontleed-
traject (lexical scanning en parsing ) overslaan: de editor onderhoudt een boom-
representatie van het ingevoerde programma. Dat betekent dat compileren niets De titel: Generating
incremental attribute
evaluators.
anders is dan het attribueren van de boom; de compiler is een (incrementele)
attribute evaluator.
Het formalisme waarmee we bomen en attributen beschrijven is het attribuut
grammatica formalisme.
We geven twee methodes om incrementele attribuut evaluatoren te construeren.
De eerste methode is een bestaande: visit-sequences sturen boom decoratie. De
tweede methode is nieuw: visit-sequences worden afgebeeld op visit-functies die
gecached worden om incrementeel gedrag te verkrijgen. Een complicatie bij deze
aanpak vormen zogeheten intra-visit-dependencies. Om dat probleem op te lossen
worden bindingen ge?ntroduceerd.
Visit-functies zijn functies zonder zij-eecten. Dit opent de mogelijkheid tot
allerhanden optimalizaties. Aan de orde komen splitting, elimination, unication,
folding, normalization en untyping.
We bespreken hoe visit-sequences berekend worden aan de hand van een gram-
matica. We wijzigen Kastens' ordered scheduling op twee vlakken. Om te beginnen
voeren we dat grafen in (in stap 4) waardoor een grotere klasse van gramatica's
geaccepteerd wordt. Ten tweede voeren we een nieuw orderings algorithme in
(chained scheduling ) dat visit-sequences berekent die beter geschikt zijn voor
omzetting naar visit-functies.
Een groot deel van het onderzoek heeft zich toegespitst op de haalbaarheid van
een functionele aanpak: we hebben een generator geschreven. De gegenereerde
evaluatoren zijn eenvoudig, elegant en robuust. Bovenal zijn ze snel. De generator
is onder andere gebruikt om een deel van zichzelf te genereren
- …