# # DO NOT MODIFY!!!! # This file is automatically generated by Racc 1.4.14 # from Racc grammer file "". # require 'racc/parser.rb' module GraphQL module Language class Parser < Racc::Parser module_eval(<<'...end parser.y/module_eval...', 'parser.y', 214) def initialize(query_string) @query_string = query_string end def parse_document @document ||= begin @tokens ||= GraphQL::Language::Lexer.tokenize(@query_string) if @tokens.none? make_node(:Document, definitions: []) else do_parse end end end def self.parse(query_string) self.new(query_string).parse_document end private def next_token lexer_token = @tokens.shift if lexer_token.nil? nil else [lexer_token.name, lexer_token] end end def on_error(parser_token_id, lexer_token, vstack) if lexer_token == "$" raise GraphQL::ParseError.new("Unexpected end of document", nil, nil, @query_string) else parser_token_name = token_to_str(parser_token_id) if parser_token_name.nil? raise GraphQL::ParseError.new("Parse Error on unknown token: {token_id: #{parser_token_id}, lexer_token: #{lexer_token}} from #{@query_string}", nil, nil, @query_string) else line, col = lexer_token.line_and_column if lexer_token.name == :BAD_UNICODE_ESCAPE raise GraphQL::ParseError.new("Parse error on bad Unicode escape sequence: #{lexer_token.to_s.inspect} (#{parser_token_name}) at [#{line}, #{col}]", line, col, @query_string) else raise GraphQL::ParseError.new("Parse error on #{lexer_token.to_s.inspect} (#{parser_token_name}) at [#{line}, #{col}]", line, col, @query_string) end end end end def make_node(node_name, assigns) assigns.each do |key, value| if key != :position_source && value.is_a?(GraphQL::Language::Token) assigns[key] = value.to_s end end GraphQL::Language::Nodes.const_get(node_name).new(assigns) end ...end parser.y/module_eval... ##### State transition tables begin ### racc_action_table = [ 86, 105, 37, 87, 106, 36, 88, 40, 105, 89, 114, 80, 81, 77, 78, 79, 86, 62, 48, 87, 70, 37, 88, 40, 44, 89, 74, 80, 81, 77, 78, 79, 86, 40, 37, 87, 9, 9, 88, 32, 9, 89, 9, 80, 81, 77, 78, 79, 86, 30, 40, 87, 108, 9, 88, 9, 40, 89, 40, 80, 81, 77, 78, 79, 86, 112, 16, 87, 97, 48, 88, 51, 40, 89, nil, 80, 81, 77, 78, 79, 11, 12, 20, 14, 15, 68, 9, nil, 11, 12, 13, 14, 15, nil, 11, 12, 20, 14, 15, 21, 11, 12, 20, 14, 15, 12, 20, 14, 15, 28, 33, 11, 12, 20, 14, 15, 94, nil, nil, nil, 28, 11, 12, 20, 14, 15, 94, nil, nil, nil, nil, 11, 12, 20, 14, 15, 42, 12, 20, 14, 15, nil, nil, 9, 40, 11, 12, 13, 14, 15, 100, 11, 12, 20, 14, 15, 110, 11, 12, 20, 14, 15, 11, 12, 20, 14, 15, 11, 12, 20, 14, 15, 11, 12, 20, 14, 15, 11, 12, 20, 14, 15, 11, 12, 20, 14, 15, 11, 12, 20, 14, 15, 11, 12, 20, 14, 15 ] racc_action_check = [ 112, 92, 27, 112, 92, 27, 112, 60, 107, 112, 107, 112, 112, 112, 112, 112, 106, 46, 46, 106, 54, 56, 106, 58, 29, 106, 64, 106, 106, 106, 106, 106, 70, 67, 50, 70, 72, 73, 70, 18, 75, 70, 49, 70, 70, 70, 70, 70, 98, 16, 31, 98, 98, 45, 98, 43, 41, 98, 38, 98, 98, 98, 98, 98, 87, 103, 1, 87, 87, 32, 87, 37, 35, 87, nil, 87, 87, 87, 87, 87, 37, 37, 37, 37, 37, 52, 3, nil, 3, 3, 3, 3, 3, nil, 52, 52, 52, 52, 52, 9, 9, 9, 9, 9, 9, 44, 44, 44, 44, 9, 22, 22, 22, 22, 22, 22, 74, nil, nil, nil, 22, 74, 74, 74, 74, 74, 94, nil, nil, nil, nil, 94, 94, 94, 94, 94, 28, 28, 28, 28, 28, nil, nil, 0, 28, 0, 0, 0, 0, 0, 88, 88, 88, 88, 88, 88, 101, 101, 101, 101, 101, 101, 40, 40, 40, 40, 40, 36, 36, 36, 36, 36, 86, 86, 86, 86, 86, 7, 7, 7, 7, 7, 42, 42, 42, 42, 42, 48, 48, 48, 48, 48, 13, 13, 13, 13, 13 ] racc_action_pointer = [ 133, 66, nil, 76, nil, nil, nil, 165, nil, 88, nil, nil, nil, 180, nil, nil, 49, nil, 37, nil, nil, nil, 99, nil, nil, nil, nil, 0, 124, 12, nil, 30, 65, nil, nil, 52, 155, 68, 38, nil, 150, 36, 170, 45, 92, 43, 14, nil, 175, 32, 32, nil, 82, nil, 15, nil, 19, nil, 3, nil, -13, nil, nil, nil, 21, nil, nil, 13, nil, nil, 28, nil, 26, 27, 109, 30, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 160, 60, 139, nil, nil, nil, -5, nil, 119, nil, nil, nil, 44, nil, nil, 145, nil, 60, nil, nil, 12, 2, nil, nil, nil, nil, -4, nil, nil, nil ] racc_action_default = [ -73, -73, -1, -2, -3, -5, -6, -9, -8, -73, -32, -33, -34, -35, -36, -37, -73, -4, -11, -10, -35, -21, -73, -25, -27, -28, -29, -38, -64, -73, 116, -64, -73, -22, -26, -64, -73, -73, -65, -66, -73, -64, -73, -73, -73, -73, -73, -13, -73, -23, -38, -39, -73, -41, -73, -67, -38, -69, -64, -71, -64, -7, -12, -14, -73, -24, -30, -64, -40, -42, -73, -68, -73, -73, -73, -23, -43, -44, -45, -46, -47, -48, -49, -50, -51, -52, -73, -73, -73, -63, -70, -72, -19, -16, -73, -31, -53, -54, -73, -56, -58, -73, -60, -73, -15, -17, -73, -73, -55, -57, -59, -61, -73, -20, -18, -62 ] racc_goto_table = [ 19, 41, 27, 92, 76, 35, 29, 104, 22, 4, 66, 47, 17, 46, 31, 27, 18, 60, 1, 52, 59, 99, 61, 107, 43, 63, 65, 45, 67, 50, 54, 49, 109, 56, 71, 58, 95, 57, 53, 3, 113, 64, 102, 98, 23, 54, 115, 101, 2, 90, 91, 55, 65, 69, 72, 111, 73, 34, nil, nil, nil, nil, nil, 75, nil, nil, nil, 93, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 96, nil, 103, nil, nil, nil, nil, nil, 93, nil, nil, nil, nil, nil, nil, 103 ] racc_goto_check = [ 7, 24, 7, 14, 16, 23, 7, 15, 17, 4, 18, 13, 4, 12, 9, 7, 8, 24, 1, 25, 11, 16, 11, 14, 10, 13, 11, 10, 23, 7, 7, 10, 16, 7, 23, 7, 18, 10, 26, 3, 16, 7, 33, 31, 19, 7, 16, 32, 2, 11, 11, 35, 11, 26, 10, 33, 10, 19, nil, nil, nil, nil, nil, 10, nil, nil, nil, 7, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 7, nil, 7, nil, nil, nil, nil, nil, 7, nil, nil, nil, nil, nil, nil, 7 ] racc_goto_pointer = [ nil, 18, 48, 39, 9, nil, nil, -7, 9, -4, -4, -23, -19, -21, -71, -85, -66, -1, -39, 35, nil, nil, nil, -22, -27, -18, 1, nil, nil, nil, nil, -44, -41, -46, nil, 13 ] racc_goto_default = [ nil, nil, nil, nil, nil, 5, 6, 7, nil, nil, nil, 8, nil, nil, nil, nil, nil, nil, nil, nil, 24, 25, 26, nil, 10, nil, nil, 82, 83, 84, 85, nil, nil, nil, 38, 39 ] racc_reduce_table = [ 0, 0, :racc_error, 1, 23, :_reduce_none, 1, 24, :_reduce_2, 1, 25, :_reduce_3, 2, 25, :_reduce_4, 1, 26, :_reduce_none, 1, 26, :_reduce_none, 5, 27, :_reduce_7, 1, 27, :_reduce_8, 0, 30, :_reduce_9, 1, 30, :_reduce_none, 0, 31, :_reduce_11, 3, 31, :_reduce_12, 1, 34, :_reduce_13, 2, 34, :_reduce_14, 5, 35, :_reduce_15, 1, 36, :_reduce_16, 2, 36, :_reduce_17, 3, 36, :_reduce_18, 0, 37, :_reduce_19, 2, 37, :_reduce_20, 2, 33, :_reduce_21, 3, 33, :_reduce_22, 0, 40, :_reduce_23, 1, 40, :_reduce_24, 1, 39, :_reduce_25, 2, 39, :_reduce_26, 1, 41, :_reduce_none, 1, 41, :_reduce_none, 1, 41, :_reduce_none, 4, 42, :_reduce_30, 6, 42, :_reduce_31, 1, 29, :_reduce_none, 1, 29, :_reduce_none, 1, 46, :_reduce_none, 1, 46, :_reduce_none, 1, 46, :_reduce_none, 1, 46, :_reduce_none, 0, 45, :_reduce_38, 2, 45, :_reduce_39, 3, 45, :_reduce_40, 1, 47, :_reduce_41, 2, 47, :_reduce_42, 3, 48, :_reduce_43, 1, 38, :_reduce_44, 1, 38, :_reduce_45, 1, 38, :_reduce_46, 1, 38, :_reduce_47, 1, 38, :_reduce_48, 1, 38, :_reduce_none, 1, 38, :_reduce_none, 1, 38, :_reduce_none, 1, 38, :_reduce_none, 2, 49, :_reduce_53, 2, 50, :_reduce_54, 3, 50, :_reduce_55, 1, 53, :_reduce_56, 2, 53, :_reduce_57, 2, 51, :_reduce_58, 3, 51, :_reduce_59, 1, 54, :_reduce_60, 2, 54, :_reduce_61, 3, 55, :_reduce_62, 1, 52, :_reduce_63, 0, 32, :_reduce_64, 1, 32, :_reduce_none, 1, 56, :_reduce_66, 2, 56, :_reduce_67, 3, 57, :_reduce_68, 3, 43, :_reduce_69, 5, 44, :_reduce_70, 3, 44, :_reduce_71, 6, 28, :_reduce_72 ] racc_reduce_n = 73 racc_shift_n = 116 racc_token_table = { false => 0, :error => 1, :RPAREN => 2, :LPAREN => 3, :VAR_SIGN => 4, :COLON => 5, :BANG => 6, :RBRACKET => 7, :LBRACKET => 8, :EQUALS => 9, :RCURLY => 10, :LCURLY => 11, :ON => 12, :IDENTIFIER => 13, :FRAGMENT => 14, :TRUE => 15, :FALSE => 16, :FLOAT => 17, :INT => 18, :STRING => 19, :DIR_SIGN => 20, :ELLIPSIS => 21 } racc_nt_base = 22 racc_use_result_var = true Racc_arg = [ racc_action_table, racc_action_check, racc_action_default, racc_action_pointer, racc_goto_table, racc_goto_check, racc_goto_default, racc_goto_pointer, racc_nt_base, racc_reduce_table, racc_token_table, racc_shift_n, racc_reduce_n, racc_use_result_var ] Racc_token_to_s_table = [ "$end", "error", "RPAREN", "LPAREN", "VAR_SIGN", "COLON", "BANG", "RBRACKET", "LBRACKET", "EQUALS", "RCURLY", "LCURLY", "ON", "IDENTIFIER", "FRAGMENT", "TRUE", "FALSE", "FLOAT", "INT", "STRING", "DIR_SIGN", "ELLIPSIS", "$start", "target", "document", "definitions_list", "definition", "operation_definition", "fragment_definition", "name", "operation_name_opt", "variable_definitions_opt", "directives_list_opt", "selection_set", "variable_definitions_list", "variable_definition", "variable_definition_type_name", "variable_definition_default_value_opt", "input_value", "selection_list", "selection_set_opt", "selection", "field", "fragment_spread", "inline_fragment", "arguments_opt", "name_without_on", "arguments_list", "argument", "variable", "list_value", "object_value", "enum_value", "list_value_list", "object_value_list", "object_value_field", "directives_list", "directive" ] Racc_debug_parser = false ##### State transition tables end ##### # reduce 0 omitted # reduce 1 omitted module_eval(<<'.,.,', 'parser.y', 4) def _reduce_2(val, _values, result) return make_node(:Document, definitions: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 7) def _reduce_3(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 8) def _reduce_4(val, _values, result) val[0] << val[1] result end .,., # reduce 5 omitted # reduce 6 omitted module_eval(<<'.,.,', 'parser.y', 16) def _reduce_7(val, _values, result) return make_node( :OperationDefinition, { operation_type: val[0], name: val[1], variables: val[2], directives: val[3], selections: val[4], position_source: val[0], } ) result end .,., module_eval(<<'.,.,', 'parser.y', 28) def _reduce_8(val, _values, result) return make_node( :OperationDefinition, { operation_type: "query", selections: val[0], } ) result end .,., module_eval(<<'.,.,', 'parser.y', 37) def _reduce_9(val, _values, result) return nil result end .,., # reduce 10 omitted module_eval(<<'.,.,', 'parser.y', 41) def _reduce_11(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 42) def _reduce_12(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 45) def _reduce_13(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 46) def _reduce_14(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 50) def _reduce_15(val, _values, result) return make_node(:VariableDefinition, { name: val[1], type: val[3], default_value: val[4], position_source: val[0], }) result end .,., module_eval(<<'.,.,', 'parser.y', 59) def _reduce_16(val, _values, result) return make_node(:TypeName, name: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 60) def _reduce_17(val, _values, result) return make_node(:NonNullType, of_type: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 61) def _reduce_18(val, _values, result) return make_node(:ListType, of_type: val[1]) result end .,., module_eval(<<'.,.,', 'parser.y', 64) def _reduce_19(val, _values, result) return nil result end .,., module_eval(<<'.,.,', 'parser.y', 65) def _reduce_20(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 68) def _reduce_21(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 69) def _reduce_22(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 72) def _reduce_23(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 73) def _reduce_24(val, _values, result) return val[0] result end .,., module_eval(<<'.,.,', 'parser.y', 76) def _reduce_25(val, _values, result) return [result] result end .,., module_eval(<<'.,.,', 'parser.y', 77) def _reduce_26(val, _values, result) val[0] << val[1] result end .,., # reduce 27 omitted # reduce 28 omitted # reduce 29 omitted module_eval(<<'.,.,', 'parser.y', 86) def _reduce_30(val, _values, result) return make_node( :Field, { name: val[0], arguments: val[1], directives: val[2], selections: val[3], position_source: val[0], } ) result end .,., module_eval(<<'.,.,', 'parser.y', 97) def _reduce_31(val, _values, result) return make_node( :Field, { alias: val[0], name: val[2], arguments: val[3], directives: val[4], selections: val[5], position_source: val[0], } ) result end .,., # reduce 32 omitted # reduce 33 omitted # reduce 34 omitted # reduce 35 omitted # reduce 36 omitted # reduce 37 omitted module_eval(<<'.,.,', 'parser.y', 120) def _reduce_38(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 121) def _reduce_39(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 122) def _reduce_40(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 125) def _reduce_41(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 126) def _reduce_42(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 129) def _reduce_43(val, _values, result) return make_node(:Argument, name: val[0], value: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 132) def _reduce_44(val, _values, result) return val[0].to_f result end .,., module_eval(<<'.,.,', 'parser.y', 133) def _reduce_45(val, _values, result) return val[0].to_i result end .,., module_eval(<<'.,.,', 'parser.y', 134) def _reduce_46(val, _values, result) return val[0].to_s result end .,., module_eval(<<'.,.,', 'parser.y', 135) def _reduce_47(val, _values, result) return true result end .,., module_eval(<<'.,.,', 'parser.y', 136) def _reduce_48(val, _values, result) return false result end .,., # reduce 49 omitted # reduce 50 omitted # reduce 51 omitted # reduce 52 omitted module_eval(<<'.,.,', 'parser.y', 142) def _reduce_53(val, _values, result) return make_node(:VariableIdentifier, name: val[1], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 145) def _reduce_54(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 146) def _reduce_55(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 149) def _reduce_56(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 150) def _reduce_57(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 153) def _reduce_58(val, _values, result) return make_node(:InputObject, arguments: [], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 154) def _reduce_59(val, _values, result) return make_node(:InputObject, arguments: val[1], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 157) def _reduce_60(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 158) def _reduce_61(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 161) def _reduce_62(val, _values, result) return make_node(:Argument, name: val[0], value: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 163) def _reduce_63(val, _values, result) return make_node(:Enum, name: val[0], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 166) def _reduce_64(val, _values, result) return [] result end .,., # reduce 65 omitted module_eval(<<'.,.,', 'parser.y', 170) def _reduce_66(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 171) def _reduce_67(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 173) def _reduce_68(val, _values, result) return make_node(:Directive, name: val[1], arguments: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 176) def _reduce_69(val, _values, result) return make_node(:FragmentSpread, name: val[1], directives: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 180) def _reduce_70(val, _values, result) return make_node(:InlineFragment, { type: val[2], directives: val[3], selections: val[4], position_source: val[0] }) result end .,., module_eval(<<'.,.,', 'parser.y', 188) def _reduce_71(val, _values, result) return make_node(:InlineFragment, { type: nil, directives: val[1], selections: val[2], position_source: val[0] }) result end .,., module_eval(<<'.,.,', 'parser.y', 198) def _reduce_72(val, _values, result) return make_node(:FragmentDefinition, { name: val[1], type: val[3], directives: val[4], selections: val[5], position_source: val[0], } ) result end .,., def _reduce_none(val, _values, result) val[0] end end # class Parser end # module Language end # module GraphQL