hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 088579531180231b851b7e0db2392d542a8a10f1
parent 02135370d1948712ce673dbee1adb82b15c66408
Author: Sebastian LaVine <mail@smlavine.com>
Date:   Thu, 26 May 2022 21:08:24 -0400

hare::ast: Add start, end fields to import

This matches the fields present in decl.

Diffstat:
Mhare/ast/import.ha | 3+++
Mhare/parse/import.ha | 2++
2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/hare/ast/import.ha b/hare/ast/import.ha @@ -1,6 +1,7 @@ // License: MPL-2.0 // (c) 2021 Drew DeVault <sir@cmpwn.com> // (c) 2021 Eyal Sawady <ecs@d2evs.net> +use hare::lex; // Variants of the import statement export type import_mode = enum uint { @@ -16,6 +17,8 @@ export type import_mode = enum uint { // An imported module. export type import = struct { + start: lex::location, + end: lex::location, mode: import_mode, ident: ident, alias: str, diff --git a/hare/parse/import.ha b/hare/parse/import.ha @@ -45,6 +45,7 @@ export fn imports(lexer: *lex::lexer) ([]ast::import | error) = { append(imports, ast::import { ... }); let import = &imports[len(imports) - 1]; + import.start = lex::mkloc(lexer); for (true) { let name = ident_trailing(lexer)?; import.ident = name.0; @@ -79,6 +80,7 @@ export fn imports(lexer: *lex::lexer) ([]ast::import | error) = { case => abort(); // Unreachable }; }; + import.end = lex::mkloc(lexer); }; return imports; };