Skip to main content
Log in

Parsing regular grammars with finite lookahead

  • Published:
Acta Informatica Aims and scope Submit manuscript

Summary

Not every unambiguous regular grammar can be parsed by a finite state machine, even if a lookahead facility is added to the machine's capabilities. Those which can be parsed with a fixed lookahead of k are said to be FL(k). If such a grammar has n non-terminals, it never needs more than (n(n−1)/2) + 1 lookahead, and there exist grammars which do require this much. An algorithm is presented for determining whether a grammar is fixed lookahead parsable, and if so, for finding the minimum lookahead needed. The algorithm sets up and solves a set of O(n2) equations using O(n4) steps. Two parsing methods for FL(k) grammars are discussed. One uses a large precomputed parsing table, and operates in real time. The second parses an input string in time proportional to its length, while using approximately 3n storage locations.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Aho, A.V., Ullman, J.D.: The theory of parsing, translation, and compiling, Vol. 1. Englewood Cliffs, N.J.: Prentice-Hall, 1972

    Google Scholar 

  2. Kintala, C.M.R., Wotschke, D.: Amounts of non-determinism in finite automata. Acta Informat. 13, 199–204 (1980)

    Google Scholar 

  3. Lewis, P.M., Stearns, R.E.: Syntax-directed transduction. JACM 15, 464–488 (1968)

    Google Scholar 

  4. Meyer, A.R., Fischer, M.J.: Economics of description by automata, grammars, and formal systems. Proc. of 12th Annual Symp. on Switching and Automata Theory, IEEE Computer Society, pp. 188–191 (1971)

  5. Rabin, M.O., Scott, D.: Finite automata and their decision problems. IBM J. Res. Develop. 3, 114–125 (1959)

    Google Scholar 

  6. Strassen, V.: Gaussian Elimination is not Optimal. Numer. Math. 13, 354–356 (1969)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

About this article

Cite this article

Ostrand, T.J., Paull, M.C. & Weyuker, E.J. Parsing regular grammars with finite lookahead. Acta Informatica 16, 125–138 (1981). https://doi.org/10.1007/BF00261256

Download citation

  • Received:

  • Issue Date:

  • DOI: https://doi.org/10.1007/BF00261256

Keywords

Navigation