hoc: don't nest calls to follow() when lexing ++/+= and --/-= (#287)
The code had a nested use of the follow() function that could cause +=+ and -=- to register as ++ and --. The first follow() to execute could consume a character and match and then the second follow() could consume another character and match. For example i-=-10 would result in a syntax error and i-=- would decrement i.
This commit is contained in:
parent
9389de63d7
commit
f1dd3f065a
1 changed files with 2 additions and 2 deletions
|
|
@ -215,8 +215,8 @@ yylex(void) /* hoc6 */
|
||||||
return STRING;
|
return STRING;
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '+': return follow('+', INC, follow('=', ADDEQ, '+'));
|
case '+': return follow('+', INC, '+') == INC ? INC : follow('=', ADDEQ, '+');
|
||||||
case '-': return follow('-', DEC, follow('=', SUBEQ, '-'));
|
case '-': return follow('-', DEC, '-') == DEC ? DEC : follow('=', SUBEQ, '-');
|
||||||
case '*': return follow('=', MULEQ, '*');
|
case '*': return follow('=', MULEQ, '*');
|
||||||
case '/': return follow('=', DIVEQ, '/');
|
case '/': return follow('=', DIVEQ, '/');
|
||||||
case '%': return follow('=', MODEQ, '%');
|
case '%': return follow('=', MODEQ, '%');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue