547 research outputs found
Open Programming Language Interpreters
Context: This paper presents the concept of open programming language
interpreters and the implementation of a framework-level metaobject protocol
(MOP) to support them. Inquiry: We address the problem of dynamic interpreter
adaptation to tailor the interpreter's behavior on the task to be solved and to
introduce new features to fulfill unforeseen requirements. Many languages
provide a MOP that to some degree supports reflection. However, MOPs are
typically language-specific, their reflective functionality is often
restricted, and the adaptation and application logic are often mixed which
hardens the understanding and maintenance of the source code. Our system
overcomes these limitations. Approach: We designed and implemented a system to
support open programming language interpreters. The prototype implementation is
integrated in the Neverlang framework. The system exposes the structure,
behavior and the runtime state of any Neverlang-based interpreter with the
ability to modify it. Knowledge: Our system provides a complete control over
interpreter's structure, behavior and its runtime state. The approach is
applicable to every Neverlang-based interpreter. Adaptation code can
potentially be reused across different language implementations. Grounding:
Having a prototype implementation we focused on feasibility evaluation. The
paper shows that our approach well addresses problems commonly found in the
research literature. We have a demonstrative video and examples that illustrate
our approach on dynamic software adaptation, aspect-oriented programming,
debugging and context-aware interpreters. Importance: To our knowledge, our
paper presents the first reflective approach targeting a general framework for
language development. Our system provides full reflective support for free to
any Neverlang-based interpreter. We are not aware of any prior application of
open implementations to programming language interpreters in the sense defined
in this paper. Rather than substituting other approaches, we believe our system
can be used as a complementary technique in situations where other approaches
present serious limitations
Incremental Attribute Evaluation for Multi-User Semantics-Based Editors
This thesis addresses two fundamental problems associated with performing incremental attribute evaluation in multi-user editors based on the attribute grammar formalism: (1) multiple asynchronous modifications of the attributed derivation tree, and (2) segmentation of the tree into separate modular units. Solutions to these problems make it possible to construct semantics-based editors for use by teams of programmers developing or maintaining large software systems. Multi-user semantics based editors improve software productivity by reducing communication costs and snafus. The objectives of an incremental attribute evaluation algorithm for multiple asynchronous changes are that (a) all attributes of the derivation tree have correct values when evaluation terminates, and (b) the cost of evaluating attributes necessary to reestablish a correctly attributed derivation tree is minimized. We present a family of algorithms that differ in how they balance the tradeoff between algorithm efficiency and expressiveness of the attribute grammar. This is important because multi-user editors seem a practical basis for many areas of computer-supported cooperative work, not just programming. Different application areas may have distinct definitions of efficiency, and may impose different requirements on the expressiveness of the attribute grammar. The characteristics of the application domain can then be used to select the most efficient strategy for each particular editor. To address the second problem, we define an extension of classical attribute grammars that allows the specification of interface consistency checking for programs composed of many modules. Classical attribute grammars can specify the static semantics of monolithic programs or modules, but not inter-module semantics; the latter was done in the past using ad hoc techniques. Extended attribute grammars support programming-in-the-large constructs found in real programming languages, including textual inclusion, multiple kinds of modular units and nested modular units. We discuss attribute evaluation in the context of programming-in-the-large, particularly the separation of concerns between the local evaluator for each modular unit and the global evaluator that propagates attribute flows across module boundaries. The result is a uniform approach to formal specification of both intra-module and inter-module static semantic properties, with the ability to use attribute evaluation algorithms to carry out a complete static semantic analysis of a multi-module program
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
One-pass transformations of attributed program trees
The classical attribute grammar framework can be extended by allowing the specification of tree transformation rules. A tree transformation rule consists of an input template, an output template, enabling conditions which are predicates on attribute instances of the input template, and re-evaluation rules which define the values of attribute instances of the output template. A tree transformation may invalidate attribute instances which are needed for additional transformations.\ud
\ud
In this paper we investigate whether consecutive tree transformations and attribute re-evaluations are safely possible during a single pass over the derivation tree. This check is made at compiler generation time rather than at compilation time.\ud
\ud
A graph theoretic characterization of attribute dependencies is given, showing in which cases the recomputation of attribute instances can be done in parallel with tree transformations
An illumination of the template enigma : software code generation with templates
Creating software is a process of refining a concept to an implementation. This process consists of several stages represented by documents, models and plans at several levels of abstraction. Mostly, the refinement process requires creativity of the programmers, but sometimes the task is boring and repetitive. This repetitive work is an indication that the program is not written at the most suitable level of abstraction. The level of abstraction offered by the used programming language might be too low to remove the recurring code. Code generators can be used to raise the level of abstraction of program specifications and to automate the repetitive work. This thesis focuses on code generators based on templates. Templates are one of the techniques to implement a code generator. Templates allow extension of the syntax of a programming language, enabling generative programming without modifying the underlying compiler. Four artifacts are involved in a template based generator: templates, input data, a template evaluator and output code. The templates we consider are a concrete (incomplete) representation of the output document, i.e. object code, that contains holes, i.e. the meta code. These holes are filled by the template evaluator using information from the input data to obtain the output code. Templates are widely used to generate HTML code in web applications. They can be used for generating all kinds of text, like e-mails or (source) code. In this thesis we limit the scope to the generation of source code. The central research question is how the quality of template based code generators can be improved. Quality, in general, is a broad notion and our scope is limited to the technical quality of templates and generated code. We focused on improving the maintainability of template based code generators and the correctness of the generated code. This is facilitated by the three main contributions provided by this thesis. First, the maintainability of template based code generators is increased by specifying the following requirement for our metalanguage. Our metalanguage should not be rich enough to allow programming in templates, without being too restrictive to express some code generators. We used the theory of formal languages to specify our metalanguage. Second, we ensure correctness of the templates and generated code. Third, the presented theory and techniques are validated by case studies. These case studies show application of templates in real world applications, increased maintainability and syntactical correctness of generated code. Our metalanguage should not be rich enough to allow programming in templates, without being too restrictive to express some code generators. The theory of formal languages is used to specify the requirements for our metalanguage. As we only consider to generate programming languages, it is sufficient to support the generation of languages defined by context-free grammars. This assumption is used to derive a metalanguage, that is rich enough to specify code generators that are able to instantiate all possible sentences of a context-free language. A specific case of a code generator, the unparser, is a program that can instantiate all sentences of a context-free language. We proved that an unparser can be implemented using a linear deterministic topdown tree-to-string transducer. We call this property unparser-completeness. Our metalanguage is based on a linear deterministic top-down tree-to-string transducer. Recall that the goal of specifying the requirements of the metalanguage is to increase the maintainability of template based code generators, without being too restrictive. To validate that our metalanguage is not too restrictive and leads to better maintainable templates, we compared it with four off-the-shelf text template systems by implementing an unparser. We have observed that the industrial template evaluators provide a Turing complete metalanguage, but they do not contain a block scoping mechanism for the meta-variables. This results in undesired additional boilerplate meta code in their templates. The second contribution is guaranteeing the correctness of the generated code. Correctness of the generated code can be divided in two concerns: syntactical correctness and semantical correctness. We start with syntactical correctness of the generated code. The use of text templates implies that syntactical correctness of the generated code can only be detected at compilation time. This means that errors detected during the compilation are reported on the level of the generated code. The developer is required to trace back manually the errors to their origin in the template or input data. We believe that programs manipulating source code should not consider the object code as text to detect errors as early as possible. We present an approach where the grammars of the object language and metalanguage can be combined in a modular way. Combining both grammars allows parsing both languages simultaneously. Syntax errors in both languages of the template will be found while parsing it. Moreover, only parsing a template is not sufficient to ensure that the generated code will be free of syntax errors. The template evaluator must be equipped with a mechanism to guarantee its output will be syntactically correct. We discuss our mechanism in short. A parse tree is constructed during the parsing of the template. This tree contains subtrees for the object code and subtrees for the meta code. While evaluating the template, subtrees of the meta code are substituted by object code subtrees. The template evaluator checks whether the root nonterminal of the object code subtree is equal to the root nonterminal of the meta code subtree. When both are equal, it is allowed to substitute the meta code. When the root nonterminals are distinct an accurate error message is generated. The template evaluator terminates when all meta code subtrees are substituted. The result is a parse tree of the object language and thus syntactically correct. We call this process syntax safe code generation. In order to validate that the presented techniques increase maintainability and ensure syntactical correctness, we implemented our ideas in a syntax safe template evaluator called Repleo. Repleo has been applied in four case studies. The first case is a real world situation, where it is required to generate a three tier web application from a data model. This case showed that multiple layers of an applications defined in different programming languages can be generated from a single model. The second case and third case are used to show that our metalanguage results in a better maintainable code generator. Our metalanguage forces to use a two layer code generator with separation of concerns between the two layers, where the original implementations are less modular. The last case study shows that ensuring syntactical correctness results in the prevention of cross-site scripting attacks in dynamic generation of web pages. Recall that one of our goals was ensuring the correctness of the generated code. We also showed that is possible to check static semantic properties of templates. Static semantic checks are defined for the metalanguage, for the object language and checks for the situations where the object language is dependent on the metalanguage. We implemented a prototype of a static semantic checker for PicoJava templates using attribute grammars. The use of attribute grammars leads to re-use of the original PicoJava checker. Summarizing, in this thesis we have formulated the requirements for a metalanguage and discussed how to implement a syntax safe template evaluator. This results in better maintainable template based code generators and more reliable generated code
Web Usability Guidelines for Air Force Knowledge Now Web Site
The Department of Defense Net-Centric Data Strategies number one key attribute is to ensure data is visible, available, and usable when and where needed to accelerate decision-making. The Internet provides opportunities for quick and efficient disseminating of information to the public, distributing information throughout the Air Force, and accessing information from a variety of sources. In 2002, the Air Force CIO designated the Air Force Knowledge Now (AFKN) as the center of excellence for Knowledge Management. The site is a one-stop resource, providing access to a great depth and breadth of information. This study seeks to determine how usable and accessible the web interface is to its customers. A literature review determined the usability inspection method called Heuristic Evaluation to be most favorable for this type of evaluation. The researcher conducted a case study using heuristic evaluation to determine the site usability compliance rate. A second case study using web content accessibility guidelines was then performed to determine the sites accessibility compliance rate. The study finally presented a comparative analysis of the usability and accessibility checklists to determine if any overlap occurred between the two or if one is a subset of the other. This exploratory research finds more emphasis on web usability and accessibility should be explored in the future for AFKN
DYNAMIC LANGUAGE UPDATING
With respect to traditional systems, language interpreters are hard to evolve and the adoption
of evolved languages is slow. Language evolution is hindered by the fact that their
implementations often overlook design principles, especially those related to modularity.
Consequently, language implementations and their updates are monolithic. Language evolution
often breaks the backward compatibility and requires developers to rewrite their applications.
Furthermore, there is little or no support to evolve language interpreters at runtime. This would
be useful for systems that cannot be shut down and to support context-aware interpreters. To
tackle these issues, we designed the concept of open interpreters which provide support for
language evolution through reflection. Open interpreters allow one to partially update a
language to maintain the backward compatibility. Furthermore, they allow one to dynamically
update a language without stopping the overlying application. Open interpreters can be
dynamically tailored on the task to be solved. The peculiarity of this approach is that the
evolution code is completely separated from the application or the original interpreter code. In
this dissertation we define the concept of open interpreters, we design a possible
implementation model, we describe a prototype implantation and provide the proof-of-concept
examples applied to various domains
- …