fix all the cases, much white noise, array to list, string to sym stuff

This commit is contained in:
Torsten Ruger 2015-09-19 14:53:30 +03:00
parent 3b0b91f2fb
commit 21b652456d
78 changed files with 690 additions and 559 deletions

View File

@ -1,3 +1,4 @@
FooBar
-- -- --
s(:list, [s(:module, "FooBar")])
s(:expressions,
s(:module, "FooBar"))

View File

@ -1,3 +1,4 @@
foo
-- -- --
s(:list, [s(:name, "foo")])
s(:expressions,
s(:name, :foo))

View File

@ -1,3 +1,4 @@
foo_bar
-- -- --
s(:list, [s(:name, "foo_bar")])
s(:expressions,
s(:name, :foo_bar))

View File

@ -1,3 +1,4 @@
_bar
-- -- --
s(:list, [s(:name, "_bar")])
s(:expressions,
s(:name, :_bar))

View File

@ -1,3 +1,4 @@
42
-- -- --
s(:list, [s(:int, 42)])
s(:expressions,
s(:int, 42))

View File

@ -1,3 +1,4 @@
"hello"
-- -- --
s(:list, [s(:string, "hello")])
s(:expressions,
s(:string, "hello"))

View File

@ -1,3 +1,4 @@
"hello \nyou"
-- -- --
s(:list, [s(:string, "hello \\nyou")])
s(:expressions,
s(:string, "hello \\nyou"))

View File

@ -1,7 +1,8 @@
puts(3 , a )
-- -- --
s(:list, [s(:call,
s(:name, "puts"),
s(:arguments,
s(:int, 3),
s(:name, "a")))])
s(:expressions,
s(:call,
s(:name, :puts),
s(:arguments,
s(:int, 3),
s(:name, :a))))

View File

@ -1,7 +1,8 @@
baz(42, foo)
-- -- --
s(:list, [s(:call,
s(:name, "baz"),
s(:arguments,
s(:int, 42),
s(:name, "foo")))])
s(:expressions,
s(:call,
s(:name, :baz),
s(:arguments,
s(:int, 42),
s(:name, :foo))))

View File

@ -1,6 +1,7 @@
puts( "hello")
-- -- --
s(:list, [s(:call,
s(:name, "puts"),
s(:arguments,
s(:string, "hello")))])
s(:expressions,
s(:call,
s(:name, :puts),
s(:arguments,
s(:string, "hello"))))

View File

@ -1,7 +1,8 @@
42.put()
-- -- --
s(:list, [s(:call,
s(:name, "put"),
s(:arguments),
s(:receiver,
s(:int, 42)))])
s(:expressions,
s(:call,
s(:name, :put),
s(:arguments),
s(:receiver,
s(:int, 42))))

View File

@ -1,6 +1,7 @@
puts( 5)
-- -- --
s(:list, [s(:call,
s(:name, "puts"),
s(:arguments,
s(:int, 5)))])
s(:expressions,
s(:call,
s(:name, :puts),
s(:arguments,
s(:int, 5))))

View File

@ -1,6 +1,7 @@
foo(42)
-- -- --
s(:list, [s(:call,
s(:name, "foo"),
s(:arguments,
s(:int, 42)))])
s(:expressions,
s(:call,
s(:name, :foo),
s(:arguments,
s(:int, 42))))

View File

@ -1,8 +1,9 @@
Object.foo(42)
-- -- --
s(:list, [s(:call,
s(:name, "foo"),
s(:arguments,
s(:int, 42)),
s(:receiver,
s(:module, "Object")))])
s(:expressions,
s(:call,
s(:name, :foo),
s(:arguments,
s(:int, 42)),
s(:receiver,
s(:module, "Object"))))

View File

@ -1,8 +1,9 @@
my_my.foo(42)
-- -- --
s(:list, [s(:call,
s(:name, "foo"),
s(:arguments,
s(:int, 42)),
s(:receiver,
s(:name, "my_my")))])
s(:expressions,
s(:call,
s(:name, :foo),
s(:arguments,
s(:int, 42)),
s(:receiver,
s(:name, :my_my))))

View File

@ -1,8 +1,9 @@
self.foo(42)
-- -- --
s(:list, [s(:call,
s(:name, "foo"),
s(:arguments,
s(:int, 42)),
s(:receiver,
s(:name, "self")))])
s(:expressions,
s(:call,
s(:name, :foo),
s(:arguments,
s(:int, 42)),
s(:receiver,
s(:name, :self))))

View File

@ -1,7 +1,8 @@
"hello".puts()
-- -- --
s(:list, [s(:call,
s(:name, "puts"),
s(:arguments),
s(:receiver,
s(:string, "hello")))])
s(:expressions,
s(:call,
s(:name, :puts),
s(:arguments),
s(:receiver,
s(:string, "hello"))))

View File

@ -2,9 +2,11 @@ class Foo < Object
ofthen(3 , var)
end
-- -- --
s(:list, [s(:class, "Foo",
s(:module, "Object"), [s(:call,
s(:name, "ofthen"),
s(:arguments,
s(:int, 3),
s(:name, "var")))])])
s(:expressions,
s(:class, :Foo,
s(:derives, :Object),
s(:call,
s(:name, :ofthen),
s(:arguments,
s(:int, 3),
s(:name, :var)))))

View File

@ -5,14 +5,18 @@ class Pifi
end
end
-- -- --
s(:list, [s(:class, "Pifi", nil, [s(:call,
s(:name, "ofthen"),
s(:arguments,
s(:int, 3),
s(:name, "var"))), s(:function, :int,
s(:name, "ofthen"),
s(:parameters,
s(:field, :int, :n),
s(:field, :ref, :m)),
s(:expressions,
s(:int, 44)))])])
s(:expressions,
s(:class, :Pifi,
s(:derives, nil),
s(:call,
s(:name, :ofthen),
s(:arguments,
s(:int, 3),
s(:name, :var))),
s(:function, :int,
s(:name, :ofthen),
s(:parameters,
s(:field, :int, :n),
s(:field, :ref, :m)),
s(:expressions,
s(:int, 44)))))

View File

@ -8,18 +8,21 @@ class Ifi
end
end
-- -- --
s(:list, [s(:class, "Ifi", nil, [s(:function, :int,
s(:name, "ofthen"),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:if,
s(:condition,
s(:int, 0)),
s(:if_true,
s(:assign,
s(:name, "isit"),
s(:int, 42))),
s(:if_false, [s(:assign,
s(:name, "maybenot"),
s(:int, 667))]))))])])
s(:expressions,
s(:class, :Ifi,
s(:derives, nil),
s(:function, :int,
s(:name, :ofthen),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:if,
s(:condition,
s(:int, 0)),
s(:if_true,
s(:assign,
s(:name, :isit),
s(:int, 42))),
s(:if_false, [s(:assign,
s(:name, :maybenot),
s(:int, 667))]))))))

View File

@ -1,7 +1,14 @@
class Foo < Object
int Foo.test()
int test()
43
end
end
-- -- --
{:expression_list=>[{:module_name=>"Foo", :derived_name=>s(:module, "Object"), :class_expressions=>[{:type=>"int", :receiver=>s(:module, "Foo"), :function_name=>s(:name, "test"), :parameter_list=>[], :expressions=>[s(:int, 43)], :end=>"end"}], :end=>"end"}]}
s(:expressions,
s(:class, :Foo,
s(:derives, :Object),
s(:function, :int,
s(:name, :test),
s(:parameters),
s(:expressions,
s(:int, 43)))))

View File

@ -4,8 +4,12 @@ class Foo
end
end
-- -- --
s(:list, [s(:class, "Foo", nil, [s(:module, "Boo", [s(:call,
s(:name, "funcall"),
s(:arguments,
s(:int, 3),
s(:name, "var")))])])])
s(:expressions,
s(:class, :Foo,
s(:derives, nil),
s(:module, :Boo,
s(:call,
s(:name, :funcall),
s(:arguments,
s(:int, 3),
s(:name, :var))))))

View File

@ -5,15 +5,18 @@ class Opers
end
end
-- -- --
s(:list, [s(:class, "Opers", nil, [s(:function, :int,
s(:name, "foo"),
s(:parameters,
s(:field, :int, :x)),
s(:expressions,
s(:name, "int"),
s(:assign,
s(:name, "abba"),
s(:int, 5)),
s(:operator, "+",
s(:name, "abba"),
s(:int, 5))))])])
s(:expressions,
s(:class, :Opers,
s(:derives, nil),
s(:function, :int,
s(:name, :foo),
s(:parameters,
s(:field, :int, :x)),
s(:expressions,
s(:name, :int),
s(:assign,
s(:name, :abba),
s(:int, 5)),
s(:operator, "+",
s(:name, :abba),
s(:int, 5))))))

View File

@ -2,4 +2,7 @@ class Foo
5
end
-- -- --
s(:list, [s(:class, "Foo", nil, [s(:int, 5)])])
s(:expressions,
s(:class, :Foo,
s(:derives, nil),
s(:int, 5)))

View File

@ -1,3 +1,6 @@
[42, foo]
-- -- --
s(:list, [s(:array, [s(:int, 42), s(:name, "foo")])])
s(:expressions,
s(:array,
s(:int, 42),
s(:name, :foo)))

View File

@ -1,8 +1,11 @@
[ 3 + 4 , foo(22) ]
-- -- --
s(:list, [s(:array, [s(:operator, "+",
s(:int, 3),
s(:int, 4)), s(:call,
s(:name, "foo"),
s(:arguments,
s(:int, 22)))])])
s(:expressions,
s(:array,
s(:operator, "+",
s(:int, 3),
s(:int, 4)),
s(:call,
s(:name, :foo),
s(:arguments,
s(:int, 22)))))

View File

@ -1,5 +1,7 @@
{ foo => 33 }
-- -- --
s(:list, [s(:hash, [s(:assoc,
s(:name, "foo"),
s(:int, 33))])])
s(:expressions,
s(:hash,
s(:assoc,
s(:name, :foo),
s(:int, 33))))

View File

@ -1,5 +1,7 @@
{ foo => true }
-- -- --
s(:list, [s(:hash, [s(:assoc,
s(:name, "foo"),
s(:true))])])
s(:expressions,
s(:hash,
s(:assoc,
s(:name, :foo),
s(:true))))

View File

@ -1,7 +1,10 @@
{foo => 33 , bar => 42}
-- -- --
s(:list, [s(:hash, [s(:assoc,
s(:name, "foo"),
s(:int, 33)), s(:assoc,
s(:name, "bar"),
s(:int, 42))])])
s(:expressions,
s(:hash,
s(:assoc,
s(:name, :foo),
s(:int, 33)),
s(:assoc,
s(:name, :bar),
s(:int, 42))))

View File

@ -1,3 +1,5 @@
[42]
-- -- --
s(:list, [s(:array, [s(:int, 42)])])
s(:expressions,
s(:array,
s(:int, 42)))

View File

@ -4,9 +4,10 @@ else
667
end
-- -- --
s(:list, [s(:if,
s(:condition,
s(:int, 0)),
s(:if_true,
s(:int, 42)),
s(:if_false, [s(:int, 667)]))])
s(:expressions,
s(:if,
s(:condition,
s(:int, 0)),
s(:if_true,
s(:int, 42)),
s(:if_false, [s(:int, 667)])))

View File

@ -4,21 +4,22 @@ else
var.new(33)
end
-- -- --
s(:list, [s(:if,
s(:condition,
s(:operator, ">",
s(:int, 3),
s(:name, "var"))),
s(:if_true,
s(:call,
s(:name, "initialize"),
s(:arguments,
s(:int, 3)),
s(:receiver,
s(:module, "Object")))),
s(:if_false, [s(:call,
s(:name, "new"),
s(:expressions,
s(:if,
s(:condition,
s(:operator, ">",
s(:int, 3),
s(:name, :var))),
s(:if_true,
s(:call,
s(:name, :initialize),
s(:arguments,
s(:int, 3)),
s(:receiver,
s(:module, "Object")))),
s(:if_false, [s(:call,
s(:name, :new),
s(:arguments,
s(:int, 33)),
s(:receiver,
s(:name, "var")))]))])
s(:name, :var)))])))

View File

@ -2,9 +2,10 @@ if(0)
42
end
-- -- --
s(:list, [s(:if,
s(:condition,
s(:int, 0)),
s(:if_true,
s(:int, 42)),
s(:if_false, nil))])
s(:expressions,
s(:if,
s(:condition,
s(:int, 0)),
s(:if_true,
s(:int, 42)),
s(:if_false, nil)))

View File

@ -2,16 +2,17 @@ if(3 > var)
Object.initialize(3)
end
-- -- --
s(:list, [s(:if,
s(:condition,
s(:operator, ">",
s(:int, 3),
s(:name, "var"))),
s(:if_true,
s(:call,
s(:name, "initialize"),
s(:arguments,
s(:int, 3)),
s(:receiver,
s(:module, "Object")))),
s(:if_false, nil))])
s(:expressions,
s(:if,
s(:condition,
s(:operator, ">",
s(:int, 3),
s(:name, :var))),
s(:if_true,
s(:call,
s(:name, :initialize),
s(:arguments,
s(:int, 3)),
s(:receiver,
s(:module, "Object")))),
s(:if_false, nil)))

View File

@ -1,5 +1,6 @@
a = 5
-- -- --
s(:list, [s(:assign,
s(:name, "a"),
s(:int, 5))])
s(:expressions,
s(:assign,
s(:name, :a),
s(:int, 5)))

View File

@ -1,5 +1,6 @@
a = 5
-- -- --
s(:list, [s(:assign,
s(:name, "a"),
s(:int, 5))])
s(:expressions,
s(:assign,
s(:name, :a),
s(:int, 5)))

View File

@ -1,5 +1,6 @@
a - b
-- -- --
s(:list, [s(:operator, "-",
s(:name, "a"),
s(:name, "b"))])
s(:expressions,
s(:operator, "-",
s(:name, :a),
s(:name, :b)))

View File

@ -1,5 +1,6 @@
a - 5
-- -- --
s(:list, [s(:operator, "-",
s(:name, "a"),
s(:int, 5))])
s(:expressions,
s(:operator, "-",
s(:name, :a),
s(:int, 5)))

View File

@ -1,5 +1,6 @@
a - "st"
-- -- --
s(:list, [s(:operator, "-",
s(:name, "a"),
s(:string, "st"))])
s(:expressions,
s(:operator, "-",
s(:name, :a),
s(:string, "st")))

View File

@ -1,5 +1,6 @@
a == true
-- -- --
s(:list, [s(:operator, "==",
s(:name, "a"),
s(:true))])
s(:expressions,
s(:operator, "==",
s(:name, :a),
s(:true)))

View File

@ -1,5 +1,6 @@
5 / 3
-- -- --
s(:list, [s(:operator, "/",
s(:int, 5),
s(:int, 3))])
s(:expressions,
s(:operator, "/",
s(:int, 5),
s(:int, 3)))

View File

@ -1,5 +1,6 @@
5 > 3
-- -- --
s(:list, [s(:operator, ">",
s(:int, 5),
s(:int, 3))])
s(:expressions,
s(:operator, ">",
s(:int, 5),
s(:int, 3)))

View File

@ -1,5 +1,6 @@
5 - 3
-- -- --
s(:list, [s(:operator, "-",
s(:int, 5),
s(:int, 3))])
s(:expressions,
s(:operator, "-",
s(:int, 5),
s(:int, 3)))

View File

@ -1,5 +1,6 @@
5 * 3
-- -- --
s(:list, [s(:operator, "*",
s(:int, 5),
s(:int, 3))])
s(:expressions,
s(:operator, "*",
s(:int, 5),
s(:int, 3)))

View File

@ -1,5 +1,6 @@
5 + 3
-- -- --
s(:list, [s(:operator, "+",
s(:int, 5),
s(:int, 3))])
s(:expressions,
s(:operator, "+",
s(:int, 5),
s(:int, 3)))

View File

@ -1,5 +1,6 @@
5 < 3
-- -- --
s(:list, [s(:operator, "<",
s(:int, 5),
s(:int, 3))])
s(:expressions,
s(:operator, "<",
s(:int, 5),
s(:int, 3)))

View File

@ -1,7 +1,8 @@
2 + 3 * 4
-- -- --
s(:list, [s(:operator, "+",
s(:int, 2),
s(:operator, "*",
s(:int, 3),
s(:int, 4)))])
s(:expressions,
s(:operator, "+",
s(:int, 2),
s(:operator, "*",
s(:int, 3),
s(:int, 4))))

View File

@ -1,7 +1,8 @@
2 * 3 + 4
-- -- --
s(:list, [s(:operator, "+",
s(:operator, "*",
s(:int, 2),
s(:int, 3)),
s(:int, 4))])
s(:expressions,
s(:operator, "+",
s(:operator, "*",
s(:int, 2),
s(:int, 3)),
s(:int, 4)))

View File

@ -1,7 +1,8 @@
2 + 3 + 4
-- -- --
s(:list, [s(:operator, "+",
s(:expressions,
s(:operator, "+",
s(:int, 2),
s(:int, 3)),
s(:int, 4))])
s(:operator, "+",
s(:int, 2),
s(:int, 3)),
s(:int, 4)))

View File

@ -1,5 +1,11 @@
int String.length( ref x )
int length( ref x )
length
end
-- -- --
{:expression_list=>[{:type=>"int", :receiver=>s(:module, "String"), :function_name=>s(:name, "length"), :parameter_list=>[s(:field, :ref, :x)], :expressions=>[s(:name, "length")], :end=>"end"}]}
s(:expressions,
s(:function, :int,
s(:name, :length),
s(:parameters,
s(:field, :ref, :x)),
s(:expressions,
s(:name, :length))))

View File

@ -10,40 +10,41 @@ int fibonaccit(int n)
end
end
-- -- --
s(:list, [s(:function, :int,
s(:name, "fibonaccit"),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:assign,
s(:name, "a"),
s(:int, 0)),
s(:assign,
s(:name, "b"),
s(:int, 1)),
s(:while,
s(:condition,
s(:operator, ">",
s(:name, "n"),
s(:int, 1))),
s(:expressions,
s(:assign,
s(:name, "tmp"),
s(:name, "a")),
s(:assign,
s(:name, "a"),
s(:name, "b")),
s(:assign,
s(:name, "b"),
s(:operator, "+",
s(:name, "tmp"),
s(:name, "b"))),
s(:call,
s(:name, "puts"),
s(:arguments,
s(:name, "b"))),
s(:assign,
s(:name, "n"),
s(:operator, "-",
s(:name, "n"),
s(:int, 1)))))))])
s(:expressions,
s(:function, :int,
s(:name, :fibonaccit),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:assign,
s(:name, :a),
s(:int, 0)),
s(:assign,
s(:name, :b),
s(:int, 1)),
s(:while,
s(:condition,
s(:operator, ">",
s(:name, :n),
s(:int, 1))),
s(:expressions,
s(:assign,
s(:name, :tmp),
s(:name, :a)),
s(:assign,
s(:name, :a),
s(:name, :b)),
s(:assign,
s(:name, :b),
s(:operator, "+",
s(:name, :tmp),
s(:name, :b))),
s(:call,
s(:name, :puts),
s(:arguments,
s(:name, :b))),
s(:assign,
s(:name, :n),
s(:operator, "-",
s(:name, :n),
s(:int, 1))))))))

View File

@ -6,18 +6,19 @@ ref ofthen(int n)
end
end
-- -- --
s(:list, [s(:function, :ref,
s(:name, "ofthen"),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:if,
s(:condition,
s(:int, 0)),
s(:if_true,
s(:assign,
s(:name, "isit"),
s(:int, 42))),
s(:if_false, [s(:assign,
s(:name, "maybenot"),
s(:int, 667))]))))])
s(:expressions,
s(:function, :ref,
s(:name, :ofthen),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:if,
s(:condition,
s(:int, 0)),
s(:if_true,
s(:assign,
s(:name, :isit),
s(:int, 42))),
s(:if_false, [s(:assign,
s(:name, :maybenot),
s(:int, 667))])))))

View File

@ -2,8 +2,9 @@ int foo()
5
end
-- -- --
s(:list, [s(:function, :int,
s(:name, "foo"),
s(:parameters),
s(:expressions,
s(:int, 5)))])
s(:expressions,
s(:function, :int,
s(:name, :foo),
s(:parameters),
s(:expressions,
s(:int, 5))))

View File

@ -3,15 +3,16 @@ int foo(int x)
abba + 5
end
-- -- --
s(:list, [s(:function, :int,
s(:name, "foo"),
s(:parameters,
s(:field, :int, :x)),
s(:expressions,
s(:name, "int"),
s(:assign,
s(:name, "abba"),
s(:int, 5)),
s(:operator, "+",
s(:name, "abba"),
s(:int, 5))))])
s(:expressions,
s(:function, :int,
s(:name, :foo),
s(:parameters,
s(:field, :int, :x)),
s(:expressions,
s(:name, :int),
s(:assign,
s(:name, :abba),
s(:int, 5)),
s(:operator, "+",
s(:name, :abba),
s(:int, 5)))))

View File

@ -3,14 +3,15 @@ int retvar(ref n)
return i
end
-- -- --
s(:list, [s(:function, :int,
s(:name, "retvar"),
s(:parameters,
s(:field, :ref, :n)),
s(:expressions,
s(:name, "int"),
s(:assign,
s(:name, "i"),
s(:int, 5)),
s(:return,
s(:name, "i"))))])
s(:expressions,
s(:function, :int,
s(:name, :retvar),
s(:parameters,
s(:field, :ref, :n)),
s(:expressions,
s(:name, :int),
s(:assign,
s(:name, :i),
s(:int, 5)),
s(:return,
s(:name, :i)))))

View File

@ -6,18 +6,19 @@ int retvar(int n)
end
end
-- -- --
s(:list, [s(:function, :int,
s(:name, "retvar"),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:if,
s(:condition,
s(:operator, ">",
s(:name, "n"),
s(:int, 5))),
s(:if_true,
s(:return,
s(:int, 10))),
s(:if_false, [s(:return,
s(:int, 20))]))))])
s(:expressions,
s(:function, :int,
s(:name, :retvar),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:if,
s(:condition,
s(:operator, ">",
s(:name, :n),
s(:int, 5))),
s(:if_true,
s(:return,
s(:int, 10))),
s(:if_false, [s(:return,
s(:int, 20))])))))

View File

@ -5,21 +5,22 @@ int retvar(int n )
end
end
-- -- --
s(:list, [s(:function, :int,
s(:name, "retvar"),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:while,
s(:condition,
s(:operator, ">",
s(:name, "n"),
s(:int, 5))),
s(:expressions,
s(:assign,
s(:name, "n"),
s(:operator, "+",
s(:name, "n"),
s(:int, 1))),
s(:return,
s(:name, "n"))))))])
s(:expressions,
s(:function, :int,
s(:name, :retvar),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:while,
s(:condition,
s(:operator, ">",
s(:name, :n),
s(:int, 5))),
s(:expressions,
s(:assign,
s(:name, :n),
s(:operator, "+",
s(:name, :n),
s(:int, 1))),
s(:return,
s(:name, :n)))))))

View File

@ -2,10 +2,11 @@ int foo( int n ,ref m)
n
end
-- -- --
s(:list, [s(:function, :int,
s(:name, "foo"),
s(:parameters,
s(:field, :int, :n),
s(:field, :ref, :m)),
s(:expressions,
s(:name, "n")))])
s(:expressions,
s(:function, :int,
s(:name, :foo),
s(:parameters,
s(:field, :int, :n),
s(:field, :ref, :m)),
s(:expressions,
s(:name, :n))))

View File

@ -6,23 +6,24 @@ ref fibonaccit(int n)
end
end
-- -- --
s(:list, [s(:function, :ref,
s(:name, "fibonaccit"),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:assign,
s(:name, "a"),
s(:int, 0)),
s(:while,
s(:condition,
s(:name, "n")),
s(:expressions,
s(:assign,
s(:name, "some"),
s(:int, 43)),
s(:assign,
s(:name, "other"),
s(:operator, "*",
s(:name, "some"),
s(:int, 4)))))))])
s(:expressions,
s(:function, :ref,
s(:name, :fibonaccit),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:assign,
s(:name, :a),
s(:int, 0)),
s(:while,
s(:condition,
s(:name, :n)),
s(:expressions,
s(:assign,
s(:name, :some),
s(:int, 43)),
s(:assign,
s(:name, :other),
s(:operator, "*",
s(:name, :some),
s(:int, 4))))))))

View File

@ -2,9 +2,10 @@ int foo(ref x)
5
end
-- -- --
s(:list, [s(:function, :int,
s(:name, "foo"),
s(:parameters,
s(:field, :ref, :x)),
s(:expressions,
s(:int, 5)))])
s(:expressions,
s(:function, :int,
s(:name, :foo),
s(:parameters,
s(:field, :ref, :x)),
s(:expressions,
s(:int, 5))))

View File

@ -2,6 +2,8 @@ module Opers
abba = 5
end
-- -- --
s(:list, [s(:module, "Opers", [s(:assign,
s(:name, "abba"),
s(:int, 5))])])
s(:expressions,
s(:module, :Opers,
s(:assign,
s(:name, :abba),
s(:int, 5))))

View File

@ -4,8 +4,12 @@ module Foo
end
end
-- -- --
s(:list, [s(:module, "Foo", [s(:class, "Bar", nil, [s(:call,
s(:name, "funcall"),
s(:arguments,
s(:int, 3),
s(:name, "var")))])])])
s(:expressions,
s(:module, :Foo,
s(:class, :Bar,
s(:derives, nil),
s(:call,
s(:name, :funcall),
s(:arguments,
s(:int, 3),
s(:name, :var))))))

View File

@ -5,15 +5,18 @@ module Soho
end
end
-- -- --
s(:list, [s(:module, "Soho", [s(:call,
s(:name, "ofthen"),
s(:arguments,
s(:int, 3),
s(:name, "var"))), s(:function, :int,
s(:name, "ofthen"),
s(:parameters,
s(:field, :int, :n),
s(:field, :ref, :m)),
s(:expressions,
s(:return,
s(:int, 44))))])])
s(:expressions,
s(:module, :Soho,
s(:call,
s(:name, :ofthen),
s(:arguments,
s(:int, 3),
s(:name, :var))),
s(:function, :int,
s(:name, :ofthen),
s(:parameters,
s(:field, :int, :n),
s(:field, :ref, :m)),
s(:expressions,
s(:return,
s(:int, 44))))))

View File

@ -8,18 +8,20 @@ module Foo
end
end
-- -- --
s(:list, [s(:module, "Foo", [s(:function, :ref,
s(:name, "ofthen"),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:if,
s(:condition,
s(:int, 0)),
s(:if_true,
s(:assign,
s(:name, "isit"),
s(:int, 42))),
s(:if_false, [s(:assign,
s(:name, "maybenot"),
s(:int, 667))]))))])])
s(:expressions,
s(:module, :Foo,
s(:function, :ref,
s(:name, :ofthen),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:if,
s(:condition,
s(:int, 0)),
s(:if_true,
s(:assign,
s(:name, :isit),
s(:int, 42))),
s(:if_false, [s(:assign,
s(:name, :maybenot),
s(:int, 667))]))))))

View File

@ -5,16 +5,18 @@ module Opers
end
end
-- -- --
s(:list, [s(:module, "Opers", [s(:function, :int,
s(:name, "foo"),
s(:parameters,
s(:field, :int, :x)),
s(:expressions,
s(:name, "int"),
s(:assign,
s(:name, "abba"),
s(:int, 5)),
s(:return,
s(:operator, "+",
s(:name, "abba"),
s(:int, 5)))))])])
s(:expressions,
s(:module, :Opers,
s(:function, :int,
s(:name, :foo),
s(:parameters,
s(:field, :int, :x)),
s(:expressions,
s(:name, :int),
s(:assign,
s(:name, :abba),
s(:int, 5)),
s(:return,
s(:operator, "+",
s(:name, :abba),
s(:int, 5)))))))

View File

@ -2,4 +2,6 @@ module Simple
5
end
-- -- --
s(:list, [s(:module, "Simple", [s(:int, 5)])])
s(:expressions,
s(:module, :Simple,
s(:int, 5)))

View File

@ -1,4 +1,5 @@
return 42
-- -- --
s(:list, [s(:return,
s(:int, 42))])
s(:expressions,
s(:return,
s(:int, 42)))

View File

@ -1,4 +1,5 @@
return "hello"
-- -- --
s(:list, [s(:return,
s(:string, "hello"))])
s(:expressions,
s(:return,
s(:string, "hello")))

View File

@ -1,4 +1,5 @@
return foo
-- -- --
s(:list, [s(:return,
s(:name, "foo"))])
s(:expressions,
s(:return,
s(:name, :foo)))

View File

@ -3,9 +3,12 @@ class FooBo
end
-- -- --
s(:list, [s(:class, "FooBo", nil, [s(:call,
s(:name, "call"),
s(:arguments,
s(:int, 35)),
s(:receiver,
s(:module, "Bar")))])])
s(:expressions,
s(:class, :FooBo,
s(:derives, nil),
s(:call,
s(:name, :call),
s(:arguments,
s(:int, 35)),
s(:receiver,
s(:module, "Bar")))))

View File

@ -4,14 +4,16 @@ end
foo( 3 )
-- -- --
s(:list, [s(:function, :int,
s(:name, "foo"),
s(:parameters,
s(:field, :ref, :x)),
s(:expressions,
s(:assign,
s(:name, "a"),
s(:int, 5)))), s(:call,
s(:name, "foo"),
s(:arguments,
s(:int, 3)))])
s(:expressions,
s(:function, :int,
s(:name, :foo),
s(:parameters,
s(:field, :ref, :x)),
s(:expressions,
s(:assign,
s(:name, :a),
s(:int, 5)))),
s(:call,
s(:name, :foo),
s(:arguments,
s(:int, 3))))

View File

@ -12,43 +12,45 @@ end
fibonaccit( 10 )
-- -- --
s(:list, [s(:function, :int,
s(:name, "fibonaccit"),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:assign,
s(:name, "a"),
s(:int, 0)),
s(:assign,
s(:name, "b"),
s(:int, 1)),
s(:while,
s(:condition,
s(:operator, ">",
s(:name, "n"),
s(:int, 1))),
s(:expressions,
s(:assign,
s(:name, "tmp"),
s(:name, "a")),
s(:assign,
s(:name, "a"),
s(:name, "b")),
s(:assign,
s(:name, "b"),
s(:operator, "+",
s(:name, "tmp"),
s(:name, "b"))),
s(:call,
s(:name, "puts"),
s(:arguments,
s(:name, "b"))),
s(:assign,
s(:name, "n"),
s(:operator, "-",
s(:name, "n"),
s(:int, 1))))))), s(:call,
s(:name, "fibonaccit"),
s(:arguments,
s(:int, 10)))])
s(:expressions,
s(:function, :int,
s(:name, :fibonaccit),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:assign,
s(:name, :a),
s(:int, 0)),
s(:assign,
s(:name, :b),
s(:int, 1)),
s(:while,
s(:condition,
s(:operator, ">",
s(:name, :n),
s(:int, 1))),
s(:expressions,
s(:assign,
s(:name, :tmp),
s(:name, :a)),
s(:assign,
s(:name, :a),
s(:name, :b)),
s(:assign,
s(:name, :b),
s(:operator, "+",
s(:name, :tmp),
s(:name, :b))),
s(:call,
s(:name, :puts),
s(:arguments,
s(:name, :b))),
s(:assign,
s(:name, :n),
s(:operator, "-",
s(:name, :n),
s(:int, 1))))))),
s(:call,
s(:name, :fibonaccit),
s(:arguments,
s(:int, 10))))

View File

@ -4,13 +4,16 @@ module Fibo
end
-- -- --
s(:list, [s(:module, "Fibo", [s(:assign,
s(:name, "a"),
s(:operator, "+",
s(:int, 5),
s(:name, "foo"))), s(:call,
s(:name, "bar"),
s(:arguments,
s(:name, "b"),
s(:name, "a"),
s(:name, "r")))])])
s(:expressions,
s(:module, :Fibo,
s(:assign,
s(:name, :a),
s(:operator, "+",
s(:int, 5),
s(:name, :foo))),
s(:call,
s(:name, :bar),
s(:arguments,
s(:name, :b),
s(:name, :a),
s(:name, :r)))))

View File

@ -8,17 +8,20 @@ module Fibo
end
-- -- --
s(:list, [s(:module, "Fibo", [s(:function, :int,
s(:name, "fibonaccit"),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:name, "int"),
s(:assign,
s(:name, "a"),
s(:int, 0)),
s(:return,
s(:name, "a")))), s(:call,
s(:name, "fibonaccit"),
s(:arguments,
s(:int, 10)))])])
s(:expressions,
s(:module, :Fibo,
s(:function, :int,
s(:name, :fibonaccit),
s(:parameters,
s(:field, :int, :n)),
s(:expressions,
s(:name, :int),
s(:assign,
s(:name, :a),
s(:int, 0)),
s(:return,
s(:name, :a)))),
s(:call,
s(:name, :fibonaccit),
s(:arguments,
s(:int, 10)))))

View File

@ -5,8 +5,12 @@ module FooBo
end
-- -- --
s(:list, [s(:module, "FooBo", [s(:class, "Bar", nil, [s(:assign,
s(:name, "a"),
s(:operator, "+",
s(:int, 5),
s(:name, "foo")))])])])
s(:expressions,
s(:module, :FooBo,
s(:class, :Bar,
s(:derives, nil),
s(:assign,
s(:name, :a),
s(:operator, "+",
s(:int, 5),
s(:name, :foo))))))

View File

@ -6,29 +6,30 @@ while( n > 1)
n = n - 1
end
-- -- --
s(:list, [s(:while,
s(:condition,
s(:operator, ">",
s(:name, "n"),
s(:int, 1))),
s(:expressions,
s(:assign,
s(:name, "tmp"),
s(:name, "a")),
s(:assign,
s(:name, "a"),
s(:name, "b")),
s(:assign,
s(:name, "b"),
s(:operator, "+",
s(:name, "tmp"),
s(:name, "b"))),
s(:call,
s(:name, "puts"),
s(:arguments,
s(:name, "b"))),
s(:assign,
s(:name, "n"),
s(:operator, "-",
s(:name, "n"),
s(:int, 1)))))])
s(:expressions,
s(:while,
s(:condition,
s(:operator, ">",
s(:name, :n),
s(:int, 1))),
s(:expressions,
s(:assign,
s(:name, :tmp),
s(:name, :a)),
s(:assign,
s(:name, :a),
s(:name, :b)),
s(:assign,
s(:name, :b),
s(:operator, "+",
s(:name, :tmp),
s(:name, :b))),
s(:call,
s(:name, :puts),
s(:arguments,
s(:name, :b))),
s(:assign,
s(:name, :n),
s(:operator, "-",
s(:name, :n),
s(:int, 1))))))

View File

@ -3,14 +3,15 @@ while(1)
puts(b)
end
-- -- --
s(:list, [s(:while,
s(:condition,
s(:int, 1)),
s(:expressions,
s(:assign,
s(:name, "tmp"),
s(:name, "a")),
s(:call,
s(:name, "puts"),
s(:arguments,
s(:name, "b")))))])
s(:expressions,
s(:while,
s(:condition,
s(:int, 1)),
s(:expressions,
s(:assign,
s(:name, :tmp),
s(:name, :a)),
s(:call,
s(:name, :puts),
s(:arguments,
s(:name, :b))))))

View File

@ -3,20 +3,21 @@ while(1)
tmp.puts(i)
end
-- -- --
s(:list, [s(:while,
s(:condition,
s(:int, 1)),
s(:expressions,
s(:assign,
s(:name, "tmp"),
s(:expressions,
s(:while,
s(:condition,
s(:int, 1)),
s(:expressions,
s(:assign,
s(:name, :tmp),
s(:call,
s(:name, :new),
s(:arguments),
s(:receiver,
s(:module, "String")))),
s(:call,
s(:name, "new"),
s(:arguments),
s(:name, :puts),
s(:arguments,
s(:name, :i)),
s(:receiver,
s(:module, "String")))),
s(:call,
s(:name, "puts"),
s(:arguments,
s(:name, "i")),
s(:receiver,
s(:name, "tmp")))))])
s(:name, :tmp))))))