[hackers] [9base] hoc: Don't nest calls to follow() when lexing ++/+= and --/-= || Evan Gates
commit 63916da7bd6d73d9a405ce83fc4ca34845667cce
Author: Evan Gates <evan_AT_gnarbox.com>
AuthorDate: Wed Sep 11 15:46:27 2019 -0700
Commit: Anselm R Garbe <anselm_AT_garbe.ca>
CommitDate: Fri Sep 13 15:56:15 2019 +0000
hoc: Don't nest calls to follow() when lexing ++/+= and --/-=
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.
diff --git a/hoc/hoc.y b/hoc/hoc.y
index 9c5a02f..f634e82 100644
--- a/hoc/hoc.y
+++ b/hoc/hoc.y
_AT_@ -215,8 +215,8 @@ yylex(void) /* hoc6 */
return STRING;
}
switch (c) {
- case '+': return follow('+', INC, follow('=', ADDEQ, '+'));
- case '-': return follow('-', DEC, follow('=', SUBEQ, '-'));
+ case '+': return follow('+', INC, '+') == INC ? INC : follow('=', ADDEQ, '+');
+ case '-': return follow('-', DEC, '-') == DEC ? DEC : follow('=', SUBEQ, '-');
case '*': return follow('=', MULEQ, '*');
case '/': return follow('=', DIVEQ, '/');
case '%': return follow('=', MODEQ, '%');
Received on Fri Sep 13 2019 - 17:56:36 CEST
This archive was generated by hypermail 2.3.0
: Fri Sep 13 2019 - 18:00:25 CEST