8 files were used for testing and they can be found here .
The first 5 files and the last file are error-free. Files 6 and 7 contain all the errors. Make sure you understand why each error occurs. Sufficient explanation is interspersed between the error messages. You may want to open a new browser window for viewing the data files along with this document.
Enter a file name: t1.txt x = 3 y = 5 sum = 35 Type another file name or 'quit' to terminate the program: t2.txt a = 1 b = 2 Type another file name or 'quit' to terminate the program: t3.txt a = 1 b = 2 sum = 3 Type another file name or 'quit' to terminate the program: t4.txt a = 1 b = 2 sum = 3 sum = 30 a = 10 b = 20 sum = 30 Type another file name or 'quit' to terminate the program: t5.txt a = 0 b = 205239756490 sum = 7 Type another file name or 'quit' to terminate the program: t6.txt Error: Undefined variableIf you find any mistakes in the test data please contact me me or any of the TAs.Here, we are trying to use the variable
Error: Undefined variablea
in RHS of line 1 without initializing it . Hence the error.Here, even though the variable
Type another file name or 'quit' to terminate the program: t7.txt Error: Expecting a variable, found something else insteada
appears in LHS in line 1, since line 1 contained an error , the assignment could not succeed.Hence the variablea
is undefined even in line 2.This is because of missing the variable name in line 1.
Error: Expecting an assignment operator, found something else insteadThis is because of missing the = in line 2.
Error: Strange characterThis is because of missing the expression in line 3.
Error: Expecting an assignment operator, found something else insteadThis is because of missing the = in line 4. It is important to note that the statment since the = operator is missing in line 4 , the characters in the input are skipped until the next semicolon, which is present in line 5. Here, it actually doesn't perform a= 1+1 even though that statment, as such , is error-free.
Error: Not a valid operatorThis is because of missing the operator in line 6.
Error: Strange characterThis is because of using the - symbol in line 7.
Error: Strange characterThis is because of missing the operand in line 8.
Error: Undefined variableThis is because of the variable
Type another file name or 'quit' to terminate the program: t8.txt thiscourse = 16 nextcourse = 17 dataStructures = 17 algorithms = 21 program = 38 Java = 13 nextSemThisCourse = 13 Compilation = 40 Execution = 60 total = 100 a = 100 something = 10 something = 15 forall = 1 aplus = 115 grade = 115 Type another file name or 'quit' to terminate the program: quite
being undefined in line 9.Again, though it is appears in the LHS of line 8, since that assignment statement was erroneous, the variablee
is not initialized.