nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
nitcc: remove warnings and improve doc
[nit.git]
/
contrib
/
nitcc
/
examples
/
minilang.nit
diff --git
a/contrib/nitcc/examples/minilang.nit
b/contrib/nitcc/examples/minilang.nit
index
4160f01
..
e316369
100644
(file)
--- a/
contrib/nitcc/examples/minilang.nit
+++ b/
contrib/nitcc/examples/minilang.nit
@@
-1,15
+1,23
@@
import minilang_test_parser
import minilang_test_parser
+# An naive recursive stack-based interpreter of the minilang language.
class Interpretor
super Visitor
class Interpretor
super Visitor
+
+ # A stack of numeric values
var stack = new Array[Int]
var stack = new Array[Int]
+
+ # A stack of boolean values
var bstack = new Array[Bool]
var bstack = new Array[Bool]
+
+ # The current values assigned to each variable
var vars = new HashMap[String, Int]
redef fun visit(n) do n.accept_calculator(self)
end
redef class Node
var vars = new HashMap[String, Int]
redef fun visit(n) do n.accept_calculator(self)
end
redef class Node
+ # Execution of the node by the interpreter `v`
fun accept_calculator(v: Interpretor) do visit_children(v)
end
fun accept_calculator(v: Interpretor) do visit_children(v)
end