Compilers (CS362 2004S)

Simplifying Pascal

At this stage of compiler writing, we will discard some aspects of Pascal to make our jobs easier. While these eliminations significantly simplify your job, they should not significantly reduce your learning, as the main learning at the type checking and translation stages comes from getting the basic compiler working. In addition, this simplification will give you greater opportunity to experiment with code optimization.

Our main changes are to the types you need to support, to the forms of functions and procedures you need to support, and to awkward control structures. If you find that there are other simplifications that will be helpful and seem reasonable, please discuss them with me.

Reducing the Number of Types

We begin by eliminating most complex types. You need only deal with the basic types integer, real, Boolean, char, and string, as well as one-dimensional arrays indexed by integers. While we will discuss (in the abstract) type checking and translation of pointers, records, variant records, multi-dimensional arrays, and user-defined types, you will not be required to type check or implement those types. You also will not be required to type check or implement sets, files, and packed types.

Because we are eliminating records, you need not deal with with statements.

Because we do not permit user-defined types, you can assume that all case statements and for loops are indexed by integers.

Simplifying Functions

You need only support integers, reals, and Booleans as parameters to functions and procedures. You need not support arrays, strings, functions, or procedures as parameters to functions and procedures. (Since we have already disallowed records and user-defined types, you should not expect to support those types.)

You need only support value parameters. You need not support variable parameters.

Eliminating Awkward Control Structures

You need suport neither labels nor the goto statement.

 

History

Thursday, 1 April 2004 [Samuel A. Rebelsky]

Monday, 5 April 2004 [Samuel A. Rebelsky]

 

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Mon Apr 26 13:19:33 2004.
The source to the document was last modified on Mon Apr 5 11:29:05 2004.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2004S/Project/simplifying.html.

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky, rebelsky@grinnell.edu