diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2024-12-31 20:49:53 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2024-12-31 20:49:53 +0400 |
commit | fd03c7b874766db42479b3e29d8861b624fd3c98 (patch) | |
tree | 87ca257b9380a821ae70ad70b09fe3e6cbbb68e8 /src | |
parent | d4c0a96d9f0cf05100dea5fa6144ca2f2190d350 (diff) |
tokenizer handles strings differently
Diffstat (limited to 'src')
-rw-r--r-- | src/main.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main.go b/src/main.go index d0c54ca..5cb7075 100644 --- a/src/main.go +++ b/src/main.go @@ -41,11 +41,19 @@ func tokenize(path string) []Token { for lineIndex := 0; lineIndex < len(lines); lineIndex++ { line := lines[lineIndex] buf := "" + isStr := false for offset := 0; offset < len(line); offset++ { char := string(line[offset]) if char == "#" { break } + if char == "\"" { + isStr = !isStr + } + if isStr { + buf += char + continue; + } if char != " " && char != "\t" { buf += char if offset != len(line) - 1 { @@ -59,7 +67,13 @@ func tokenize(path string) []Token { tokens = append(tokens, tokenBuf) buf = "" } + if isStr { + panic("invalid syntax") + } } + + print(tokens) + os.Exit(0) return tokens } |