skip to main content
article
Open Access

Efficient and flexible incremental parsing

Published:01 September 1998Publication History
Skip Abstract Section

Abstract

Previously published algorithms for LR (k) incremental parsing are inefficient, unnecessarily restrictive, and in some cases incorrect. We present a simple algorithm based on parsing LR(k) sentential forms that can incrementally parse an arbitrary number of textual and/or structural modifications in optimal time and with no storage overhead. The central role of balanced sequences in achieving truly incremental behavior from analysis algorithms is described, along with automated methods to support balancing during parse table generation and parsing. Our approach extends the theory of sentential-form parsing to allow for ambiguity in the grammar, exploiting it for notational convenience, to denote sequences, and to construct compact (“abstract”) syntax trees directly. Combined, these techniques make the use of automatically generated incremental parsers in interactive software development environments both practical and effective. In addition, we address information preservation in these environments: Optimal node reuse is defined; previous definitions are shown to be insufficient; and a method for detecting node reuse is provided that is both simpler and faster than existing techniques. A program representation based on self-versioning documents is used to detect changes in the program, generate efficient change reports for subsequent analyses, and allow the parsing transformation itself to be treated as a reversible modification in the edit log.

References

  1. AASA, A. 1995. Precedences in specifications and implementations of programming languages. Theor. Comput. Sci. I~P, 1 (May), 3-26. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. AGRAWAL, R. AND DETRO, K. D. 1983. An efficient incremental LR parser for grammars with epsilon productions. Acta Inf. 19, 369-376. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. AHO, A. V., JOHNSON, S. C., AND ULLMAN~ J. D. 1975. Deterministic parsing of ambiguous grammars. Commun. ACM 18, 8 (Aug.), 441-452. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. AHO, A. V., SETHI, R., AND ULLMAN~ Z. D. 1986. Compilers: Principles, Techniques, and Tools. Addison-Wesley, Reading, Mass. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. BALLANCE, R. A., BUTCHER, J., AND GRAHAM~ S. L. 1988. Grammatical abstraction and incremental syntax analysis in a language-based editor. In Proceedings of the A CM SIGPLAN '88 Symposium on Compiler Construction. ACM Press, New York, 185-198. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. BEETEM, J. F. AND BEETEM, A. F. 1991. Incremental scanning and parsing with Galaxy. IEEE Trans. Softw. Eng. 17, 7 (July), 641-651. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. BURKE, M. G. AND FISHER, G. A. 1987. A practical method for LR and LL syntactic error diagnosis and recovery. ACM Trans. Program. Lang. Syst. 9, 2 (Apr.), 164-197. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. CORBETT, Ro 1992. bison release 1.24. Free Software Foundation, Inc., 675 Mass Ave., Cambridge, MA 02139.Google ScholarGoogle Scholar
  9. DEGANO~ P., MANNUCCI, S., AND MOJANA, B. 1988. Efficient incremental LR parsing for syntaxdirected editors. ACM Trans. Program. Lang. Syst. 10, 3 (July), 345-373. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. GAFTER, N. M. 1990. Parallel incremental compilation. Ph.D. thesis, University of Rochester, Rochester, N.Y. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. GHEZZI, C. AND MANDRIOLI, D. 1980. Augmenting parsers to support incrementality. J. A CM PT, 3 (July), 564-579. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. HEDIN, G. 1992. Incremental semantic analysis. Ph.D. thesis, Department of Computer Science, Lund University~Google ScholarGoogle Scholar
  13. HEERING~ J., HENDRIKS, P. R. H.~ KLINT, P., AND REKERS, J. 1992. The syntax definition formalism SDF Reference Manual. ASF+SDF Project.Google ScholarGoogle Scholar
  14. HEILBRUNNER, S. 1979. On the definition of ELR(k) and ELL(k)grammars. Acta Inf. 1i, 169-176.Google ScholarGoogle Scholar
  15. JALIL}(, F~ AND GALLIER, J. S. 1982. Building friendly parsers. In Proceedings of the 9th A CM Symposium on the Principles of Programming Languages. ACM Press, New York, 196-206. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. KLINT, P. AND VISSER, E. 1994. Using filters for the disaznbiguation of context-free grammars. In Proceedings of the ASMICS Workshop on Parsing Theory.Google ScholarGoogle Scholar
  17. LALONDE, W. R. 1977. Regular right part grammars and their parsers. Commun. ACM 20, 10, 731-740. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. LARCHEVEQUE, J. M. 1995. Optimal incremental parsing. A CM Trans. Program. Lang. Syst. 17, 1, 1-15. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. LI, W. X. 1995a. A simple and efficient incremental LL(1) parsing. In SOFSEM '95: Theory and Practice of Informatics (MiIovy, Czech Republic). Lecture Notes in Computer Science. Springer-Verlag, Berlin, 399-404. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. LI, Wo X. 1995b. Towards generating practical language-based editing systems. Ph.D. thesis, University of Western Australia.Google ScholarGoogle Scholar
  21. MADDOX, W. 1997. Incremental static semantic analysis. Ph.D. thesis, University of California, Berkeley. Tech. Rep. UCB/CSD-97-948. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. MAVERICK, V. 1997. Presentation by tree transformation. Ph.D. thesis, University of California, Berkeley. Tech. Rep UCB/CSD-97-947. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. MURCHING, A. M., PRASAD, Y. V., AND SRIKANT, V. N. 1990. Incremental recursive descent parsing. Comput. Lang. 15, 4, 193-204. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. PETRONE, L. 1995. Reusing batch parsers as incremental parsers. In Proceeding of the 15th Conference on Foundations of Software Technology and Theoretical Computer Science (Bangalore, India). Lecture Notes in Computer Science, vol. 1026. Springer-Verlag, Berlin, 111-123. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. REPS, W. W. AND TEITELBAUM, W. 1989. The Synthesizer Generator: A System for Constructing Language-Based Editors. Springer-Verlag, Berlin. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. SASSA, M. AND NAKATA, I. 1987. A simple realization of LR-parsers for regular right part grammars. Inf. Proc. Lett. 24, 113-120. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. SHILLING, J. J. 1992. Incremental LL(1) parsing in language-based editors. IEEE Trans. Softw. Eng. 19, 9 (Sept.), 935-940. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. TARJAN~ R. E. 1983. Data Structures and Network Algorithms. Society for Industrial and Applied Mathematics, Philadelphia, Pa. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. THORUP, M. 1994. Controlled grammatic ambiguity. A CM Trans. Program. Lang. Syst. 16, 3 (May), 1024-1050. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. VAN DE VANTER, M. L., GRAHAM, S. L., AND BALLANCE, R. A. 1992. Coherent user interfaces for language-based editing systems. Int. J. Man-Machine Stud. 37, 431-466. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. VlSSER, E. 1995. A case study in optimizing parsing schemata by disambiguation filters. Tech. Rep. P9507, Programming Research Group, University of Amsterdam. July.Google ScholarGoogle Scholar
  32. WAGNER, T. A. 1997. Practical algorithms for incremental software development environments. Ph.D. thesis, University of California, Berkeley. Tech. Rep. UCB/CSD-97-946. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. WAGNER, T. A. AND GRAHAM, S. L. 1997. Efficient self-versioning documents. In CompCon '97. IEEE Computer Society Press, Los Alamitos, Calif., 62-67. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. WEGMAN, M. N. 1980. Parsing for structural editors. In Proceeding of the 21st Annual IEEE Symposium on Foundations of Computer Science. IEEE Press, New York, 320-327.Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. YANG~ W. 1994. Incremental LR parsing. In 1994 International Computer Symposium Conference Proceedings vol. 1. National Chiao Tung University, Hsinchu, Taiwan, 577-583.Google ScholarGoogle Scholar
  36. YEH, D. AND KASTENS, U. 1988. Automatic construction of incremental LR(1) parsers. ACM SIGPLAN Not. 23, 3 (Mar.), 33-42. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Efficient and flexible incremental parsing

                Recommendations

                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

                • Published in

                  cover image ACM Transactions on Programming Languages and Systems
                  ACM Transactions on Programming Languages and Systems  Volume 20, Issue 5
                  Sept. 1998
                  193 pages
                  ISSN:0164-0925
                  EISSN:1558-4593
                  DOI:10.1145/293677
                  Issue’s Table of Contents

                  Copyright © 1998 ACM

                  Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

                  Publisher

                  Association for Computing Machinery

                  New York, NY, United States

                  Publication History

                  • Published: 1 September 1998
                  Published in toplas Volume 20, Issue 5

                  Permissions

                  Request permissions about this article.

                  Request Permissions

                  Check for updates

                  Qualifiers

                  • article

                PDF Format

                View or Download as a PDF file.

                PDF

                eReader

                View online with eReader.

                eReader