Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ Assigns AST

  • Loading branch information...
commit 1e95a97415a5a3183d8a9968226869754f2c922a 1 parent 88c4c17
@kschiess authored
View
3  lib/wt/ast.rb
@@ -6,4 +6,7 @@ class IntLit < Struct.new(:int)
class Expression < Struct.new(:left, :op, :right)
end
+
+ class Assign < Struct.new(:ident, :exp)
+ end
end
View
3  lib/wt/transform.rb
@@ -6,5 +6,6 @@ class Wt::Transform < Parslet::Transform
IntLit.new(Integer(int)) }
rule(left: simple(:left), op: simple(:op), right: simple(:right)) {
Expression.new(left, op, right) }
-
+ rule(ident: simple(:ident), exp: simple(:exp)) {
+ Assign.new(ident, exp) }
end
View
5 spec/wt/transform_spec.rb
@@ -16,4 +16,9 @@
it { should == Expression.new('l', '+', 'r') }
end
+ describe "assignments (ident: 'a', exp: ...)" do
+ let(:tree) { {ident: 'a', exp: 'e'} }
+
+ it { should == Assign.new('a', 'e') }
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.