scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit ddba429bd0500e4f241f06073f8a27e1b93243f7
parent 6ff9042e978fbc63cd8c012eb5b428686a0de8c7
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 25 Jan 2018 12:33:03 +0100

[as] Define regmode

When we are in regmode % can initiate a symbol name, but when we
aren't it cannot. This is done to allow % to be the modulo operation
at the same time that it is part of register names.

Diffstat:
Mas/expr.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/as/expr.c b/as/expr.c @@ -21,6 +21,7 @@ static int yytoken; static char yytext[INTIDENTSIZ+1], *textp, *endp; static size_t yylen; static union yylval yylval; +static int regmode; #define accept(t) (yytoken == (t) ? next() : 0) @@ -318,6 +319,9 @@ next(void) case '\'': c = character(); break; + case '%': + c = (regmode ? iden : operator)(); + break; case '_': c = iden(); break; @@ -515,6 +519,7 @@ expr(void) int op; Node *np; + regmode = 0; np = and(); for (;;) { switch (op = yytoken) { @@ -535,6 +540,7 @@ operand(char **strp) int imm = 0; Node *np; + regmode = 1; textp = *strp; switch (next()) { case EOS: