aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2024-06-18 21:27:24 +0200
committerBad Diode <bd@badd10de.dev>2024-06-18 21:27:24 +0200
commitad14773fcebdbd989c1d7c3245b59a1cae666d2f (patch)
treea7eb2ceebfc7c89fd04a143d535b5701de5bfa98 /src
parent3d88e46dd0d1b54bc0a414b5db42ed76ddc08363 (diff)
downloadbdl-ad14773fcebdbd989c1d7c3245b59a1cae666d2f.tar.gz
bdl-ad14773fcebdbd989c1d7c3245b59a1cae666d2f.zip
Add `tests` target to makefile
Diffstat (limited to 'src')
-rw-r--r--src/main.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 68ad857..1c0d2e1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -80,6 +80,8 @@ typedef enum NodeKind {
80 NODE_CASE, 80 NODE_CASE,
81 NODE_COND, 81 NODE_COND,
82 NODE_ENUM, 82 NODE_ENUM,
83 NODE_BREAK,
84 NODE_CONTINUE,
83 // Helpers. 85 // Helpers.
84 NODE_SYMBOL_IDX, 86 NODE_SYMBOL_IDX,
85 NODE_TYPE, 87 NODE_TYPE,
@@ -131,6 +133,8 @@ Str node_str[] = {
131 [NODE_CASE] = cstr("CASE"), 133 [NODE_CASE] = cstr("CASE"),
132 [NODE_COND] = cstr("COND"), 134 [NODE_COND] = cstr("COND"),
133 [NODE_ENUM] = cstr("ENUM"), 135 [NODE_ENUM] = cstr("ENUM"),
136 [NODE_BREAK] = cstr("BREAK"),
137 [NODE_CONTINUE] = cstr("CONTINUE"),
134 // Helpers. 138 // Helpers.
135 [NODE_TYPE] = cstr("TYPE"), 139 [NODE_TYPE] = cstr("TYPE"),
136 [NODE_ARR_TYPE] = cstr("TYPE (ARR)"), 140 [NODE_ARR_TYPE] = cstr("TYPE (ARR)"),
@@ -663,6 +667,14 @@ parse_keyword(Parser *parser) {
663 array_push(node->match_cases, tmp, parser->storage); 667 array_push(node->match_cases, tmp, parser->storage);
664 } 668 }
665 } break; 669 } break;
670 case TOK_BREAK: {
671 node = node_alloc(parser, NODE_BREAK, prev);
672 if (!node) return;
673 } break;
674 case TOK_CONTINUE: {
675 node = node_alloc(parser, NODE_CONTINUE, prev);
676 if (!node) return;
677 } break;
666 default: return; // Unreachable. 678 default: return; // Unreachable.
667 } 679 }
668 array_push(parser->nodes, node, parser->storage); 680 array_push(parser->nodes, node, parser->storage);
@@ -966,7 +978,7 @@ process_file(Str path) {
966 FileContents file = platform_read_file(path, &lexer_arena); 978 FileContents file = platform_read_file(path, &lexer_arena);
967 if (file.err) { 979 if (file.err) {
968 eprintln("%s: error: %s", path, cstr("WOT")); 980 eprintln("%s: error: %s", path, cstr("WOT"));
969 return; 981 exit(EXIT_FAILURE);
970 } 982 }
971 sz errors = 0; 983 sz errors = 0;
972 984
@@ -986,7 +998,7 @@ process_file(Str path) {
986 } 998 }
987 // Only proceed if there are no errors. 999 // Only proceed if there are no errors.
988 if (errors) { 1000 if (errors) {
989 goto stop; 1001 exit(EXIT_FAILURE);
990 } 1002 }
991 if (mode == PRINT_LEX) { 1003 if (mode == PRINT_LEX) {
992 print_tokens(path, tokens); 1004 print_tokens(path, tokens);
@@ -1011,7 +1023,7 @@ process_file(Str path) {
1011 } 1023 }
1012 } 1024 }
1013 if (parser.err) { 1025 if (parser.err) {
1014 goto stop; 1026 exit(EXIT_FAILURE);
1015 } 1027 }
1016 if (mode == PRINT_PARSE) { 1028 if (mode == PRINT_PARSE) {
1017 graph_ast(parser.nodes); 1029 graph_ast(parser.nodes);