Commit d5eba005 authored by Kenton Varda's avatar Kenton Varda

Refactor lexer.capnp to use unnamed unions.

parent 7b8bbc87
......@@ -72,54 +72,54 @@ kj::String doLex(kj::StringPtr constText) {
TEST(Lexer, Tokens) {
EXPECT_STREQ(
"(tokens = ["
"(body = identifier('foo'), endByte = 3), "
"(body = identifier('bar'), startByte = 4, endByte = 7)"
"(identifier = 'foo', endByte = 3), "
"(identifier = 'bar', startByte = 4, endByte = 7)"
"])",
doLex<LexedTokens>("foo bar").cStr());
EXPECT_STREQ(
"(tokens = ["
"(body = identifier('foo'), endByte = 3), "
"(body = identifier('bar'), startByte = 15, endByte = 18)"
"(identifier = 'foo', endByte = 3), "
"(identifier = 'bar', startByte = 15, endByte = 18)"
"])",
doLex<LexedTokens>("foo # comment\n bar").cStr());
EXPECT_STREQ(
"(tokens = ["
"(body = stringLiteral('foo '), startByte = 2, endByte = 11), "
"(body = integerLiteral(123), startByte = 12, endByte = 15), "
"(body = floatLiteral(2.75), startByte = 16, endByte = 20), "
"(body = floatLiteral(60000), startByte = 21, endByte = 24), "
"(body = operator('+'), startByte = 25, endByte = 26), "
"(body = operator('-='), startByte = 27, endByte = 29)"
"(stringLiteral = 'foo ', startByte = 2, endByte = 11), "
"(integerLiteral = 123, startByte = 12, endByte = 15), "
"(floatLiteral = 2.75, startByte = 16, endByte = 20), "
"(floatLiteral = 60000, startByte = 21, endByte = 24), "
"(operator = '+', startByte = 25, endByte = 26), "
"(operator = '-=', startByte = 27, endByte = 29)"
"])",
doLex<LexedTokens>(" 'foo\\x20' 123 2.75 6e4 + -= ").cStr());
EXPECT_STREQ(
"(tokens = ["
"(body = parenthesizedList(["
"(parenthesizedList = ["
"["
"(body = identifier('foo'), startByte = 1, endByte = 4), "
"(body = identifier('bar'), startByte = 5, endByte = 8)"
"(identifier = 'foo', startByte = 1, endByte = 4), "
"(identifier = 'bar', startByte = 5, endByte = 8)"
"], ["
"(body = identifier('baz'), startByte = 10, endByte = 13), "
"(body = identifier('qux'), startByte = 14, endByte = 17)"
"(identifier = 'baz', startByte = 10, endByte = 13), "
"(identifier = 'qux', startByte = 14, endByte = 17)"
"], ["
"(body = identifier('corge'), startByte = 19, endByte = 24), "
"(body = identifier('grault'), startByte = 25, endByte = 31)"
"(identifier = 'corge', startByte = 19, endByte = 24), "
"(identifier = 'grault', startByte = 25, endByte = 31)"
"]"
"]), endByte = 32)"
"], endByte = 32)"
"])",
doLex<LexedTokens>("(foo bar, baz qux, corge grault)").cStr());
EXPECT_STREQ(
"(tokens = ["
"(body = parenthesizedList(["
"(parenthesizedList = ["
"["
"(body = identifier('foo'), startByte = 1, endByte = 4), "
"(body = identifier('bar'), startByte = 5, endByte = 8)"
"(identifier = 'foo', startByte = 1, endByte = 4), "
"(identifier = 'bar', startByte = 5, endByte = 8)"
"]"
"]), endByte = 9)"
"], endByte = 9)"
"])",
doLex<LexedTokens>("(foo bar)").cStr());
......@@ -127,50 +127,50 @@ TEST(Lexer, Tokens) {
// list.
EXPECT_STREQ(
"(tokens = ["
"(body = parenthesizedList([]), endByte = 4)"
"(parenthesizedList = [], endByte = 4)"
"])",
doLex<LexedTokens>("( )").cStr());
EXPECT_STREQ(
"(tokens = ["
"(body = bracketedList(["
"(bracketedList = ["
"["
"(body = identifier('foo'), startByte = 1, endByte = 4), "
"(body = identifier('bar'), startByte = 5, endByte = 8)"
"(identifier = 'foo', startByte = 1, endByte = 4), "
"(identifier = 'bar', startByte = 5, endByte = 8)"
"], ["
"(body = identifier('baz'), startByte = 10, endByte = 13), "
"(body = identifier('qux'), startByte = 14, endByte = 17)"
"(identifier = 'baz', startByte = 10, endByte = 13), "
"(identifier = 'qux', startByte = 14, endByte = 17)"
"], ["
"(body = identifier('corge'), startByte = 19, endByte = 24), "
"(body = identifier('grault'), startByte = 25, endByte = 31)"
"(identifier = 'corge', startByte = 19, endByte = 24), "
"(identifier = 'grault', startByte = 25, endByte = 31)"
"]"
"]), endByte = 32)"
"], endByte = 32)"
"])",
doLex<LexedTokens>("[foo bar, baz qux, corge grault]").cStr());
EXPECT_STREQ(
"(tokens = ["
"(body = bracketedList(["
"(bracketedList = ["
"["
"(body = identifier('foo'), startByte = 1, endByte = 4)"
"(identifier = 'foo', startByte = 1, endByte = 4)"
"], ["
"(body = parenthesizedList(["
"(parenthesizedList = ["
"["
"(body = identifier('bar'), startByte = 7, endByte = 10)"
"(identifier = 'bar', startByte = 7, endByte = 10)"
"], ["
"(body = identifier('baz'), startByte = 12, endByte = 15)"
"(identifier = 'baz', startByte = 12, endByte = 15)"
"]"
"]), startByte = 6, endByte = 16)"
"], startByte = 6, endByte = 16)"
"]"
"]), endByte = 17), "
"(body = identifier('qux'), startByte = 18, endByte = 21)"
"], endByte = 17), "
"(identifier = 'qux', startByte = 18, endByte = 21)"
"])",
doLex<LexedTokens>("[foo, (bar, baz)] qux").cStr());
EXPECT_STREQ(
"(tokens = ["
"(body = identifier('foo'), endByte = 3), "
"(body = identifier('bar'), startByte = 7, endByte = 10)"
"(identifier = 'foo', endByte = 3), "
"(identifier = 'bar', startByte = 7, endByte = 10)"
"])",
doLex<LexedTokens>("foo\n\r\t\vbar").cStr());
}
......@@ -179,8 +179,8 @@ TEST(Lexer, Statements) {
EXPECT_STREQ(
"(statements = ["
"(tokens = ["
"(body = identifier('foo'), endByte = 3), "
"(body = identifier('bar'), startByte = 4, endByte = 7)"
"(identifier = 'foo', endByte = 3), "
"(identifier = 'bar', startByte = 4, endByte = 7)"
"], endByte = 8)"
"])",
doLex<LexedStatements>("foo bar;").cStr());
......@@ -188,13 +188,13 @@ TEST(Lexer, Statements) {
EXPECT_STREQ(
"(statements = ["
"(tokens = ["
"(body = identifier('foo'), endByte = 3)"
"(identifier = 'foo', endByte = 3)"
"], endByte = 4), "
"(tokens = ["
"(body = identifier('bar'), startByte = 5, endByte = 8)"
"(identifier = 'bar', startByte = 5, endByte = 8)"
"], startByte = 5, endByte = 9), "
"(tokens = ["
"(body = identifier('baz'), startByte = 10, endByte = 13)"
"(identifier = 'baz', startByte = 10, endByte = 13)"
"], startByte = 10, endByte = 14)"
"])",
doLex<LexedStatements>("foo; bar; baz; ").cStr());
......@@ -203,20 +203,20 @@ TEST(Lexer, Statements) {
"(statements = ["
"("
"tokens = ["
"(body = identifier('foo'), endByte = 3)"
"(identifier = 'foo', endByte = 3)"
"], "
"block = statements(["
"block = (statements = ["
"(tokens = ["
"(body = identifier('bar'), startByte = 5, endByte = 8)"
"(identifier = 'bar', startByte = 5, endByte = 8)"
"], startByte = 5, endByte = 9), "
"(tokens = ["
"(body = identifier('baz'), startByte = 10, endByte = 13)"
"(identifier = 'baz', startByte = 10, endByte = 13)"
"], startByte = 10, endByte = 14)"
"]), "
"endByte = 15"
"), "
"(tokens = ["
"(body = identifier('qux'), startByte = 16, endByte = 19)"
"(identifier = 'qux', startByte = 16, endByte = 19)"
"], startByte = 16, endByte = 20)"
"])",
doLex<LexedStatements>("foo {bar; baz;} qux;").cStr());
......@@ -227,7 +227,7 @@ TEST(Lexer, DocComments) {
"(statements = ["
"("
"tokens = ["
"(body = identifier('foo'), endByte = 3)"
"(identifier = 'foo', endByte = 3)"
"], "
"docComment = 'blah blah\\n', "
"endByte = 16"
......@@ -239,7 +239,7 @@ TEST(Lexer, DocComments) {
"(statements = ["
"("
"tokens = ["
"(body = identifier('foo'), endByte = 3)"
"(identifier = 'foo', endByte = 3)"
"], "
"docComment = 'blah blah\\n', "
"endByte = 15"
......@@ -251,7 +251,7 @@ TEST(Lexer, DocComments) {
"(statements = ["
"("
"tokens = ["
"(body = identifier('foo'), endByte = 3)"
"(identifier = 'foo', endByte = 3)"
"], "
"docComment = ' blah blah\\n', "
"endByte = 17"
......@@ -263,7 +263,7 @@ TEST(Lexer, DocComments) {
"(statements = ["
"("
"tokens = ["
"(body = identifier('foo'), endByte = 3)"
"(identifier = 'foo', endByte = 3)"
"], "
"docComment = 'blah blah\\n', "
"endByte = 16"
......@@ -275,7 +275,7 @@ TEST(Lexer, DocComments) {
"(statements = ["
"("
"tokens = ["
"(body = identifier('foo'), endByte = 3)"
"(identifier = 'foo', endByte = 3)"
"], "
"endByte = 4"
")"
......@@ -286,7 +286,7 @@ TEST(Lexer, DocComments) {
"(statements = ["
"("
"tokens = ["
"(body = identifier('foo'), endByte = 3)"
"(identifier = 'foo', endByte = 3)"
"], "
"docComment = 'bar baz\\nqux corge\\n', "
"endByte = 30"
......@@ -298,21 +298,21 @@ TEST(Lexer, DocComments) {
"(statements = ["
"("
"tokens = ["
"(body = identifier('foo'), endByte = 3)"
"(identifier = 'foo', endByte = 3)"
"], "
"block = statements(["
"block = (statements = ["
"(tokens = ["
"(body = identifier('bar'), startByte = 17, endByte = 20)"
"(identifier = 'bar', startByte = 17, endByte = 20)"
"], docComment = 'hi\\n', startByte = 17, endByte = 27), "
"(tokens = ["
"(body = identifier('baz'), startByte = 28, endByte = 31)"
"(identifier = 'baz', startByte = 28, endByte = 31)"
"], startByte = 28, endByte = 32)"
"]), "
"docComment = 'blah blah\\n', "
"endByte = 44"
"), "
"(tokens = ["
"(body = identifier('qux'), startByte = 44, endByte = 47)"
"(identifier = 'qux', startByte = 44, endByte = 47)"
"], startByte = 44, endByte = 48)"
"])",
doLex<LexedStatements>("foo {# blah blah\nbar; # hi\n baz;} # ignored\nqux;").cStr());
......@@ -321,21 +321,21 @@ TEST(Lexer, DocComments) {
"(statements = ["
"("
"tokens = ["
"(body = identifier('foo'), endByte = 3)"
"(identifier = 'foo', endByte = 3)"
"], "
"block = statements(["
"block = (statements = ["
"(tokens = ["
"(body = identifier('bar'), startByte = 5, endByte = 8)"
"(identifier = 'bar', startByte = 5, endByte = 8)"
"], startByte = 5, endByte = 9), "
"(tokens = ["
"(body = identifier('baz'), startByte = 10, endByte = 13)"
"(identifier = 'baz', startByte = 10, endByte = 13)"
"], startByte = 10, endByte = 14)"
"]), "
"docComment = 'late comment\\n', "
"endByte = 31"
"), "
"(tokens = ["
"(body = identifier('qux'), startByte = 31, endByte = 34)"
"(identifier = 'qux', startByte = 31, endByte = 34)"
"], startByte = 31, endByte = 35)"
"])",
doLex<LexedStatements>("foo {bar; baz;}\n# late comment\nqux;").cStr());
......
......@@ -78,11 +78,11 @@ namespace {
typedef p::Span<uint32_t> Location;
Token::Body::Builder initTok(Orphan<Token>& t, const Location& loc) {
auto tb = t.get();
tb.setStartByte(loc.begin());
tb.setEndByte(loc.end());
return tb.getBody();
Token::Builder initTok(Orphan<Token>& t, const Location& loc) {
auto builder = t.get();
builder.setStartByte(loc.begin());
builder.setEndByte(loc.end());
return builder;
}
void buildTokenSequenceList(List<List<Token>>::Builder builder,
......
......@@ -28,18 +28,18 @@ using Cxx = import "/capnp/c++.capnp";
$Cxx.namespace("capnp::compiler");
struct Token {
body @0 union {
identifier @1 :Text;
stringLiteral @2 :Text;
integerLiteral @3 :UInt64;
floatLiteral @4 :Float64;
operator @5 :Text;
parenthesizedList @6 :List(List(Token));
bracketedList @7 :List(List(Token));
union {
identifier @0 :Text;
stringLiteral @1 :Text;
integerLiteral @2 :UInt64;
floatLiteral @3 :Float64;
operator @4 :Text;
parenthesizedList @5 :List(List(Token));
bracketedList @6 :List(List(Token));
}
startByte @8 :UInt32;
endByte @9 :UInt32;
startByte @7 :UInt32;
endByte @8 :UInt32;
}
struct Statement {
......
......@@ -5,17 +5,17 @@
namespace capnp {
namespace schemas {
static const ::capnp::_::AlignedData<55> b_91cc55cd57de5419 = {
static const ::capnp::_::AlignedData<165> b_91cc55cd57de5419 = {
{ 0, 0, 0, 0, 5, 0, 5, 0,
25, 84, 222, 87, 205, 85, 204, 145,
0, 0, 0, 0, 1, 0, 3, 0,
238, 195, 31, 98, 210, 86, 57, 167,
1, 0, 7, 0, 0, 0, 0, 0,
1, 0, 7, 0, 0, 0, 7, 0,
0, 0, 0, 0, 0, 0, 0, 0,
17, 0, 0, 0, 10, 1, 0, 0,
33, 0, 0, 0, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
29, 0, 0, 0, 175, 0, 0, 0,
29, 0, 0, 0, 255, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
99, 97, 112, 110, 112, 47, 99, 111,
109, 112, 105, 108, 101, 114, 47, 108,
......@@ -23,121 +23,70 @@ static const ::capnp::_::AlignedData<55> b_91cc55cd57de5419 = {
110, 112, 58, 84, 111, 107, 101, 110,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 1, 0,
12, 0, 0, 0, 3, 0, 4, 0,
0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 1, 0, 0, 0, 0, 0,
51, 143, 77, 217, 86, 219, 152, 251,
69, 0, 0, 0, 42, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 1, 0, 0, 0,
0, 0, 1, 0, 8, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
45, 0, 0, 0, 82, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
44, 0, 0, 0, 2, 0, 1, 0,
52, 0, 0, 0, 2, 0, 1, 0,
2, 0, 0, 0, 4, 0, 0, 0,
0, 0, 1, 0, 9, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
49, 0, 0, 0, 66, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
44, 0, 0, 0, 2, 0, 1, 0,
52, 0, 0, 0, 2, 0, 1, 0,
98, 111, 100, 121, 0, 0, 0, 0,
115, 116, 97, 114, 116, 66, 121, 116,
101, 0, 0, 0, 0, 0, 0, 0,
8, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
8, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
101, 110, 100, 66, 121, 116, 101, 0,
8, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
8, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, }
};
static const ::capnp::_::RawSchema* const d_91cc55cd57de5419[] = {
&s_fb98db56d94d8f33,
};
static const uint16_t m_91cc55cd57de5419[] = {0, 2, 1};
static const uint16_t i_91cc55cd57de5419[] = {0, 1, 2};
const ::capnp::_::RawSchema s_91cc55cd57de5419 = {
0x91cc55cd57de5419, b_91cc55cd57de5419.words, 55, d_91cc55cd57de5419, m_91cc55cd57de5419,
1, 3, i_91cc55cd57de5419, nullptr, nullptr
};
static const ::capnp::_::AlignedData<135> b_fb98db56d94d8f33 = {
{ 0, 0, 0, 0, 5, 0, 5, 0,
51, 143, 77, 217, 86, 219, 152, 251,
33, 0, 0, 0, 1, 0, 3, 0,
25, 84, 222, 87, 205, 85, 204, 145,
1, 0, 7, 0, 1, 0, 7, 0,
0, 0, 0, 0, 0, 0, 0, 0,
17, 0, 0, 0, 50, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
36, 0, 0, 0, 3, 0, 4, 0,
0, 0, 255, 255, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
25, 0, 0, 0, 143, 1, 0, 0,
237, 0, 0, 0, 90, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
99, 97, 112, 110, 112, 47, 99, 111,
109, 112, 105, 108, 101, 114, 47, 108,
101, 120, 101, 114, 46, 99, 97, 112,
110, 112, 58, 84, 111, 107, 101, 110,
46, 98, 111, 100, 121, 0, 0, 0,
28, 0, 0, 0, 3, 0, 4, 0,
0, 0, 255, 255, 0, 0, 0, 0,
236, 0, 0, 0, 2, 0, 1, 0,
244, 0, 0, 0, 2, 0, 1, 0,
1, 0, 254, 255, 0, 0, 0, 0,
0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
181, 0, 0, 0, 90, 0, 0, 0,
241, 0, 0, 0, 114, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
180, 0, 0, 0, 2, 0, 1, 0,
188, 0, 0, 0, 2, 0, 1, 0,
1, 0, 254, 255, 0, 0, 0, 0,
240, 0, 0, 0, 2, 0, 1, 0,
248, 0, 0, 0, 2, 0, 1, 0,
2, 0, 253, 255, 1, 0, 0, 0,
0, 0, 1, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
185, 0, 0, 0, 114, 0, 0, 0,
245, 0, 0, 0, 122, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
184, 0, 0, 0, 2, 0, 1, 0,
192, 0, 0, 0, 2, 0, 1, 0,
2, 0, 253, 255, 1, 0, 0, 0,
244, 0, 0, 0, 2, 0, 1, 0,
252, 0, 0, 0, 2, 0, 1, 0,
3, 0, 252, 255, 1, 0, 0, 0,
0, 0, 1, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
189, 0, 0, 0, 122, 0, 0, 0,
249, 0, 0, 0, 106, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
188, 0, 0, 0, 2, 0, 1, 0,
196, 0, 0, 0, 2, 0, 1, 0,
3, 0, 252, 255, 1, 0, 0, 0,
248, 0, 0, 0, 2, 0, 1, 0,
0, 1, 0, 0, 2, 0, 1, 0,
4, 0, 251, 255, 0, 0, 0, 0,
0, 0, 1, 0, 4, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
193, 0, 0, 0, 106, 0, 0, 0,
253, 0, 0, 0, 74, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
192, 0, 0, 0, 2, 0, 1, 0,
200, 0, 0, 0, 2, 0, 1, 0,
4, 0, 251, 255, 0, 0, 0, 0,
252, 0, 0, 0, 2, 0, 1, 0,
4, 1, 0, 0, 2, 0, 1, 0,
5, 0, 250, 255, 0, 0, 0, 0,
0, 0, 1, 0, 5, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
197, 0, 0, 0, 74, 0, 0, 0,
1, 1, 0, 0, 146, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
196, 0, 0, 0, 2, 0, 1, 0,
204, 0, 0, 0, 2, 0, 1, 0,
5, 0, 250, 255, 0, 0, 0, 0,
4, 1, 0, 0, 2, 0, 1, 0,
36, 1, 0, 0, 2, 0, 1, 0,
6, 0, 249, 255, 0, 0, 0, 0,
0, 0, 1, 0, 6, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
201, 0, 0, 0, 146, 0, 0, 0,
33, 1, 0, 0, 114, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
204, 0, 0, 0, 2, 0, 1, 0,
236, 0, 0, 0, 2, 0, 1, 0,
6, 0, 249, 255, 0, 0, 0, 0,
32, 1, 0, 0, 2, 0, 1, 0,
64, 1, 0, 0, 2, 0, 1, 0,
7, 0, 0, 0, 1, 0, 0, 0,
0, 0, 1, 0, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
233, 0, 0, 0, 114, 0, 0, 0,
61, 1, 0, 0, 82, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
60, 1, 0, 0, 2, 0, 1, 0,
68, 1, 0, 0, 2, 0, 1, 0,
8, 0, 0, 0, 4, 0, 0, 0,
0, 0, 1, 0, 8, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
65, 1, 0, 0, 66, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
232, 0, 0, 0, 2, 0, 1, 0,
8, 1, 0, 0, 2, 0, 1, 0,
60, 1, 0, 0, 2, 0, 1, 0,
68, 1, 0, 0, 2, 0, 1, 0,
105, 100, 101, 110, 116, 105, 102, 105,
101, 114, 0, 0, 0, 0, 0, 0,
12, 0, 0, 0, 0, 0, 0, 0,
......@@ -205,17 +154,32 @@ static const ::capnp::_::AlignedData<135> b_fb98db56d94d8f33 = {
25, 84, 222, 87, 205, 85, 204, 145,
0, 0, 0, 0, 0, 0, 0, 0,
14, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
115, 116, 97, 114, 116, 66, 121, 116,
101, 0, 0, 0, 0, 0, 0, 0,
8, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
8, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
101, 110, 100, 66, 121, 116, 101, 0,
8, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
8, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, }
};
static const ::capnp::_::RawSchema* const d_fb98db56d94d8f33[] = {
static const ::capnp::_::RawSchema* const d_91cc55cd57de5419[] = {
&s_91cc55cd57de5419,
};
static const uint16_t m_fb98db56d94d8f33[] = {6, 3, 0, 2, 4, 5, 1};
static const uint16_t i_fb98db56d94d8f33[] = {0, 1, 2, 3, 4, 5, 6};
const ::capnp::_::RawSchema s_fb98db56d94d8f33 = {
0xfb98db56d94d8f33, b_fb98db56d94d8f33.words, 135, d_fb98db56d94d8f33, m_fb98db56d94d8f33,
1, 7, i_fb98db56d94d8f33, nullptr, nullptr
static const uint16_t m_91cc55cd57de5419[] = {6, 8, 3, 0, 2, 4, 5, 7, 1};
static const uint16_t i_91cc55cd57de5419[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
const ::capnp::_::RawSchema s_91cc55cd57de5419 = {
0x91cc55cd57de5419, b_91cc55cd57de5419.words, 165, d_91cc55cd57de5419, m_91cc55cd57de5419,
1, 9, i_91cc55cd57de5419, nullptr, nullptr
};
static const ::capnp::_::AlignedData<87> b_c6725e678d60fa37 = {
{ 0, 0, 0, 0, 5, 0, 5, 0,
......@@ -475,8 +439,6 @@ const ::capnp::_::RawSchema s_a11f97b9d6c73dd4 = {
namespace _ { // private
CAPNP_DEFINE_STRUCT(
::capnp::compiler::Token);
CAPNP_DEFINE_STRUCT(
::capnp::compiler::Token::Body);
CAPNP_DEFINE_STRUCT(
::capnp::compiler::Statement);
CAPNP_DEFINE_STRUCT(
......
......@@ -12,14 +12,6 @@ namespace compiler {
struct Token {
Token() = delete;
class Reader;
class Builder;
struct Body;
};
struct Token::Body {
Body() = delete;
class Reader;
class Builder;
enum Which: uint16_t {
......@@ -75,7 +67,6 @@ namespace capnp {
namespace schemas {
extern const ::capnp::_::RawSchema s_91cc55cd57de5419;
extern const ::capnp::_::RawSchema s_fb98db56d94d8f33;
extern const ::capnp::_::RawSchema s_c6725e678d60fa37;
extern const ::capnp::_::RawSchema s_dd02827efc95ca64;
extern const ::capnp::_::RawSchema s_9e69a92512b19d18;
......@@ -87,9 +78,6 @@ namespace _ { // private
CAPNP_DECLARE_STRUCT(
::capnp::compiler::Token, 91cc55cd57de5419,
3, 1, INLINE_COMPOSITE);
CAPNP_DECLARE_STRUCT(
::capnp::compiler::Token::Body, fb98db56d94d8f33,
3, 1, INLINE_COMPOSITE);
CAPNP_DECLARE_STRUCT(
::capnp::compiler::Statement, c6725e678d60fa37,
2, 3, INLINE_COMPOSITE);
......@@ -122,76 +110,6 @@ public:
return _reader.totalSize() / ::capnp::WORDS;
}
inline Body::Reader getBody() const;
inline bool hasStartByte() const;
inline ::uint32_t getStartByte() const;
inline bool hasEndByte() const;
inline ::uint32_t getEndByte() const;
private:
::capnp::_::StructReader _reader;
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
template <typename T, ::capnp::Kind k>
friend struct ::capnp::_::PointerHelpers;
template <typename T, ::capnp::Kind k>
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Token::Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(Token::Reader reader) {
return ::capnp::_::structString<Token>(reader._reader);
}
class Token::Builder {
public:
typedef Token Builds;
Builder() = default;
inline explicit Builder(::capnp::_::StructBuilder base): _builder(base) {}
inline operator Reader() const { return Reader(_builder.asReader()); }
inline Reader asReader() const { return *this; }
inline size_t totalSizeInWords() { return asReader().totalSizeInWords(); }
inline Body::Builder getBody();
inline Body::Builder initBody();
inline bool hasStartByte();
inline ::uint32_t getStartByte();
inline void setStartByte( ::uint32_t value);
inline bool hasEndByte();
inline ::uint32_t getEndByte();
inline void setEndByte( ::uint32_t value);
private:
::capnp::_::StructBuilder _builder;
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Token::Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(Token::Builder builder) {
return ::capnp::_::structString<Token>(builder._builder.asReader());
}
class Token::Body::Reader {
public:
typedef Body Reads;
Reader() = default;
inline explicit Reader(::capnp::_::StructReader base): _reader(base) {}
inline size_t totalSizeInWords() const {
return _reader.totalSize() / ::capnp::WORDS;
}
inline Which which() const;
inline bool hasIdentifier() const;
inline ::capnp::Text::Reader getIdentifier() const;
......@@ -214,6 +132,12 @@ public:
inline bool hasBracketedList() const;
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Reader getBracketedList() const;
inline bool hasStartByte() const;
inline ::uint32_t getStartByte() const;
inline bool hasEndByte() const;
inline ::uint32_t getEndByte() const;
private:
::capnp::_::StructReader _reader;
template <typename T, ::capnp::Kind k>
......@@ -224,16 +148,16 @@ private:
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Token::Body::Reader reader);
friend ::kj::StringTree KJ_STRINGIFY(Token::Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(Token::Body::Reader reader) {
return ::capnp::_::structString<Token::Body>(reader._reader);
inline ::kj::StringTree KJ_STRINGIFY(Token::Reader reader) {
return ::capnp::_::structString<Token>(reader._reader);
}
class Token::Body::Builder {
class Token::Builder {
public:
typedef Body Builds;
typedef Token Builds;
Builder() = default;
inline explicit Builder(::capnp::_::StructBuilder base): _builder(base) {}
......@@ -288,16 +212,24 @@ public:
inline void adoptBracketedList(::capnp::Orphan< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>&& value);
inline ::capnp::Orphan< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>> disownBracketedList();
inline bool hasStartByte();
inline ::uint32_t getStartByte();
inline void setStartByte( ::uint32_t value);
inline bool hasEndByte();
inline ::uint32_t getEndByte();
inline void setEndByte( ::uint32_t value);
private:
::capnp::_::StructBuilder _builder;
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Token::Body::Builder builder);
friend ::kj::StringTree KJ_STRINGIFY(Token::Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(Token::Body::Builder builder) {
return ::capnp::_::structString<Token::Body>(builder._builder.asReader());
inline ::kj::StringTree KJ_STRINGIFY(Token::Builder builder) {
return ::capnp::_::structString<Token>(builder._builder.asReader());
}
class Statement::Reader {
......@@ -584,378 +516,369 @@ inline ::kj::StringTree KJ_STRINGIFY(LexedStatements::Builder builder) {
// =======================================================================================
inline Token::Body::Reader Token::Reader::getBody() const {
return Token::Body::Reader(_reader);
}
inline Token::Body::Builder Token::Builder::getBody() {
return Token::Body::Builder(_builder);
}
inline Token::Body::Builder Token::Builder::initBody() {
return Token::Body::Builder(_builder);
}
inline bool Token::Reader::hasStartByte() const {
return _reader.hasDataField< ::uint32_t>(1 * ::capnp::ELEMENTS);
}
inline bool Token::Builder::hasStartByte() {
return _builder.hasDataField< ::uint32_t>(1 * ::capnp::ELEMENTS);
}
inline ::uint32_t Token::Reader::getStartByte() const {
return _reader.getDataField< ::uint32_t>(
1 * ::capnp::ELEMENTS);
}
inline ::uint32_t Token::Builder::getStartByte() {
return _builder.getDataField< ::uint32_t>(
1 * ::capnp::ELEMENTS);
}
inline void Token::Builder::setStartByte( ::uint32_t value) {
_builder.setDataField< ::uint32_t>(
1 * ::capnp::ELEMENTS, value);
}
inline bool Token::Reader::hasEndByte() const {
return _reader.hasDataField< ::uint32_t>(4 * ::capnp::ELEMENTS);
}
inline bool Token::Builder::hasEndByte() {
return _builder.hasDataField< ::uint32_t>(4 * ::capnp::ELEMENTS);
}
inline ::uint32_t Token::Reader::getEndByte() const {
return _reader.getDataField< ::uint32_t>(
4 * ::capnp::ELEMENTS);
}
inline ::uint32_t Token::Builder::getEndByte() {
return _builder.getDataField< ::uint32_t>(
4 * ::capnp::ELEMENTS);
}
inline void Token::Builder::setEndByte( ::uint32_t value) {
_builder.setDataField< ::uint32_t>(
4 * ::capnp::ELEMENTS, value);
}
inline Token::Body::Which Token::Body::Reader::which() const {
inline Token::Which Token::Reader::which() const {
return _reader.getDataField<Which>(0 * ::capnp::ELEMENTS);
}
inline Token::Body::Which Token::Body::Builder::which() {
inline Token::Which Token::Builder::which() {
return _builder.getDataField<Which>(0 * ::capnp::ELEMENTS);
}
inline bool Token::Body::Reader::hasIdentifier() const {
KJ_IREQUIRE(which() == Token::Body::IDENTIFIER,
inline bool Token::Reader::hasIdentifier() const {
KJ_IREQUIRE(which() == Token::IDENTIFIER,
"Must check which() before get()ing a union member.");
return !_reader.isPointerFieldNull(0 * ::capnp::POINTERS);
}
inline bool Token::Body::Builder::hasIdentifier() {
KJ_IREQUIRE(which() == Token::Body::IDENTIFIER,
inline bool Token::Builder::hasIdentifier() {
KJ_IREQUIRE(which() == Token::IDENTIFIER,
"Must check which() before get()ing a union member.");
return !_builder.isPointerFieldNull(0 * ::capnp::POINTERS);
}
inline ::capnp::Text::Reader Token::Body::Reader::getIdentifier() const {
KJ_IREQUIRE(which() == Token::Body::IDENTIFIER,
inline ::capnp::Text::Reader Token::Reader::getIdentifier() const {
KJ_IREQUIRE(which() == Token::IDENTIFIER,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::Text>::get(
_reader, 0 * ::capnp::POINTERS);
}
inline ::capnp::Text::Builder Token::Body::Builder::getIdentifier() {
KJ_IREQUIRE(which() == Token::Body::IDENTIFIER,
inline ::capnp::Text::Builder Token::Builder::getIdentifier() {
KJ_IREQUIRE(which() == Token::IDENTIFIER,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::Text>::get(
_builder, 0 * ::capnp::POINTERS);
}
inline void Token::Body::Builder::setIdentifier( ::capnp::Text::Reader value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::IDENTIFIER);
inline void Token::Builder::setIdentifier( ::capnp::Text::Reader value) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::IDENTIFIER);
::capnp::_::PointerHelpers< ::capnp::Text>::set(
_builder, 0 * ::capnp::POINTERS, value);
}
inline ::capnp::Text::Builder Token::Body::Builder::initIdentifier(unsigned int size) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::IDENTIFIER);
inline ::capnp::Text::Builder Token::Builder::initIdentifier(unsigned int size) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::IDENTIFIER);
return ::capnp::_::PointerHelpers< ::capnp::Text>::init(
_builder, 0 * ::capnp::POINTERS, size);
}
inline void Token::Body::Builder::adoptIdentifier(
inline void Token::Builder::adoptIdentifier(
::capnp::Orphan< ::capnp::Text>&& value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::IDENTIFIER);
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::IDENTIFIER);
::capnp::_::PointerHelpers< ::capnp::Text>::adopt(
_builder, 0 * ::capnp::POINTERS, kj::mv(value));
}
inline ::capnp::Orphan< ::capnp::Text> Token::Body::Builder::disownIdentifier() {
KJ_IREQUIRE(which() == Token::Body::IDENTIFIER,
inline ::capnp::Orphan< ::capnp::Text> Token::Builder::disownIdentifier() {
KJ_IREQUIRE(which() == Token::IDENTIFIER,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::Text>::disown(
_builder, 0 * ::capnp::POINTERS);
}
inline bool Token::Body::Reader::hasStringLiteral() const {
KJ_IREQUIRE(which() == Token::Body::STRING_LITERAL,
inline bool Token::Reader::hasStringLiteral() const {
KJ_IREQUIRE(which() == Token::STRING_LITERAL,
"Must check which() before get()ing a union member.");
return !_reader.isPointerFieldNull(0 * ::capnp::POINTERS);
}
inline bool Token::Body::Builder::hasStringLiteral() {
KJ_IREQUIRE(which() == Token::Body::STRING_LITERAL,
inline bool Token::Builder::hasStringLiteral() {
KJ_IREQUIRE(which() == Token::STRING_LITERAL,
"Must check which() before get()ing a union member.");
return !_builder.isPointerFieldNull(0 * ::capnp::POINTERS);
}
inline ::capnp::Text::Reader Token::Body::Reader::getStringLiteral() const {
KJ_IREQUIRE(which() == Token::Body::STRING_LITERAL,
inline ::capnp::Text::Reader Token::Reader::getStringLiteral() const {
KJ_IREQUIRE(which() == Token::STRING_LITERAL,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::Text>::get(
_reader, 0 * ::capnp::POINTERS);
}
inline ::capnp::Text::Builder Token::Body::Builder::getStringLiteral() {
KJ_IREQUIRE(which() == Token::Body::STRING_LITERAL,
inline ::capnp::Text::Builder Token::Builder::getStringLiteral() {
KJ_IREQUIRE(which() == Token::STRING_LITERAL,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::Text>::get(
_builder, 0 * ::capnp::POINTERS);
}
inline void Token::Body::Builder::setStringLiteral( ::capnp::Text::Reader value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::STRING_LITERAL);
inline void Token::Builder::setStringLiteral( ::capnp::Text::Reader value) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::STRING_LITERAL);
::capnp::_::PointerHelpers< ::capnp::Text>::set(
_builder, 0 * ::capnp::POINTERS, value);
}
inline ::capnp::Text::Builder Token::Body::Builder::initStringLiteral(unsigned int size) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::STRING_LITERAL);
inline ::capnp::Text::Builder Token::Builder::initStringLiteral(unsigned int size) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::STRING_LITERAL);
return ::capnp::_::PointerHelpers< ::capnp::Text>::init(
_builder, 0 * ::capnp::POINTERS, size);
}
inline void Token::Body::Builder::adoptStringLiteral(
inline void Token::Builder::adoptStringLiteral(
::capnp::Orphan< ::capnp::Text>&& value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::STRING_LITERAL);
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::STRING_LITERAL);
::capnp::_::PointerHelpers< ::capnp::Text>::adopt(
_builder, 0 * ::capnp::POINTERS, kj::mv(value));
}
inline ::capnp::Orphan< ::capnp::Text> Token::Body::Builder::disownStringLiteral() {
KJ_IREQUIRE(which() == Token::Body::STRING_LITERAL,
inline ::capnp::Orphan< ::capnp::Text> Token::Builder::disownStringLiteral() {
KJ_IREQUIRE(which() == Token::STRING_LITERAL,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::Text>::disown(
_builder, 0 * ::capnp::POINTERS);
}
inline bool Token::Body::Reader::hasIntegerLiteral() const {
KJ_IREQUIRE(which() == Token::Body::INTEGER_LITERAL,
inline bool Token::Reader::hasIntegerLiteral() const {
KJ_IREQUIRE(which() == Token::INTEGER_LITERAL,
"Must check which() before get()ing a union member.");
return _reader.hasDataField< ::uint64_t>(1 * ::capnp::ELEMENTS);
}
inline bool Token::Body::Builder::hasIntegerLiteral() {
KJ_IREQUIRE(which() == Token::Body::INTEGER_LITERAL,
inline bool Token::Builder::hasIntegerLiteral() {
KJ_IREQUIRE(which() == Token::INTEGER_LITERAL,
"Must check which() before get()ing a union member.");
return _builder.hasDataField< ::uint64_t>(1 * ::capnp::ELEMENTS);
}
inline ::uint64_t Token::Body::Reader::getIntegerLiteral() const {
KJ_IREQUIRE(which() == Token::Body::INTEGER_LITERAL,
inline ::uint64_t Token::Reader::getIntegerLiteral() const {
KJ_IREQUIRE(which() == Token::INTEGER_LITERAL,
"Must check which() before get()ing a union member.");
return _reader.getDataField< ::uint64_t>(
1 * ::capnp::ELEMENTS);
}
inline ::uint64_t Token::Body::Builder::getIntegerLiteral() {
KJ_IREQUIRE(which() == Token::Body::INTEGER_LITERAL,
inline ::uint64_t Token::Builder::getIntegerLiteral() {
KJ_IREQUIRE(which() == Token::INTEGER_LITERAL,
"Must check which() before get()ing a union member.");
return _builder.getDataField< ::uint64_t>(
1 * ::capnp::ELEMENTS);
}
inline void Token::Body::Builder::setIntegerLiteral( ::uint64_t value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::INTEGER_LITERAL);
inline void Token::Builder::setIntegerLiteral( ::uint64_t value) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::INTEGER_LITERAL);
_builder.setDataField< ::uint64_t>(
1 * ::capnp::ELEMENTS, value);
}
inline bool Token::Body::Reader::hasFloatLiteral() const {
KJ_IREQUIRE(which() == Token::Body::FLOAT_LITERAL,
inline bool Token::Reader::hasFloatLiteral() const {
KJ_IREQUIRE(which() == Token::FLOAT_LITERAL,
"Must check which() before get()ing a union member.");
return _reader.hasDataField<double>(1 * ::capnp::ELEMENTS);
}
inline bool Token::Body::Builder::hasFloatLiteral() {
KJ_IREQUIRE(which() == Token::Body::FLOAT_LITERAL,
inline bool Token::Builder::hasFloatLiteral() {
KJ_IREQUIRE(which() == Token::FLOAT_LITERAL,
"Must check which() before get()ing a union member.");
return _builder.hasDataField<double>(1 * ::capnp::ELEMENTS);
}
inline double Token::Body::Reader::getFloatLiteral() const {
KJ_IREQUIRE(which() == Token::Body::FLOAT_LITERAL,
inline double Token::Reader::getFloatLiteral() const {
KJ_IREQUIRE(which() == Token::FLOAT_LITERAL,
"Must check which() before get()ing a union member.");
return _reader.getDataField<double>(
1 * ::capnp::ELEMENTS);
}
inline double Token::Body::Builder::getFloatLiteral() {
KJ_IREQUIRE(which() == Token::Body::FLOAT_LITERAL,
inline double Token::Builder::getFloatLiteral() {
KJ_IREQUIRE(which() == Token::FLOAT_LITERAL,
"Must check which() before get()ing a union member.");
return _builder.getDataField<double>(
1 * ::capnp::ELEMENTS);
}
inline void Token::Body::Builder::setFloatLiteral(double value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::FLOAT_LITERAL);
inline void Token::Builder::setFloatLiteral(double value) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::FLOAT_LITERAL);
_builder.setDataField<double>(
1 * ::capnp::ELEMENTS, value);
}
inline bool Token::Body::Reader::hasOperator() const {
KJ_IREQUIRE(which() == Token::Body::OPERATOR,
inline bool Token::Reader::hasOperator() const {
KJ_IREQUIRE(which() == Token::OPERATOR,
"Must check which() before get()ing a union member.");
return !_reader.isPointerFieldNull(0 * ::capnp::POINTERS);
}
inline bool Token::Body::Builder::hasOperator() {
KJ_IREQUIRE(which() == Token::Body::OPERATOR,
inline bool Token::Builder::hasOperator() {
KJ_IREQUIRE(which() == Token::OPERATOR,
"Must check which() before get()ing a union member.");
return !_builder.isPointerFieldNull(0 * ::capnp::POINTERS);
}
inline ::capnp::Text::Reader Token::Body::Reader::getOperator() const {
KJ_IREQUIRE(which() == Token::Body::OPERATOR,
inline ::capnp::Text::Reader Token::Reader::getOperator() const {
KJ_IREQUIRE(which() == Token::OPERATOR,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::Text>::get(
_reader, 0 * ::capnp::POINTERS);
}
inline ::capnp::Text::Builder Token::Body::Builder::getOperator() {
KJ_IREQUIRE(which() == Token::Body::OPERATOR,
inline ::capnp::Text::Builder Token::Builder::getOperator() {
KJ_IREQUIRE(which() == Token::OPERATOR,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::Text>::get(
_builder, 0 * ::capnp::POINTERS);
}
inline void Token::Body::Builder::setOperator( ::capnp::Text::Reader value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::OPERATOR);
inline void Token::Builder::setOperator( ::capnp::Text::Reader value) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::OPERATOR);
::capnp::_::PointerHelpers< ::capnp::Text>::set(
_builder, 0 * ::capnp::POINTERS, value);
}
inline ::capnp::Text::Builder Token::Body::Builder::initOperator(unsigned int size) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::OPERATOR);
inline ::capnp::Text::Builder Token::Builder::initOperator(unsigned int size) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::OPERATOR);
return ::capnp::_::PointerHelpers< ::capnp::Text>::init(
_builder, 0 * ::capnp::POINTERS, size);
}
inline void Token::Body::Builder::adoptOperator(
inline void Token::Builder::adoptOperator(
::capnp::Orphan< ::capnp::Text>&& value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::OPERATOR);
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::OPERATOR);
::capnp::_::PointerHelpers< ::capnp::Text>::adopt(
_builder, 0 * ::capnp::POINTERS, kj::mv(value));
}
inline ::capnp::Orphan< ::capnp::Text> Token::Body::Builder::disownOperator() {
KJ_IREQUIRE(which() == Token::Body::OPERATOR,
inline ::capnp::Orphan< ::capnp::Text> Token::Builder::disownOperator() {
KJ_IREQUIRE(which() == Token::OPERATOR,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::Text>::disown(
_builder, 0 * ::capnp::POINTERS);
}
inline bool Token::Body::Reader::hasParenthesizedList() const {
KJ_IREQUIRE(which() == Token::Body::PARENTHESIZED_LIST,
inline bool Token::Reader::hasParenthesizedList() const {
KJ_IREQUIRE(which() == Token::PARENTHESIZED_LIST,
"Must check which() before get()ing a union member.");
return !_reader.isPointerFieldNull(0 * ::capnp::POINTERS);
}
inline bool Token::Body::Builder::hasParenthesizedList() {
KJ_IREQUIRE(which() == Token::Body::PARENTHESIZED_LIST,
inline bool Token::Builder::hasParenthesizedList() {
KJ_IREQUIRE(which() == Token::PARENTHESIZED_LIST,
"Must check which() before get()ing a union member.");
return !_builder.isPointerFieldNull(0 * ::capnp::POINTERS);
}
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Reader Token::Body::Reader::getParenthesizedList() const {
KJ_IREQUIRE(which() == Token::Body::PARENTHESIZED_LIST,
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Reader Token::Reader::getParenthesizedList() const {
KJ_IREQUIRE(which() == Token::PARENTHESIZED_LIST,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::get(
_reader, 0 * ::capnp::POINTERS);
}
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Builder Token::Body::Builder::getParenthesizedList() {
KJ_IREQUIRE(which() == Token::Body::PARENTHESIZED_LIST,
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Builder Token::Builder::getParenthesizedList() {
KJ_IREQUIRE(which() == Token::PARENTHESIZED_LIST,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::get(
_builder, 0 * ::capnp::POINTERS);
}
inline void Token::Body::Builder::setParenthesizedList( ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Reader value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::PARENTHESIZED_LIST);
inline void Token::Builder::setParenthesizedList( ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Reader value) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::PARENTHESIZED_LIST);
::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::set(
_builder, 0 * ::capnp::POINTERS, value);
}
inline void Token::Body::Builder::setParenthesizedList(std::initializer_list< ::capnp::List< ::capnp::compiler::Token>::Reader> value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::PARENTHESIZED_LIST);
inline void Token::Builder::setParenthesizedList(std::initializer_list< ::capnp::List< ::capnp::compiler::Token>::Reader> value) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::PARENTHESIZED_LIST);
::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::set(
_builder, 0 * ::capnp::POINTERS, value);
}
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Builder Token::Body::Builder::initParenthesizedList(unsigned int size) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::PARENTHESIZED_LIST);
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Builder Token::Builder::initParenthesizedList(unsigned int size) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::PARENTHESIZED_LIST);
return ::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::init(
_builder, 0 * ::capnp::POINTERS, size);
}
inline void Token::Body::Builder::adoptParenthesizedList(
inline void Token::Builder::adoptParenthesizedList(
::capnp::Orphan< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>&& value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::PARENTHESIZED_LIST);
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::PARENTHESIZED_LIST);
::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::adopt(
_builder, 0 * ::capnp::POINTERS, kj::mv(value));
}
inline ::capnp::Orphan< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>> Token::Body::Builder::disownParenthesizedList() {
KJ_IREQUIRE(which() == Token::Body::PARENTHESIZED_LIST,
inline ::capnp::Orphan< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>> Token::Builder::disownParenthesizedList() {
KJ_IREQUIRE(which() == Token::PARENTHESIZED_LIST,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::disown(
_builder, 0 * ::capnp::POINTERS);
}
inline bool Token::Body::Reader::hasBracketedList() const {
KJ_IREQUIRE(which() == Token::Body::BRACKETED_LIST,
inline bool Token::Reader::hasBracketedList() const {
KJ_IREQUIRE(which() == Token::BRACKETED_LIST,
"Must check which() before get()ing a union member.");
return !_reader.isPointerFieldNull(0 * ::capnp::POINTERS);
}
inline bool Token::Body::Builder::hasBracketedList() {
KJ_IREQUIRE(which() == Token::Body::BRACKETED_LIST,
inline bool Token::Builder::hasBracketedList() {
KJ_IREQUIRE(which() == Token::BRACKETED_LIST,
"Must check which() before get()ing a union member.");
return !_builder.isPointerFieldNull(0 * ::capnp::POINTERS);
}
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Reader Token::Body::Reader::getBracketedList() const {
KJ_IREQUIRE(which() == Token::Body::BRACKETED_LIST,
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Reader Token::Reader::getBracketedList() const {
KJ_IREQUIRE(which() == Token::BRACKETED_LIST,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::get(
_reader, 0 * ::capnp::POINTERS);
}
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Builder Token::Body::Builder::getBracketedList() {
KJ_IREQUIRE(which() == Token::Body::BRACKETED_LIST,
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Builder Token::Builder::getBracketedList() {
KJ_IREQUIRE(which() == Token::BRACKETED_LIST,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::get(
_builder, 0 * ::capnp::POINTERS);
}
inline void Token::Body::Builder::setBracketedList( ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Reader value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::BRACKETED_LIST);
inline void Token::Builder::setBracketedList( ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Reader value) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::BRACKETED_LIST);
::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::set(
_builder, 0 * ::capnp::POINTERS, value);
}
inline void Token::Body::Builder::setBracketedList(std::initializer_list< ::capnp::List< ::capnp::compiler::Token>::Reader> value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::BRACKETED_LIST);
inline void Token::Builder::setBracketedList(std::initializer_list< ::capnp::List< ::capnp::compiler::Token>::Reader> value) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::BRACKETED_LIST);
::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::set(
_builder, 0 * ::capnp::POINTERS, value);
}
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Builder Token::Body::Builder::initBracketedList(unsigned int size) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::BRACKETED_LIST);
inline ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>::Builder Token::Builder::initBracketedList(unsigned int size) {
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::BRACKETED_LIST);
return ::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::init(
_builder, 0 * ::capnp::POINTERS, size);
}
inline void Token::Body::Builder::adoptBracketedList(
inline void Token::Builder::adoptBracketedList(
::capnp::Orphan< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>&& value) {
_builder.setDataField<Token::Body::Which>(
0 * ::capnp::ELEMENTS, Token::Body::BRACKETED_LIST);
_builder.setDataField<Token::Which>(
0 * ::capnp::ELEMENTS, Token::BRACKETED_LIST);
::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::adopt(
_builder, 0 * ::capnp::POINTERS, kj::mv(value));
}
inline ::capnp::Orphan< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>> Token::Body::Builder::disownBracketedList() {
KJ_IREQUIRE(which() == Token::Body::BRACKETED_LIST,
inline ::capnp::Orphan< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>> Token::Builder::disownBracketedList() {
KJ_IREQUIRE(which() == Token::BRACKETED_LIST,
"Must check which() before get()ing a union member.");
return ::capnp::_::PointerHelpers< ::capnp::List< ::capnp::List< ::capnp::compiler::Token>>>::disown(
_builder, 0 * ::capnp::POINTERS);
}
inline bool Token::Reader::hasStartByte() const {
return _reader.hasDataField< ::uint32_t>(1 * ::capnp::ELEMENTS);
}
inline bool Token::Builder::hasStartByte() {
return _builder.hasDataField< ::uint32_t>(1 * ::capnp::ELEMENTS);
}
inline ::uint32_t Token::Reader::getStartByte() const {
return _reader.getDataField< ::uint32_t>(
1 * ::capnp::ELEMENTS);
}
inline ::uint32_t Token::Builder::getStartByte() {
return _builder.getDataField< ::uint32_t>(
1 * ::capnp::ELEMENTS);
}
inline void Token::Builder::setStartByte( ::uint32_t value) {
_builder.setDataField< ::uint32_t>(
1 * ::capnp::ELEMENTS, value);
}
inline bool Token::Reader::hasEndByte() const {
return _reader.hasDataField< ::uint32_t>(4 * ::capnp::ELEMENTS);
}
inline bool Token::Builder::hasEndByte() {
return _builder.hasDataField< ::uint32_t>(4 * ::capnp::ELEMENTS);
}
inline ::uint32_t Token::Reader::getEndByte() const {
return _reader.getDataField< ::uint32_t>(
4 * ::capnp::ELEMENTS);
}
inline ::uint32_t Token::Builder::getEndByte() {
return _builder.getDataField< ::uint32_t>(
4 * ::capnp::ELEMENTS);
}
inline void Token::Builder::setEndByte( ::uint32_t value) {
_builder.setDataField< ::uint32_t>(
4 * ::capnp::ELEMENTS, value);
}
inline bool Statement::Reader::hasTokens() const {
return !_reader.isPointerFieldNull(0 * ::capnp::POINTERS);
}
......
......@@ -186,12 +186,11 @@ struct Located {
// =======================================================================================
template <typename T, Token::Body::Which type, T (Token::Body::Reader::*get)() const>
template <typename T, Token::Which type, T (Token::Reader::*get)() const>
struct MatchTokenType {
kj::Maybe<Located<T>> operator()(Token::Reader token) const {
auto body = token.getBody();
if (body.which() == type) {
return Located<T>((body.*get)(), token.getStartByte(), token.getEndByte());
if (token.which() == type) {
return Located<T>((token.*get)(), token.getStartByte(), token.getEndByte());
} else {
return nullptr;
}
......@@ -200,7 +199,7 @@ struct MatchTokenType {
#define TOKEN_TYPE_PARSER(type, discrim, getter) \
p::transformOrReject(p::any, \
MatchTokenType<type, Token::Body::discrim, &Token::Body::Reader::getter>())
MatchTokenType<type, Token::discrim, &Token::Reader::getter>())
constexpr auto identifier = TOKEN_TYPE_PARSER(Text::Reader, IDENTIFIER, getIdentifier);
constexpr auto stringLiteral = TOKEN_TYPE_PARSER(Text::Reader, STRING_LITERAL, getStringLiteral);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment