Add type identifier source locations
This commit is contained in:
parent
709c7a7a0a
commit
6276d97c6b
4 changed files with 4 additions and 5 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
* Mutually recursive functions
|
* Mutually recursive functions
|
||||||
* Type identifier location
|
* Figure out indentation: keep tabs - what to do with printing errors? Enforce e.g. 4 spaces?
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ struct vec2:
|
||||||
x : f32
|
x : f32
|
||||||
y : f32
|
y : f32
|
||||||
|
|
||||||
func add(a : vec2, b : vec2) -> vec2:
|
func add(a : vec2, b : vec2) -> qwe:
|
||||||
return vec2(a.x + b.x, a.y + b.y)
|
return vec2(a.x + b.x, a.y + b.y)
|
||||||
|
|
||||||
mut v = add(vec2(1.0, 2.0), vec2(3.0, 4.0))
|
mut v = add(vec2(1.0, 2.0), vec2(3.0, 4.0))
|
||||||
|
|
|
||||||
|
|
@ -90,8 +90,7 @@ namespace pslang::ast
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO location
|
throw parse_error("Identifier \"" + identifier.name + "\" not found", identifier.location);
|
||||||
throw parse_error("Identifier \"" + identifier.name + "\" not found", {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void resolve_identifiers(context & context, type & type)
|
void resolve_identifiers(context & context, type & type)
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ variable_keyword
|
||||||
type_expression
|
type_expression
|
||||||
: unit { $$ = types::unit_type{}; }
|
: unit { $$ = types::unit_type{}; }
|
||||||
| primitive_type { $$ = ast::type($1); }
|
| primitive_type { $$ = ast::type($1); }
|
||||||
| name { $$ = ast::type_identifier{$1}; }
|
| name { $$ = ast::type_identifier{$1, @$}; }
|
||||||
| type_expression lbracket lit_i32 rbracket { $$ = ast::array_type{std::make_unique<ast::type>($1), std::stoull($3)}; }
|
| type_expression lbracket lit_i32 rbracket { $$ = ast::array_type{std::make_unique<ast::type>($1), std::stoull($3)}; }
|
||||||
| type_expression arrow type_expression { std::vector<ast::type_ptr> args; args.push_back(std::make_unique<ast::type>($1)); $$ = ast::function_type{std::move(args), std::make_unique<ast::type>($3)}; }
|
| type_expression arrow type_expression { std::vector<ast::type_ptr> args; args.push_back(std::make_unique<ast::type>($1)); $$ = ast::function_type{std::move(args), std::make_unique<ast::type>($3)}; }
|
||||||
| lparen function_paren_type_list rparen arrow type_expression { $$ = ast::function_type{$2, std::make_unique<ast::type>($5)}; }
|
| lparen function_paren_type_list rparen arrow type_expression { $$ = ast::function_type{$2, std::make_unique<ast::type>($5)}; }
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue