mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Support lexing and parsing positional params (#7651)
This implements lexing and parsing positional parameters such as `$0`.
This commit is contained in:
@@ -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 = "\"\\"},
|
||||
|
||||
Reference in New Issue
Block a user