commit 500e09ac440d0b91c980fe44ffeb8e799a6e49d8
parent cae714c448ebdea4a6de048b012927b96be9b628
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 14 Apr 2014 10:50:18 +0200
Add stubs for or() and and()
or() and and() are functions that will implement the logical conectors,
and the code of this patch only add them to the parser, but no semantic
actions are taken.
Diffstat:
M | cc.h | | | 2 | +- |
M | expr.c | | | 28 | ++++++++++++++++++++++++++++ |
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/cc.h b/cc.h
@@ -223,7 +223,7 @@ enum {
OSHR, OLT, OGT, OGE, OLE, OEQ, ONE, OBAND,
OBXOR, OBOR, OASSIGN, OA_MUL, OA_DIV,
OA_MOD, OA_ADD, OA_SUB, OA_SHL, OA_SHR,
- OA_AND, OA_XOR, OA_OR, OADDR
+ OA_AND, OA_XOR, OA_OR, OADDR, OAND, OOR
};
extern void
diff --git a/expr.c b/expr.c
@@ -23,6 +23,12 @@ floatconv(Node **np1, Node **np2)
}
static Node *
+logic(char op, Node *np1, Node *np2)
+{
+ return np1;
+}
+
+static Node *
bitlogic(char op, Node *np1, Node *np2)
{
Type *tp1, *tp2;
@@ -493,6 +499,28 @@ bit_or(void)
}
static Node *
+and(void)
+{
+ register Node *np;
+
+ np = bit_or();
+ while (accept(AND))
+ np = logic(OAND, np, bit_or());
+ return np;
+}
+
+static Node *
+or(void)
+{
+ register Node *np;
+
+ np = and();
+ while (accept(OR))
+ np = logic(OOR, np, and());
+ return np;
+}
+
+static Node *
ternary(void)
{
register Node *cond, *ifyes, *ifno;