Using an LALR compiler compiler to generate incremental parsers (original) (raw)

Incremental Expression Parsing for Syntax-Directed Editors

1982

This document describes an algorithm for incremental parsing of expressions in the context of syntax-directed editors for programming languages. Since a syntax-directed editor represents programs as trees and statements and expressions as nodes in trees, making minor modifications in an expression can be difficult. Consider, for example, changing a" +" operator to a-"-eoryi. adi.j fortS8ui~expTe~ssion i a ayju, ii,,l, ybt-o....-cturaIl cor " " i.~., .~ a"isrll "1 (d" at the # mark In-"(a-+ b-# 4-c)-.To make these changes in a typical syntax-directed editor, the user must understand the tree structure and type a number of tree-oriented construction and manipulation commands. This document describes an algorithm that allows the usar to think in terms of the syntax of the expression as it is displayed on the screen (in infix notation) rather than in terms of its internal representation (which is effectively prefix), while maintaining the benefits of syntax-directed editing. The time and space complexities of the modifications for each new token are linear in the depth of the syntax tree.

Grammatical abstraction and incremental syntax analysis in a language-based editor

Proceedings of the ACM SIGPLAN 1988 conference on Programming Language design and Implementation - PLDI '88, 1988

Processors for programming languages and other formal languages typically use a concrete syntax to describe the user's view of a program and an abstract syntax to represent language structures internally. Grammatical abstraction is defined as a relationship between two context-free grammars. It formalizes the notion of one syntax being "more abstract" than another. Two variants of abstraction are presented. Weak grammatical abstraction supports (i) the construction during LR parsing of an internal representation that is closely related to the abstract syntax and (ii) incremental LR parsing using that internal representation as its base, Strong grammatical abstraction tightens the correspondence so that top-down construction of incrementally-parsable internal representations is possible. These results arise from an investigation into language-based editing systems, but apply to any program that transforms a linguistic object from a representation in its concrete syntax to, a representation in its abstract syntax or vice versa.

An LALR Parser Generator Supporting Conflict Resolution

Journal of Universal Computer Science, 2008

Despite all the advance brought by LALR parsing method by DeRemer in the late 60's, conflicts continue to be removed in a non-productive way, by means of analysis of a huge amount of textual and low level data dumped by the parser generator tool. For the purpose of changing this scenario, we present a parser generator capable of automatically removing

Visual language editors based on LR parsing techniques

8th International Workshop on Parsing Technologies (IWPT’03), 2003

Visual language editors should provide a user-friendly environment where users are supported in an effective way in the construction of visual sentences. In this paper, we propose an approach for the construction of syntax-directed visual language editors by integrating incremental parsers into freehand editors. The approach combines the LR-based techniques for parsing visual languages with the more general incremental Generalized LR parsing techniques developed for string languages.

ANTLR: A predicated-LL(k) parser generator

Software: Practice and Experience, 1995

Despite the parsing power of© © algorithms, e.g. YACC 1 , programmers often choose to write recursive-descent parsers by hand to obtain increased flexibility, better error handling, and ease of debugging. We introduce ANTLR, a public-domain parser generator that combines the flexibility of hand-coded parsing with the convenience of a parser generator, which is a component of PCCTS 2 . ANTLR has many features that make it easier to use than other language tools. Most important, ANTLR provides predicates which let the programmer systematically direct the parse via arbitrary expressions using semantic and syntactic context; in practice, the use of predicates eliminates the need to hand-tweak the ANTLR output, even for difficult parsing problems. ANTLR also integrates the description of lexical and syntactic analysis, accepts " ! g rammars for $ # & % w ith extended BNF notation, and can automatically generate abstract syntax trees.

Abstract parsing with string updates using LR-parsing technology

2010

parsing with string updates using LR-parsing technology Kyung-Goo Doh, Hyunha Kim, David A. Schmidt 1 Hanyang University, Ansan, South Korea 2 Kansas State University, Manhattan, Kansas, USA Abstract. We combine LR(k)-parsing technology and data-flow analysis to analyze, in advance of execution, the documents generated dynamically by a program. Based on the document language’s context-free reference grammar and the program’s control structure, formatted as a set of flow equations, the analysis predicts how the documents will be generated and simultaneously parses the predicted documents. Recursions in the flow equations cause the analysis to emit a set of residual equations that are solved by least-fixed point calculation in the domain of abstract (folded) LR-parse stacks. Since the technique accommodates LR(k) grammars, it can also handle string-update operations in the programs by translating the updates into finite-state transducers, whose controllers are composed with the LR(k)-...

Abstract LDTA’04 Preliminary Version Parameterized LR Parsing

2008

Common LR parser generators lack abstraction facilities for defining recurring patterns of productions. Although there are generators capable of supporting regular expressions on the right hand side of productions, no generator supports user defined patterns in grammars. Parameterized LR parsing extends standard LR parsing technology by admitting grammars with parameterized non-terminal symbols. A generator can implement such a grammar in two ways, either by expansion or directly. We develop the theory required for the direct implementation and show that it leads to significantly smaller parse tables and that it has fewer parsing conflicts than the expanded grammar. Attribute evaluation for a parameterized non-terminal is possible in the same way as before, if the semantic functions related to the non-terminal are polymorphic with respect to the parameter. We have implemented parameterized LR parsing in the context of Essence, a partial-evaluation based LR parser generator for Schem...

Construction Methods of LR Parsers

1981

This paper presents five different LR parser generators and an error recovery method which is derived directly from the LR parser. The parsers presented include the original LR (1) parser defined by Knuth. The SLR(1) and LALR(1) parsers defined by DeRemer, and the weak and strong compatible LR parsers presented by Pager. All five parsers have been implemented by the author using two programs. Furthermore, the implementation of the SLR (1) parser generator includes an error recovery method and produces an SLR(1) parser with error recovery built in.

Parameterized LR Parsing

Electronic Notes in Theoretical Computer Science

Common LR parser generators lack abstraction facilities for defining recurring patterns of productions. Although there are generators capable of supporting regular expressions on the right hand side of productions, no generator supports user defined patterns in grammars.Parameterized LR parsing extends standard LR parsing technology by admitting grammars with parameterized non-terminal symbols. A generator can implement such a grammar in two ways, either by expansion or directly. We develop the theory required for the direct implementation and show that it leads to significantly smaller parse tables and that it has fewer parsing conflicts than the expanded grammar. Attribute evaluation for a parameterized non-terminal is possible in the same way as before, if the semantic functions related to the non-terminal are polymorphic with respect to the parameter.We have implemented parameterized LR parsing in the context of Essence, a partial-evaluation based LR parser generator for Scheme.

ANTLR: A Predicated-LL(k) Parser

1997

Despite the parsing power of© © algorithms, e.g. YACC 1 , programmers often choose to write recursive-descent parsers by hand to obtain increased flexibility, better error handling, and ease of debugging. We introduce ANTLR, a public-domain parser generator that combines the flexibility of hand-coded parsing with the convenience of a parser generator, which is a component of PCCTS 2 . ANTLR has many features that make it easier to use than other language tools. Most important, ANTLR provides predicates which let the programmer systematically direct the parse via arbitrary expressions using semantic and syntactic context; in practice, the use of predicates eliminates the need to hand-tweak the ANTLR output, even for difficult parsing problems. ANTLR also integrates the description of lexical and syntactic analysis, accepts " ! g rammars for $ # & % w ith extended BNF notation, and can automatically generate abstract syntax trees.