CS 3310 - Language Translators Lab

Homework 2: Macro expansion and Parsing for MacroJava

Use Bison to write a MacroJava to MiniJava translator. Your Bison file should be called macrojava.y and if X.Java contains a MacroJava program to be processed then

bison -d macrojava.y
flex macrojava.l
gcc macrojava.tab.c lex.yy.c -lfl -o macrojava
./macrojava < X.java > Y.java

should generate the correct minijava code in Y.java. Note, your program must take input from standard input and write to standard output (so that we can use the redirection). The format for the minijava programs is given by the minijava grammar.
If the input macrojava code does not parse then output "// Failed to parse macrojava code."
Else output "// Macrojava code parsed and minijava code generated successfully.".


Grading policy
Your homework will be graded for a total of 100 marks.
[ under development ]