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