lib/shuwar/stdlib/base.rb in shuwar-1.2.0 vs lib/shuwar/stdlib/base.rb in shuwar-1.3.0

- old
+ new

@@ -1,6 +1,6 @@ -require "shuwar/stdlib" +require "shuwar" module Shuwar::Stdlib module Base VALUES = { load: lambda do |lib| @@ -15,9 +15,32 @@ vals.each {|a| p a} end, puts: lambda do |*vals| puts *vals + end, + + load_file: lambda do |name| + File.open name do |f| + tk = Shuwar::Tokenizer.new f + parser = Shuwar::Parser.new tk + runtime = Shuwar::Runtime.new + + parser.each_object do |x| + runtime.evaluate x + end + + runtime + end + end, + + fetch: lambda do |env, key| + env.get_value key + end, + + from_file: lambda do |name, key| + env = evaluate [:load_file, name] + env.get_value key end } MARCOS = { quote: lambda do |val| \ No newline at end of file