aboutsummaryrefslogtreecommitdiffstats
path: root/map.h
diff options
context:
space:
mode:
authorGalin Simeonov <gts@volconst.com>2021-05-17 17:29:08 +0300
committerGalin Simeonov <gts@volconst.com>2021-07-15 18:00:15 +0300
commitf768d9bdb84e846d89aac66a4f3433a44241c298 (patch)
treeb7e8248bebd80c8b1f911f666260ad52b7213b84 /map.h
parent679cbe58c4e53f0163588a7731154f3afe2d25aa (diff)
downloadMEGATRON-f768d9bdb84e846d89aac66a4f3433a44241c298.tar.gz
parser formed
Diffstat (limited to 'map.h')
-rw-r--r--map.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/map.h b/map.h
new file mode 100644
index 0000000..ced43a7
--- /dev/null
+++ b/map.h
@@ -0,0 +1,41 @@
+#ifndef GMAP_H
+#define GMAP_H GMAP_H
+#include <stdlib.h>
+#include <stdio.h>
+#include <stack.h>
+#include <queue.h>
+#include <assert.h>
+
+typedef struct Map Map;
+
+
+
+/*
+ * A looples automata with things attached to the nodes
+ * */
+struct Map
+{
+ char is_final;
+ Map *delta[256];
+ /*ID cannot point to itself ( this is used in the deletion of the map ) */
+ void *ID;
+};
+
+void Map_Init(Map *tree);
+void Map_Scour(Map *tree,void *str,size_t size,size_t *where,Map **final_node);
+void Map_Push(Map *tree,void *str,size_t size,void *id);
+void* Map_Check(Map *tree, void *str,size_t size);
+struct Map* Map_Check_And_Get(Map *tree, void *str,size_t size);
+void Map_Remove(Map *tree, void *str,size_t size);
+void Map_Map(Map *tree,void (*map)(void*));
+void Map_Map_Extended(Map *tree,void (*map)(void*,void*),void* pass_data);
+
+void Map_Destroy(Map *tree);
+void Map_Delete_Map(struct Map *tree);
+struct Condensed_Map* Map_Condense(Map* tree);
+
+struct Map* Map_Push_And_Get(struct Map* tree,void *str,size_t size,void *id);
+/*returns NULL if id is not taken , returns pointer to taken id otherwise*/
+void* Map_Check_And_Push(struct Map *tree,void *str,size_t size,void *id);
+
+#endif