From b8cece0ee0fbb507a3c303d635b1f5b22ae1a201 Mon Sep 17 00:00:00 2001 From: Zander Thannhauser Date: Sun, 26 Jan 2025 19:31:24 -0600 Subject: [PATCH] . --- examples/init.txt | 3 +++ expression/error/evaluate.c | 2 ++ expression/error/prettyprint.c | 2 ++ expression/error/struct.h | 2 ++ handle_interactive.c | 17 +++++++++++++++++ main.c | 9 ++++++++- makefile | 4 ++-- parse/parse.c | 5 ++++- parse/token/kind.h | 2 +- parse/tokenizer/next.c | 13 +++++-------- parse/tokenizer/next.h | 3 +++ srclist.mk | 4 ++++ statement/error/execute.c | 2 ++ statement/error/prettyprint.c | 2 ++ statement/error/struct.h | 2 ++ 15 files changed, 59 insertions(+), 13 deletions(-) diff --git a/examples/init.txt b/examples/init.txt index 70e06a9..ebdfa72 100644 --- a/examples/init.txt +++ b/examples/init.txt @@ -3,6 +3,9 @@ # true <- 位 x, y: x # false <- 位 x, y: y + +# there should be easy ways of inserting these special unicode math letters. + 饾惣 <- 位 x: x 饾憣 <- 位 f: (位 x: f (x x)) (位 x: f (x x)) diff --git a/expression/error/evaluate.c b/expression/error/evaluate.c index 271e14b..e8067f3 100644 --- a/expression/error/evaluate.c +++ b/expression/error/evaluate.c @@ -1,4 +1,6 @@ +#include + #include #include "../evaluate.h" diff --git a/expression/error/prettyprint.c b/expression/error/prettyprint.c index cb71766..27f1f66 100644 --- a/expression/error/prettyprint.c +++ b/expression/error/prettyprint.c @@ -1,4 +1,6 @@ +#include + #include #include diff --git a/expression/error/struct.h b/expression/error/struct.h index aa7bd61..0845bf3 100644 --- a/expression/error/struct.h +++ b/expression/error/struct.h @@ -1,4 +1,6 @@ +#include + #include "../struct.h" struct error_expression diff --git a/handle_interactive.c b/handle_interactive.c index 044ab6c..ad980bf 100644 --- a/handle_interactive.c +++ b/handle_interactive.c @@ -1,4 +1,5 @@ +#if 0 #include #include #include @@ -44,6 +45,7 @@ #include "handle_interactive.h" +#if 0 static const enum state { s_error, @@ -112,6 +114,7 @@ static const enum state { [s_csi]['H'] = s_home, [s_csi]['F'] = s_end, }; +#endif void handle_interactive( struct environment** environment, @@ -124,6 +127,17 @@ void handle_interactive( { ENTER; + // use repl-main + + // which seperates out the tokenizer and buffer-manager thing. + + // also the input string is a seperate array. + + // and somehow the error statements and expressions + // write to the buffer + + TODO; + #if 0 int fd; struct termios termios; @@ -584,6 +598,8 @@ void handle_interactive( free(line.data); + #endif + EXIT; } @@ -624,3 +640,4 @@ void handle_interactive( // free result #endif +#endif diff --git a/main.c b/main.c index 83f6583..82b7acd 100644 --- a/main.c +++ b/main.c @@ -28,7 +28,9 @@ #include #include -#include +/*#include */ + +#include int main(int argc, char* const* argv) { @@ -86,6 +88,10 @@ int main(int argc, char* const* argv) case ik_interactive: { + repl_main(); + + TODO; + #if 0 #ifdef RELEASE_BUILD if (!isatty(1)) { @@ -103,6 +109,7 @@ int main(int argc, char* const* argv) flags->test_interactive_using_input_file #endif ); + #endif break; } diff --git a/makefile b/makefile index db1a99b..dc8fd1f 100644 --- a/makefile +++ b/makefile @@ -50,9 +50,9 @@ ${prefix}/13: ${objs} ${optionset} | ${prefix}/ args += --echo args += --color -#args += --no-init +args += --no-init -args += --custom-init-path ./examples/init.txt +#args += --custom-init-path ./examples/init.txt #args += -c '1' diff --git a/parse/parse.c b/parse/parse.c index 4c49717..4cfd968 100644 --- a/parse/parse.c +++ b/parse/parse.c @@ -445,8 +445,10 @@ struct statement* parse_statement( switch (tokenizer->token->kind) { - case tk_arrow: + case tk_colonequals: { + TODO; + #if 0 tokenizer_next(tokenizer); struct expression* expression = @@ -459,6 +461,7 @@ struct statement* parse_statement( /* expression: */ expression); free_expression(expression); + #endif break; } diff --git a/parse/token/kind.h b/parse/token/kind.h index 5c618df..d9105bc 100644 --- a/parse/token/kind.h +++ b/parse/token/kind.h @@ -14,7 +14,7 @@ enum token_kind tk_dot, - tk_arrow, + tk_colonequals, tk_semicolon, diff --git a/parse/tokenizer/next.c b/parse/tokenizer/next.c index 5ae9904..8844fe0 100644 --- a/parse/tokenizer/next.c +++ b/parse/tokenizer/next.c @@ -142,6 +142,10 @@ void tokenizer_next( { ENTER; + // needs to keep references to all tokens. + + TODO; + #if 0 if (this->put_back) { free_token(this->token); @@ -273,14 +277,6 @@ void tokenizer_next( /* start position: */ start_position, /* end position: */ end_clone); } - else if (!wcscmp(this->rawtoken.data, L"<-")) - { - this->token = new_token( - /* kind: */ tk_arrow, - /* text: */ text, - /* start position: */ start_position, - /* end position: */ end_clone); - } else { this->token = new_token( @@ -406,6 +402,7 @@ void tokenizer_next( free_position(end_clone); } + #endif EXIT; } diff --git a/parse/tokenizer/next.h b/parse/tokenizer/next.h index 430f49a..9aa7b5c 100644 --- a/parse/tokenizer/next.h +++ b/parse/tokenizer/next.h @@ -1,3 +1,6 @@ void tokenizer_next( struct tokenizer* this); + + + diff --git a/srclist.mk b/srclist.mk index 5083662..64012a2 100644 --- a/srclist.mk +++ b/srclist.mk @@ -122,6 +122,10 @@ srcs += ./parse/tokenizer/put_back.c srcs += ./parse/token/free.c srcs += ./parse/token/inc.c srcs += ./parse/token/new.c +srcs += ./repl/main.c +srcs += ./repl/tokenizer/free.c +srcs += ./repl/tokenizer/new.c +srcs += ./repl/tokenizer/next.c srcs += ./statement/assignment/execute.c srcs += ./statement/assignment/free.c srcs += ./statement/assignment/inheritance.c diff --git a/statement/error/execute.c b/statement/error/execute.c index 419b00b..84f67af 100644 --- a/statement/error/execute.c +++ b/statement/error/execute.c @@ -1,4 +1,6 @@ +#include + #include #include diff --git a/statement/error/prettyprint.c b/statement/error/prettyprint.c index 6ec5ae8..6fd33bd 100644 --- a/statement/error/prettyprint.c +++ b/statement/error/prettyprint.c @@ -1,4 +1,6 @@ +#include + #include #include diff --git a/statement/error/struct.h b/statement/error/struct.h index 0ff539e..7bcdbfb 100644 --- a/statement/error/struct.h +++ b/statement/error/struct.h @@ -1,4 +1,6 @@ +#include + #include "../struct.h" struct error_statement