CodePlexProject Hosting for Open Source Software

1

Vote
The parser does not accept certain arithmetic expressions, for example x+1, because it expects a space after binary operators.

The problem is in lexer.lex with these lines:

[-+]?[0-9]+ { return (int)Tokens.DIGITS; }

[-+]?[0-9]+[.][0-9]+ { return (int)Tokens.REAL; }

[-+]?[0-9]+[\/][-+]?[0-9]*[1-9] { return (int)Tokens.FRAC; } *

The problem being that the + and - sign are considered part of the DIGITS/REALS/FRAC token, which forbids the parser to decide whether they are binary or unary operators.

A fix is to change the lines to the following code, and let the parser decide between unary minus, binary minus and binary plus operators (but this way +1 is not a valid number, since there is no unary + operator defined in the parser):

[0-9]+ { return (int)Tokens.DIGITS; }

[0-9]+[.][0-9]+ { return (int)Tokens.REAL; }

[0-9]+[\/][-+]?[0-9][1-9] { return (int)Tokens.FRAC; }

The problem is in lexer.lex with these lines:

[-+]?[0-9]+ { return (int)Tokens.DIGITS; }

[-+]?[0-9]+[.][0-9]+ { return (int)Tokens.REAL; }

[-+]?[0-9]+[\/][-+]?[0-9]

The problem being that the + and - sign are considered part of the DIGITS/REALS/FRAC token, which forbids the parser to decide whether they are binary or unary operators.

A fix is to change the lines to the following code, and let the parser decide between unary minus, binary minus and binary plus operators (but this way +1 is not a valid number, since there is no unary + operator defined in the parser):

[0-9]+ { return (int)Tokens.DIGITS; }

[0-9]+[.][0-9]+ { return (int)Tokens.REAL; }

[0-9]+[\/][-+]?[0-9]

No files are attached

## comments