diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2025-01-03 00:24:10 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2025-01-03 00:24:10 +0400 |
commit | 6eaf5a6e0b4120535c018a89f0aae03e61f0f997 (patch) | |
tree | 1deb0524419536130dadac425f2e5592627ea55b | |
parent | 282145a4e97ee03d8acc3595eaf8870a07bacd03 (diff) |
file added to Token struct
-rw-r--r-- | src/main.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main.go b/src/main.go index f8280f8..e296eba 100644 --- a/src/main.go +++ b/src/main.go @@ -23,6 +23,7 @@ type Operation struct { /* TODO: Add file name */ type Token struct { str string + file string line int offset int } @@ -71,7 +72,7 @@ func tokenize(path string) []Token { if buf == "" { continue } - tokenBuf := Token{str: buf, line: lineIndex + 1, offset: offset - len(buf) + 1} + tokenBuf := Token{str: buf, file: path, line: lineIndex + 1, offset: offset - len(buf) + 1} tokens = append(tokens, tokenBuf) buf = "" } @@ -246,7 +247,7 @@ func parse(tokens[]Token) []Operation { } if op.name == "" { - fmt.Fprintf(os.Stderr, "Undefined word `%s` at %d:%d\n", tokens[i].str, tokens[i].line, tokens[i].offset) + fmt.Fprintf(os.Stderr, "Undefined word `%s` %s: %d:%d\n", tokens[i].str, tokens[i].file, tokens[i].line, tokens[i].offset) os.Exit(1) } |