scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit e9f3f4b6f347e80196c224028a80d48099495168
parent 1886809da90d62f4c4929fa78f89f445348fe8a4
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 11 Apr 2014 16:21:38 +0200

Add logical bit or

Diffstat:
Mcc.h | 2+-
Mcode.c | 3++-
Mexpr.c | 15++++++++++++++-
3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/cc.h b/cc.h @@ -221,7 +221,7 @@ enum { OCAST, OPTR, OADD, OARY, OSIZE, OMUL, OSUB, OINC, ODEC, OPINC, OPDEC, ODIV, OMOD, OSHL, OSHR, OLT, OGT, OGE, OLE, OEQ, ONE, OBAND, - OBXOR + OBXOR, OBOR }; extern void diff --git a/code.c b/code.c @@ -25,7 +25,8 @@ char *opcodes[] = { [OEQ] = "=", [ONE] = "!", [OBAND] = "&", - [OBXOR] = "^" + [OBXOR] = "^", + [OBOR] = "|" }; Node * diff --git a/expr.c b/expr.c @@ -403,13 +403,26 @@ bit_xor(void) return np; } +static Node * +bit_or(void) +{ + register Node *np; + + np = bit_xor(); + while (yytoken == '|') { + next(); + np = bitlogic(OBOR, np, bit_xor()); + } + return np; +} + Node * expr(void) { register Node *np; do - np = bit_xor(); + np = bit_or(); while (yytoken == ','); return np; }