Class: Calyx::Format::JSONGrammar

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

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ JSONGrammar

Returns a new instance of JSONGrammar.



32
33
34
35
36
37
# File 'lib/calyx/format.rb', line 32

def initialize(filename)
  require 'json'
  @filename = filename
  @contents = File.read(@filename)
  @rules = JSON.parse(@contents)
end

Instance Method Details

#each_rule(&block) ⇒ Object



39
40
41
42
43
# File 'lib/calyx/format.rb', line 39

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