

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Compiler Design (CIS 4930/6930) [Fall 2007] Programming Assignment II Objectives
Compilation of the Lexer Compile your lexer with the following commands (where “>” is a command prompt).
flex dj.l bison dj.y gcc dj.tab.c –lfl –o dj-lex Example Executions The good1.dj program is: class C extends Object { } main { 0; } This good1.dj file is correctly tokenized as follows. ./dj-lex good1.dj CLASS ID(C) EXTENDS ID(Object) LBRACE RBRACE MAIN LBRACE NATLITERAL(0) SEMICOLON RBRACE ENDOFFILE
As another example, the good3.dj program is: //prints 4 main { var nat x; x=0; x=x+1; x=x+1; x=x+1; x=x+1; printNat(x); } This good3.dj file is correctly tokenized as follows.
./dj-lex good3.dj MAIN LBRACE VAR NATTYPE ID(x) SEMICOLON ID(x) ASSIGN NATLITERAL(0) SEMICOLON ID(x) ASSIGN ID(x) PLUS NATLITERAL(1) SEMICOLON ID(x) ASSIGN ID(x) PLUS NATLITERAL(1) SEMICOLON ID(x) ASSIGN ID(x) PLUS NATLITERAL(1) SEMICOLON ID(x) ASSIGN ID(x) PLUS NATLITERAL(1) SEMICOLON PRINTNAT LPAREN ID(x) RPAREN SEMICOLON RBRACE ENDOFFILE
Please note that we will test your lexer on DJ files that have not been distributed to the class. Submission Notes Type the following pledge as an initial comment in your dj.l file: “I pledge my honor that I have not cheated on this assignment.” Type your name after the pledge. Not including this pledge will lower your grade 50%. Upload and submit your dj.l file into the digital dropbox in Blackboard. For every day that your assignment is late, your grade reduces 10%. Your program must be commented appropriately. 2