Notes on parser error messages ------------------------------ By default we just get an error message telling us that parsing failed or that an unrecognized token was encountered, and the row/column where successful parsing stopped (the location of the last token it handled successfully, tracked via the row and col variables). With this language/grammar, we are sometimes able to identify when the parser has entered/exited particular constructs, e.g. after the "IF" keyword we know we're working on an if statement, after a "READ" keyword we know we're working on a read statement, etc. A setstmt function has been added to lab4.lex, which can be called to specify when we have entered/exited a particular kind of construct. If you check the lab4.yacc implementation of the print statement, for instance, you'll see that after the PRTCTRL keyword it runs { setstmt(2); } to specify it knows it's in a print. You can add similar calls within statements for read, if, function calls, function definitions, array definitions, and variable definitions. The argument values expected by setstmt are 1 for read 5 for function definitions 2 for print 6 for array definitions 3 for if 7 for variable definitions 4 for function calls The setstmt function itself also records the row and column it was on at the time it was called, and the yyerror function includes in its output the name/location of the last statement it recognized.