# # DO NOT MODIFY!!!! # This file is automatically generated by Racc 1.4.9 # from Racc grammer file "". # 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, 33, 24, 18, 32, 15, 34, 39, 16, 37, 34, 33, 33, 36, 32, 32, 52, 27, 4, 4, 34, 34, 6, 6, 26, 5, 5, 48, 43, 44, 29, 41, 42, 22, 29, 46, 47, 21, 20, 19, 54, 7, 44, 44 ] racc_action_check = [ 4, 21, 23, 17, 21, 47, 17, 4, 47, 4, 21, 26, 4, 23, 47, 44, 39, 22, 44, 39, 39, 18, 0, 2, 44, 39, 0, 2, 38, 0, 2, 38, 30, 30, 20, 27, 28, 16, 33, 35, 36, 15, 14, 7, 45, 1, 50, 55 ] racc_action_pointer = [ 20, 45, 21, nil, -4, nil, nil, 43, nil, nil, nil, nil, nil, nil, 34, 33, 29, -8, 13, nil, 29, -7, 6, -1, nil, nil, 4, 25, 22, nil, 18, nil, nil, 33, nil, 25, 33, nil, 17, 8, nil, nil, nil, nil, 7, 30, nil, -3, 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, 11, 12, 13, 10, 9, 35, 53, 17, 23, 45, 40, 2, 50, 51, nil, nil, 49, nil, nil, nil, 55 ] racc_goto_check = [ 10, 16, 9, 3, 1, 3, 6, 7, 8, 5, 4, 11, 12, 13, 14, 9, 15, 2, 10, 17, nil, nil, 16, nil, nil, nil, 10 ] racc_goto_pointer = [ nil, 4, 17, 3, 6, 5, 2, 3, 4, -18, -21, -11, -32, 9, -3, -11, -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 ] 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" ] 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(:type => val[0].downcase.to_sym, :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