diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-05-28 12:18:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-28 12:18:15 +0100 |
| commit | 74524b6050d340840fcd636cd94b48e4187695aa (patch) | |
| tree | 217644e5ec4c7fa35baca19d68392e6c67069033 /core | |
| parent | 23852c16be2ed8ae1618c1d951c9904eb40a4198 (diff) | |
| parent | d91054b615e5e185ded106e4903cdd66b2c4f582 (diff) | |
Merge pull request #3644 from odin-lang/foreign-import-improvements
Allow `foreign import` import paths to be evaluated in the semantic phase rather than parsing
Diffstat (limited to 'core')
| -rw-r--r-- | core/odin/ast/ast.odin | 2 | ||||
| -rw-r--r-- | core/odin/parser/parser.odin | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/core/odin/ast/ast.odin b/core/odin/ast/ast.odin index be541befa..7891fb12d 100644 --- a/core/odin/ast/ast.odin +++ b/core/odin/ast/ast.odin @@ -538,7 +538,7 @@ Foreign_Import_Decl :: struct { import_tok: tokenizer.Token, name: ^Ident, collection_name: string, - fullpaths: []string, + fullpaths: []^Expr, comment: ^Comment_Group, } diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index e32fbdced..813585ba4 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -1190,12 +1190,12 @@ parse_foreign_decl :: proc(p: ^Parser) -> ^ast.Decl { error(p, name.pos, "illegal foreign import name: '_'") } - fullpaths: [dynamic]string + fullpaths: [dynamic]^ast.Expr if allow_token(p, .Open_Brace) { for p.curr_tok.kind != .Close_Brace && p.curr_tok.kind != .EOF { - path := expect_token(p, .String) - append(&fullpaths, path.text) + path := parse_expr(p, false) + append(&fullpaths, path) allow_token(p, .Comma) or_break } @@ -1203,7 +1203,9 @@ parse_foreign_decl :: proc(p: ^Parser) -> ^ast.Decl { } else { path := expect_token(p, .String) reserve(&fullpaths, 1) - append(&fullpaths, path.text) + bl := ast.new(ast.Basic_Lit, path.pos, end_pos(path)) + bl.tok = tok + append(&fullpaths, bl) } if len(fullpaths) == 0 { |