Abstract
This paper describes a general method of compiler implementation using higher order abstract syntax and logic programming. A working compiler written in λProlog is used to demonstrate this method. Various stages of compilation are formulated as higher order logic programming including parsing and the generation of higher order representations, type checking, intermediate representation in continuationpassing style, and machine-dependent code generation. The performance overhead of using higher order representations is also addressed.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
M. Abadi, L. Cardelli, P. Curien, and J. Levy. Explicit substitutions. Journal of Functional Programming, 1(4):375–416, 1991.
A. W. Appel. Compiling with Continuations. Cambridge University Press, 1992.
A. W. Appel. Modern Compiler Implementation in ML. Cambridge University Press, 1998.
J. Cohen and T. Hickey. Parsing and compiling using Prolog. ACM Transactions on Programming Languages and Systems, 9(2):125–163, 1987.
L. Damas and R. Milner. Principal type-schemes for functional programs. In Ninth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 207–212, January 1982.
O. Danvy. Back to direct style. Science of Computer Programming, 22(3):183–195, 1994.
O. Danvy, B. Dzafic, and F. Pfenning. On proving syntactic properties of CPS programs. In Proceedings of the Third International Workshop on Higher Order Operational Techniques in Semantics, September 1999.
A. Felty. Defining object-level parsers in λProlog. In Proceedings of the Workshop on the λProlog Programming Language, 1992. Department of Computer and Information Science, University of Pennsylvania, Technical Report MS-CIS-92-86.
M. Fischer. Lambda calculus schemata. In ACM Conference on Proving Assertions about Programs, SIGPLAN Notices 7, number 1, pages 104–109, 1972.
C. Flanagan, A. Sabry, B. Duba, and M. Felleisen. The essence of compiling with continuations. In ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 237–247. ACM Press, 1993.
R. Floyd. Bounded context syntactic analysis. Communications of the ACM, 7(2):62–67, 1964.
S. L. Graham. On bounded right context languages and grammars. SIAM Journal on Computing, 3(3):224–254, 1974.
J. Hannan. Investigating a Proof-Theoretic Meta-Language for Functional Programs. PhD thesis, University of Pennsylvania, August 1990.
J. Hannan and D. Miller. Uses of higher-order unification for implementing program transformers. In Fifth International Logic Programming Conference, pages 942–959, Seattle, Washington, August 1988. MIT Press.
J. Hannan and F. Pfenning. Compiler verification in LF. In Seventh Annual IEEE Symposium on Logic in Computer Science, Santa Cruz, California, June 1992. IEEE Computer Society Press.
M. Harrison and I. Havel. On the parsing of deterministic languages. Journal of the ACM, 21(4):525–548, 1974.
J. Hodas and D. Miller. Logic programming in a fragment of intuitionistic linear logic. Information and Computation, 110(2):327–365, 1994.
Gérard Huet. A unification algorithm for typed λ-calculus. Theoretical Computer Science, 1:27–57, 1975.
S. Le Huitouze, P. Louvet, and O. Ridoux. Logic grammars and λProlog. In David S. Warren, editor, Proceedings of the Tenth International Conference on Logic Programming, pages 64–79. MIT Press, 1993.
D. E. Knuth. On the translation of languages from left to right. Information and Control, 8(6):607–639, 1965.
D. Kranz, R. Kelsey, J. Rees, P. Hudak, J. Philbin, and N. Adams. ORBIT: An optimizing compiler for Scheme. In SIGPLAN 1986 Symposium on Compiler Construction, SIGPLAN Notices 21, number 7, pages 219–233, 1986.
C. Liang. Let-polymorphism and eager type schemes. In TAPSOFT’ 97: Theory and Practice of Software Development, pages 490–501. Springer Verlag LNCS Vol. 1214, 1997.
C. Liang. A deterministic shift-reduce parser generator for a logic programming language. In Computational Logic-CL 2000, Springer-Verlag LNAI no. 1861, pages 1315–1329, July 2000.
C. Liang and G. Nadathur. Trade-offs in the intensional representation of lambda terms. Submitted for publication.
D. Miller. A logic programming language with λ-abstraction, function variables, and simple unification. Journal of Logic and Computation, 1(4):497–536, 1991.
D. Miller. Unification of simply typed lambda-terms as logic programming. In 8th International Logic Programming Conference, pages 255–269. MIT Press, 1991.
D. Miller. Abstract syntax for variable binders: An overview. In Computational Logic-CL 2000, Springer-Verlag LNAI no. 1861, pages 239–253, July 2000.
D. Miller, G. Nadathur, F. Pfenning, and A. Scedrov. Uniform proofs as a foundation for logic programming. Annals of Pure and Applied Logic, 51:125–157, 1991.
G. Nadathur. An explicit substitution notation in a ?Prolog implementation. Technical Report TR-98-01, Department of Computer Science, University of Chicago, January 1998. Also appears in the Proceedings of the First InternationalWorkshop on Explicit Substitutions, Tsukuba, Japan, March1998.
G. Nadathur. A fine-grained notation for lambda terms and its use in intensional operations. Journal of Functional and Logic Programming, 1999(2), March1999.
G. Nadathur and D. Miller. An Overview of λProlog. In Fifth International Logic Programming Conference, pages 810–827. MIT Press, August 1988.
G. Nadathur and D. Miller. Higher-order logic programming. In D. Gabbay, C. Hogger, and A. Robinson, editors, Handbook of Logic in Artificial Intelligence and Logic Programming, volume 5, pages 499–590. Oxford University Press, 1998.
G. Nadathur and D. Mitchell. System description: Teyjus-a compiler and abstract machine based implementation of λProlog. In Automated Deduction-CADE-13, Springer-Verlag LNAI no. 1632, pages 287–291, July 1999.
R. Paul. Sparc architecture, assembly language programming, and C. Prentice Hall, second edition, 2000.
F. Pereira and D. Warren. Definite clause grammars for language analysis. Artificial Intelligence, 13:231–278, 1980.
F. Pereira and D. Warren. Parsing as deduction. In 21st Annual Meeting of the Association for Computational Linguistics, pages 137–144, 1983.
F. Pfenning. Logic programming in the LF logical framework. In G. Huet and G. D. Plotkin, editors, Logical Frameworks. Cambridge University Press, 1991.
F. Pfenning and C. Elliot. Higher-order abstract syntax. In ACM-SIGPLAN Conference on Programming Language Design and Implementation, pages 199–208. ACM Press, 1988.
A. Sabry and M. Felleisen. Reasoning about programs in continuation-passing style. Lisp and Symbolic Computation, 6(3/4):289–360, 1993.
M. Wand. Correctness of procedure representations in higher-order assembly language. In Proceedings: Mathematical Foundations of Programming Semantics’ 91, pages 294–311. Springer-Verlag LNCS vol. 598, 1992.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2002 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Liang, C.C. (2002). Compiler Construction in Higher Order Logic Programming. In: Krishnamurthi, S., Ramakrishnan, C.R. (eds) Practical Aspects of Declarative Languages. PADL 2002. Lecture Notes in Computer Science, vol 2257. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45587-6_5
Download citation
DOI: https://doi.org/10.1007/3-540-45587-6_5
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-43092-6
Online ISBN: 978-3-540-45587-5
eBook Packages: Springer Book Archive