Browse Source

Allow core:odin to parse @(require) import

Jeroen van Rijn 1 year ago
parent
commit
aa27cd4b0b
2 changed files with 4 additions and 0 deletions
  1. 1 0
      core/odin/ast/ast.odin
  2. 3 0
      core/odin/parser/parser.odin

+ 1 - 0
core/odin/ast/ast.odin

@@ -513,6 +513,7 @@ Package_Decl :: struct {
 Import_Decl :: struct {
 	using node: Decl,
 	docs:       ^Comment_Group,
+	attributes:  [dynamic]^Attribute, // dynamic as parsing will add to them lazily
 	is_using:    bool,
 	import_tok:  tokenizer.Token,
 	name:        tokenizer.Token,

+ 3 - 0
core/odin/parser/parser.odin

@@ -1103,6 +1103,9 @@ parse_attribute :: proc(p: ^Parser, tok: tokenizer.Token, open_kind, close_kind:
 	case ^ast.Foreign_Import_Decl:
 		if d.docs == nil { d.docs = docs }
 		append(&d.attributes, attribute)
+	case ^ast.Import_Decl:
+		if d.docs == nil { d.docs = docs }
+		append(&d.attributes, attribute)
 	case:
 		error(p, decl.pos, "expected a value or foreign declaration after an attribute")
 		free(attribute)