forked from rmosolgo/graphql-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update error tests, improve Parser lifecycle and organization, fix mo…
…re SDL
- Loading branch information
Showing
12 changed files
with
242 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 9 additions & 27 deletions
36
graphql-c_parser/ext/graphql_c_parser_ext/graphql_c_parser_ext.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,22 @@ | ||
#include "graphql_c_parser_ext.h" | ||
|
||
VALUE GraphQL_Language_CLexer_tokenize(VALUE self, VALUE query_string) { | ||
VALUE GraphQL_CParser_Lexer_tokenize(VALUE self, VALUE query_string) { | ||
return tokenize(query_string); | ||
} | ||
|
||
VALUE call_tokenize(VALUE yield_arg, VALUE query_string, int argc, VALUE* argv, VALUE block_arg) { | ||
return tokenize(query_string); | ||
} | ||
|
||
VALUE call_yyparse(VALUE yield_arg, VALUE parser, int argc, VALUE* argv, VALUE block_arg) { | ||
yyparse(parser); | ||
return rb_ivar_get(parser, rb_intern("@result")); | ||
} | ||
|
||
VALUE GraphQL_Language_CParser_parse(VALUE self, VALUE query_string, VALUE trace) { | ||
VALUE opts = rb_hash_new(); | ||
rb_hash_aset(opts, ID2SYM(rb_intern("query_string")), query_string); | ||
VALUE argv[] = {opts}; | ||
VALUE tokens = rb_block_call_kw(trace, rb_intern("lex"), 1, argv, call_tokenize, query_string, RB_PASS_KEYWORDS); | ||
|
||
VALUE parser = rb_class_new(self); | ||
rb_ivar_set(parser, rb_intern("@query_string"), query_string); | ||
rb_ivar_set(parser, rb_intern("@tokens"), tokens); | ||
rb_ivar_set(parser, rb_intern("@next_token_index"), INT2FIX(0)); | ||
rb_ivar_set(parser, rb_intern("@result"), Qnil); | ||
return rb_block_call_kw(trace, rb_intern("parse"), 1, argv, call_yyparse, parser, RB_PASS_KEYWORDS); | ||
VALUE GraphQL_CParser_Parser_c_parse(VALUE self) { | ||
yyparse(self); | ||
return Qnil; | ||
} | ||
|
||
void Init_graphql_c_parser_ext() { | ||
VALUE GraphQL = rb_define_module("GraphQL"); | ||
VALUE Language = rb_define_module_under(GraphQL, "Language"); | ||
VALUE CLexer = rb_define_module_under(Language, "CLexer"); | ||
rb_define_singleton_method(CLexer, "tokenize", GraphQL_Language_CLexer_tokenize, 1); | ||
VALUE CParser = rb_define_module_under(GraphQL, "CParser"); | ||
VALUE Lexer = rb_define_module_under(CParser, "Lexer"); | ||
rb_define_singleton_method(Lexer, "tokenize", GraphQL_CParser_Lexer_tokenize, 1); | ||
setup_static_token_variables(); | ||
|
||
VALUE CParser = rb_define_class_under(Language, "CParser", rb_cObject); | ||
rb_define_singleton_method(CParser, "parse", GraphQL_Language_CParser_parse, 2); | ||
VALUE Parser = rb_define_class_under(CParser, "Parser", rb_cObject); | ||
rb_define_method(Parser, "c_parse", GraphQL_CParser_Parser_c_parse, 0); | ||
initialize_node_class_variables(); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters