From 817fbfef34908931ebeaa4da1a8d21ef79572e5a Mon Sep 17 00:00:00 2001 From: Carlos Maniero Date: Thu, 27 Apr 2023 00:57:30 -0300 Subject: scope: Add a scope stack for identifier resolutions Before accepting an identifier, the parser should check if that identifier will be available. With this implementation it will be possible. Take the following code example: main(): i32 { return my_exit_code; } The parser must return an error informing that *my_exit_code* is not defined in the example above. The ast scope is a support module for parser and ast, simplifying identifier resolution. Once a curly bracket ({) is open the *scope_enter()* is called and when it is closed (}) we pop the entire stack with *scope_leave()*. Signed-off-by: Carlos Maniero --- test/Makefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/Makefile') diff --git a/test/Makefile b/test/Makefile index 717b430..6d8bfb7 100644 --- a/test/Makefile +++ b/test/Makefile @@ -30,5 +30,8 @@ lexer_test: munit.o ../build/string_view.o ../build/lexer.o lexer_test.o parser_test: munit.o ../build/string_view.o ../build/vector.o ../build/lexer.o ../build/ast.o ../build/parser.o parser_test.o $(CC) $? $(CFLAGS) -o $@ +scope_test: munit.o ../build/string_view.o ../build/vector.o ../build/ast.o ../build/scope.o scope_test.o + $(CC) $? $(CFLAGS) -o $@ + integration_test: munit.o integration_test.o $(CC) $? $(CFLAGS) -o $@ -- cgit v1.2.3