23 Lexer lexer(
"plain text $var $VaR ${x}\n");
28 EXPECT_EQ(
"[plain text ][$var][ ][$VaR][ ][$x]",
33 Lexer lexer(
"$ $$ab c$: $\ncde\n");
38 EXPECT_EQ(
"[ $ab c: cde]",
43 Lexer lexer(
"foo baR baz_123 foo-bar");
46 EXPECT_EQ(
"foo", ident);
48 EXPECT_EQ(
"baR", ident);
50 EXPECT_EQ(
"baz_123", ident);
52 EXPECT_EQ(
"foo-bar", ident);
58 Lexer lexer(
"foo.dots $bar.dots ${bar.dots}\n");
61 EXPECT_EQ(
"foo.dots", ident);
67 EXPECT_EQ(
"[$bar][.dots ][$bar.dots]",
72 Lexer lexer(
"foo$\nbad $");
76 EXPECT_EQ(
"input:2: bad $-escape (literal $ must be written as $$)\n"
92 Lexer lexer(
" \tfoobar");
TEST(Lexer, ReadVarValue)
A tokenized string that contains variable references.
std::string Serialize() const
Construct a human-readable representation of the parsed state, for use in tests.
std::string DescribeLastError()
If the last token read was an ERROR token, provide more info or the empty string.
Token ReadToken()
Read a Token from the Token enum.
bool ReadVarValue(EvalString *value, std::string *err)
Read the value side of a var = value line (complete with $escapes).
bool ReadIdent(std::string *out)
Read a simple identifier (a rule or variable name).
void Error(const char *msg, va_list ap)