comparison lwcc/tree.c @ 501:f3e9732973f1

Add basic integer operations to lwcc Add +, -, *, and / to lwcc parser and code generator. Multiplication and division require helper functions in a yet to be created support library. These operations are integer only for the moment.
author William Astle <lost@l-w.ca>
date Tue, 24 Sep 2019 22:07:56 -0600
parents 1bd2d590d734
children 14a40f8bb4eb
comparison
equal deleted inserted replaced
500:733fd05ca2a8 501:f3e9732973f1
51 "FUNDECL", 51 "FUNDECL",
52 "FUNARGS", 52 "FUNARGS",
53 "BLOCK", 53 "BLOCK",
54 "STMT_RETURN", 54 "STMT_RETURN",
55 "CONST_INT", 55 "CONST_INT",
56 "OPER_PLUS",
57 "OPER_MINUS",
58 "OPER_TIMES",
59 "OPER_DIVIDE",
56 }; 60 };
57 61
58 62
59 63
60 node_t *node_create(int type, ...) 64 node_t *node_create(int type, ...)
68 memset(r, 0, sizeof(node_t)); 72 memset(r, 0, sizeof(node_t));
69 r -> type = type; 73 r -> type = type;
70 74
71 switch (type) 75 switch (type)
72 { 76 {
77 case NODE_OPER_PLUS:
78 case NODE_OPER_MINUS:
79 case NODE_OPER_TIMES:
80 case NODE_OPER_DIVIDE:
81 nargs = 2;
82 break;
83
73 case NODE_DECL: 84 case NODE_DECL:
74 nargs = 2; 85 nargs = 2;
75 break; 86 break;
76 87
77 case NODE_TYPE_PTR: 88 case NODE_TYPE_PTR: