|
From: Keith J. <bu...@us...> - 2003-08-07 17:10:00
|
Update of /cvsroot/cup-language/cup/src/compiler
In directory sc8-pr-cvs1:/tmp/cvs-serv24091/cup/src/compiler
Modified Files:
binary.c compiler.h parser.y
Log Message:
Added != (NEQ) and == (EQ). Also finished NOT opcode.
Index: binary.c
===================================================================
RCS file: /cvsroot/cup-language/cup/src/compiler/binary.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** binary.c 6 Aug 2003 19:06:47 -0000 1.17
--- binary.c 7 Aug 2003 17:09:57 -0000 1.18
***************
*** 258,261 ****
--- 258,285 ----
cupc_code_write(comp, CUPOP_SET);
break;
+ case CUPCOP_EQ:
+ // Node 1
+ // Node 2
+ // EQ
+ cupc_bin_build(comp, node->one, 0, 0, 0);
+ if (comp->traceback)
+ return;
+ cupc_bin_build(comp, node->two, 0, 0, 0);
+ if (comp->traceback)
+ return;
+ cupc_code_write(comp, CUPOP_EQ);
+ break;
+ case CUPCOP_NEQ:
+ // Node 1
+ // Node 2
+ // EQ
+ cupc_bin_build(comp, node->one, 0, 0, 0);
+ if (comp->traceback)
+ return;
+ cupc_bin_build(comp, node->two, 0, 0, 0);
+ if (comp->traceback)
+ return;
+ cupc_code_write(comp, CUPOP_NEQ);
+ break;
case CUPCOP_ADD:
// Node 1
Index: compiler.h
===================================================================
RCS file: /cvsroot/cup-language/cup/src/compiler/compiler.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** compiler.h 22 Aug 2002 18:57:25 -0000 1.12
--- compiler.h 7 Aug 2003 17:09:57 -0000 1.13
***************
*** 65,68 ****
--- 65,71 ----
CUPCOP_OR,
+ CUPCOP_EQ,
+ CUPCOP_NEQ,
+
CUPCOP_BLOCK,
CUPCOP_WHILE,
Index: parser.y
===================================================================
RCS file: /cvsroot/cup-language/cup/src/compiler/parser.y,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** parser.y 23 Aug 2002 19:01:34 -0000 1.14
--- parser.y 7 Aug 2003 17:09:57 -0000 1.15
***************
*** 64,67 ****
--- 64,68 ----
%left TOKEN_OR
%left TOKEN_AND
+ %left TOKEN_EQ TOKEN_NEQ
%left '%'
%left '-' '+'
***************
*** 252,255 ****
--- 253,260 ----
| '-' expr
{ $$ = cupc_node_new(CUPCOP_NEG, $2, NULL, NULL, NULL); }
+ | expr TOKEN_EQ expr
+ { $$ = cupc_node_new(CUPCOP_EQ, $1, $3, NULL, NULL); }
+ | expr TOKEN_NEQ expr
+ { $$ = cupc_node_new(CUPCOP_NEQ, $1, $3, NULL, NULL); }
;
|