Module: RazyK

Defined in:
lib/razyk.rb,
lib/razyk/vm.rb,
lib/razyk/node.rb,
lib/razyk/parser.rb,
lib/razyk/webapp.rb,
lib/razyk/version.rb,
lib/razyk/application.rb

Defined Under Namespace

Modules: Audio Classes: Application, ApplicationError, Combinator, Node, Pair, Parser, VM, WebApp

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.run(program, opt = {}, &blk) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/razyk.rb', line 7

def self.run(program, opt={}, &blk)
  opt[:input] ||= $stdin
  if opt[:audio]
    opt[:output] = RazyK::Audio::Port.new
  else
    opt[:output] ||= $stdout
  end
  opt[:memory] ||= {}
  tree = Parser.parse(program, opt)
  root = Pair.new(:OUT, Pair.new(tree, :IN))
  vm = VM.new(root, opt[:input], opt[:output], recursive: opt[:recursive], statistics: opt[:statistics])

  if blk
    vm.run(&blk)
  else
    vm.run
  end
end