hare

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

commit af5f3cf5b78efefca4bc1ffe848fd2f9eb185605
parent 94a11210f9acfcd090b2110db653c505ffecf068
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat, 13 Feb 2021 12:01:03 -0500

hare::lex: replace linecol tuple with struct

Diffstat:
Mhare/lex/lex.ha | 10+++++-----
Mhare/lex/token.ha | 2+-
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -17,7 +17,7 @@ export type lexer = struct { export fn lexer_init(in: *io::stream, path: str) lexer = lexer { in = in, path = path, - loc = (1, 1), + loc = linecol { line = 1, col = 1 }, un = void, rb = [void...], }; @@ -80,13 +80,13 @@ fn unget(lex: *lexer, r: (rune | io::EOF)) void = { let lexer = lexer_init(bufio::fixed([]), "<test>"); unlex(&lexer, (base_token::IF, location { path = "<test>", - start = (1234, 1234), - end = (1234, 1234), + start = linecol { line = 1234, col = 1234 }, + end = linecol { line = 1234, col = 1234 }, })); let t = lex(&lexer) as (token, location); assert(t.0 is base_token); assert(t.0 as base_token == base_token::IF); assert(t.1.path == "<test>"); - assert(t.1.start.0 == 1234 && t.1.start.1 == 1234); - assert(t.1.end.0 == 1234 && t.1.end.1 == 1234); + assert(t.1.start.line == 1234 && t.1.start.col == 1234); + assert(t.1.end.line == 1234 && t.1.end.col == 1234); }; diff --git a/hare/lex/token.ha b/hare/lex/token.ha @@ -148,7 +148,7 @@ export type literal = struct { }; // A tuple of a line number and column number, counting from 1. -export type linecol = (uint, uint); +export type linecol = struct { line: uint, col: uint }; // A location within a source file. export type location = struct {