100,971 research outputs found

    Active templates: Manipulating pointers with pictures

    Get PDF
    Active templates are a semi-automatic visual mechanism for generating algorithms for manipulating pointer-based data structures. The programmer creates a picture showing the affected part of a data structure before and after a general-case manipulation. Code for the operation is compiled directly from the picture, which also provides the development environment with enough information to generate, automatically, a series of templates for other similar pictures, each describing a different configuration which the data structure may possess. The programmer completes the algorithm by creating matching after-pictures for each of these cases. At every stage, most of the picture-generation is automatic. Much of the tedious detail of conventional pointer-based data-structure manipulation, such as maintenance of current pointers, is unnecessary in a system based on active templates

    A Neural Model for Generating Natural Language Summaries of Program Subroutines

    Full text link
    Source code summarization -- creating natural language descriptions of source code behavior -- is a rapidly-growing research topic with applications to automatic documentation generation, program comprehension, and software maintenance. Traditional techniques relied on heuristics and templates built manually by human experts. Recently, data-driven approaches based on neural machine translation have largely overtaken template-based systems. But nearly all of these techniques rely almost entirely on programs having good internal documentation; without clear identifier names, the models fail to create good summaries. In this paper, we present a neural model that combines words from code with code structure from an AST. Unlike previous approaches, our model processes each data source as a separate input, which allows the model to learn code structure independent of the text in code. This process helps our approach provide coherent summaries in many cases even when zero internal documentation is provided. We evaluate our technique with a dataset we created from 2.1m Java methods. We find improvement over two baseline techniques from SE literature and one from NLP literature

    An illumination of the template enigma : software code generation with templates

    Get PDF
    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

    20-SIM code generation for PC/104 target

    Get PDF
    From version 3.2, 20-Sim will contain a new tool, called C-code generation. With this tool it will be possible to generate C code from a 20-Sim model. This tool works on basis of templates. For each target, a target specific template has to be made.\ud The goal of this project was to write a new 20-Sim template for a PC/104 target, a embedded Intel 80486 pc on the mobile robot Arty. It should to be possible to control the robot with a 20-Sim model. The template had to be written using the Phar Lap TNT Toolsuite Lite, a toolsuite for real-time embedded development. The written template is working and to demonstrate this, a 20-Sim model that controls the robot is made.\ud Another goal of this project was testing the code generation tool and doing some recommendations for improvement. From this project it followed that this tool works good, but that the following points have to be improved:\ud · Controlling the target hardware from a 20-Sim model is possible but only via a time-consuming workaround route.\ud · The generated code is large, because it contains many not-used functions and redundant variables and equations.\ud · The Runge Kutta routines fail to work in the existing templates when a model has no states

    Information System Generator

    Get PDF
    Cílem této práce je navrhnout a implementovat nástroj pro pasivní generování zdrojových kódů pro specifický framework informačního systému. Tímto frameworkem je ZeroFramework, který je určen k vývoji klient-server aplikací na platformě .NET. Pro generování je použita knihovna T4Scaffolding, která umožňuje rozdělit logiku generování kódu na separátní části (tzv. scaffoldery). Tato práce se zabývá převážně návrhem a implementací těchto scaffolderů a jejich provázání s knihovnou T4Scaffolding. Výsledkem této práce jsou šablony a logika pro vygenerování souborů a tříd, které implementují logiku potřebnou pro zobrazení, přidání, úpravu a smazání konkrétní databázové entity.Goal of this work is to design and implement too for passive code generation for specific information system framework. This framework is ZeroFramework that is targeted at client-server development of applications running on .NET platform. For code generation, T4 Scaffolding library is used, which allows to divide code generation logic into separate parts (scaffolders). This work is mainly concerned with design and implementation of those scaffolders and their linking with T4Scaffolding library. Results of this work are templates and logic for generation of files and classes, which implement logic needed for display, adding, modification and deletion of specific database entity.

    EUGENE: a STEP-based framework to build Application Generators

    No full text
    International audienceApplications generators translate specifications into products. We defined a method inspired of the STEP standardization process, and its implementation with EUGENE. The goal is to build a meta-model close to the target product, formally derived from others meta-models. Template are then applied to this meta-model. As benefits of this method, the final meta-model offers a higher abstraction of the generation process, and the complexity of code templates is greatly reduced

    C++ Metaprogramming Examples

    Get PDF
    Tato práce pojednává o metaprogramování v jazyce C++. Obsahuje přehledovou část zaměřenou na metaprogramování obecně a dále sadu příkladů demonstrujících různé techniky podporující metaprogramování v C++ s důrazem na nové vlastnosti nadcházející verze normy, zatím zvané C++0x. Příklady ukazují použití šablon s proměnným počtem parametrů, jejich výpočetní sílu, staticky polymorfní generování kódu a také obecnou implementaci několika návrhových vzorů.In this thesis we investigate possibilities of metaprogramming in C++. It contains a~general overview of metaprogramming and a~set of examples of various metaprogramming techniques in the C++ programming language with an emphasis on the possibilities proposed by the upcoming standard, called C++0x for now. Examples demonstrate usage of variadic templates, computational power of templates, statically polymorphic generation of a~runtime code and generic implementation of several design patterns.

    Generating collaborative systems for digital libraries: A model-driven approach

    Get PDF
    This is an open access article shared under a Creative Commons Attribution 3.0 Licence (http://creativecommons.org/licenses/by/3.0/). Copyright @ 2010 The Authors.The design and development of a digital library involves different stakeholders, such as: information architects, librarians, and domain experts, who need to agree on a common language to describe, discuss, and negotiate the services the library has to offer. To this end, high-level, language-neutral models have to be devised. Metamodeling techniques favor the definition of domainspecific visual languages through which stakeholders can share their views and directly manipulate representations of the domain entities. This paper describes CRADLE (Cooperative-Relational Approach to Digital Library Environments), a metamodel-based framework and visual language for the definition of notions and services related to the development of digital libraries. A collection of tools allows the automatic generation of several services, defined with the CRADLE visual language, and of the graphical user interfaces providing access to them for the final user. The effectiveness of the approach is illustrated by presenting digital libraries generated with CRADLE, while the CRADLE environment has been evaluated by using the cognitive dimensions framework
    corecore