Implement public import parsing and add test case
This commit is contained in:
@@ -56,6 +56,12 @@ Module* parser_parse(TokenStream* ts) {
|
||||
module->imports = new_imports;
|
||||
|
||||
t = tokenstream_next(ts);
|
||||
bool is_public = false;
|
||||
if (t.token == TOKEN_IDENTIFIER && strncmp(t.text.data, "public", t.text.length) == 0) {
|
||||
is_public = true;
|
||||
t = tokenstream_next(ts);
|
||||
}
|
||||
|
||||
if (t.token != TOKEN_IDENTIFIER) {
|
||||
log_on_line(&t.location, t.location.column_end, "expected module name to import");
|
||||
parser_free(module);
|
||||
@@ -69,6 +75,7 @@ Module* parser_parse(TokenStream* ts) {
|
||||
}
|
||||
memcpy(module->imports[module->import_count].module_name, t.text.data, t.text.length);
|
||||
module->imports[module->import_count].module_name[t.text.length] = '\0';
|
||||
module->imports[module->import_count].is_public = is_public;
|
||||
module->import_count++;
|
||||
|
||||
t = tokenstream_next(ts);
|
||||
|
||||
Reference in New Issue
Block a user