216 research outputs found

    Modular and type-safe definition of Attribute Grammars with AspectAG

    Get PDF
    AspectAG is a Haskell-embedded domain-specific language (EDSL) that encodes first-class attribute grammars (AGs). AspectAG ensures the wellformedness of AGs at compile time by using extensible records and predicates encoded using old-fashioned type-level programming features, such as multiparameter type classes and functional dependencies. AspectAG suffers the usual drawbacks of EDSLs: when type errors occur they usually do not deliver error messages that refer to domain terms, but to the host language. Often, implementation details of the EDSL are leaked in those messages. The use of type-level programming techniques makes the situation worse since type-level abstraction mechanisms are quite poor. Additionally, old-fashioned type-level programs are untyped at type-level, which is inconsistent with the general approach of strongly-typed functional programming. By using modern Haskell extensions and techniques we propose a reworked version of AspectAG that tackles those weaknesses. New AG definitions are safer, both at the level of types and at the level of kinds. Furthemore, a set of identified domain-specific errors are reported with DSL-oriented messages. To achieve this, we define and use a framework for manipulating type errors that can be used in any EDSL. We show the pragmatics of AspectAG by defining languages and extending them both with new syntax and semantics. We use MateFun, a purelyfunctional language used to teach mathematics as a case study.AspectAG es un lenguaje de dominio específico embebido (EDSL) que codifica gramáticas de atributos (AGs) como ciudadanos de primera clase. AspectAG garantiza la buena formación de las AGs en tiempo de compilación por medio del uso de registros extensibles y predicados, codificados gracias al uso de características antiguas de programación a nivel de tipos, como clases multiparámetro y dependencias funcionales. AspectAG sufre las desventajas usuales de los EDSLs: cuando ocurren errores de tipado, los mensajes de error reportados no se expresan en términos del dominio, sino del lenguaje anfitrión. También es usual que detalles de implementación del EDSL se vean filtrados en estos mensajes. El uso de técnicas de programación a nivel de tipos agrava la situación porque los mecanismos de abstracción a nivel de tipos son pobres. Ademas, las técnicas de programación a nivel de tipos usadas en AspectAG son esencialmente no tipadas, lo que es inconsistente con nuestro enfoque de tipado fuerte. Usando extensiones modernas al sistema de tipos de Haskell, proponemos una nueva versión de la biblioteca AspectAG, abordando los problemas antes mencionados. Las nuevas definiciones de AGs son mas seguras tanto a nivel de tipado como a nivel de kinds (tipado a nivel de tipos). Ademas, un conjunto identificado de errores específicos del dominio son reportados con mensajes referentes al mismo. Para lograr esto, definimos y utilizamos un framework para manipular errores de tipado, que puede ser aplicado a cualquier EDSL. Mostramos la pragmática de AspectAG definiendo lenguajes y extendiéndoles con nueva sintaxis y con nueva semántica. Utilizamos el lenguaje MateFun, un lenguaje funcional puro utilizado para enseñar matemáticas como caso de estudio

    Object Grammars: Compositional & Bidirectional Mapping Between Text and Graphs

    Get PDF
    Abstract: Object Grammars define mappings between text and object graphs. Parsing recognizes syntactic features and creates the corresponding object structure. In the reverse direction, formatting recognizes object graph features and generates an appropriate textual presentation. The key to Object Grammars is the expressive power of the mapping, which decouples the syntactic structure from the graph structure. To handle graphs, Object Grammars support declarative annotations for resolving textual names that refer to arbitrary objects in the graph structure. Predicates on the semantic structure provide additional control over the mapping. Furthermore, Object Grammars are compositional so that languages may be defined in a modular fashion. We have implemented our approach to Object Grammars as one of the foundations of the Ensō system and illustrate the utility of our approach by showing how it enables definition and composition of domain-specific languages (DSLs)

    Compiler of a Language with User-Defined Syntax for New Constructs

    Get PDF
    Tato práce si klade za cíl navrhnout a implementovat experimentální programovací jazyk s podporou uživatelsky definovaných syntaktických konstrukcí. Nový jazyk je kompilován do nativní binární podoby a vyžaduje statickou typovou disciplínu v době překladu. Jazyk se skládá ze dvou hlavních komponent. První z nich je minimalistické jádro založené na principech zásobníkově orientovaných jazyků. Druhou částí je mechanismus pro definici nových syntaktických konstrukcí uživatelem. Poté jsou shrnuty poznatky nabyté při návrhu a experimentování s prototypem překladače tohoto jazyka.This project aims to design and implement an experimental programming language. The main feature of the language shall be the ability of the user to define new syntactic constructs. The language shall be statically typed and compiled to a native binary form. The language consists of two parts. The first part is a minimalistic core based on the principles of stack-oriented languages. The second part is a mechanism that lets users define new syntactic constructs. Then we elaborate on findings that have risen from design and experiments performed with the prototype implementation of the language.

    Needle & knot : binder boilerplate tied up

    No full text
    To lighten the burden of programming language mechanization, many approaches have been developed that tackle the substantial boilerplate which arises from variable binders. Unfortunately, the existing approaches are limited in scope. They typically do not support complex binding forms (such as multi-binders) that arise in more advanced languages, or they do not tackle the boilerplate due to mentioning variables and binders in relations. As a consequence, the human mechanizer is still unnecessarily burdened with binder boilerplate and discouraged from taking on richer languages. This paper presents Knot, a new approach that substantially extends the support for binder boilerplate. Knot is a highly expressive language for natural and concise specification of syntax with binders. Its meta-theory constructively guarantees the coverage of a considerable amount of binder boilerplate for well-formed specifications, including that for well-scoping of terms and context lookups. Knot also comes with a code generator, Needle, that specializes the generic boilerplate for convenient embedding in COQ and provides a tactic library for automatically discharging proof obligations that frequently come up in proofs of weakening and substitution lemmas of type-systems. Our evaluation shows, that Needle & Knot significantly reduce the size of language mechanizations (by 40% in our case study). Moreover, as far as we know, Knot enables the most concise mechanization of the POPLmark Challenge (1a + 2a) and is two-thirds the size of the next smallest. Finally, Knot allows us to mechanize for instance dependentlytyped languages, which is notoriously challenging because of dependent contexts and mutually-recursive sorts with variables

    When is a container a comonad?

    Full text link
    Abbott, Altenkirch, Ghani and others have taught us that many parameterized datatypes (set functors) can be usefully analyzed via container representations in terms of a set of shapes and a set of positions in each shape. This paper builds on the observation that datatypes often carry additional structure that containers alone do not account for. We introduce directed containers to capture the common situation where every position in a data-structure determines another data-structure, informally, the sub-data-structure rooted by that position. Some natural examples are non-empty lists and node-labelled trees, and data-structures with a designated position (zippers). While containers denote set functors via a fully-faithful functor, directed containers interpret fully-faithfully into comonads. But more is true: every comonad whose underlying functor is a container is represented by a directed container. In fact, directed containers are the same as containers that are comonads. We also describe some constructions of directed containers. We have formalized our development in the dependently typed programming language Agda

    Bidirectional Transformation "bx" (Dagstuhl Seminar 11031)

    Get PDF
    Bidirectional transformations bx are a mechanism for maintaining the consistency of two (or more) related sources of information. Researchers from many different areas of computer science including databases (DB), graph transformations (GT), software engineering (SE), and programming languages (PL) are actively investigating the use of bx to solve a diverse set of problems. Although researchers have been actively working on bidirectional transformations in the above mentioned communities for many years already, there has been very little cross-discipline interaction and cooperation so far. The purpose of a first International Meeting on Bidirectional Transformations (GRACE-BX), held in December 2008 near Tokyo, was therefore to bring together international elites, promising young researchers, and leading practitioners to share problems, discuss solutions, and open a dialogue towards understanding the common underpinnings of bx in all these areas. While the GRACE-BX meeting provided a starting point for exchanging ideas in different communities and confirmed our believe that there is a considerable overlap of studied problems and developed solutions in the identified communities, the Dagstuhl Seminar 11031 on ``Bidirectional Transformations\u27\u27 also aimed at providing a place for working together to define a common vocabulary of terms and desirable properties of bidirectional transformations, develop a suite of benchmarks, solve some challenging problems, and launch joint efforts to form a living bx community of cooperating experts across the identified subdisciplines. This report documents the program and the outcomes of Dagstuhl Seminar 11031 with abstracts of tutorials, working groups, and presentations on specific research topics

    Derivation without lexical rules

    Get PDF
    In Krieger and Nerbonne (1992) we showed how to get rid of LEXICAL RULES for DERIVATION, as they are explicated by Pollard and Sag (1987) in HPSG I, Ch. 8.2. We proposed a treatment of derivation not by means of traditional lexical rules but instead in terms of PRINCIPLES, RULES, and LEXICAL ENTRIES entirely in the spirit of HPSG, together with unification-based inheritance of a very sophisticated kind. One major disadvantage of this approach was the employment of complex functions in certain principles. In this paper I first extend the old approach and then show how to eliminate these functional dependencies in the domain of derivational morphology by going back to simpler ones like cons, first, and rest. But this simplification is only achieved if we assume more complex feature structures than the ones described in Krieger and Nerbonne (e.g., by introducing two different SUBCAT features) and by proposing modified versions of the old Constituent Order Principle and the Subcategorization Principle for morphology. In addition, I postulate a hierarchy of affixes which is cross-classified, for instance, according to the effects these affixes contribute to the subcategorization information of a compound word. The structure of the paper is as follows. We start with a very short introduction about the residence of word-formation rules in modern feature-based theories. After that we present our approach to derivational morphology which is distinguished in that it gives up the notion of lexical rule as a single entity (operator). We describe the structure of affixes and words (e.g., which attributes are appropriate?) and introduce the relevant principles and the rule schema of our approach to derivational morphology. The section shows how to reduce functional dependencies to a minimum at the cost of the size of our feature structures. We also present a technique which allows us to state relational dependencies as they are called by HPSG in a functional manner. In the next section we show how the whole treatment works by applying it to tough phenomena from prefixation and suffixation. The section presents many examples, which might serve as a how to guide to a practitioner. After that we explain the idea which will lead us to the affix hierarchy. We will see that the affix hierarchy is inspired by the work of HPSG on structured lexicons (i.e., by the hierarchy of lexical types). A lot of examples will again be given throughout this section. We finish the paper by summarizing our approach and by saying a few words about the topics which we will tackle next

    Natural language software registry (second edition)

    Get PDF

    A Tool for Describing and Checking Natural Semantics Definitions of Programming Languages

    Full text link
    Many universities have courses and projects revolving around compiler or interpreter implementation as part of their degree programmes in computer science. In such teaching activities, tool support can be highly beneficial. While there are already several tools for assisting with development of the front end of compilers, tool support tapers off towards the back end, or requires more background experience than is expected of undergraduate students. Structural operational semantics is a useful and mathematically simple formalism for specifying the behaviour of programs and a specification lends itself well to implementation; in particular big-step or natural semantics is often a useful and simple approach. However, many students struggle with learning the notation and often come up with ill-defined and meaningless attempts at defining a structural operational semantics. A survey shows that students working on programming language projects feel that tool support is lacking and would be useful. Many of these problems encountered when developing a semantic definition are similar to problems encountered in programming, in particular ones that are essentially the result of type errors. We present a pedagogical metalanguage based on natural semantics, and its implementation, as an attempt to marry two notions: a syntax similar to textbook notation for natural semantics on the one hand, and automatic verification of some correctness properties on the other by means of a strong type discipline. The metalanguage and the tool provide the facilities for writing and executing specifications as a form of programming. The user can check that the specification is not meaningless as well as execute programs, if the specification makes sense.Comment: In Proceedings FROM 2022, arXiv:2209.0920
    corecore