Permalink
Browse files

Fix keyword symbols (like #foo:bar:)

  • Loading branch information...
1 parent 52fa78b commit 4ca01a096beaceea62f9770bed93c627a4c4a34b @rkh committed Jan 19, 2011
Showing with 19 additions and 5 deletions.
  1. +15 −5 bin/reak
  2. +4 −0 lib/reak/parser/transformer.rb
View
@@ -10,7 +10,7 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'reak'
require 'pp'
-ast, sexp, bench, syntax, evals = false, false, false, :reak, []
+ast, sexp, bench, syntax, show_tree, evals = false, false, false, :reak, false, []
options = Rubinius::Options.new "Usage: #$0 [options] [script]", 20
@@ -30,15 +30,19 @@ options.on "-s", "SYNTAX", "What SYNTAX to use (ansi, gst, reak)" do |s|
syntax = s.to_sym
end
+options.on "-B", "Benchmark parsing" do
+ bench = true
+end
+
+options.on "-T", "Show parse result (use this if -A fails)" do
+ show_tree = true
+end
+
options.on "-h", "--help", "Display this help" do
puts options
exit 0
end
-options.on "-B", "Benchmark parsing" do
- bench = true
-end
-
file = options.parse(ARGV).first
display = proc do |code|
@@ -53,6 +57,12 @@ display = proc do |code|
tree = parser.parse(code)
end
+ if show_tree
+ puts "========= TREE ========"
+ pp tree
+ puts "------------------------"
+ end
+
if ast
puts "========= AST ========="
tree.graph
@@ -21,6 +21,10 @@ def self.arglist(list)
Reak::Syntax::Symbol.new(value)
end
+ rule :symbol => subtree(:values) do
+ Reak::Syntax::Symbol.new values.map { |v| v[:keyword] }.join
+ end
+
rule :character => simple(:character) do
Reak::Syntax::Character.new(character)
end

0 comments on commit 4ca01a0

Please sign in to comment.