#
# DO NOT MODIFY!!!!
# This file is automatically generated by Racc 1.7.3
# from Racc grammar file "bibtex.y".
#

require 'racc/parser.rb'

require 'bibtex/lexer'

module BibTeX
  class Parser < Racc::Parser

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

  attr_reader :lexer, :options

  @defaults = {
    :include => [:errors],
    :allow_missing_keys => false,
    :debug => false
  }.freeze

  class << self
    attr_reader :defaults
  end

  def initialize(options = {})
    @options = Parser.defaults.merge(options)
    @lexer = Lexer.new(@options)
  end

  def parse(input)
    @yydebug = debug?

    lexer.analyse(input)
    do_parse
    #yyparse(@lexer,:each)
  end

  def next_token
    lexer.next_token
  end

  def debug?
    options[:debug] || ENV['DEBUG']
  end

  def allow_missing_keys?
    options[:allow_missing_keys]
  end

  def missing_key
    unless allow_missing_keys?
      raise ParseError, "Failed to parse BibTeX entry: cite-key missing"
    end
  end

  def on_error(tid, val, vstack)
    message =
      "Failed to parse BibTeX on value #{val.inspect} (#{token_to_str(tid) || '?'}) #{ vstack.inspect}"

    BibTeX.log.error message
    raise ParseError, message
  end

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

racc_action_table = [
    14,    33,    38,    26,    32,    26,    24,    18,    48,    15,
    34,    33,    16,    37,    32,    52,    33,     7,    33,    32,
    34,    32,     4,    19,     4,    34,     6,    34,     6,     5,
    20,     5,    43,    44,    21,    22,    27,    29,    36,    39,
    41,    42,    29,    46,    47,    54,    44,    44 ]

racc_action_check = [
     4,    21,    23,    17,    21,    38,    17,     4,    38,     4,
    21,    39,     4,    23,    39,    39,    44,     1,    47,    44,
    39,    47,     0,     7,     2,    44,     0,    47,     2,     0,
    14,     2,    30,    30,    15,    16,    18,    20,    22,    26,
    27,    28,    33,    35,    36,    45,    50,    55 ]

racc_action_pointer = [
    20,    17,    22,   nil,    -4,   nil,   nil,    23,   nil,   nil,
   nil,   nil,   nil,   nil,    22,    26,    27,    -8,    28,   nil,
    32,    -7,    27,    -1,   nil,   nil,    32,    30,    27,   nil,
    18,   nil,   nil,    37,   nil,    29,    37,   nil,    -6,     3,
   nil,   nil,   nil,   nil,     8,    31,   nil,    10,   nil,   nil,
    31,   nil,   nil,   nil,   nil,    32 ]

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

racc_goto_table = [
    30,    25,    28,     3,     1,     8,     2,     9,    10,    11,
    12,    13,    35,    53,    17,    45,    23,    40,    50,    51,
   nil,   nil,    49,   nil,   nil,   nil,    55 ]

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

racc_goto_pointer = [
   nil,     4,     6,     3,     3,     4,     5,     6,     7,   -18,
   -21,   -10,   -31,    10,    -1,   -10,   -16,   -20 ]

racc_goto_default = [
   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
   nil,   nil,    31,   nil,   nil,   nil,   nil,   nil ]

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

racc_reduce_n = 34

racc_shift_n = 56

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

racc_nt_base = 18

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 ]
Ractor.make_shareable(Racc_arg) if defined?(Ractor)

Racc_token_to_s_table = [
  "$end",
  "error",
  "AT",
  "COMMA",
  "COMMENT",
  "CONTENT",
  "ERROR",
  "EQ",
  "LBRACE",
  "META_CONTENT",
  "KEY",
  "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",
  "opt_key",
  "assignment",
  "value" ]
Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)

Racc_debug_parser = false

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

# reduce 0 omitted

module_eval(<<'.,.,', 'bibtex.y', 32)
  def _reduce_1(val, _values, result)
     result = BibTeX::Bibliography.new(@options)
    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 = BibTeX::Bibliography.new(@options) << 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::MetaContent.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[1]
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 63)
  def _reduce_22(val, _values, result)
     result = val[0]
    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] << val[1]
    result
  end
.,.,

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

module_eval(<<'.,.,', 'bibtex.y', 69)
  def _reduce_26(val, _values, result)
     result = BibTeX::Entry.new(:bibtex_type => val[0].downcase.to_sym, :bibtex_key => val[2])
    result
  end
.,.,

module_eval(<<'.,.,', 'bibtex.y', 71)
  def _reduce_27(val, _values, result)
     missing_key
    result
  end
.,.,

# reduce 28 omitted

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

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

module_eval(<<'.,.,', 'bibtex.y', 77)
  def _reduce_31(val, _values, result)
     result = { val[0].downcase.to_sym => val[2] }
    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[0]
    result
  end
.,.,

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

  end   # class Parser
end   # module BibTeX
