Module: YABFI

Defined in:
lib/yabfi.rb,
lib/yabfi/lexer.rb,
lib/yabfi/parser.rb,
lib/yabfi/unroll.rb,
lib/yabfi/encoder.rb,
lib/yabfi/version.rb,
lib/yabfi/consumer.rb

Overview

YABFI is the top level module for the gem.

Defined Under Namespace

Modules: Encoder, Parser, Unroll Classes: Consumer, Lexer, VM

Constant Summary collapse

BaseError =

This is the base error for the gem from which the rest of the errors subclass.

Class.new(StandardError)
VERSION =

Gem (semantic) version.

'0.1.2'

Class Method Summary collapse

Class Method Details

.eval!(commands, input: $stdin, output: $stdout, eof: 0) ⇒ Object

Evaluate an IO of commands

Parameters:

  • commands (String, IO)

    the commands to execute.

  • input (IO) (defaults to: $stdin)

    the input from which the commands read.

  • output (IO) (defaults to: $stdout)

    the output to which the commands write.

  • eof (Integer) (defaults to: 0)

    the value to set when EOF is reached.

Raises:

  • (BaseError)

    when there is a compiling or execution error.



18
19
20
21
22
23
24
25
26
27
# File 'lib/yabfi.rb', line 18

def eval!(commands, input: $stdin, output: $stdout, eof: 0)
  io = commands.is_a?(String) ? StringIO.new(commands) : commands
  tokens = Parser.parse(io)
  lexed = Lexer.run!(tokens.to_a)
  commands = Unroll.unroll(lexed)
  encoded = Encoder.encode(commands)
  vm = VM.new(input, output, eof)
  vm.load!(encoded)
  vm.execute!
end