feat: implement string escape sequence parsing in lexer and add test coverage
Add escape sequence handling to the string literal lexer in compiler.c, translating common escape sequences (\", \\, \n) into their literal character equivalents during tokenization. Introduce a fixed-size buffer (MAX_STRING 1024) in the Parser struct to accumulate the unescaped string content, along with a helper function addStringChar() to append characters. The readString() function now loops over input characters, breaking on an unescaped double quote, and processing backslash-prefixed escapes via a switch statement. Remove the previous TODO placeholder comment and the elapsed time computation simplification in benchmark/fib.lua. Add a new test file test/string_escapes.wren that verifies the three supported escape sequences, and remove the now-obsolete TODO about escapes from test/string_literals.wren.
This commit is contained in:
+1
-2
@@ -7,5 +7,4 @@ local start = os.clock()
|
||||
for i = 1, 5 do
|
||||
io.write(fib(30) .. "\n")
|
||||
end
|
||||
local elapsed = os.clock() - start
|
||||
io.write(string.format("elapsed: %.8f\n", elapsed))
|
||||
io.write(string.format("elapsed: %.8f\n", os.clock() - start))
|
||||
|
||||
Reference in New Issue
Block a user