Class: Calyx::Format::YAMLGrammar

Inherits:
Object
  • Object
show all
Defined in:
lib/calyx/format.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ YAMLGrammar

Returns a new instance of YAMLGrammar.



47
48
49
50
51
52
# File 'lib/calyx/format.rb', line 47

def initialize(filename)
  require 'yaml'
  @filename = filename
  @contents = File.read(@filename)
  @rules = YAML.load(@contents)
end

Instance Method Details

#each_rule(&block) ⇒ Object



54
55
56
57
58
# File 'lib/calyx/format.rb', line 54

def each_rule(&block)
  @rules.each do |rule, productions|
    yield rule, productions, Trace.new(/#{rule}:/, @filename, @contents)
  end
end