summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-03-15 23:41:05 +0100
committerkdx <kikoodx@paranoici.org>2023-03-15 23:41:33 +0100
commitc08b0e3791c2d96d0d54de4c3e099fa0428ad395 (patch)
treeb0ba84ecabb28f1072f3859523c4eada0f4e4f84
parentbd485fb4527a1d171e2afbc94cd092444a67303f (diff)
downloadgolem-c08b0e3791c2d96d0d54de4c3e099fa0428ad395.tar.gz
simplify function declaration syntax
-rw-r--r--README.md10
-rw-r--r--identify.c4
-rw-r--r--identify.h2
-rw-r--r--main.c2
-rw-r--r--mvp.golem8
-rw-r--r--onlymain.golem4
6 files changed, 16 insertions, 14 deletions
diff --git a/README.md b/README.md
index 8749cd1..5cf75a6 100644
--- a/README.md
+++ b/README.md
@@ -13,12 +13,12 @@ Work in progress bytecode language created by and for [kdx](https://kdx.re).
global g_heap;
global g_another g_one;
-main(argc argv) {
+main argc argv {
local hello;
local world;
g_heap = 8000;
- hello = (strdup "bonjour");
+ hello = (strdup "bonjour");;;
world = (strdup "monde");
(print hello);
(print " ");
@@ -27,7 +27,7 @@ main(argc argv) {
return 0;
}
-alloc(size) {
+alloc size {
local ptr;
ptr = g_heap;
@@ -36,7 +36,7 @@ alloc(size) {
return heap;
}
-strdup(str) {
+strdup str {
local dest;
local i;
@@ -53,7 +53,7 @@ strdup(str) {
return dest;
}
-print(str) {
+print str {
local i;
i = 1;
diff --git a/identify.c b/identify.c
index 2298ad0..6847b8b 100644
--- a/identify.c
+++ b/identify.c
@@ -2,9 +2,9 @@
#include <stddef.h>
void
-identify_function(Token **list)
+identify_function(Token *list)
{
- for (Token *e = *list; e != NULL; e = e->next)
+ 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
index 4800168..d1014d0 100644
--- a/identify.h
+++ b/identify.h
@@ -1,4 +1,4 @@
#pragma once
#include "token.h"
-void identify_function(Token **list);
+void identify_function(Token *list);
diff --git a/main.c b/main.c
index 5333e70..56d91fa 100644
--- a/main.c
+++ b/main.c
@@ -3,6 +3,7 @@
#include "lexer.h"
#include "token.h"
#include "group.h"
+#include "identify.h"
#include <stdio.h>
#include <stdlib.h>
@@ -36,6 +37,7 @@ main(int argc, char **argv)
destroy_duplicates(&tokens, TOK_END);
group_scope(&tokens);
group_atom(&tokens);
+ identify_function(tokens);
token_print(tokens, 1, 0);
token_destroy(tokens);
}
diff --git a/mvp.golem b/mvp.golem
index efa081d..2ff9be3 100644
--- a/mvp.golem
+++ b/mvp.golem
@@ -6,7 +6,7 @@
global g_heap;
global g_another g_one;
-main(argc argv) {
+main argc argv {
local hello;
local world;
@@ -20,7 +20,7 @@ main(argc argv) {
return 0;
}
-alloc(size) {
+alloc size {
local ptr;
ptr = g_heap;
@@ -29,7 +29,7 @@ alloc(size) {
return heap;
}
-strdup(str) {
+strdup str {
local dest;
local i;
@@ -46,7 +46,7 @@ strdup(str) {
return dest;
}
-print(str) {
+print str {
local i;
i = 1;
diff --git a/onlymain.golem b/onlymain.golem
index e973537..43556bb 100644
--- a/onlymain.golem
+++ b/onlymain.golem
@@ -1,4 +1,4 @@
-main(argc argv) {
+main argc argv {
(print [argv (sub argc 1)]);
return (less argc 2);
-};
+}