Class: Refi::MinilangScript

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

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ MinilangScript



251
252
253
254
255
# File 'lib/minilang_refi.rb', line 251

def initialize(str)
  @parser = MinilangGrammarParser.new
  @parse_result = @parser.parse(str)
  @val = nil
end

Instance Method Details

#assert_validObject



260
261
262
263
264
265
# File 'lib/minilang_refi.rb', line 260

def assert_valid
  unless valid 
    report_errors
    dperr 1010,"#{self.class} assert_valid failed"
  end
end

#compute_valObject

TODO logger



270
271
272
# File 'lib/minilang_refi.rb', line 270

def compute_val
  @val = @parse_result.content
end

#get_valObject



273
274
275
# File 'lib/minilang_refi.rb', line 273

def get_val
  return @val || compute_val
end

#report_errorsObject



266
267
268
269
# File 'lib/minilang_refi.rb', line 266

def report_errors
  pp @parser.get_errors
   # TODO logger

end

#run(env) ⇒ Object



276
277
278
# File 'lib/minilang_refi.rb', line 276

def run env
  return @parse_result.run(env)
end

#validObject



256
257
258
259
# File 'lib/minilang_refi.rb', line 256

def valid
  return true if @parse_result
  return false
end