Saturday, June 29, 2013

Minor Parser Correction

Implementation of the new translator will start with simple expressions consisting of simple operands (constants and identifiers without parentheses), unary operators, binary operators and possibly parenthetical expressions.  While implementing the new routines (more details in following posts), a minor parser problem was discovered.

When in operand state (which allows a minus sign in front of a numerical constant for a negative constant), if the expression started with a "-E" string, it was interpreted as an incorrectly formed floating point constant that was missing digits before the start of the exponent.  Any other character besides an "E" was correctly interpreted as an operator followed by an identifier without parentheses.

The problem occurred in the parser get number routine when there was an 'E' character that was not preceded by digits, which returned the "expected digits in mantissa of floating point constant" error.  For this condition, a check was added if a sign was seen and no decimal point was seen, then the routine returns that no number was found.  The parser then proceeds to the get operator routine.

[commit bae8b420b8]