Your program will be graded on the student Red Hat 7 machines (student00-02.cse.nd.edu) using /usr/bin/gcc, so it is your responsibility to make sure that your code compiles and works there. If which gcc does not print out /usr/bin/gcc then you are using the wrong compiler for this class.
Your program must be written in plain C (not C++) using /usr/bin/gcc (not G++) and use flex to generate the scanner. You must have a Makefile such that when you type make, all the pieces are compiled and result in a binary program called bminor. make clean should also delete all temporary files, so that the program can be made again from scratch.
Your program must be invoked as follows:
./bminor -scan sourcefile.bminorIt must output to the standard output using printf the symbolic token types for each element of the input. For literal values (integers, strings, characters) and identifiers, you must also output the body of the token, with the quotes removed and any escape codes translated. If the input contains an invalid token, then the program should print a message to the standard error stream (fprintf(stderr,"...")) and exit(1); immediately. Otherwise, the program should exit with return code zero.
For example, if the input looks like this:
string 1534 'a' Notre Dame "Notre\nDame"; >= @then your output should be:
STRING INTEGER_LITERAL 1534 CHARACTER_LITERAL a IDENTIFIER Notre IDENTIFIER Dame STRING_LITERAL Notre Dame SEMICOLON GE scan error: @ is not a valid characterA compiler has many odd corner cases that you must carefully handle. To encourage you to test thoroughly, we will also require you to turn in twenty test cases. Ten should be named good[0-9].bminor and should contain valid tokens. Ten should be named bad[0-9].bminor and should contain at least one erroneous token. We strongly recommend that you also try these example test cases. We will evaluate your code using these and some other hidden test cases.
As always, exercise good style in programming by choosing sensible variable names, breaking complex tasks down into smaller functions, and using constructive comments where appropriate. Please review the General Instructions for Turning In
This assignment is due on Friday, September 20th at 5PM. Late assignments are not accepted.
"hello world"A: No, a newline in a string needs to be escaped, like this: "hello\nworld"