diff options
| author | Mustafa Quraish <[email protected]> | 2022-02-06 21:18:04 -0500 |
|---|---|---|
| committer | Mustafa Quraish <[email protected]> | 2022-02-06 21:19:45 -0500 |
| commit | 0dd893225bebffd9a25f1345ec49922aa961b882 (patch) | |
| tree | e843cef529e0e1d6cdba85c2268742e3aed68749 /compiler/lexer.cup | |
| parent | Add some information to the README (diff) | |
| download | cup-0dd893225bebffd9a25f1345ec49922aa961b882.tar.xz cup-0dd893225bebffd9a25f1345ec49922aa961b882.zip | |
[C]: Add `here` keyword that evaluates to a string with it's location
It's not really a keyword like the other ones, but just handled
completely at the lexer level since it already knows the location of the
token, so it injects a string literal instead.
We also use this in the self-hosted compiler now for better error
reporting for where the error happened internally.
Diffstat (limited to 'compiler/lexer.cup')
| -rw-r--r-- | compiler/lexer.cup | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/lexer.cup b/compiler/lexer.cup index c0062a2..a7fd032 100644 --- a/compiler/lexer.cup +++ b/compiler/lexer.cup @@ -217,7 +217,7 @@ fn lexer_next(lexer: Lexer*, token: Token*) { lexer_loc(lexer, &loc); if (pos == lexer.len) - die_loc(&loc, "EOF while parsing string literal"); + die_loc(here, &loc, "EOF while parsing string literal"); // Careful with indexing here, because we want to skip opening and closing quotes let str_len = pos - lexer.pos - 1; |