Incremental parsing without a parser

  • Authors:
  • Gail E. Kaiser;Elaine Kant

  • Affiliations:
  • Carnegie-Mellon University U.S.A.;Carnegie-Mellon University U.S.A.

  • Venue:
  • Journal of Systems and Software
  • Year:
  • 1985

Quantified Score

Hi-index 0.00

Visualization

Abstract

This article 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 ''*'' operator or adding a short subexpression at a syntactically but not structurally correct position, such as inserting '') * (d'' at the # mark in'' (a + b # + 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 article describes an algorithm that allows the user 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. This algorithm is significantly different from other incremental parsing algorithms in that it does not involve modifications to a traditional parsing algorithm or the overhead of maintaining a parser stack or any data structure other than the syntax tree. Instead, the algorithm applies tree transformations, in real-time as each token is inserted or deleted, to maintain a correct syntax tree.