From a8bfa841540a13aea75fafcf11fe27688f1ea939 Mon Sep 17 00:00:00 2001 From: c+1 Date: Wed, 17 May 2023 11:38:44 -0400 Subject: new sytax? --- examples/simple.halk | 1 + examples/v2.halk | 16 ++++++++++++++++ src/main.c | 2 +- src/parser.c | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 examples/simple.halk create mode 100644 examples/v2.halk diff --git a/examples/simple.halk b/examples/simple.halk new file mode 100644 index 0000000..a46b51f --- /dev/null +++ b/examples/simple.halk @@ -0,0 +1 @@ +let.variable -> "Hi"; diff --git a/examples/v2.halk b/examples/v2.halk new file mode 100644 index 0000000..c116ed7 --- /dev/null +++ b/examples/v2.halk @@ -0,0 +1,16 @@ +` new syntax ` + +#include."IO.halk"; ` preprocessor directives start with '#' and end with ';' ` +#macro."PI","3.14159"; ` replace every instance of PI with 3.14159 ` + + +` mut:?: = ; ` + +str:hello = "Hello"; ` by default, variables are immutable ` +mut:str:world = "world" ` one can create an immutable variable with mut: ` + +void:say_hello.str:to = { ` functions need no special keyword ` + io.stdout.to; +} + + diff --git a/src/main.c b/src/main.c index 5d5b69c..d9e617a 100644 --- a/src/main.c +++ b/src/main.c @@ -12,7 +12,7 @@ int main(int argc, char* argv[]) { long fsource_size; char *source; - fsource = fopen ("examples/simple.halk", "rb"); + fsource = fopen ("examples/hello.halk", "rb"); if (!fsource) { log_err("Source file not found"); exit(1); diff --git a/src/parser.c b/src/parser.c index 0e6a015..c647e64 100644 --- a/src/parser.c +++ b/src/parser.c @@ -21,6 +21,7 @@ parser_t* parser_init(lexer_t* lexer) { // check for expected token, or throw syntax error void parser_check_expect(parser_t* parser, int token_type) { if (parser->token->type == token_type) { + log_dbg(strcat("Got expected token", lexer_get_c_as_string(parser->lexer))); parser->token = lexer_get_next_token(parser->lexer); } else { log_err("Unexpected token"); -- cgit v1.2.3