aboutsummaryrefslogtreecommitdiff
path: root/src/id_table.c
diff options
context:
space:
mode:
authorShinya Sato <shinnya.sato@gmail.com>2022-04-28 21:41:58 +0900
committerShinya Sato <shinnya.sato@gmail.com>2022-04-28 21:41:58 +0900
commiteddac153a064648bee2aef6fb733ab6820bb96c3 (patch)
treec12f212dc501e6053ec034d1a9f4734b8b94b4d2 /src/id_table.c
parent1c9344fa14cc018558ec9ebfbf1215a772960b6e (diff)
downloadinpla-eddac153a064648bee2aef6fb733ab6820bb96c3.tar.gz
inpla-eddac153a064648bee2aef6fb733ab6820bb96c3.zip
v0.8.2
Diffstat (limited to 'src/id_table.c')
-rw-r--r--src/id_table.c51
1 files changed, 7 insertions, 44 deletions
diff --git a/src/id_table.c b/src/id_table.c
index 0b4a93a..86655b5 100644
--- a/src/id_table.c
+++ b/src/id_table.c
@@ -51,7 +51,9 @@ void IdTable_init() {
IdTable[ID_DIV2].aux.arity = 2;
IdTable[ID_MOD].aux.arity = 2;
IdTable[ID_MOD2].aux.arity = 2;
+ IdTable[ID_ERASER].aux.arity = 0;
+
IdTable[ID_INT].name = "int";
IdTable[ID_TUPLE0].name = "Tuple0";
IdTable[ID_TUPLE1].name = "Tuple1";
@@ -76,6 +78,9 @@ void IdTable_init() {
IdTable[ID_DIV2].name = "_Div";
IdTable[ID_MOD].name = "Mod";
IdTable[ID_MOD2].name = "_Mod";
+
+ IdTable[ID_ERASER].name = "Eraser";
+
}
@@ -104,56 +109,14 @@ int IdTable_getid_builtin_funcAgent(Ast *agent) {
id = ID_INTAGENT;
} else if (strcmp((char *)agent->left->sym, "Merger") == 0) {
id = ID_MERGER;
+ } else if (strcmp((char *)agent->left->sym, "Eraser") == 0) {
+ id = ID_ERASER;
}
return id;
}
-int IdTable_is_builtin_rule(Ast *agentL, Ast *agentR) {
- // puts_ast(agentL);
- // printf(" ");
- // puts_ast(agentR);
- // printf("\n");
-
-
- if ( (agentL->id == AST_TUPLE) && (agentR->id == AST_TUPLE) ) {
- // compare these arities
- if (agentL->intval == agentR->intval) {
- return 1;
- }
- return 0;
- }
-
- int idL = IdTable_getid_builtin_funcAgent(agentL);
- if (agentR->id == AST_INT) {
- if ((idL == ID_ADD) || (idL == ID_SUB) || (idL == ID_MUL)
- || (idL == ID_DIV) || (idL == ID_MOD)) {
- return 1;
- }
- return 0;
- }
-
- if (idL == ID_APPEND) {
- if ((agentR->id == AST_OPCONS) || (agentR->id == AST_NIL)) {
- return 1;
- }
- return 0;
- }
-
- if (idL == ID_MERGER) {
- if ((agentR->id == AST_TUPLE) && (agentR->intval == 2)) {
- // Merger >< Tuple2
- return 1;
- }
- return 0;
- }
-
-
-
- return 0;
-}
-
void IdTable_set_name(int id, char *symname)
{