summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lex.c11
-rw-r--r--lex.h8
-rw-r--r--main.c1
3 files changed, 12 insertions, 8 deletions
diff --git a/lex.c b/lex.c
index e8d6425..c59057e 100644
--- a/lex.c
+++ b/lex.c
@@ -205,14 +205,9 @@ TokenVec lex_level(RawLine* line, char until, ExpansionRegionVec* reg_arena) {
}
-typedef struct {
- TokenVec top_tokens;
- ExpansionRegionVec reg_arena;
-} LexResult;
-
-
-TokenVec lex(char* input) {
+LexResult lex(char* input) {
RawLine line = {.str = input, .pos = 0};
ExpansionRegionVec reg_arena = make_ExpansionRegionVec(256);
- return lex_level(&line, '\0', &reg_arena);
+ TokenVec toks = lex_level(&line, '\0', &reg_arena);
+ return (LexResult){.top_tokens = toks, .reg_arena = reg_arena};
}
diff --git a/lex.h b/lex.h
index b27c03e..77b6838 100644
--- a/lex.h
+++ b/lex.h
@@ -76,4 +76,12 @@ DECLARE_MAYBE(Chunk);
DECLARE_VEC(ExpansionRegion, ExpansionRegionVec)
+
+typedef struct {
+ TokenVec top_tokens;
+ ExpansionRegionVec reg_arena;
+} LexResult;
+
+
+LexResult lex(char* input);
#endif
diff --git a/main.c b/main.c
index 03cff7f..84ea5c1 100644
--- a/main.c
+++ b/main.c
@@ -12,6 +12,7 @@ int main() {
line = readline("$");
if (line[0] == '\0') continue;
if (strcmp(line, "exit") == 0) exit(0);
+ LexResult res = lex(line);
printf("%s \n", line);
}