Sha256: 7066eb1e55a5a7aafd86fd3bfe42a90cc46deadc250f4b5eea9f3cc8c7fdafa5
Contents?: true
Size: 864 Bytes
Versions: 2
Compression:
Stored size: 864 Bytes
Contents
require 'hashie' require 'kaiser_ruby/parser' require 'kaiser_ruby/transformer' require 'kaiser_ruby/refinements' require 'pry' module KaiserRuby class RockstarSyntaxError < SyntaxError end def self.parse(input) # eat comments since we don't care about them input = input.gsub(/\n *\(.*?\) *\n/m, "\n\n") input = input.gsub(/\(.*?\)\s*\n/m, "\n").gsub(/ +/, ' ') parser = KaiserRuby::Parser.new(input) parser.parse end def self.transpile(input) tree = parse(input) KaiserRuby::Transformer.new(tree).transform end using KaiserRuby::Refinements def self.execute(input) with_captured_stdout do instance_eval transpile(input) end end private def self.with_captured_stdout old_stdout = $stdout $stdout = StringIO.new yield $stdout.string ensure $stdout = old_stdout end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kaiser-ruby-0.7.1 | lib/kaiser_ruby.rb |
kaiser-ruby-0.7 | lib/kaiser_ruby.rb |