@@ -12,16 +12,28 @@ namespace facebook {
1212namespace graphql {
1313namespace peg {
1414
15- using namespace tao ::pegtl ;
15+ using namespace tao ::graphqlpeg ;
1616
1717template <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)
1919{
2020 for (const auto & child : n.children )
2121 {
22- if (child->is <_Rule>()
23- && !func (*child))
22+ if (child->is <_Rule>())
2423 {
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);
2537 return ;
2638 }
2739 }
@@ -94,13 +106,13 @@ struct string_escape_sequence
94106};
95107
96108struct string_quote_character
97- : source_character
109+ : plus<seq<not_at<backslash_token>, not_at<quote_token>, not_at<ascii::eol>, source_character>>
98110{
99111};
100112
101113// https://facebook.github.io/graphql/June2018/#StringCharacter
102114struct 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>
104116{
105117};
106118
@@ -110,18 +122,18 @@ struct block_quote_token
110122};
111123
112124struct block_escape_sequence
113- : if_must <backslash_token, block_quote_token>
125+ : seq <backslash_token, block_quote_token>
114126{
115127};
116128
117129struct block_quote_character
118- : source_character
130+ : plus<seq<not_at<block_quote_token>, not_at<block_escape_sequence>, source_character>>
119131{
120132};
121133
122134// https://facebook.github.io/graphql/June2018/#BlockStringCharacter
123135struct 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>
125137{
126138};
127139
@@ -804,7 +816,7 @@ struct definition
804816
805817// https://facebook.github.io/graphql/June2018/#Document
806818struct 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>
808820{
809821};
810822
0 commit comments