@@ -12,16 +12,28 @@ namespace facebook {
12
12
namespace graphql {
13
13
namespace peg {
14
14
15
- using namespace tao ::pegtl ;
15
+ using namespace tao ::graphqlpeg ;
16
16
17
17
template <typename _Rule>
18
- void for_each_child (const ast_node& n, std::function<bool (const ast_node&)>&& func)
18
+ void for_each_child (const ast_node& n, std::function<void (const ast_node&)>&& func)
19
19
{
20
20
for (const auto & child : n.children )
21
21
{
22
- if (child->is <_Rule>()
23
- && !func (*child))
22
+ if (child->is <_Rule>())
24
23
{
24
+ func (*child);
25
+ }
26
+ }
27
+ }
28
+
29
+ template <typename _Rule>
30
+ void on_first_child (const ast_node& n, std::function<void (const ast_node&)>&& func)
31
+ {
32
+ for (const auto & child : n.children )
33
+ {
34
+ if (child->is <_Rule>())
35
+ {
36
+ func (*child);
25
37
return ;
26
38
}
27
39
}
@@ -94,13 +106,13 @@ struct string_escape_sequence
94
106
};
95
107
96
108
struct string_quote_character
97
- : source_character
109
+ : plus<seq<not_at<backslash_token>, not_at<quote_token>, not_at<ascii::eol>, source_character>>
98
110
{
99
111
};
100
112
101
113
// https://facebook.github.io/graphql/June2018/#StringCharacter
102
114
struct string_quote
103
- : if_must<quote_token, star<seq<not_at<quote_token>, not_at<ascii::eol>, sor<string_escape_sequence, string_quote_character> >>, quote_token>
115
+ : if_must<quote_token, star<sor<string_escape_sequence, string_quote_character>>, quote_token>
104
116
{
105
117
};
106
118
@@ -110,18 +122,18 @@ struct block_quote_token
110
122
};
111
123
112
124
struct block_escape_sequence
113
- : if_must <backslash_token, block_quote_token>
125
+ : seq <backslash_token, block_quote_token>
114
126
{
115
127
};
116
128
117
129
struct block_quote_character
118
- : source_character
130
+ : plus<seq<not_at<block_quote_token>, not_at<block_escape_sequence>, source_character>>
119
131
{
120
132
};
121
133
122
134
// https://facebook.github.io/graphql/June2018/#BlockStringCharacter
123
135
struct block_quote
124
- : if_must<block_quote_token, star<seq<not_at<block_quote_token>, sor<block_escape_sequence, block_quote_character> >>, block_quote_token>
136
+ : if_must<block_quote_token, star<sor<block_escape_sequence, block_quote_character>>, block_quote_token>
125
137
{
126
138
};
127
139
@@ -804,7 +816,7 @@ struct definition
804
816
805
817
// https://facebook.github.io/graphql/June2018/#Document
806
818
struct document
807
- : must<bof, opt<utf8::bom>, star<ignored>, list<definition, plus<ignored>>, star<ignored>, tao::pegtl ::eof>
819
+ : must<bof, opt<utf8::bom>, star<ignored>, list<definition, plus<ignored>>, star<ignored>, tao::graphqlpeg ::eof>
808
820
{
809
821
};
810
822
0 commit comments