Permalink
Browse files

Add ast graph output and a couple fixes.

  • Loading branch information...
1 parent c47781a commit 23b979719c1c5bef7614241097602fb8a3b4c8c4 @brixen committed Jul 29, 2010
Showing with 21 additions and 3 deletions.
  1. +5 −2 bin/poison
  2. +8 −0 lib/poison/systems/rbx/compiler/syntax.rb
  3. +8 −1 lib/poison/systems/rbx/library/code_loader.rb
View
@@ -12,6 +12,8 @@ class PoisonScript
@asts = []
@sexps = []
@parses = []
+ @source = nil
+ @script = nil
end
def options(argv=ARGV)
@@ -59,7 +61,7 @@ class PoisonScript
options.doc ""
rest = options.parse(argv)
- @source ||= rest.first
+ @script ||= rest.first
end
def evals
@@ -91,7 +93,8 @@ class PoisonScript
def script
return unless @script
- if File.exists? @scrip
+ if File.exists? @script
+
Poison::CodeLoader.execute_file @script
else
STDERR.puts "Unable to find '#{@script}' to run"
@@ -10,9 +10,17 @@ def to_sexp
@syntax.to_sexp
end
+ def graph
+ @syntax.graph
+ end
+
class Node
def to_sexp
end
+
+ def graph
+ Rubinius::AST::AsciiGrapher.new(self, Node).print
+ end
end
class Script < Node
@@ -1,9 +1,16 @@
module Poison
class CodeLoader
+ def self.execute_file(name)
+ source = File.read name
+ execute_script source
+ end
+
def self.execute_script(source)
compiler = Compiler.new source
ast = compiler.parse
- p ast
+
+ # just give some output for now
+ ast.graph
end
end
end

0 comments on commit 23b9797

Please sign in to comment.