More buildins and vscode exstention <CO-AUthored, ai>

This commit is contained in:
allexanderbergmns
2026-08-25 16:20:11 +02:00
parent 5daadce7a9
commit 7ed774089e
27 changed files with 2080 additions and 122 deletions
+20
View File
@@ -220,6 +220,11 @@ fn (mut l Lexer) next() !Tok {
return l.lex_number(line, col)
}
else {
// r"..." raw strings (no escape processing) — handy for regex
// patterns like r"\d+" that would otherwise need double escaping
if c == `r` && l.peek2() == `\"` {
return l.lex_raw_string(line, col)!
}
if (c >= `a` && c <= `z`) || (c >= `A` && c <= `Z`) || c == `_` {
return l.lex_ident(line, col)
}
@@ -310,6 +315,21 @@ fn (mut l Lexer) lex_ident(line int, col int) Tok {
return Tok{ kind: kind, lit: lit, line: line, col: col }
}
// lex_raw_string reads an r"..." string verbatim: backslashes, quotes and
// ${...} sequences are all kept literally, so regex patterns pass through
// untouched. The token is a plain str_lit whose content is the raw text.
fn (mut l Lexer) lex_raw_string(line int, col int) !Tok {
l.advance() // 'r'
l.advance() // opening quote
start := l.pos
for l.pos < l.src.len {
if l.advance() == `\"` {
return Tok{ kind: .str_lit, lit: l.src[start..l.pos - 1], line: line, col: col }
}
}
return error('unterminated raw string at line ${line}, col ${col}')
}
fn (mut l Lexer) lex_string(line int, col int) !Tok {
l.advance() // opening quote
mut s := ''