feat: backtick raw/multi-line strings + QBE backend fixes
- Add backtick raw string literals (Go-style ): no escape processing, multi-line - C backend: handle backtick strings in emitExpr - Self-hosted lexer: lexScanBacktickString support - QBE backend: handle backtick strings in data sections - QBE: remove broken extern declarations (QBE resolves at link time) - QBE: fix comparison result types (ceql → w, extend to l) - QBE: fix SSA parameter name clash (_p_ prefix for params) - QBE: const inlining via HirLower + QBE emitter - QBE: proper type mapping for bool/char types - hir_lower: collect dkConst declarations for const propagation
This commit is contained in:
@@ -384,6 +384,20 @@ func lexScanNumber(lex: *Lexer) {
|
||||
// Strings and chars
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
func lexScanBacktickString(lex: *Lexer) {
|
||||
lexMarkStart(lex);
|
||||
if lexPeek(lex, 0) == 96 { discard lexAdvance(lex); } // opening backtick
|
||||
while !lexIsAtEnd(lex) && lexPeek(lex, 0) != 96 {
|
||||
discard lexAdvance(lex);
|
||||
}
|
||||
if lexIsAtEnd(lex) {
|
||||
lexEmitDiag(lex, "unterminated backtick string literal");
|
||||
} else {
|
||||
discard lexAdvance(lex); // closing backtick
|
||||
}
|
||||
lexEmitToken(lex, tkStringLiteral);
|
||||
}
|
||||
|
||||
func lexScanString(lex: *Lexer) {
|
||||
lexMarkStart(lex);
|
||||
if lexPeek(lex, 0) == 34 { discard lexAdvance(lex); } // opening "
|
||||
@@ -618,6 +632,11 @@ func lexNextToken(lex: *Lexer) {
|
||||
lexScanString(lex); return;
|
||||
}
|
||||
|
||||
// Backtick raw string
|
||||
if c == 96 { // backtick
|
||||
lexScanBacktickString(lex); return;
|
||||
}
|
||||
|
||||
// Char prefixes: c8' c16' c32'
|
||||
if c == 99 { // 'c'
|
||||
let d: uint32 = lexPeek(lex, 1);
|
||||
|
||||
Reference in New Issue
Block a user