Abstract
We consider methods by which a precedence matrix may be modified without severely degrading the error-detecting capability of a parser utilizing the matrix. Two different definitions of “the same” error detection capability are considered. The first, called “exact equivalence”, permits only useless parts of the precedence matrix to be modified. The second, called simply “equivalence”, allows the modified matrix to perform some reductions, but never to shift an input symbol, after the original has detected an error.
We give necessary and sufficient conditions for a modified precedence parser to be equivalent or exactly equivalent to the canonical parser. We then consider the interesting case where the modification is caused by replacing the precedence matrix by linear precedence functions. A simple algorithm to find (if they exist) exactly equivalent linear precedence functions for a given precedence matrix is presented.
Similar content being viewed by others
References
N. Wirth andH. Weber, Euler—a generalization ofAlgol and its formal definition I,J. Assoc. Comput. Mach. 9 (1966), 13–25.
N. Wirth, PL360, a programming language for the 360 computers,J. Assoc. Comput. Mach. 15 (1968), 37–74.
R. P. Leinius,Error Detection and Recovery for Syntax Directed Compiler Systems, Ph.D. Thesis, University of Wisconsin, Madison, Wisconsin, 1970.
R. W. Floyd, Syntactic analysis and operator precedence,J. Assoc. Comput. Mach. 10 (1963), 316–333.
J. R. Bell, A new method for determining linear precedence functions for precedence grammars,Comm. Assoc. Comput. Mach. 12 (1969), 567–569.
D. F. Martin, A Boolean matrix method for the computation of linear precedence functions,Comm. Assoc. Comput. Mach. 15 (1972), 448–454.
A. V. Aho andJ. D. Ullman, “Linear Precedence Functions for Weak Precedence Grammars”,Internat. J. Comput. Math. (to appear).
A. V. Aho andJ. D. Ullman,The Theory of Parsing, Translation and Compiling, Prentice Hall, Englewood Cliffs, New Jersey, 1972.
A. J. Korenjak, A practical method for constructingLR(k) processors,Comm. Assoc. Comput. Mach. 12 (1969), 613–623.
F. DeRemer,Practical Translators for LR(k) Languages, Project MAC Report MAC TR-65, Cambridge, Mass., October 1969. (Cf. also “SimpleLR(k) grammars”,Comm. Assoc. Comput. Mach. 14 (1971), 453–460.)
A. V. Aho andJ. D. Ullman, Optimization ofLR(k) parsers,J. Computer System Sci., to appear.
W. M. McKeeman, J. J. Horning andD. B. Wortman,A Compiler Generator, Prentice Hall, Englewood Cliffs, New Jersey, 1970.
A. V. Aho, P. J. Denning andJ. D. Ullman, Weak and mixed strategy precedence parsing,J. Assoc. Comput. Mach. 19 (1972), 225–242.
J. D. Ichbiah andS. P. Morse, A technique for generating almost optimal Floyd-Evans Productions for precedence grammars,Comm. Assoc. Comput. Mach. 13 (1970), 501–508.
J. N. Gray,Precedence Parsers for Programming Languages, Ph.D. Thesis, University of California, Berkeley, Calif., 1969.
Author information
Authors and Affiliations
Additional information
The work by this author was partially supported by NSF grant GJ-465.
About this article
Cite this article
Aho, A.V., Ullman, J.D. Error detection in precedence parsers. Math. Systems Theory 7, 97–113 (1973). https://doi.org/10.1007/BF01762230
Received:
Issue Date:
DOI: https://doi.org/10.1007/BF01762230