{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

PA3 - CS 143 Compilers Handout 6 Programming Assignment III...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 143 Compilers Handout 6 Programming Assignment III Due Thursday, November 5, 2009 at 11:59 PM 1 Introduction In this assignment, you will implement the static semantics of Cool. You will use the abstract syntax trees (AST) built by the parser to check that a program conforms to the Cool specification. Your static semantic component should reject erroneous programs; for correct programs, it must gather certain information for use by the code generator. The output of the semantic analyzer will be an annotated AST for use by the code generator. This assignment has much more room for design decisions than previous assignments. Your program is correct if it checks programs against the specification. There is no one “right” way to do the assignment, but there are wrong ways. There are a number of standard practices that we think make life easier, and we will try to convey them to you. However, what you do is largely up to you. Whatever you decide to do, be prepared to justify and explain your solution. You will need to refer to the typing rules, identifier scoping rules, and other restrictions of Cool as defined in the Cool Reference Manual. You will also need to add methods and data members to the AST class definitions for this phase. The functions the tree package provides are documented in the Tour of Cool Support Code . There is a lot of information in this handout, and you need to know most of it to write a working semantic analyzer. Please read the handout thoroughly. At a high level, your semantic checker will have to perform the following major tasks: 1. Look at all classes and build an inheritance graph. 2. Check that the graph is well-formed. 3. For each class (a) Traverse the AST, gathering all visible declarations in a symbol table. (b) Check each expression for type correctness. (c) Annotate the AST with types. This list of tasks is not exhaustive; it is up to you to faithfully implement the specification in the manual. As before, you may work individually or as a pair. 2 Files and Directories To get started, create a directory where you want to do the assignment and execute one of the following commands in that directory . For the C++ version of the assignment, you should type make -f /usr/class/cs143/assignments/PA4/Makefile For Java, type: Fall 2009/2010 page 1 of 6
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CS 143 Compilers Handout 6 make -f /usr/class/cs143/assignments/PA4J/Makefile (notice the “J” in the path name). As usual, there are several files used in the assignment that are symbolically linked to your directory or are included from /usr/class/cs143/include/PA4 . Do not modify these files. Almost all of these files have have been described in previous assignments. See the instructions in the README file. We now describe the most important files for each version of the project.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}