Support lexing and parsing positional params (#7651)

This implements lexing and parsing positional parameters such as `$0`.
This commit is contained in:
Özgür T. Önsoy
2026-09-03 19:06:20 +00:00
committed by GitHub
parent 27849b385c
commit 5474347d7d
14 changed files with 282 additions and 8 deletions
+5 -5
View File
@@ -369,7 +369,7 @@ TEST_F(LexerTest, SplitsNumericLiteralsProperly) {
}
TEST_F(LexerTest, HandlesGarbageCharacters) {
constexpr char GarbageText[] = "$$💩-$\n$\0$12$\n\\\"\\\n\"x";
constexpr char GarbageText[] = "##💩-#\n#\0#12#\n\\\"\\\n\"x";
auto& buffer = compile_helper_.GetTokenizedBuffer(
llvm::StringRef(GarbageText, sizeof(GarbageText) - 1));
EXPECT_TRUE(buffer.has_errors());
@@ -381,16 +381,16 @@ TEST_F(LexerTest, HandlesGarbageCharacters) {
.line = 1,
.column = 1,
// 💩 takes 4 bytes, and we count column as bytes offset.
.text = llvm::StringRef("$$💩", 6)},
.text = llvm::StringRef("##💩", 6)},
{.kind = TokenKind::Minus, .line = 1, .column = 7},
{.kind = TokenKind::Error, .line = 1, .column = 8, .text = "$"},
{.kind = TokenKind::Error, .line = 1, .column = 8, .text = "#"},
// newline
{.kind = TokenKind::Error,
.line = 2,
.column = 1,
.text = llvm::StringRef("$\0$", 3)},
.text = llvm::StringRef("#\0#", 3)},
{.kind = TokenKind::IntLiteral, .line = 2, .column = 4, .text = "12"},
{.kind = TokenKind::Error, .line = 2, .column = 6, .text = "$"},
{.kind = TokenKind::Error, .line = 2, .column = 6, .text = "#"},
// newline
{.kind = TokenKind::Backslash, .line = 3, .column = 1, .text = "\\"},
{.kind = TokenKind::Error, .line = 3, .column = 2, .text = "\"\\"},