CIT 594 Errata #4 for Bugs Grammar (and Code)
Spring 2008, David Matuszek

Two minor changes.

The <var declaration> should end with an <eol>:

Was:
<var declaration> ::= "var" <NAME> { "," <NAME> }
Now:
<var declaration> ::= "var" <NAME> { "," <NAME> } <eol>

I said in class that we had no negative numbers, and that '+' and '-' were always operators. True, but...my code did not take into account the two places that these are unary operators: at the very beginning of an expression, and immediately following an open parenthesis. Fortunately, this is easily fixed by adding two lines to isFactor();

Was:
public boolean isFactor() {
    if (isVariable()) {
        if (symbol(".")) {              // reference to another Bug
            if (name()) return true;
            else error("Incorrect use of dot notation");
        }
        else if (isParameterList()) return true; // function call
        else return true;                        // just a variable
    }
    if (number()) return true;
    if (symbol("(")) {
        if (!isExpression()) error("Error in parenthesized expression");
        if (!symbol(")")) error("Unclosed parenthetical expression");
        return true;
   }
   return false;
}
Now:
public boolean isFactor() {
    boolean startsWithUnary = symbol("+") || symbol("-");
    if (isVariable()) {
        if (symbol(".")) {              // reference to another Bug
            if (name()) return true;
            else error("Incorrect use of dot notation");
        }
        else if (isParameterList()) return true; // function call
        else return true;                        // just a variable
    }
    if (number()) return true;
    if (symbol("(")) {
        if (!isExpression()) error("Error in parenthesized expression");
        if (!symbol(")")) error("Unclosed parenthetical expression");
        return true;
   }
   if (startsWithUnary) error("Error in factor");
   return false;
}

Please make these changes. Plus, you should update your JUnit to test whether unary plus and minus can now be used in factors--I'll leave that bit of code to you..