Abstract
This paper presents an alternative approach to implementation of DCGs. In contrast to the standard implementation we use the well-known bottom-up SLR(1)-parsing technique. An experimental system, AID, based on this technique is presented and discussed. The aim of this work is twofold. Firstly, we describe an alternative principle of implementation of DCGs, which makes it possible to cope with left-recursive DCGs and to avoid unnecessary backtracking when parsing. Secondly, we demonstrate that Prolog can be used for implementation of table driven parsers that generalize deterministic LR(k)-parsing techniques to the case of ambiguous grammars. The parsers generated by our system are deterministic whenever the submitted grammar is SLR(1). Otherwise the shift/reduce or reduce/reduce conflicts are stored in the generalized table and are used as Prolog backtrack points.
Similar content being viewed by others
References
Aho, A. and Ullman, J.,Principles of Compiler Design, Addison-Wesley, 1977.
Barklund, J.Logic Programming Seminar, IDA Linköping University (private communication).
Bowen, D. L. (ed.),DECsystem-10 Prolog User’s Manual, DAI, University of Edinburgh, 1982.
Colmerauer, A., “Metamorphosis Grammars”,Natural Language Communication with Computers, Lecture Notes in Computer Science, 63, Springer-Verlag, 1978.
Deransart, P. and Maluszynski, J., “Relating Logic Programs and Attribute Grammars”,Journal of Logic Programming,Vol. 3,No. 2, 1985.
Johnson, S. C.,Yacc: Yet Another Compiler-Compiler, Bell Laboratories, 1978.
Knuth, D. E., “On Translation of Languages From Left to Right”,Information and Control,Vol. 8,No. 6, 1965.
Kowalski, R. A., “Algorithm=Logic+Control”,Comm. ACM,Vol. 22,No. 7, 1979.
Lloyd, J. W.,Foundations of Logic Programming, Springer-Verlag, 1984.
Matsumoto, Y., Tanaka, H., Hirakawa, H., Miyoshi, H. and Yasukawa, H., “BUP: A Bottom-Up Parser Embedded in Prolog”,New Generation Computing, Vol. 1, 1983.
Pereira, F. C. N. and Warren, D. H. D., “Definite Clause Grammars for Language Analysis—A Survey of the Formalism and a Comparison with Augmented Transition Network”,Artificial Intelligence, Vol. 13, 1980.
Uehara, K., Ochitani, R., Kakusho, O., Toyoda, J., “A Bottom-Up Parser Based on Predicate Logic: A Survey of the Formalism and its Implementation Technique”,Proc. 1984 International Symposium on Logic Programming, IEEE, Atlantic City, 1984.
Warren, D. H. D., “Implementing Prolog—Compiling Predicate Logic Programs”,DAI Research Report 39 & 40, University of Edinburgh, 1977.
Author information
Authors and Affiliations
About this article
Cite this article
Nilsson, U. AID: An alternative implementation of DCGs. New Gener Comput 4, 383–399 (1986). https://doi.org/10.1007/BF03037391
Received:
Issue Date:
DOI: https://doi.org/10.1007/BF03037391