#
# DO NOT MODIFY!!!!
# This file is automatically generated by Racc 1.4.7
# from Racc grammer file "".
#

require 'racc/parser.rb'


require 'nokogiri/css/parser_extras'
module Nokogiri
  module CSS
    class Parser < Racc::Parser
##### State transition tables begin ###

racc_action_table = [
     5,    57,    28,    23,    13,    25,    61,    58,     5,     1,
     6,    60,    13,    58,    66,    24,    17,     1,    83,    20,
    94,    93,     6,    13,     9,    11,    14,    20,    17,    42,
     6,     5,     9,    11,    14,    13,    17,    76,    42,     5,
     1,     6,    65,    13,    11,    62,    63,    17,     1,    60,
    20,     5,    63,     6,    84,     9,    11,    14,    20,    17,
     1,     6,    30,     9,    11,    14,    13,    17,    13,    85,
    20,     1,    64,    13,    59,     9,    88,    13,    13,    89,
    28,    54,    13,    55,     6,    42,     6,    11,    14,    11,
    17,     6,    17,    45,    11,     6,     6,    17,    11,    11,
     6,    17,    17,    11,     5,    92,    17,    69,    71,    28,
    54,    22,    55,    50,    28,    54,    95,    55,    70,    72,
    73,   -24,    75,    20,    69,    71,    67,    97,     9,    98,
   nil,   nil,    34,    36,    38,    70,    72,    73,   nil,    75,
   nil,   nil,    33,    67,    35,    37,    28,    54,   nil,    55 ]

racc_action_check = [
     0,    21,     5,     5,     0,     5,    23,    43,     9,     0,
    15,    23,     9,    21,    28,     5,    15,     9,    43,     0,
    74,    74,     0,     8,     0,     0,     0,     9,     0,    40,
     9,    32,     9,     9,     9,    32,     9,    30,     8,    58,
    32,     8,    27,    58,     8,    25,    25,     8,    58,    54,
    32,     6,    55,    32,    56,    32,    32,    32,    58,    32,
     6,    58,     6,    58,    58,    58,    42,    58,    80,    57,
     6,    42,    26,    10,    22,     6,    61,    19,    18,    62,
    60,    60,    16,    60,    42,    12,    80,    42,    42,    80,
    42,    10,    80,    11,    10,    19,    18,    10,    19,    18,
    16,    19,    18,    16,    17,    68,    16,    31,    31,    20,
    20,     4,    20,    17,    63,    63,    77,    63,    31,    31,
    31,     1,    31,    17,    29,    29,    31,    82,    17,    89,
   nil,   nil,     7,     7,     7,    29,    29,    29,   nil,    29,
   nil,   nil,     7,    29,     7,     7,    66,    66,   nil,    66 ]

racc_action_pointer = [
    -2,    92,   nil,   nil,    82,    -8,    49,   125,    17,     6,
    67,    82,    64,   nil,   nil,   -14,    76,   102,    72,    71,
    99,     1,    63,    -1,   nil,    34,    49,    19,     2,   121,
    12,   104,    29,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     8,   nil,    60,    -5,   nil,   nil,   nil,   nil,   nil,   nil,
   nil,   nil,   nil,   nil,    37,    40,    31,    69,    37,   nil,
    70,    63,    72,   104,   nil,   nil,   136,   nil,    80,   nil,
   nil,   nil,   nil,   nil,    10,   nil,   nil,    91,   nil,   nil,
    62,   nil,   104,   nil,   nil,   nil,   nil,   nil,   nil,   116,
   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil ]

racc_action_default = [
   -25,   -23,   -20,    -2,   -70,   -70,   -25,   -18,   -46,   -25,
   -51,   -70,   -16,   -55,   -21,   -12,   -54,   -70,   -53,   -52,
   -70,   -70,   -70,   -39,   -29,   -37,   -70,   -70,   -38,   -58,
   -70,   -58,   -25,    -5,    -3,    -8,    -4,    -7,    -6,    -9,
   -45,   -11,   -25,   -70,   -47,   -19,   -15,   -13,   -14,   -50,
   -44,   -43,   -49,   -48,   -39,   -37,   -70,   -70,   -25,   -22,
   -70,   -70,   -42,   -70,   -30,   -31,   -70,   -59,   -70,   -64,
   -60,   -65,   -61,   -62,   -70,   -63,   -28,   -70,   -17,   -10,
   -67,   -69,   -70,   -33,   -32,    99,    -1,   -36,   -41,   -70,
   -34,   -35,   -26,   -56,   -57,   -27,   -68,   -66,   -40 ]

racc_goto_table = [
    40,    26,    44,    41,    78,    21,    31,    46,    49,    29,
    52,    53,    47,    68,    43,    77,    56,    51,    48,    39,
    80,    32,    27,    82,   nil,   nil,   nil,   nil,   nil,   nil,
    86,   nil,   nil,   nil,    81,    79,   nil,   nil,   nil,   nil,
   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
   nil,   nil,   nil,   nil,   nil,   nil,    87,   nil,   nil,    90,
   nil,   nil,    91,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
   nil,   nil,    96 ]

racc_goto_check = [
     7,    16,     7,     8,     2,     1,     9,     8,     7,    13,
     7,     7,    10,    15,     1,    15,    16,     9,    11,     6,
     5,     3,    17,    20,   nil,   nil,   nil,   nil,   nil,   nil,
     2,   nil,   nil,   nil,     7,     8,   nil,   nil,   nil,   nil,
   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
   nil,   nil,   nil,   nil,   nil,   nil,    16,   nil,   nil,    16,
   nil,   nil,    16,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
   nil,   nil,     7 ]

racc_goto_pointer = [
   nil,     5,   -28,    14,   nil,   -22,    11,    -8,    -5,     0,
    -3,     3,   nil,     3,   nil,   -16,    -4,    17,   nil,   nil,
   -19 ]

racc_goto_default = [
   nil,   nil,     3,   nil,     7,     8,   nil,    12,   nil,    15,
    16,    18,    19,     2,     4,   nil,   nil,   nil,    10,    74,
   nil ]

racc_reduce_table = [
  0, 0, :racc_error,
  3, 32, :_reduce_1,
  1, 32, :_reduce_2,
  1, 34, :_reduce_3,
  1, 34, :_reduce_4,
  1, 34, :_reduce_5,
  1, 34, :_reduce_6,
  1, 34, :_reduce_7,
  1, 34, :_reduce_8,
  2, 35, :_reduce_9,
  3, 35, :_reduce_10,
  2, 35, :_reduce_11,
  1, 35, :_reduce_none,
  2, 35, :_reduce_13,
  2, 35, :_reduce_14,
  2, 35, :_reduce_15,
  1, 35, :_reduce_16,
  3, 33, :_reduce_17,
  1, 33, :_reduce_none,
  2, 43, :_reduce_19,
  1, 36, :_reduce_none,
  1, 36, :_reduce_21,
  3, 44, :_reduce_22,
  1, 44, :_reduce_23,
  1, 45, :_reduce_24,
  0, 45, :_reduce_none,
  4, 42, :_reduce_26,
  4, 42, :_reduce_27,
  3, 42, :_reduce_28,
  2, 40, :_reduce_29,
  3, 40, :_reduce_30,
  3, 40, :_reduce_31,
  3, 40, :_reduce_32,
  3, 40, :_reduce_33,
  3, 47, :_reduce_34,
  3, 47, :_reduce_35,
  3, 47, :_reduce_36,
  1, 47, :_reduce_none,
  1, 47, :_reduce_none,
  1, 47, :_reduce_39,
  4, 48, :_reduce_40,
  3, 48, :_reduce_41,
  2, 48, :_reduce_42,
  2, 41, :_reduce_43,
  2, 41, :_reduce_44,
  1, 37, :_reduce_none,
  0, 37, :_reduce_none,
  2, 38, :_reduce_47,
  2, 38, :_reduce_48,
  2, 38, :_reduce_49,
  2, 38, :_reduce_50,
  1, 38, :_reduce_none,
  1, 38, :_reduce_none,
  1, 38, :_reduce_none,
  1, 38, :_reduce_none,
  1, 49, :_reduce_55,
  2, 46, :_reduce_56,
  2, 46, :_reduce_57,
  0, 46, :_reduce_none,
  1, 50, :_reduce_59,
  1, 50, :_reduce_60,
  1, 50, :_reduce_61,
  1, 50, :_reduce_62,
  1, 50, :_reduce_63,
  1, 50, :_reduce_64,
  1, 50, :_reduce_65,
  3, 39, :_reduce_66,
  1, 51, :_reduce_none,
  2, 51, :_reduce_none,
  1, 51, :_reduce_none ]

racc_reduce_n = 70

racc_shift_n = 99

racc_token_table = {
  false => 0,
  :error => 1,
  :FUNCTION => 2,
  :INCLUDES => 3,
  :DASHMATCH => 4,
  :LBRACE => 5,
  :HASH => 6,
  :PLUS => 7,
  :GREATER => 8,
  :S => 9,
  :STRING => 10,
  :IDENT => 11,
  :COMMA => 12,
  :NUMBER => 13,
  :PREFIXMATCH => 14,
  :SUFFIXMATCH => 15,
  :SUBSTRINGMATCH => 16,
  :TILDE => 17,
  :NOT_EQUAL => 18,
  :SLASH => 19,
  :DOUBLESLASH => 20,
  :NOT => 21,
  :EQUAL => 22,
  :RPAREN => 23,
  :LSQUARE => 24,
  :RSQUARE => 25,
  :HAS => 26,
  "." => 27,
  "*" => 28,
  "|" => 29,
  ":" => 30 }

racc_nt_base = 31

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",
  "FUNCTION",
  "INCLUDES",
  "DASHMATCH",
  "LBRACE",
  "HASH",
  "PLUS",
  "GREATER",
  "S",
  "STRING",
  "IDENT",
  "COMMA",
  "NUMBER",
  "PREFIXMATCH",
  "SUFFIXMATCH",
  "SUBSTRINGMATCH",
  "TILDE",
  "NOT_EQUAL",
  "SLASH",
  "DOUBLESLASH",
  "NOT",
  "EQUAL",
  "RPAREN",
  "LSQUARE",
  "RSQUARE",
  "HAS",
  "\".\"",
  "\"*\"",
  "\"|\"",
  "\":\"",
  "$start",
  "selector",
  "simple_selector_1toN",
  "combinator",
  "simple_selector",
  "element_name",
  "hcap_0toN",
  "hcap_1toN",
  "negation",
  "function",
  "pseudo",
  "attrib",
  "class",
  "namespaced_ident",
  "namespace",
  "attrib_val_0or1",
  "expr",
  "an_plus_b",
  "attribute_id",
  "eql_incl_dash",
  "negation_arg" ]

Racc_debug_parser = false

##### State transition tables end #####

# reduce 0 omitted

def _reduce_1(val, _values, result)
        result = [val.first, val.last].flatten
      
    result
end

def _reduce_2(val, _values, result)
 result = val.flatten 
    result
end

def _reduce_3(val, _values, result)
 result = :DIRECT_ADJACENT_SELECTOR 
    result
end

def _reduce_4(val, _values, result)
 result = :CHILD_SELECTOR 
    result
end

def _reduce_5(val, _values, result)
 result = :PRECEDING_SELECTOR 
    result
end

def _reduce_6(val, _values, result)
 result = :DESCENDANT_SELECTOR 
    result
end

def _reduce_7(val, _values, result)
 result = :DESCENDANT_SELECTOR 
    result
end

def _reduce_8(val, _values, result)
 result = :CHILD_SELECTOR 
    result
end

def _reduce_9(val, _values, result)
        result =  if val[1].nil?
                    val.first
                  else
                    Node.new(:CONDITIONAL_SELECTOR, [val.first, val[1]])
                  end
      
    result
end

def _reduce_10(val, _values, result)
        result = Node.new(:CONDITIONAL_SELECTOR,
          [
            val.first,
            Node.new(:COMBINATOR, [val[1], val.last])
          ]
        )
      
    result
end

def _reduce_11(val, _values, result)
        result = Node.new(:CONDITIONAL_SELECTOR, val)
      
    result
end

# reduce 12 omitted

def _reduce_13(val, _values, result)
        result = Node.new(:CONDITIONAL_SELECTOR, val)
      
    result
end

def _reduce_14(val, _values, result)
        result = Node.new(:CONDITIONAL_SELECTOR, val)
      
    result
end

def _reduce_15(val, _values, result)
        result = Node.new(:CONDITIONAL_SELECTOR,
          [
            Node.new(:ELEMENT_NAME, ['*']),
            Node.new(:COMBINATOR, val)
          ]
        )
      
    result
end

def _reduce_16(val, _values, result)
        result = Node.new(:CONDITIONAL_SELECTOR,
          [Node.new(:ELEMENT_NAME, ['*']), val.first]
        )
      
    result
end

def _reduce_17(val, _values, result)
        result = Node.new(val[1], [val.first, val.last])
      
    result
end

# reduce 18 omitted

def _reduce_19(val, _values, result)
 result = Node.new(:CLASS_CONDITION, [val[1]]) 
    result
end

# reduce 20 omitted

def _reduce_21(val, _values, result)
 result = Node.new(:ELEMENT_NAME, val) 
    result
end

def _reduce_22(val, _values, result)
        result = Node.new(:ELEMENT_NAME,
          [[val.first, val.last].compact.join(':')]
        )
      
    result
end

def _reduce_23(val, _values, result)
        name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
        result = Node.new(:ELEMENT_NAME, [name])
      
    result
end

def _reduce_24(val, _values, result)
 result = val[0] 
    result
end

# reduce 25 omitted

def _reduce_26(val, _values, result)
        result = Node.new(:ATTRIBUTE_CONDITION,
          [val[1]] + (val[2] || [])
        )
      
    result
end

def _reduce_27(val, _values, result)
        result = Node.new(:ATTRIBUTE_CONDITION,
          [val[1]] + (val[2] || [])
        )
      
    result
end

def _reduce_28(val, _values, result)
        # Non standard, but hpricot supports it.
        result = Node.new(:PSEUDO_CLASS,
          [Node.new(:FUNCTION, ['nth-child(', val[1]])]
        )
      
    result
end

def _reduce_29(val, _values, result)
        result = Node.new(:FUNCTION, [val.first.strip])
      
    result
end

def _reduce_30(val, _values, result)
        result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
      
    result
end

def _reduce_31(val, _values, result)
        result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
      
    result
end

def _reduce_32(val, _values, result)
        result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
      
    result
end

def _reduce_33(val, _values, result)
        result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
      
    result
end

def _reduce_34(val, _values, result)
 result = [val.first, val.last] 
    result
end

def _reduce_35(val, _values, result)
 result = [val.first, val.last] 
    result
end

def _reduce_36(val, _values, result)
 result = [val.first, val.last] 
    result
end

# reduce 37 omitted

# reduce 38 omitted

def _reduce_39(val, _values, result)
        if val[0] == 'even'
          val = ["2","n","+","0"]
          result = Node.new(:AN_PLUS_B, val)
        elsif val[0] == 'odd'
          val = ["2","n","+","1"]
          result = Node.new(:AN_PLUS_B, val)
        else
          # This is not CSS standard.  It allows us to support this:
          # assert_xpath("//a[foo(., @href)]", @parser.parse('a:foo(@href)'))
          # assert_xpath("//a[foo(., @a, b)]", @parser.parse('a:foo(@a, b)'))
          # assert_xpath("//a[foo(., a, 10)]", @parser.parse('a:foo(a, 10)'))
          result = val
        end
      
    result
end

def _reduce_40(val, _values, result)
        if val[1] == 'n'
          result = Node.new(:AN_PLUS_B, val)
        else
          raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
        end
      
    result
end

def _reduce_41(val, _values, result)
               # n+3, -n+3
        if val[0] == 'n'
          val.unshift("1")
          result = Node.new(:AN_PLUS_B, val)
        elsif val[0] == '-n'
          val[0] = 'n'
          val.unshift("-1")
          result = Node.new(:AN_PLUS_B, val)
        else
          raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
        end
      
    result
end

def _reduce_42(val, _values, result)
        if val[1] == 'n'
          val << "+"
          val << "0"
          result = Node.new(:AN_PLUS_B, val)
        else
          raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
        end
      
    result
end

def _reduce_43(val, _values, result)
        result = Node.new(:PSEUDO_CLASS, [val[1]])
      
    result
end

def _reduce_44(val, _values, result)
 result = Node.new(:PSEUDO_CLASS, [val[1]]) 
    result
end

# reduce 45 omitted

# reduce 46 omitted

def _reduce_47(val, _values, result)
        result = Node.new(:COMBINATOR, val)
      
    result
end

def _reduce_48(val, _values, result)
        result = Node.new(:COMBINATOR, val)
      
    result
end

def _reduce_49(val, _values, result)
        result = Node.new(:COMBINATOR, val)
      
    result
end

def _reduce_50(val, _values, result)
        result = Node.new(:COMBINATOR, val)
      
    result
end

# reduce 51 omitted

# reduce 52 omitted

# reduce 53 omitted

# reduce 54 omitted

def _reduce_55(val, _values, result)
 result = Node.new(:ID, val) 
    result
end

def _reduce_56(val, _values, result)
 result = [val.first, val[1]] 
    result
end

def _reduce_57(val, _values, result)
 result = [val.first, val[1]] 
    result
end

# reduce 58 omitted

def _reduce_59(val, _values, result)
 result = :equal 
    result
end

def _reduce_60(val, _values, result)
 result = :prefix_match 
    result
end

def _reduce_61(val, _values, result)
 result = :suffix_match 
    result
end

def _reduce_62(val, _values, result)
 result = :substring_match 
    result
end

def _reduce_63(val, _values, result)
 result = :not_equal 
    result
end

def _reduce_64(val, _values, result)
 result = :includes 
    result
end

def _reduce_65(val, _values, result)
 result = :dash_match 
    result
end

def _reduce_66(val, _values, result)
        result = Node.new(:NOT, [val[1]])
      
    result
end

# reduce 67 omitted

# reduce 68 omitted

# reduce 69 omitted

def _reduce_none(val, _values, result)
  val[0]
end

    end   # class Parser
    end   # module CSS
  end   # module Nokogiri
