Language Implementation by Source Transformation

Compilation involves transforming a high level language source program into an equivalent assembly or machine language program. Programming language implementation can therefore be viewed as a source to source transformation from the original high level source code to the corresponding low level ass...

Full description

Bibliographic Details
Main Author: Dayanand, Pooja
Other Authors: Queen's University (Kingston, Ont.). Theses (Queen's University (Kingston, Ont.))
Format: Others
Language:en
en
Published: 2008
Subjects:
Online Access:http://hdl.handle.net/1974/1010
id ndltd-LACETR-oai-collectionscanada.gc.ca-OKQ.1974-1010
record_format oai_dc
spelling ndltd-LACETR-oai-collectionscanada.gc.ca-OKQ.1974-10102013-12-20T03:38:35ZLanguage Implementation by Source TransformationDayanand, Poojacomputer sciencesoftware engineeringsource transformationcompilerlanguage implementationCompilation involves transforming a high level language source program into an equivalent assembly or machine language program. Programming language implementation can therefore be viewed as a source to source transformation from the original high level source code to the corresponding low level assembly language source code. This thesis presents an experiment in implementing an entire programming language system using declarative source transformation. To this end a complete compiler/interpreter is implemented using TXL, a source transformation system. The TXL-based PT Pascal compiler/interpreter is implemented in phases similar to those in a traditional compiler. In the lexical and syntactic analysis phase any lexical and syntactic errors present are detected when the source program is parsed according to the TXL grammar specified. The semantic analysis phase is then run in which semantic checks are performed on the source program and error messages are generated when semantic errors are detected. The source program is also annotated with type information. The typed intermediate code produced by the semantic analysis phase can be directly executed in the execution phase. Alternatively, the intermediate typed source can be transformed into a bytecode instruction sequence by running the code generation phase. This bytecode instruction sequence is then executed by a TXL implementation of an abstract stack machine in the code simulation phase. The TXL-based PT Pascal compiler/interpreter is compared against the traditional S/SL implementation of the PT Pascal compiler. The declarative style of TXL makes the rules and functions in the TXL-based PT Pascal compiler/interpreter easier to understand and the number of lines of code in the TXL implementation is less than in the S/SL implementation. The TXL implementation is however slower and less scalable. The implementation of the TXL-based PT Pascal compiler/interpreter and the advantages and disadvantages of this approach are discussed in greater detail in this thesis.Thesis (Master, Computing) -- Queen's University, 2008-01-29 19:31:31.454Queen's University (Kingston, Ont.). Theses (Queen's University (Kingston, Ont.))2008-01-29 19:31:31.4542008-02-01T18:15:37Z2008-02-01T18:15:37Z2008-02-01T18:15:37ZThesis474043 bytesapplication/pdfhttp://hdl.handle.net/1974/1010enenCanadian thesesThis publication is made available by the authority of the copyright owner solely for the purpose of private study and research and may not be copied or reproduced except as permitted by the copyright laws without written authority from the copyright owner.
collection NDLTD
language en
en
format Others
sources NDLTD
topic computer science
software engineering
source transformation
compiler
language implementation
spellingShingle computer science
software engineering
source transformation
compiler
language implementation
Dayanand, Pooja
Language Implementation by Source Transformation
description Compilation involves transforming a high level language source program into an equivalent assembly or machine language program. Programming language implementation can therefore be viewed as a source to source transformation from the original high level source code to the corresponding low level assembly language source code. This thesis presents an experiment in implementing an entire programming language system using declarative source transformation. To this end a complete compiler/interpreter is implemented using TXL, a source transformation system. The TXL-based PT Pascal compiler/interpreter is implemented in phases similar to those in a traditional compiler. In the lexical and syntactic analysis phase any lexical and syntactic errors present are detected when the source program is parsed according to the TXL grammar specified. The semantic analysis phase is then run in which semantic checks are performed on the source program and error messages are generated when semantic errors are detected. The source program is also annotated with type information. The typed intermediate code produced by the semantic analysis phase can be directly executed in the execution phase. Alternatively, the intermediate typed source can be transformed into a bytecode instruction sequence by running the code generation phase. This bytecode instruction sequence is then executed by a TXL implementation of an abstract stack machine in the code simulation phase. The TXL-based PT Pascal compiler/interpreter is compared against the traditional S/SL implementation of the PT Pascal compiler. The declarative style of TXL makes the rules and functions in the TXL-based PT Pascal compiler/interpreter easier to understand and the number of lines of code in the TXL implementation is less than in the S/SL implementation. The TXL implementation is however slower and less scalable. The implementation of the TXL-based PT Pascal compiler/interpreter and the advantages and disadvantages of this approach are discussed in greater detail in this thesis. === Thesis (Master, Computing) -- Queen's University, 2008-01-29 19:31:31.454
author2 Queen's University (Kingston, Ont.). Theses (Queen's University (Kingston, Ont.))
author_facet Queen's University (Kingston, Ont.). Theses (Queen's University (Kingston, Ont.))
Dayanand, Pooja
author Dayanand, Pooja
author_sort Dayanand, Pooja
title Language Implementation by Source Transformation
title_short Language Implementation by Source Transformation
title_full Language Implementation by Source Transformation
title_fullStr Language Implementation by Source Transformation
title_full_unstemmed Language Implementation by Source Transformation
title_sort language implementation by source transformation
publishDate 2008
url http://hdl.handle.net/1974/1010
work_keys_str_mv AT dayanandpooja languageimplementationbysourcetransformation
_version_ 1716620674070478848