diff options
author | Bad Diode <bd@badd10de.dev> | 2021-11-10 17:13:56 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-11-10 17:13:56 +0100 |
commit | 09406d74711fd241a16f4e0d4cc76bfa11e42a60 (patch) | |
tree | ca71813665031687c9c6d2bc1bb090a901d51dea /src/parser.c | |
parent | 69f6b03296f96a60dd7fc103ff89d187f1a29aec (diff) | |
download | bdl-09406d74711fd241a16f4e0d4cc76bfa11e42a60.tar.gz bdl-09406d74711fd241a16f4e0d4cc76bfa11e42a60.zip |
Add initial local definition/access
Diffstat (limited to 'src/parser.c')
-rw-r--r-- | src/parser.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/parser.c b/src/parser.c index 100916b..2bf95d4 100644 --- a/src/parser.c +++ b/src/parser.c | |||
@@ -569,6 +569,7 @@ parse(Token *tokens, Errors *errors) { | |||
569 | 569 | ||
570 | // Prepare global environment of builtin functions. | 570 | // Prepare global environment of builtin functions. |
571 | Environment *global_env = env_alloc(NULL); | 571 | Environment *global_env = env_alloc(NULL); |
572 | Environment *env = env_alloc(global_env); | ||
572 | size_t n_builtins = sizeof(builtins) / sizeof(char*); | 573 | size_t n_builtins = sizeof(builtins) / sizeof(char*); |
573 | for (size_t i = 0; i < n_builtins; i++) { | 574 | for (size_t i = 0; i < n_builtins; i++) { |
574 | // Prepare builtin symbol. | 575 | // Prepare builtin symbol. |
@@ -600,7 +601,7 @@ parse(Token *tokens, Errors *errors) { | |||
600 | } | 601 | } |
601 | } | 602 | } |
602 | array_push(final_roots, root); | 603 | array_push(final_roots, root); |
603 | semantic_analysis(global_env, root, errors); | 604 | semantic_analysis(env, root, errors); |
604 | if (errors->n != 0) { | 605 | if (errors->n != 0) { |
605 | array_free(final_roots); | 606 | array_free(final_roots); |
606 | return (Program){0}; | 607 | return (Program){0}; |
@@ -614,7 +615,7 @@ parse(Token *tokens, Errors *errors) { | |||
614 | // TODO: Type check basic expressions (e.g. arithmetic/numeric comparisons). | 615 | // TODO: Type check basic expressions (e.g. arithmetic/numeric comparisons). |
615 | // We can't be sure when we have functions unless the return type is known. | 616 | // We can't be sure when we have functions unless the return type is known. |
616 | 617 | ||
617 | return (Program){roots, global_env}; | 618 | return (Program){roots, env}; |
618 | } | 619 | } |
619 | 620 | ||
620 | Environment * | 621 | Environment * |