putstring

This commit is contained in:
Torsten Ruger 2015-10-17 10:29:04 +03:00
parent b8dd2b257c
commit 0db8d87c09

View File

@ -1,121 +1,13 @@
include AST::Sexp
CODE =
s(:expressions,
s(:class, :Integer,
s(:derives, :Object),
s(:expressions,
s(:function, :ref,
s(:name, :digit),
s(:parameters,
s(:parameter, :int, :rest)),
s(:expressions,
s(:if,
s(:condition,
s(:operator, "==",
s(:name, :rest),
s(:int, 5))),
s(:if_true,
s(:return,
s(:string, "5"))),
s(:if_false, nil)),
s(:if,
s(:condition,
s(:operator, "==",
s(:name, :rest),
s(:int, 1))),
s(:if_true,
s(:return,
s(:string, "1"))),
s(:if_false, nil)),
s(:if,
s(:condition,
s(:operator, "==",
s(:name, :rest),
s(:int, 2))),
s(:if_true,
s(:return,
s(:string, "2"))),
s(:if_false, nil)),
s(:if,
s(:condition,
s(:operator, "==",
s(:name, :rest),
s(:int, 3))),
s(:if_true,
s(:return,
s(:string, "3"))),
s(:if_false, nil)),
s(:if,
s(:condition,
s(:operator, "==",
s(:name, :rest),
s(:int, 4))),
s(:if_true,
s(:return,
s(:string, "4"))),
s(:if_false, nil)))),
s(:function, :ref,
s(:name, :add_string),
s(:parameters,
s(:parameter, :ref, :str)),
s(:expressions,
s(:field_def, :int, :div),
s(:assign,
s(:name, :div),
s(:operator, "/",
s(:name, :self),
s(:int, 10))),
s(:field_def, :int, :rest),
s(:assign,
s(:name, :rest),
s(:operator, "-",
s(:name, :self),
s(:name, :div))),
s(:if,
s(:condition,
s(:operator, "<",
s(:name, :rest),
s(:int, 0))),
s(:if_true,
s(:assign,
s(:name, :str),
s(:operator, "+",
s(:name, :str),
s(:call,
s(:name, :digit),
s(:arguments,
s(:name, :rest)))))),
s(:if_false,
s(:assign,
s(:name, :str),
s(:call,
s(:name, :add_string),
s(:arguments,
s(:name, :str)),
s(:receiver,
s(:name, :div)))))),
s(:return,
s(:name, :str)))),
s(:function, :ref,
s(:name, :to_string),
s(:parameters),
s(:expressions,
s(:field_def, :ref, :start,
s(:string, " ")),
s(:return,
s(:call,
s(:name, :add_string),
s(:arguments,
s(:name, :start)))))))),
s(:class, :Object,
s(:derives, nil),
s(:expressions,
s(:function, :int,
s(:name, :main),
s(:parameters),
s(:expressions,
s(:call,
s(:name, :to_string),
s(:arguments),
s(:receiver,
s(:int, 5))))))))
CODE = s(:class, :Object,
s(:derives, nil),
s(:statements,
s(:function, :int,
s(:name, :main),
s(:parameters),
s(:statements,
s(:call,
s(:name, :putstring),
s(:arguments),
s(:receiver,
s(:string, "Hello again")))))))