Compiler generation from relational semantics
1986, Lecture Notes in Computer Science
Abstract
We consider the problem of automatically deriving correct compilers from relational semantic specifications of programming languages. A relational semantics is an assignment of initial-state final-state relations (defined by means of proof rules) to programs. Compilers are generated in three steps. First, the language definition is transformed into a stack semantics in which the sto~age of semantic values is made explicit. Next, stack rules are assembled into a socalled language scheme containing exactly one rule for each language construct. We consider languages for which non-deterministic branches may be replaced by deterministic ones. Finally, rules are expanded for the purpose of recursion detection, thus obtaining schemes which may be used for code generation in a syntax-directed compiler.
References (22)
- J.A. Goguen, J.W. Thatcher, E.G. Wagner: An Initial Algebra Approach to the Speci- fication, Correctness, and Implementation of Abstract Data Types. In: Current Trends in Programming Methodology, Vol. IV, R.T. Yeh (editor), Prentice-Hall 1978.
- D. Bj~rner: Formal Development of Interpre- ters and Compilers, DtH ID673, 1977.
- J.W. De Bakker, W.P. De Roever: A Calcu- lus for Recursive Program Schemes° In: Automata, Languages, Programming, Nivat (editor), North-Holland, Amsterdam 1972.
- H. Ganzinger: Transforming Denotational Semantics into practical Attribute Gram- mars. In: Semantics-Directed Compiler Ge- neration, LNCS 94, N.D. Jones (editor), 1980.
- M.J.C. Gordon: The Denotational Descrip- tion of Programming Languages -An Intro- duction, Springer-Verlag 1979.
- I.Greif, A.R. Meyer: Specifying the Se- mantics of while Programs: A Tutorial and Critique of a Paper by Hoare and Lauer, ACM Transactions on Programming Languages and Systems, Vol. 3, No. 4, Oct. 1981.
- C.A.R. Hoare, P.E. Lauer: Consistent and Complementary Formal Theories of the Se- mantics of Programming Languages, Acta Informatica 3, 1974. [Jensen/Dam 85]
- Fo Jensen, M. Dam: Automatisk generering af overs~ttere udfra operationelt seman- tiske definitioner af programmeringssprog, M.Sc. Thesis (in danish), Aalborg Univer- sity Centre, 1985. [Jones/Chris- tiansen 81]
- N.D. Jones, H. Christiansen: Control Flow Treatment in a Simple Semantics-Directed Compiler Generator, DAIMI PB-137, sept. 1981.
- Jones/Schmidt 80] N.D. Jones, D.A. Schmidt: Compiler Gene- ration from Denotational Semantics. In: Semantics-Directed Compiler Generation, LNCS 94, N.D. Jones (editor), 1980.
- R. Kowalski: Predicate Logic as Program- ming Language. In: Information Processing 74, North-Holland 1974.
- Milne/Strachey 76] R. Milne, C. Strachey: A Theory of Pro- gramming Language Semantics, Chapman and Hall, 1976.
- F.L. Morris: Advice on Structuring Compi- lers and Proving Them Correct, Proc. 2nd ACM Symp. on Principles of Prog. Lan., 1973.
- P. Mosses: SIS-Semantics Implementation System, Reference Manual and User's Guide, DAIMI MD-30, 1979.
- P. Mosses: A Constructive Approach to Com- piler Correctness. In: Semantics-Directed Compiler Generation, LNCS 94, N.D. Jones (editor), 1980.
- H.R. Nielson: Hoare Logic's for Run-time Analysis of Programs, Ph.D. Thesis, Uni- versity of Edinburgh, oct. 1984. [Nielson/ Nielson 85] [Plotkin 81] [ Schmidt 85] [Sethi 83] [Stoy 77]
- F. Nielson, H.R. Nielson: Pragmatic Aspects of Two-Level Denotational Meta-Languages, AUC R-85-13°
- G.D. Plotkin: A Structural Approach to Operational Semantics, DAIMI FN-19, sept. 1981.
- D.A. Schmidt: Detecting Global Variables in Denotational Specifications, ACM Trans- actions on Programming Languages and Sys- tems, Vol. 7, No. 2, april 1985.
- R. Sethi: Control-Flow Aspects of Seman- tics-Directed Compiling, ACM Transactions on Programming Languages and Systems, Vol. 5, No. 4, oct. 1983.
- J.E. Stoy: Denotational Semantics: The Scott-Strachey Approach to Programming Lan- guage Theory, MIT Press, 1977.
- M. Wand: Deriving Target Code as a Repre- sentation of Continuation Semantics, ACM Transactions on Programming Languages and Systems, Voi. 4, No. 3, july 1982.