deliverable: comments and desugaring

Note that this is one of two deliverables due by the end of week 5!
The following modifications should be made to the flex/bison C version of the compiler. You must document the lines that need to be changed; source code comments are preferred.

C-style comments

The A- implementation only allows one-line comments such as:

// this is a comment

It would be nice to additionally allow multi-line comments, such as:

/* this is a
longer comment */

This improvement can be implemented by only making changes to the file joos.l. Hint: if you get stuck, it's a good idea to RTFM. (Where F stands for Flex, naturally.) We do not demand that you implement support for nested comments such as:

/* this is a comment /* this is a nested comment; comes in handy when commenting out large chunks of code*/ */

However, try to answer the question "Why are nested comments hard to handle in a scanner?".

Increments and for-loops

It would be very nice to include standard increments and for-loops such as:

for (i=0; i<10; i++) k=k*i;

These constructs may be introduced as mere syntactic sugar, since they can readily be expressed in the JOOS language itself. This improvement can be implemented by only making changes to the files joos.l and joos.y.

You should not reject a for-loop in places where javac would accept it.

Also, note that you do not have to add the postincrement instruction in its full generality: you don't have to allow expressions of the form identifier++ - statements of the form identifier++; are sufficient. Also, you don't have to allow for on-the-fly declaration of variables within the for-loop, i.e. it is sufficient to support for(i=0;... ; no need  to provide for for(int i=0;...

Use Subversion to copy the A- JOOS source to your group directory:

$ svn cp public_html/joos/a- group-X/joos/scanparse

and commit that before beginning work. Then, make your modifications, include some tiny test programs that compile and run correctly with your improved compiler---but also test your benchmark program for this week if it uses these constructs---and add a README file (group-X/joos/scanparse/README) describing your work and the changes you needed to make. It is fine to leave precise details to comments in the source code. Format your text in 80 column blocks for readability, and stick to the current JOOS programming style. Your TA will use Subversion to look at your changes and run your test programs in order to evaluate you. Multiple small test inputs are more useful than one big test input that attempts to cover all features; a combination of both is even better.

There is no need to email us on completion. Unless you took a late day we will automatically take the version into account that was checked in last before the point of the deadline.

Maintained by Eric Bodden. [HOME]