diff options
| author | gingerBill <bill@gingerbill.org> | 2018-08-13 01:22:14 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-08-13 01:22:14 +0100 |
| commit | 89f4e7a8dbed4272f85f10568a542697aa3b38f8 (patch) | |
| tree | 125195ac6f23c9ec830b1ea0423001771eeb7592 /src/tokenizer.cpp | |
| parent | 55f4eabecdb5282d975369ec770078ec7bd49be6 (diff) | |
`-no-crt` flag for windows amd64
Diffstat (limited to 'src/tokenizer.cpp')
| -rw-r--r-- | src/tokenizer.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 2c233ee9b..507a4b45d 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -142,16 +142,15 @@ String const token_strings[] = { struct TokenPos { String file; - isize line; - isize column; + isize offset; // starting at 0 + isize line; // starting at 1 + isize column; // starting at 1 }; -TokenPos token_pos(String file, isize line, isize column) { - TokenPos pos = {file, line, column}; - return pos; -} - i32 token_pos_cmp(TokenPos const &a, TokenPos const &b) { + if (a.offset != b.offset) { + return (a.offset < b.offset) ? -1 : +1; + } if (a.line != b.line) { return (a.line < b.line) ? -1 : +1; } @@ -825,6 +824,7 @@ Token tokenizer_get_token(Tokenizer *t) { token.string = make_string(t->curr, 1); token.pos.file = t->fullpath; token.pos.line = t->line_count; + token.pos.offset = t->curr - t->start; token.pos.column = t->curr - t->line + 1; Rune curr_rune = t->curr_rune; |