lib/bibtex/parser.rb in bibtex-ruby-1.2.1 vs lib/bibtex/parser.rb in bibtex-ruby-1.3.0
- old
+ new
@@ -13,36 +13,39 @@
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)
+ def initialize(options = {})
+ self.options.merge!(options)
+ @lexer = Lexer.new(@options)
end
+ def options
+ @options ||= { :include => [:errors], :debug => ENV['DEBUG'] == true }
+ end
+
def parse(input)
- @yydebug = self.debug?
+ @yydebug = debug?
- self.lexer.src = input
- self.lexer.analyse
+ @lexer.src = input
+ @lexer.analyse
do_parse
end
def next_token
- token = self.lexer.next_token
+ token = @lexer.next_token
if token[0] == :ERROR
- self.include_errors? ? token : next_token
+ include_errors? ? token : next_token
else
[token[0],token[1][0]]
end
end
def debug?
- @options[:debug] == true || ENV['DEBUG'] == true
+ @options[:debug] == true
end
def include_errors?
@options[:include].include?(:errors)
end
@@ -154,11 +157,11 @@
:COMMENT => 4,
:CONTENT => 5,
:ERROR => 6,
:EQ => 7,
:LBRACE => 8,
- :META_COMMENT => 9,
+ :META_CONTENT => 9,
:NAME => 10,
:NUMBER => 11,
:PREAMBLE => 12,
:RBRACE => 13,
:SHARP => 14,
@@ -193,11 +196,11 @@
"COMMENT",
"CONTENT",
"ERROR",
"EQ",
"LBRACE",
- "META_COMMENT",
+ "META_CONTENT",
"NAME",
"NUMBER",
"PREAMBLE",
"RBRACE",
"SHARP",
@@ -220,19 +223,19 @@
"assignments",
"key",
"assignment",
"value" ]
-Racc_debug_parser = true
+Racc_debug_parser = false
##### State transition tables end #####
# reduce 0 omitted
module_eval(<<'.,.,', 'bibtex.y', 32)
def _reduce_1(val, _values, result)
- result = Bibliography.new
+ result = BibTeX::Bibliography.new
result
end
.,.,
module_eval(<<'.,.,', 'bibtex.y', 33)
@@ -242,11 +245,11 @@
end
.,.,
module_eval(<<'.,.,', 'bibtex.y', 35)
def _reduce_3(val, _values, result)
- result = Bibliography.new << val[0]
+ result = BibTeX::Bibliography.new << val[0]
result
end
.,.,
module_eval(<<'.,.,', 'bibtex.y', 36)
@@ -263,10 +266,10 @@
end
.,.,
module_eval(<<'.,.,', 'bibtex.y', 39)
def _reduce_6(val, _values, result)
- result = BibTeX::MetaComment.new(val[0])
+ result = BibTeX::MetaContent.new(val[0])
result
end
.,.,
module_eval(<<'.,.,', 'bibtex.y', 40)