commit fac68a28be2a0744ab2b516a89c00a44c5564cee
parent b515534d31e288cc70eaf80d950f406310682535
Author: William Casarin <jb55@jb55.com>
Date: Sun, 22 Oct 2017 01:13:53 -0700
fixed some recursion issues
Diffstat:
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/parser.y b/parser.y
@@ -32,7 +32,7 @@ script:
;
line: T_NEWLINE
- | T_OP line { printf("%s\n", op_str($1)); }
+ | T_OP { printf("%s\n", op_name($1)); }
/* opcode: */
/* | T_OP { op_add($$); } */
diff --git a/script.c b/script.c
@@ -135,8 +135,8 @@ op_from_token(enum opcode_token opcode) {
}
}
-
-const char* op_str(enum opcode opcode)
+const char*
+op_name(enum opcode opcode)
{
switch (opcode)
{
@@ -199,6 +199,28 @@ const char* op_str(enum opcode opcode)
// splice ops
case OP_CAT : return "CAT";
+ case OP_SUBSTR : return "SUBSTR";
+ case OP_LEFT : return "LEFT";
+ case OP_RIGHT : return "RIGHT";
+ case OP_SIZE : return "SIZE";
+
+ // bit logic
+ case OP_INVERT : return "INVERT";
+ case OP_AND : return "AND";
+ case OP_OR : return "OR";
+ case OP_XOR : return "XOR";
+ case OP_EQUAL : return "EQUAL";
+ case OP_EQUALVERIFY : return "EQUALVERIFY";
+ case OP_RESERVED1 : return "RESERVED1";
+ case OP_RESERVED2 : return "RESERVED2";
+
+ // numeric
+ case OP_1ADD : return "1ADD";
+ case OP_1SUB : return "1SUB";
+ case OP_2MUL : return "2MUL";
+ case OP_2DIV : return "2DIV";
+ case OP_NEGATE : return "NEGATE";
+ case OP_ABS : return "ABS";
case OP_NOT : return "NOT";
case OP_0NOTEQUAL : return "0NOTEQUAL";
case OP_ADD : return "ADD";
@@ -305,7 +327,7 @@ op_parse_opcode(const char *str) {
int hash = op_hash(str);
int maybe_op = op_from_token(hash);
- if (strcmp(op_str(maybe_op), op_normalized_tok(str, hash)) == 0)
+ if (strcmp(op_name(maybe_op), op_normalized_tok(str, hash)) == 0)
return maybe_op;
else
return OP_INVALIDOPCODE;
diff --git a/script.h b/script.h
@@ -296,7 +296,7 @@ enum opcode_token
};
void op_add(enum opcode);
-const char * op_str(enum opcode);
+const char * op_name(enum opcode);
enum opcode op_tokenize(char *);
#endif /* BCS_SCRIPT_H */