Sam McCall 3132e9cd7c [pseudo] Key guards by RuleID, add guards to literals (and 0).
After this, NUMERIC_CONSTANT and strings should parse only one way.

There are 8 types of literals, and 24 valid (literal, TokenKind) pairs.
This means adding 8 new named guards (or 24, if we want to assert the token).

It seems fairly clear to me at this point that the guard names are unneccesary
indirection: the guards are in fact coupled to the rule signature.

(Also add the zero guard I forgot in the previous patch.)

Differential Revision: https://reviews.llvm.org/D130066
2022-07-21 22:42:31 +02:00

44 lines
2.0 KiB
C++

// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest -forest-abbrev=0 | FileCheck %s --implicit-check-not=ambiguous
auto list = {
0, // CHECK: := integer-literal
0b1011, // CHECK: := integer-literal
0777, // CHECK: := integer-literal
42_u, // CHECK: := user-defined-integer-literal
0LL, // CHECK: := integer-literal
0h, // CHECK: := user-defined-integer-literal
0., // CHECK: := floating-point-literal
.2, // CHECK: := floating-point-literal
2e1, // CHECK: := floating-point-literal
0x42d, // CHECK: := integer-literal
0x42_d, // CHECK: := user-defined-integer-literal
0x42ds, // CHECK: := user-defined-integer-literal
0x1.2p2,// CHECK: := floating-point-literal
"", // CHECK: literal := string-literal
L"", // CHECK: literal := string-literal
u8"", // CHECK: literal := string-literal
u"", // CHECK: literal := string-literal
U"", // CHECK: literal := string-literal
R"()", // CHECK: literal := string-literal
uR"()", // CHECK: literal := string-literal
"a" "b", // CHECK: literal := string-literal
u8"a" "b", // CHECK: literal := string-literal
u"a" u"b", // CHECK: literal := string-literal
"a"_u "b", // CHECK: user-defined-literal := user-defined-string-literal
"a"_u u"b", // CHECK: user-defined-literal := user-defined-string-literal
R"(a)" "\n", // CHECK: literal := string-literal
R"c(a)c"_u u"\n", // CHECK: user-defined-literal := user-defined-string-literal
'a', // CHECK: := character-literal
'abc', // CHECK: := character-literal
'abcdef', // CHECK: := character-literal
u'a', // CHECK: := character-literal
U'a', // CHECK: := character-literal
L'a', // CHECK: := character-literal
L'abc', // CHECK: := character-literal
U'\u1234',// CHECK: := character-literal
'\u1234', // CHECK: := character-literal
u'a'_u, // CHECK: := user-defined-character-literal
};