From: Brendan Hansen Date: Thu, 14 May 2020 22:05:10 +0000 (-0500) Subject: Fixed Tokenizer producing wrong line number and column #6 X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=138032313a12a22044b84eb776f4826f8df778f6;p=onyx.git Fixed Tokenizer producing wrong line number and column #6 --- diff --git a/onyx b/onyx index 413bb28f..12c20cea 100755 Binary files a/onyx and b/onyx differ diff --git a/onyx.c b/onyx.c index 5195faf5..a7925bb1 100644 --- a/onyx.c +++ b/onyx.c @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) { printf("There are %d tokens (Allocated space for %d tokens)\n", bh_arr_length(token_arr), bh_arr_capacity(token_arr)); for (OnyxToken* it = token_arr; !bh_arr_end(token_arr, it); it++) { - printf("%s\n", onyx_get_token_type_name(*it)); + printf("%s (Line %ld, Col %ld)\n", onyx_get_token_type_name(*it), it->line_number, it->line_column); } bh_hash_iterator it = bh_hash_iter_setup(u16, symbol_count); diff --git a/onyxlex.c b/onyxlex.c index fb552d13..dbbfad53 100644 --- a/onyxlex.c +++ b/onyxlex.c @@ -61,12 +61,11 @@ static const char* onyx_token_type_names[] = { #ifndef INCREMENT_CURR_TOKEN #define INCREMENT_CURR_TOKEN(tkn) { \ - (tkn)->curr++; \ - while (*(tkn)->curr == '\n' && (tkn)->curr != (tkn)->end) { \ - (tkn)->curr++; \ + if (*(tkn)->curr == '\n') { \ (tkn)->line_number++; \ - (tkn)->line_start = (tkn)->curr; \ + (tkn)->line_start = (tkn)->curr + 1; \ } \ + (tkn)->curr++; \ } #endif diff --git a/progs/demo.onyx b/progs/demo.onyx index b0d3cf07..2300ab04 100644 --- a/progs/demo.onyx +++ b/progs/demo.onyx @@ -6,7 +6,6 @@ use "core"; /* Looks for "core.onyx" in the current directory */ Foo :: struct { x i32, y i32 }; -add :: (a i32, b i32) -> i32 { - return a + b + 1234.56; -}; - +add :: proc (a i32, b i32) -> i32 { + return a + b + 1234.56; +}; \ No newline at end of file diff --git a/progs/mvp.onyx b/progs/mvp.onyx index 1a8d8c00..cef77e50 100644 --- a/progs/mvp.onyx +++ b/progs/mvp.onyx @@ -2,13 +2,15 @@ /* nested comments /* are /* okay */ */ */ */ -foreign proc "console" "log" :: (data ptr, length i32) -> void; +foreign "console" "log" :: proc (data ptr, length i32) -> void ---; -export proc add :: (a i32, b i32) -> i32 { +global thing :: + +export add :: proc (a i32, b i32) -> i32 { return a + b; }; -export proc max :: (a i32, b i32) -> i32 { +export max :: proc (a i32, b i32) -> i32 { /* Curly braces are required */ x := "String literal! HERE \\\"Woot Woot\" done";