Summary
This paper describes a method of syntax description for programming languages which allows one to factor out that part of the description which deals with the relative precedences of syntactic units. This has been found to produce simpler and more flexible syntax descriptions. It is done by allowing the normal part of the description, which is done in BNF, to be ambiguous; these ambiguities are then resolved by a separate part of the description which gives precedence relations between the conflicting productions from the grammar. The method can be used with any left-to-right parser which is capable of detecting ambiguities and recognizing which productions they come from; We have studied its use with an LR(1) parser, and it requires a small and localized addition to the parser to enable it to deal with the precedence relations.
Similar content being viewed by others
References
Naur, P., et al.: Revised report on the algorithmic language ALGOL 60. Comm. ACM 6, 1–17 (1963)
Korenjak, A. J.: A practical method for constructing LR(k) processors. Comm. ACM 12, 613–623 (1969)
Earley, J.: An efficient context-free parsing algorithm. Comm. ACM 13, 94–102 (1970)
Reynolds, J. C.: A set-theoretic approach to the concept of type. Argonne National Laboratory, 1969
Knuth, D. E.: On the translation of languages from left to right. Information and Control 8, 607–639 (1965)
De Remer, F. L.: Simple LR(k) grammars. Comm. ACM 14, 453–460 (1971)
Floyd, R. W.: The syntax of programming languages—a survey. IEEE Transactions EC-13, 4 (1964)
Floyd, R. W.: Syntactic analysis and operator precedence. J. ACM 10, 316–333 (1963)
Wirth, N., Weber, H.: Euler—a generalization of ALGOL and its definition. Comm. ACM 9, 13–25 (1966)
Aho, A. V., Johnson, S. C.: LR Parsing. Bell Laboratories, Murray Hill (N.J.)
Author information
Authors and Affiliations
Additional information
This work was supported by the National Science Foundation under contract GJ 34342X.
Rights and permissions
About this article
Cite this article
Earley, J. Ambiguity and precedence in syntax description. Acta Informatica 4, 183–192 (1975). https://doi.org/10.1007/BF00288747
Received:
Issue Date:
DOI: https://doi.org/10.1007/BF00288747