From fd03c7b874766db42479b3e29d8861b624fd3c98 Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Tue, 31 Dec 2024 20:49:53 +0400 Subject: tokenizer handles strings differently --- src/main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') 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 } -- cgit v1.2.3