scc

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

commit b20db931867df763206ca9856fc0ec2a34af54cb
parent 4f051c93ff2993d15cce71a5097fcb172a1c3df8
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 11 Aug 2014 22:44:56 +0200

Add relational operators

Diffstat:
Mcc2/cc2.h | 6++++++
Mcc2/cgen.c | 2++
Mcc2/parser.c | 6++++++
3 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -78,6 +78,12 @@ enum nerrors { #define OBXOR '^' #define OPTR '@' #define OADDR 'a' +#define OLT '<' +#define OGT '>' +#define OGE ']' +#define OLE '[' +#define OEQ '=' +#define ONE '!' extern void error(unsigned nerror, ...); extern void genaddable(Node *list[]); diff --git a/cc2/cgen.c b/cc2/cgen.c @@ -126,6 +126,7 @@ xcgen(Node *np) switch (np->op) { case OPTR: case OADDR: case OINC: + case OLT: case OGT: case OGE: case OLE: case OEQ: case ONE: case OADD: case OSUB: case OASSIG: case OMOD: case ODIV: case OSHL: case OSHR: case OBAND: case OBOR: case OBXOR: @@ -196,6 +197,7 @@ xaddable(Node *np) case OPTR: case OADDR: xaddable(lp); break; + case OLT: case OGT: case OGE: case OLE: case OEQ: case ONE: case OINC: case OASSIG: case OADD: case OSUB: case OMOD: case ODIV: case OSHL: case OSHR: diff --git a/cc2/parser.c b/cc2/parser.c @@ -294,6 +294,12 @@ static void (*optbl[])(char *) = { ['#'] = immediate, ['@'] = unary, ['a'] = unary, + ['<'] = operator, + ['>'] = operator, + [']'] = operator, + ['['] = operator, + ['='] = operator, + ['!'] = operator, ['\177'] = NULL };