If your program is invoked like this:
./bminor -parse sourcefile.bminorThen it should behave as follows:
./bminor -scan sourcefile.bminorThen it should continue to operate as in the previous assignment; this will facilitate debugging.
expr : expr TOKEN_ADD expr | expr TOKEN_SUB expr ... ;Then, verify that your grammar has no shift-reduce or reduce-reduce conflicts. If it does, look at the detailed output of Bison and re-write your grammar rules to address them. Once you have basic expressions working, then start adding control-flow structures, and then declarations, until you have constructed the complete grammar.
Note that Bison will tell you if your grammar has errors. In particular, your grammar must not have any shift-reduce or reduce-reduce conflicts. To eliminate them, you may only re-write the production rules, you may not apply disambiguating rules, operator precedence specifiers, or apply other "tricks" found in Bison. (The purpose of this rule is to force you to fully understand the key ideas in LR parsing.)
The starter code provides some example tests to give you the idea, but they are not comprehensive, so write your own thorough tests.
The exit status of bminor is very important because it indicates to the user whether the program succeeded or not. The Unix convention is that the result of main (or the call to exit) should be zero to indicate success and non-zero to indicate failure. We will use the program exit status to determine the correctness of your submissions and your test, using a script like this:
#!/bin/sh for testfile in good*.bminor do if bminor -parse $testfile > $testfile.out then echo "$testfile success (as expected)" else echo "$testfile failure (INCORRECT)" fi done for testfile in bad*.bminor do if bminor -parse $testfile > $testfile.out then echo "$testfile success (INCORRECT)" else echo "$testfile failure (as expected)" fi done
Your submission will be tested on the ND student Linux machines, so make sure that your code works there. If you develop on your laptop or another computer, leave plenty of time before final submission to debug any differences between your computer and ours.
For this assignment, your grade will be based upon the following:
This assignment is due on Friday, October 11th at 5PM.,Monday, October 14th, at 5PM. Late assignments are not accepted.
Q: Is return; a valid statement?
A: Yes, it indicates a return with no value in a void function.
Q: Does B-minor permit this syntax?
for(i=0;i<10,j<10;i++) { ... }A: No, commas may only be used in print statements, function calls, function prototypes, and array expressions.
Q: Can a single statement (without braces) be used after a for-loop or an if-statement?
A: Yes, the following are valid statements, just as in C and C++:
for(i=0;i<10;i++) print i; if(a) x=y; else z=w;
Q: Is a single semicolon a valid statement?
A: No.
Q: Can an array be zero length?
A: No - An array must be declared with a positive length.
Q: Can an array initializer by empty?
A: No - An initializer must either match the length of the array, or be omitted. It cannot be empty.
(It also avoids the case of an empty initializer {} begin confused with an
empty statement block {}.