# # 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', 222) 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 = [ 24, 25, 26, 43, 111, 46, 42, 112, 14, 24, 25, 26, 39, 19, 20, 21, 22, 23, 24, 25, 26, 36, 34, 20, 21, 22, 23, 111, 38, 120, 27, 19, 20, 21, 22, 23, 24, 25, 26, 50, 34, 68, 54, 46, 54, 46, 24, 25, 26, 48, 20, 21, 22, 23, 24, 25, 26, 46, 57, 19, 20, 21, 22, 23, 24, 25, 26, 19, 20, 21, 22, 23, 24, 25, 26, 46, 74, 19, 20, 21, 22, 23, 24, 25, 26, 19, 20, 21, 22, 23, 24, 25, 26, 46, 12, 19, 20, 21, 22, 23, 24, 25, 26, 19, 20, 21, 22, 23, 100, 24, 25, 26, 12, 19, 20, 21, 22, 23, 24, 25, 26, 12, 19, 20, 21, 22, 23, 43, 76, 43, 106, 19, 20, 21, 22, 23, 24, 25, 26, 46, 80, 46, 12, 12, 100, 24, 25, 26, 12, 19, 20, 21, 22, 23, 24, 25, 26, 116, 19, 20, 21, 22, 23, 24, 25, 26, 118, 19, 20, 21, 22, 23, 9, 10, 11, nil, 19, 20, 21, 22, 23, nil, 92, 12, nil, 93, nil, 13, 94, nil, nil, 95, nil, 86, 87, 83, 84, 85, 92, nil, nil, 93, 103, nil, 94, nil, nil, 95, nil, 86, 87, 83, 84, 85, 92, nil, nil, 93, nil, nil, 94, nil, nil, 95, nil, 86, 87, 83, 84, 85, 92, nil, nil, 93, 114, nil, 94, nil, nil, 95, nil, 86, 87, 83, 84, 85, 9, 10, 11, nil, nil, nil, nil, 92, nil, nil, 93, 12, nil, 94, nil, 13, 95, nil, 86, 87, 83, 84, 85 ] racc_action_check = [ 28, 28, 28, 33, 98, 64, 33, 98, 1, 50, 50, 50, 28, 28, 28, 28, 28, 28, 12, 12, 12, 14, 28, 50, 50, 50, 50, 113, 16, 113, 12, 12, 12, 12, 12, 12, 34, 34, 34, 35, 12, 52, 52, 37, 38, 41, 46, 46, 46, 34, 34, 34, 34, 34, 43, 43, 43, 34, 43, 46, 46, 46, 46, 46, 7, 7, 7, 43, 43, 43, 43, 43, 58, 58, 58, 44, 58, 7, 7, 7, 7, 7, 42, 42, 42, 58, 58, 58, 58, 58, 48, 48, 48, 47, 49, 42, 42, 42, 42, 42, 80, 80, 80, 48, 48, 48, 48, 48, 80, 92, 92, 92, 51, 80, 80, 80, 80, 80, 94, 94, 94, 55, 92, 92, 92, 92, 92, 56, 60, 62, 94, 94, 94, 94, 94, 94, 100, 100, 100, 66, 70, 73, 78, 79, 100, 107, 107, 107, 81, 100, 100, 100, 100, 100, 54, 54, 54, 107, 107, 107, 107, 107, 107, 13, 13, 13, 109, 54, 54, 54, 54, 54, 0, 0, 0, nil, 13, 13, 13, 13, 13, nil, 76, 0, nil, 76, nil, 0, 76, nil, nil, 76, nil, 76, 76, 76, 76, 76, 93, nil, nil, 93, 93, nil, 93, nil, nil, 93, nil, 93, 93, 93, 93, 93, 118, nil, nil, 118, nil, nil, 118, nil, nil, 118, nil, 118, 118, 118, 118, 118, 104, nil, nil, 104, 104, nil, 104, nil, nil, 104, nil, 104, 104, 104, 104, 104, 3, 3, 3, nil, nil, nil, nil, 112, nil, nil, 112, 3, nil, 112, nil, 3, 112, nil, 112, 112, 112, 112, 112 ] racc_action_pointer = [ 170, 8, nil, 244, nil, nil, nil, 62, nil, nil, nil, nil, 16, 161, 21, nil, 23, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, -2, nil, nil, nil, nil, -2, 34, 24, nil, 20, 37, nil, nil, 22, 80, 52, 52, nil, 44, 70, 88, 81, 7, 99, 35, nil, 152, 108, 122, nil, 70, nil, 120, nil, 124, nil, -18, nil, 116, nil, nil, nil, 132, nil, nil, 118, nil, nil, 175, nil, 129, 130, 98, 135, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 107, 191, 116, nil, nil, nil, -5, nil, 134, nil, nil, nil, 223, nil, nil, 143, nil, 158, nil, nil, 246, 18, nil, nil, nil, nil, 207, nil, nil, nil ] racc_action_default = [ -79, -79, -1, -2, -3, -5, -6, -12, -8, -9, -10, -11, -79, -79, -79, -4, -14, -13, -35, -36, -37, -38, -39, -40, -41, -42, -43, -24, -79, -28, -30, -31, -32, -44, -70, -79, 122, -70, -79, -25, -29, -70, -79, -79, -71, -72, -79, -70, -79, -79, -79, -79, -79, -16, -79, -26, -44, -45, -79, -47, -79, -73, -44, -75, -70, -77, -70, -7, -15, -17, -79, -27, -33, -70, -46, -48, -79, -74, -79, -79, -79, -26, -49, -50, -51, -52, -53, -54, -55, -56, -57, -58, -79, -79, -79, -69, -76, -78, -22, -19, -79, -34, -59, -60, -79, -62, -64, -79, -66, -79, -18, -20, -79, -79, -61, -63, -65, -67, -79, -23, -21, -68 ] racc_goto_table = [ 17, 82, 65, 29, 67, 98, 35, 72, 71, 59, 49, 47, 53, 51, 61, 41, 2, 55, 105, 40, 3, 16, 37, 63, 75, 113, 69, 66, 52, 115, 110, 96, 97, 101, 71, 56, 60, 119, 73, 62, 78, 64, 79, 121, 77, 108, 28, 70, 58, 81, 4, 60, 104, 15, 107, 1, nil, nil, 117, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 99, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 102, nil, 109, nil, nil, nil, nil, nil, 99, nil, nil, nil, nil, nil, nil, 109 ] racc_goto_check = [ 12, 17, 11, 20, 11, 15, 12, 19, 11, 27, 10, 25, 14, 10, 36, 24, 2, 10, 17, 20, 3, 8, 9, 10, 27, 15, 14, 25, 13, 17, 16, 11, 11, 19, 11, 12, 12, 17, 24, 12, 10, 12, 10, 17, 24, 34, 18, 12, 26, 10, 4, 12, 32, 4, 33, 1, nil, nil, 34, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 12, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 12, nil, 12, nil, nil, nil, nil, nil, 12, nil, nil, nil, nil, nil, nil, 12 ] racc_goto_pointer = [ nil, 55, 16, 20, 50, nil, nil, nil, 14, 6, -24, -47, -7, -10, -26, -75, -68, -75, 34, -48, -9, nil, nil, nil, -18, -23, 5, -34, nil, nil, nil, nil, -41, -40, -49, nil, -30 ] racc_goto_default = [ nil, nil, nil, nil, nil, 5, 6, 7, nil, nil, nil, 8, 33, nil, nil, nil, nil, nil, nil, nil, nil, 30, 31, 32, nil, 18, nil, nil, 88, 89, 90, 91, nil, nil, nil, 44, 45 ] racc_reduce_table = [ 0, 0, :racc_error, 1, 26, :_reduce_none, 1, 27, :_reduce_2, 1, 28, :_reduce_3, 2, 28, :_reduce_4, 1, 29, :_reduce_none, 1, 29, :_reduce_none, 5, 30, :_reduce_7, 1, 30, :_reduce_8, 1, 32, :_reduce_none, 1, 32, :_reduce_none, 1, 32, :_reduce_none, 0, 33, :_reduce_12, 1, 33, :_reduce_none, 0, 34, :_reduce_14, 3, 34, :_reduce_15, 1, 38, :_reduce_16, 2, 38, :_reduce_17, 5, 39, :_reduce_18, 1, 40, :_reduce_19, 2, 40, :_reduce_20, 3, 40, :_reduce_21, 0, 41, :_reduce_22, 2, 41, :_reduce_23, 2, 36, :_reduce_24, 3, 36, :_reduce_25, 0, 44, :_reduce_26, 1, 44, :_reduce_27, 1, 43, :_reduce_28, 2, 43, :_reduce_29, 1, 45, :_reduce_none, 1, 45, :_reduce_none, 1, 45, :_reduce_none, 4, 46, :_reduce_33, 6, 46, :_reduce_34, 1, 37, :_reduce_none, 1, 37, :_reduce_none, 1, 50, :_reduce_none, 1, 50, :_reduce_none, 1, 50, :_reduce_none, 1, 50, :_reduce_none, 1, 50, :_reduce_none, 1, 50, :_reduce_none, 1, 50, :_reduce_none, 0, 49, :_reduce_44, 2, 49, :_reduce_45, 3, 49, :_reduce_46, 1, 51, :_reduce_47, 2, 51, :_reduce_48, 3, 52, :_reduce_49, 1, 42, :_reduce_50, 1, 42, :_reduce_51, 1, 42, :_reduce_52, 1, 42, :_reduce_53, 1, 42, :_reduce_54, 1, 42, :_reduce_none, 1, 42, :_reduce_none, 1, 42, :_reduce_none, 1, 42, :_reduce_none, 2, 53, :_reduce_59, 2, 54, :_reduce_60, 3, 54, :_reduce_61, 1, 57, :_reduce_62, 2, 57, :_reduce_63, 2, 55, :_reduce_64, 3, 55, :_reduce_65, 1, 58, :_reduce_66, 2, 58, :_reduce_67, 3, 59, :_reduce_68, 1, 56, :_reduce_69, 0, 35, :_reduce_70, 1, 35, :_reduce_none, 1, 60, :_reduce_72, 2, 60, :_reduce_73, 3, 61, :_reduce_74, 3, 47, :_reduce_75, 5, 48, :_reduce_76, 3, 48, :_reduce_77, 6, 31, :_reduce_78 ] racc_reduce_n = 79 racc_shift_n = 122 racc_token_table = { false => 0, :error => 1, :QUERY => 2, :MUTATION => 3, :SUBSCRIPTION => 4, :RPAREN => 5, :LPAREN => 6, :VAR_SIGN => 7, :COLON => 8, :BANG => 9, :RBRACKET => 10, :LBRACKET => 11, :EQUALS => 12, :RCURLY => 13, :LCURLY => 14, :ON => 15, :IDENTIFIER => 16, :FRAGMENT => 17, :TRUE => 18, :FALSE => 19, :FLOAT => 20, :INT => 21, :STRING => 22, :DIR_SIGN => 23, :ELLIPSIS => 24 } racc_nt_base = 25 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", "QUERY", "MUTATION", "SUBSCRIPTION", "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", "operation_type", "operation_name_opt", "variable_definitions_opt", "directives_list_opt", "selection_set", "name", "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 .,., # reduce 9 omitted # reduce 10 omitted # reduce 11 omitted module_eval(<<'.,.,', 'parser.y', 42) def _reduce_12(val, _values, result) return nil result end .,., # reduce 13 omitted module_eval(<<'.,.,', 'parser.y', 46) def _reduce_14(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 47) def _reduce_15(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 50) def _reduce_16(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 51) def _reduce_17(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 55) def _reduce_18(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', 64) def _reduce_19(val, _values, result) return make_node(:TypeName, name: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 65) def _reduce_20(val, _values, result) return make_node(:NonNullType, of_type: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 66) def _reduce_21(val, _values, result) return make_node(:ListType, of_type: val[1]) result end .,., module_eval(<<'.,.,', 'parser.y', 69) def _reduce_22(val, _values, result) return nil result end .,., module_eval(<<'.,.,', 'parser.y', 70) def _reduce_23(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 73) def _reduce_24(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 74) def _reduce_25(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 77) def _reduce_26(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 78) def _reduce_27(val, _values, result) return val[0] result end .,., module_eval(<<'.,.,', 'parser.y', 81) def _reduce_28(val, _values, result) return [result] result end .,., module_eval(<<'.,.,', 'parser.y', 82) def _reduce_29(val, _values, result) val[0] << val[1] result end .,., # reduce 30 omitted # reduce 31 omitted # reduce 32 omitted module_eval(<<'.,.,', 'parser.y', 91) def _reduce_33(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', 102) def _reduce_34(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 35 omitted # reduce 36 omitted # reduce 37 omitted # reduce 38 omitted # reduce 39 omitted # reduce 40 omitted # reduce 41 omitted # reduce 42 omitted # reduce 43 omitted module_eval(<<'.,.,', 'parser.y', 128) def _reduce_44(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 129) def _reduce_45(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 130) def _reduce_46(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 133) def _reduce_47(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 134) def _reduce_48(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 137) def _reduce_49(val, _values, result) return make_node(:Argument, name: val[0], value: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 140) def _reduce_50(val, _values, result) return val[0].to_f result end .,., module_eval(<<'.,.,', 'parser.y', 141) def _reduce_51(val, _values, result) return val[0].to_i result end .,., module_eval(<<'.,.,', 'parser.y', 142) def _reduce_52(val, _values, result) return val[0].to_s result end .,., module_eval(<<'.,.,', 'parser.y', 143) def _reduce_53(val, _values, result) return true result end .,., module_eval(<<'.,.,', 'parser.y', 144) def _reduce_54(val, _values, result) return false result end .,., # reduce 55 omitted # reduce 56 omitted # reduce 57 omitted # reduce 58 omitted module_eval(<<'.,.,', 'parser.y', 150) def _reduce_59(val, _values, result) return make_node(:VariableIdentifier, name: val[1], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 153) def _reduce_60(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 154) def _reduce_61(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 157) def _reduce_62(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 158) def _reduce_63(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 161) def _reduce_64(val, _values, result) return make_node(:InputObject, arguments: [], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 162) def _reduce_65(val, _values, result) return make_node(:InputObject, arguments: val[1], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 165) def _reduce_66(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 166) def _reduce_67(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 169) def _reduce_68(val, _values, result) return make_node(:Argument, name: val[0], value: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 171) def _reduce_69(val, _values, result) return make_node(:Enum, name: val[0], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 174) def _reduce_70(val, _values, result) return [] result end .,., # reduce 71 omitted module_eval(<<'.,.,', 'parser.y', 178) def _reduce_72(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 179) def _reduce_73(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 181) def _reduce_74(val, _values, result) return make_node(:Directive, name: val[1], arguments: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 184) def _reduce_75(val, _values, result) return make_node(:FragmentSpread, name: val[1], directives: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 188) def _reduce_76(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', 196) def _reduce_77(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', 206) def _reduce_78(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