CSC448: Homework [1/1] Previous pageContents

                             INTRODUCTION

Start by reading examples\clogs\README.txt.

                                TASK 1

First, experiment with the CLOGS compiler.  Produce a small working
Clogs program whose output when compiled to an executable is:

  1=1
  1+2=3
  1+2+3=6
  1+2+3+4=10
  1+2+3+4+5=15
  1+2+3+4+5+6=21

Your program must be parameterized, i.e., there is a global integer
variable called "numRepetitions" that determines how many triangular
numbers are displayed.  

Name your Clogs source code as "examples\clogs\triangular.clogs".

Negative points will be awarded for hardcoding the entire strings,
i.e.,

  print ("1=1");
  print ("1+2=3");
  print ("1+2+3=6");
  ...


                                TASK 2

Extend the CLOGS lexer, parser, abstract syntax tree, and pretty
printer with the following constructs:

* do-while loops

* for loops

* switch statements (C-style, with fall-through, default)

* continue

* break

* pre-increment: ++e 

* post-increment: e++

* conditional expressions: e1?e2:e3

Should be modelled on ANSI C rather than Java.

Consult the online grammars

  http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
  http://www.quut.com/c/ANSI-C-grammar-y.html

Create a phase XML file that only includes parsing and pretty
printing.  (The remaining phases won't be able to handle the
constructs you introduce.)  (You must also comment out lines 51 and
148 of Driver.java.)

Create Clogs source code examples for each of the constructs,
named "examples\clogs\example-{1,2,3,4,5,6,7,8}.clogs".

HINT: do everything for do-while first!

========================================================================

                              SUBMISSION

The same criteria for grading and submission instructions apply as
before.  Copy grader.txt into examples/clogs/grader.txt and run "ant
submit" in examples/clogs.

Previous pageContents