skip to main content
article
Free Access

Extending context-free grammars with permutation phrases

Published:01 March 1993Publication History
Skip Abstract Section

Abstract

A permutation phrase is a grammatical phrase that specifies a syntactic construct as any permutation of a set of constituent elements. Permutation phrases allow for the concise and natural expression of free-order constructs as found in programming languages and notations such as C, Cobol, BibTEX, and Unix command lines.

The conciseness and clarity of expression that permutation phrase grammars offer over context-free grammars are illustrated through a case study of the declarations in C. The parsing problem for permutation phrase grammars is considered, and it is shown how efficient linear-time parsing can be achieved for permutation phrase grammars satisfying an extended notion of the LL(1) property.

References

  1. AHO, A. V., SETHI, R., AND ULLMAN, J.D. 1986. Compilers: Principles, Techniques and Tools. AddisomWesley, Reading, Mass.]] Google ScholarGoogle Scholar
  2. AMERICAN NATIONAL STANDARDS INSTITUTE. 1989. American National Standard for Information Systems--Programming Language--C. ANSI, New York.]]Google ScholarGoogle Scholar
  3. AMERICAN NATIONAL STANDARDS INSTITUTE. 1985. American National Standard for Information Systems--Programming Language--COBOL. ANSI, New York.]]Google ScholarGoogle Scholar
  4. BARTON, G. E., Jr. 1985. On tha complexity of ID/LP par~ing. Comput. LinE. 11, 4 (Oct.-Dee.), 205-218.]] Google ScholarGoogle Scholar
  5. COMPUTER SYSTEMS RESEARCH GROUP. 1986. UNIX User's Reference Manual--4.3 Berkeley Software Distribution. Univ. of California, Berkeley, Calif.]]Google ScholarGoogle Scholar
  6. DAHL, V. AND POPOWlCH, F. 1990. Parsing and generation with static discontinuity grammars. New Gen. Comput. 8, 3 (Dec.), 245-274.]] Google ScholarGoogle Scholar
  7. GAZDAR, G., KLEIN, E., PULLUM, G., AND SAG, I. 1985. Generahzed Phrase Structure Grammar. Basil Blackwell, Oxford, U.K.]]Google ScholarGoogle Scholar
  8. HARBISON, S. P. AND STEELE, G. L., JR. 1991. C, A Reference Manual. 3rd ed. Prentice Hall, Englewood Cliffs, N.J.]] Google ScholarGoogle Scholar
  9. KERNIGHAN, B. W. AND RITCHIE, D.M. 1988. The C Programming Language. 2nd ed. Prentice Hall, Englewood Cliffs, N.J.]] Google ScholarGoogle Scholar
  10. LAMPORT, L. 1986. LATEX: A Document Preparation System. Addison-Wesley, Reading, Mass.]] Google ScholarGoogle Scholar
  11. NELSON, G., (Ed.) 1992. Systems Programming in Modula-3. Prentice Hall, Englewood Cliffs, N.J.]]Google ScholarGoogle Scholar
  12. SHIEBER, S.M. 1984. Direct parsing of ID/LP grammars. Ltng. Philos. 7, 2, 135-154.]]Google ScholarGoogle Scholar
  13. U.S. DEPARTMENT OF DEFENSE. 1983. Reference Manual for the Ada Programming Language. ANSI/MIL-STD-1815A-1983, U.S. Dept. of Defense, Washington, D.C.]] Google ScholarGoogle Scholar

Index Terms

  1. Extending context-free grammars with permutation phrases

          Recommendations

          Reviews

          Frank George Pagan

          In this pithy and interesting paper, the author proposes the permutation phase as a notational extension for Backus-Naur form (BNF) grammars. Like optionality ([…]) and iteration ({…}), this extension improves the clarity and conciseness of grammars but does not increase their definitional power beyond the context-free level. A permutation phrase of the form e 1 &dvbm0;e 2 &dvbm0;&ldots;&dvbm0;e n is equivalent to an alternation of the n! different concatenation sequences containing exactly one occurrence of each grammatical phrase e i . For example, the production rule X::= b&dvbm0; C &dvbm0;dE is equivalent to X :: = b C dE&vbm0;bdE C &vbm0; C bdE&vbm0; C dEb&vbm0;dE C b&vbm0;dEb C . The author uses the syntax of C language declarations to illustrate the expressive utility of permutation phrases and investigates the feasibility of constructing reasonable-sized, linear-time, top-down parses for grammars containing such phrases. He shows that recursive-descent-style parsing is possible whenever the following criteria are satisfied: no optional constituent of any permutation phrase derives a string beginning with any terminal symbol a in the FOLLOW set of the phrase; for no terminal symbol a do any pair of constituents of any permutation phrase derive strings beginning with a ; and the grammar is otherwise LL(1). The paper will be readily understandable to readers with a good knowledge of grammars and parsers for programming languages. The relationship to earlier work is adequately documented by the references. From the perspective of language specification alone, the concept of the permutation phrase is of such evident worth that one might wonder why no one has proposed it before. From the perspective of parser construction, the author has done a creditable job as far as top-down analysis is concerned; the feasibility of bottom-up parsing for grammars with permutation phrases is, as suggested in the papers conclusion, the aspect for which further investigation is most obviously indicated.

          Access critical reviews of Computing literature here

          Become a reviewer for Computing Reviews.

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!