2 research outputs found

    Concise Concrete Syntax

    Get PDF
    We introduce a notion of ordered context-free grammars (OCFGs) with datatype tags to concisely specify grammars of programming languages. Our work is an extension of syntax definition formalism (SDF) and concrete datatypes that automate scanning, parsing, and syntax tree construction. But OCFGs also capture associativity and precedence at the level of production rules instead of lexical tokens such that a concrete syntax grammar is succinct enough be an abstract syntax definition. By expanding and re-indexing grammar symbols, OCFGs can be translated to grammars for standard lex and yacc such that existing and efficient parsing infrastructures can be reused. We have implemented a Java 5 compiler frontend with OCFGs. The complete grammar for such a realistic language fits comfortably in two pages of this paper, showing the practicality of our formalism

    Precedences for Conctypes

    No full text
    We consider again a user defined syntax feature, the conctype, which is a new datatype construction. An embedded language can easily be introduced into a programming language using conctypes, and computations are easily expressed using the concrete syntax and a special pattern matching form. Context-free grammars serve as a basis for the definition of the new syntax. A problem that is investigated in this paper is how to use precedences to resolve ambiguity. The way precedences are used in LR-parsers is sometimes unnatural and is hard to translate to other parsing techniques. We isolate one kind of ambiguity which can be resolved with precedence rules and show that it is easy for a user to augment a grammar with precedence rules. We define the generated language for such a grammar in terms of an attribute grammar and show that it is easy to automatically construct a parser that recognizes the language. 1 Conctypes In a previous paper [APS88] we described a user defined syntax featu..
    corecore