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

require 'racc/parser.rb'

require File.expand_path(File.dirname(__FILE__)) +  '/lexer'

module BibTeX
  class Parser < Racc::Parser

module_eval(<<'...end bibtex.y/module_eval...', 'bibtex.y', 89)

  attr_reader :lexer
  
  def initialize(options={})
    @options = options
    @options[:include] ||= [:errors]
    @lexer = Lexer.new(options)
  end

  def parse(input)
    @yydebug = self.debug?
    
    self.lexer.src = input
    self.lexer.analyse
    
    do_parse
  end
  
  def next_token
    token = self.lexer.next_token
    if token[0] == :ERROR
      self.include_errors? ? token : next_token
    else
      [token[0],token[1][0]]
    end
  end
  
  def debug?
    @options[:debug] == true || ENV['DEBUG'] == true
  end
  
  def include_errors?
    @options[:include].include?(:errors)
  end
  
  def on_error(tid, val, vstack)
    #raise(ParseError, "Failed to parse BibTeX on value %s (%s) %s" % [val.inspect, token_to_str(tid) || '?', vstack.inspect])
    Log.error("Failed to parse BibTeX on value %s (%s) %s" % [val.inspect, token_to_str(tid) || '?', vstack.inspect])
  end

# -*- racc -*-
...end bibtex.y/module_eval...
##### State transition tables begin ###

racc_action_table = [
    13,    52,    37,    31,    49,    38,    15,    31,     8,    28,
     1,    12,    36,    28,     2,     1,    33,     5,    31,     2,
    31,    35,     5,    27,    28,    25,    28,    25,    23,    26,
    48,    40,    39,    42,    43,    44,    45,    46,    21,    20,
    53,    19,    17,    43,    35,    43,    57 ]

racc_action_check = [
     1,    38,    24,    38,    38,    25,     1,    43,     1,    38,
     4,     1,    24,    43,     4,     0,    20,     4,    45,     0,
    19,    21,     0,    17,    45,    14,    19,    37,    14,    15,
    37,    26,    26,    29,    29,    32,    33,    34,    13,    12,
    41,     8,     3,    51,    52,    55,    56 ]

racc_action_pointer = [
    13,    -4,   nil,    42,     8,   nil,   nil,   nil,    33,   nil,
   nil,   nil,    31,    30,    15,    21,   nil,    23,   nil,    10,
     6,    16,   nil,   nil,    -1,    -2,    21,   nil,   nil,    20,
   nil,   nil,    22,    29,    24,   nil,   nil,    17,    -7,   nil,
   nil,    37,   nil,    -3,   nil,     8,   nil,   nil,   nil,   nil,
   nil,    29,    39,   nil,   nil,    31,    33,   nil ]

racc_action_default = [
    -1,   -34,    -7,   -34,    -2,    -6,    -3,    -8,   -34,    -9,
   -10,   -11,   -34,   -34,   -34,   -34,    -5,   -34,    -4,   -34,
   -34,   -13,   -28,   -24,   -34,   -34,   -34,    58,   -21,   -34,
   -18,   -20,   -34,   -34,   -34,   -14,   -22,   -34,   -34,   -27,
   -26,   -34,   -15,   -34,   -16,   -34,   -12,   -29,   -23,   -32,
   -30,   -31,   -13,   -25,   -19,   -17,   -34,   -33 ]

racc_goto_table = [
    34,    29,    22,     6,     3,     9,    10,    18,    11,     7,
    16,    32,    54,    14,    24,    41,     4,    50,   nil,   nil,
    51,   nil,   nil,   nil,   nil,    47,   nil,    55,   nil,   nil,
   nil,    56 ]

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

racc_goto_pointer = [
   nil,     4,    16,     3,     9,     8,     4,     5,     7,   -21,
   -18,    -9,   -31,    12,     0,   -11,   -12,   -21 ]

racc_goto_default = [
   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
   nil,   nil,    30,   nil,   nil,   nil,   nil,   nil ]

racc_reduce_table = [
  0, 0, :racc_error,
  0, 18, :_reduce_1,
  1, 18, :_reduce_2,
  1, 19, :_reduce_3,
  2, 19, :_reduce_4,
  2, 20, :_reduce_5,
  1, 20, :_reduce_6,
  1, 20, :_reduce_7,
  1, 21, :_reduce_8,
  1, 21, :_reduce_9,
  1, 21, :_reduce_10,
  1, 21, :_reduce_11,
  4, 22, :_reduce_12,
  0, 26, :_reduce_13,
  1, 26, :_reduce_14,
  4, 24, :_reduce_15,
  4, 23, :_reduce_16,
  3, 28, :_reduce_17,
  1, 27, :_reduce_18,
  3, 27, :_reduce_19,
  1, 29, :_reduce_20,
  1, 29, :_reduce_21,
  3, 25, :_reduce_22,
  4, 25, :_reduce_23,
  2, 25, :_reduce_24,
  4, 30, :_reduce_25,
  1, 32, :_reduce_26,
  1, 32, :_reduce_27,
  1, 31, :_reduce_28,
  3, 31, :_reduce_29,
  3, 33, :_reduce_30,
  1, 34, :_reduce_31,
  1, 34, :_reduce_32,
  3, 34, :_reduce_33 ]

racc_reduce_n = 34

racc_shift_n = 58

racc_token_table = {
  false => 0,
  :error => 1,
  :AT => 2,
  :COMMA => 3,
  :COMMENT => 4,
  :CONTENT => 5,
  :ERROR => 6,
  :EQ => 7,
  :LBRACE => 8,
  :META_COMMENT => 9,
  :NAME => 10,
  :NUMBER => 11,
  :PREAMBLE => 12,
  :RBRACE => 13,
  :SHARP => 14,
  :STRING => 15,
  :STRING_LITERAL => 16 }

racc_nt_base = 17

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",
  "AT",
  "COMMA",
  "COMMENT",
  "CONTENT",
  "ERROR",
  "EQ",
  "LBRACE",
  "META_COMMENT",
  "NAME",
  "NUMBER",
  "PREAMBLE",
  "RBRACE",
  "SHARP",
  "STRING",
  "STRING_LITERAL",
  "$start",
  "bibliography",
  "objects",
  "object",
  "at_object",
  "comment",
  "string",
  "preamble",
  "entry",
  "content",
  "string_value",
  "string_assignment",
  "string_literal",
  "entry_head",
  "assignments",
  "key",
  "assignment",
  "value" ]

Racc_debug_parser = true

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

# reduce 0 omitted

module_eval(<<'.,.,', 'bibtex.y', 32)
  def _reduce_1(val, _values, result)
     result = Bibliography.new 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 33)
  def _reduce_2(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 35)
  def _reduce_3(val, _values, result)
     result = Bibliography.new << val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 36)
  def _reduce_4(val, _values, result)
     result << val[1] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 38)
  def _reduce_5(val, _values, result)
     result = val[1] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 39)
  def _reduce_6(val, _values, result)
     result = BibTeX::MetaComment.new(val[0]) 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 40)
  def _reduce_7(val, _values, result)
     result = BibTeX::Error.new(val[0]) 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 42)
  def _reduce_8(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 43)
  def _reduce_9(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 44)
  def _reduce_10(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 45)
  def _reduce_11(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 47)
  def _reduce_12(val, _values, result)
     result = BibTeX::Comment.new(val[2]) 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 49)
  def _reduce_13(val, _values, result)
     result = '' 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 50)
  def _reduce_14(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 52)
  def _reduce_15(val, _values, result)
     result = BibTeX::Preamble.new(val[2]) 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 54)
  def _reduce_16(val, _values, result)
     result = BibTeX::String.new(val[2][0],val[2][1]); 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 56)
  def _reduce_17(val, _values, result)
     result = [val[0].downcase.to_sym, val[2]] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 58)
  def _reduce_18(val, _values, result)
     result = [val[0]] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 59)
  def _reduce_19(val, _values, result)
     result << val[2] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 61)
  def _reduce_20(val, _values, result)
     result = val[0].downcase.to_sym 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 62)
  def _reduce_21(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 64)
  def _reduce_22(val, _values, result)
     result = val[0] << val[1] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 65)
  def _reduce_23(val, _values, result)
     result = val[0] << val[1] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 66)
  def _reduce_24(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 68)
  def _reduce_25(val, _values, result)
     result = BibTeX::Entry.new(val[0].downcase.to_sym,val[2]) 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 70)
  def _reduce_26(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 71)
  def _reduce_27(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 73)
  def _reduce_28(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 74)
  def _reduce_29(val, _values, result)
     result.merge!(val[2]) 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 76)
  def _reduce_30(val, _values, result)
     result = { val[0].downcase.to_sym => val[2] } 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 78)
  def _reduce_31(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 79)
  def _reduce_32(val, _values, result)
     result = val[0] 
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 80)
  def _reduce_33(val, _values, result)
     result = val[1] 
    result
  end
.,.,

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

  end   # class Parser
  end   # module BibTeX
