Class: Bibtex::RuleSet

Inherits:
Object
  • Object
show all
Defined in:
lib/bibtex/lexer.rb

Instance Method Summary collapse

Constructor Details

#initializeRuleSet

Returns a new instance of RuleSet.



19
20
21
# File 'lib/bibtex/lexer.rb', line 19

def initialize
  @rules = []
end

Instance Method Details

#eachObject



33
34
35
36
37
# File 'lib/bibtex/lexer.rb', line 33

def each
  @rules.each do |pair|
    yield pair[0], pair[1]
  end
end

#literals(words) ⇒ Object



27
28
29
30
31
# File 'lib/bibtex/lexer.rb', line 27

def literals(words)
  words.each do |w|
    match /#{w}/, w
  end
end

#match(regexp, result) ⇒ Object



23
24
25
# File 'lib/bibtex/lexer.rb', line 23

def match(regexp, result)
  @rules << [regexp, result]
end