summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-03-15 23:38:46 +0100
committerkdx <kikoodx@paranoici.org>2023-03-15 23:38:46 +0100
commitbd485fb4527a1d171e2afbc94cd092444a67303f (patch)
tree3f351834922857ac6d9ede34f877185b4edcc47d
parent48040131e60465c118c6e89161359662d1ddea94 (diff)
downloadgolem-bd485fb4527a1d171e2afbc94cd092444a67303f.tar.gz
placeholder identify_function
-rw-r--r--group.c2
-rw-r--r--identify.c10
-rw-r--r--identify.h4
-rw-r--r--token.c6
-rw-r--r--token.h1
5 files changed, 22 insertions, 1 deletions
diff --git a/group.c b/group.c
index 16f2642..87d4145 100644
--- a/group.c
+++ b/group.c
@@ -72,7 +72,7 @@ group_atom(Token **list)
{
// Recurse in child GROUP_SCOPEs.
for (Token *e = *list; e != NULL; e = e->next)
- if (e->type == TOK_GROUP && e->group.type == GROUP_SCOPE)
+ if (token_isgroup(e, GROUP_SCOPE))
if (group_atom(&e->group.tokens))
return 1;
diff --git a/identify.c b/identify.c
new file mode 100644
index 0000000..2298ad0
--- /dev/null
+++ b/identify.c
@@ -0,0 +1,10 @@
+#include "identify.h"
+#include <stddef.h>
+
+void
+identify_function(Token **list)
+{
+ for (Token *e = *list; e != NULL; e = e->next)
+ if (token_isgroup(e, GROUP_ATOM))
+ e->group.type = GROUP_FUNCTION;
+}
diff --git a/identify.h b/identify.h
new file mode 100644
index 0000000..4800168
--- /dev/null
+++ b/identify.h
@@ -0,0 +1,4 @@
+#pragma once
+#include "token.h"
+
+void identify_function(Token **list);
diff --git a/token.c b/token.c
index 4d3f631..b419908 100644
--- a/token.c
+++ b/token.c
@@ -108,3 +108,9 @@ token_print(Token *token, int recurse, int depth)
}
return tok;
}
+
+int
+token_isgroup(Token *token, unsigned int type)
+{
+ return (token->type == TOK_GROUP && token->group.type == type);
+}
diff --git a/token.h b/token.h
index 4cfee5a..d421176 100644
--- a/token.h
+++ b/token.h
@@ -43,3 +43,4 @@ void token_delete(Token **list, Token *elem);
Token *token_search(Token *list, unsigned int type);
Token *token_search_closing(Token *list, unsigned int type, unsigned int opn);
Token *token_print(Token *token, int recurse, int depth);
+int token_isgroup(Token *token, unsigned int type);