# # 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', 211) 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 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 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 = [ 85, 36, 104, 86, 35, 105, 87, 104, 88, 113, 79, 80, 40, 76, 77, 78, 85, 61, 47, 86, 69, 40, 87, 36, 88, 43, 79, 80, 73, 76, 77, 78, 85, 40, 36, 86, 9, 9, 87, 31, 88, 9, 79, 80, 9, 76, 77, 78, 85, 29, 40, 86, 107, 9, 87, 9, 88, 40, 79, 80, 40, 76, 77, 78, 85, 111, 15, 86, 96, 47, 87, 50, 88, 40, 79, 80, 67, 76, 77, 78, 10, 19, 12, 13, 14, 10, 19, 12, 13, 14, 20, 10, 19, 12, 13, 14, nil, nil, nil, nil, 27, 32, 10, 19, 12, 13, 14, 93, nil, nil, nil, 27, 10, 19, 12, 13, 14, 93, nil, nil, nil, nil, 10, 19, 12, 13, 14, 10, 19, 12, 13, 37, nil, nil, 9, 40, 10, 11, 12, 13, 14, 9, nil, 10, 11, 12, 13, 14, 109, 10, 19, 12, 13, 14, 99, 10, 19, 12, 13, 14, 10, 19, 12, 13, 14, 10, 19, 12, 13, 14, 10, 19, 12, 13, 14, 10, 19, 12, 13, 14, 10, 19, 12, 13, 14, 10, 19, 12, 13, 14, 10, 19, 12, 13, 14, 10, 19, 12, 13, 14 ] racc_action_check = [ 111, 26, 91, 111, 26, 91, 111, 106, 111, 106, 111, 111, 59, 111, 111, 111, 105, 45, 45, 105, 53, 54, 105, 56, 105, 28, 105, 105, 63, 105, 105, 105, 69, 66, 49, 69, 70, 72, 69, 17, 69, 74, 69, 69, 48, 69, 69, 69, 97, 15, 30, 97, 97, 44, 97, 42, 97, 41, 97, 97, 38, 97, 97, 97, 86, 102, 1, 86, 86, 31, 86, 36, 86, 34, 86, 86, 51, 86, 86, 86, 36, 36, 36, 36, 36, 51, 51, 51, 51, 51, 9, 9, 9, 9, 9, 9, nil, nil, nil, nil, 9, 21, 21, 21, 21, 21, 21, 73, nil, nil, nil, 21, 73, 73, 73, 73, 73, 93, nil, nil, nil, nil, 93, 93, 93, 93, 93, 27, 27, 27, 27, 27, nil, nil, 3, 27, 3, 3, 3, 3, 3, 0, nil, 0, 0, 0, 0, 0, 100, 100, 100, 100, 100, 100, 87, 87, 87, 87, 87, 87, 47, 47, 47, 47, 47, 37, 37, 37, 37, 37, 85, 85, 85, 85, 85, 40, 40, 40, 40, 40, 7, 7, 7, 7, 7, 35, 35, 35, 35, 35, 43, 43, 43, 43, 43, 11, 11, 11, 11, 11 ] racc_action_pointer = [ 131, 66, nil, 124, nil, nil, nil, 168, nil, 79, nil, 183, nil, nil, nil, 49, nil, 37, nil, nil, nil, 90, nil, nil, nil, nil, -1, 115, 9, nil, 30, 65, nil, nil, 53, 173, 68, 153, 40, nil, 163, 37, 45, 178, 43, 14, nil, 148, 34, 32, nil, 73, nil, 15, 1, nil, 21, nil, nil, -8, nil, nil, nil, 23, nil, nil, 13, nil, nil, 28, 26, nil, 27, 100, 31, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 158, 60, 143, nil, nil, nil, -4, nil, 110, nil, nil, nil, 44, nil, nil, 137, nil, 60, nil, nil, 12, 1, nil, nil, nil, nil, -4, nil, nil, nil ] racc_action_default = [ -72, -72, -1, -2, -3, -5, -6, -9, -8, -72, -32, -33, -34, -35, -36, -72, -4, -11, -10, -33, -21, -72, -25, -27, -28, -29, -37, -63, -72, 115, -63, -72, -22, -26, -63, -72, -72, -36, -64, -65, -72, -63, -72, -72, -72, -72, -13, -72, -23, -37, -38, -72, -40, -72, -63, -66, -37, -68, -70, -63, -7, -12, -14, -72, -24, -30, -63, -39, -41, -72, -72, -67, -72, -72, -23, -42, -43, -44, -45, -46, -47, -48, -49, -50, -51, -72, -72, -72, -62, -69, -71, -19, -16, -72, -31, -52, -53, -72, -55, -57, -72, -59, -72, -15, -17, -72, -72, -54, -56, -58, -60, -72, -20, -18, -61 ] racc_goto_table = [ 18, 34, 26, 46, 28, 4, 75, 58, 16, 60, 22, 103, 65, 64, 26, 45, 21, 62, 42, 30, 41, 44, 33, 98, 66, 48, 91, 17, 49, 53, 54, 71, 57, 56, 108, 89, 59, 90, 94, 64, 63, 52, 112, 1, 53, 70, 106, 101, 114, 51, 72, 3, 97, 100, 2, 55, 68, 74, nil, nil, 110, nil, nil, nil, nil, nil, 92, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 95, nil, 102, nil, nil, nil, nil, nil, 92, nil, nil, nil, nil, nil, nil, 102 ] racc_goto_check = [ 7, 23, 7, 13, 7, 4, 16, 11, 4, 11, 19, 15, 18, 11, 7, 12, 17, 13, 10, 9, 7, 10, 19, 16, 23, 10, 14, 8, 7, 7, 7, 23, 10, 7, 16, 11, 7, 11, 18, 11, 7, 25, 16, 1, 7, 10, 14, 32, 16, 24, 10, 3, 30, 31, 2, 34, 25, 10, nil, nil, 32, nil, nil, 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, 43, 54, 51, 5, nil, nil, -7, 20, 2, -9, -35, -16, -28, -47, -80, -63, 7, -36, 1, nil, nil, nil, -25, 13, 5, nil, nil, nil, nil, -34, -34, -40, nil, 17 ] racc_goto_default = [ nil, nil, nil, nil, nil, 5, 6, 7, nil, nil, nil, 8, nil, nil, nil, nil, nil, nil, nil, nil, 23, 24, 25, nil, nil, nil, 81, 82, 83, 84, 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, 29, :_reduce_none, 1, 29, :_reduce_none, 1, 29, :_reduce_none, 0, 45, :_reduce_37, 2, 45, :_reduce_38, 3, 45, :_reduce_39, 1, 46, :_reduce_40, 2, 46, :_reduce_41, 3, 47, :_reduce_42, 1, 38, :_reduce_43, 1, 38, :_reduce_44, 1, 38, :_reduce_45, 1, 38, :_reduce_46, 1, 38, :_reduce_47, 1, 38, :_reduce_none, 1, 38, :_reduce_none, 1, 38, :_reduce_none, 1, 38, :_reduce_none, 2, 48, :_reduce_52, 2, 49, :_reduce_53, 3, 49, :_reduce_54, 1, 52, :_reduce_55, 2, 52, :_reduce_56, 2, 50, :_reduce_57, 3, 50, :_reduce_58, 1, 53, :_reduce_59, 2, 53, :_reduce_60, 3, 54, :_reduce_61, 1, 51, :_reduce_62, 0, 32, :_reduce_63, 1, 32, :_reduce_none, 1, 55, :_reduce_65, 2, 55, :_reduce_66, 3, 56, :_reduce_67, 3, 43, :_reduce_68, 5, 44, :_reduce_69, 3, 44, :_reduce_70, 6, 28, :_reduce_71 ] racc_reduce_n = 72 racc_shift_n = 115 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, :IDENTIFIER => 12, :FRAGMENT => 13, :TRUE => 14, :FALSE => 15, :ON => 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", "IDENTIFIER", "FRAGMENT", "TRUE", "FALSE", "ON", "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", "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 module_eval(<<'.,.,', 'parser.y', 117) def _reduce_37(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 118) def _reduce_38(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 119) def _reduce_39(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 122) def _reduce_40(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 123) def _reduce_41(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 126) def _reduce_42(val, _values, result) return make_node(:Argument, name: val[0], value: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 129) def _reduce_43(val, _values, result) return val[0].to_f result end .,., module_eval(<<'.,.,', 'parser.y', 130) def _reduce_44(val, _values, result) return val[0].to_i result end .,., module_eval(<<'.,.,', 'parser.y', 131) def _reduce_45(val, _values, result) return val[0].to_s result end .,., module_eval(<<'.,.,', 'parser.y', 132) def _reduce_46(val, _values, result) return true result end .,., module_eval(<<'.,.,', 'parser.y', 133) def _reduce_47(val, _values, result) return false result end .,., # reduce 48 omitted # reduce 49 omitted # reduce 50 omitted # reduce 51 omitted module_eval(<<'.,.,', 'parser.y', 139) def _reduce_52(val, _values, result) return make_node(:VariableIdentifier, name: val[1], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 142) def _reduce_53(val, _values, result) return [] result end .,., module_eval(<<'.,.,', 'parser.y', 143) def _reduce_54(val, _values, result) return val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 146) def _reduce_55(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 147) def _reduce_56(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 150) def _reduce_57(val, _values, result) return make_node(:InputObject, arguments: [], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 151) def _reduce_58(val, _values, result) return make_node(:InputObject, arguments: val[1], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 154) def _reduce_59(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 155) def _reduce_60(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 158) def _reduce_61(val, _values, result) return make_node(:Argument, name: val[0], value: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 160) def _reduce_62(val, _values, result) return make_node(:Enum, name: val[0], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 163) def _reduce_63(val, _values, result) return [] result end .,., # reduce 64 omitted module_eval(<<'.,.,', 'parser.y', 167) def _reduce_65(val, _values, result) return [val[0]] result end .,., module_eval(<<'.,.,', 'parser.y', 168) def _reduce_66(val, _values, result) val[0] << val[1] result end .,., module_eval(<<'.,.,', 'parser.y', 170) def _reduce_67(val, _values, result) return make_node(:Directive, name: val[1], arguments: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 173) def _reduce_68(val, _values, result) return make_node(:FragmentSpread, name: val[1], directives: val[2], position_source: val[0]) result end .,., module_eval(<<'.,.,', 'parser.y', 177) def _reduce_69(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', 185) def _reduce_70(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', 195) def _reduce_71(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