Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlogolas.nit
More file actions
Latest commit
77 lines (62 loc) · 1.07 KB
/
Copy pathlogolas.nit
File metadata and controls
77 lines (62 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
modulelogolas
importlogolas_parser
importlogolas_lexer
importlogolas_test_parser
classInterp
superVisitor
varx = 0
vary = 0
varangle = 0
redeffunvisit(node) do
node.accept(self)
#print "{x}, {y} @ {angle}"
end
end
redefclassNode
funaccept(v: Interp) dovisit_children(v)
end
redefclassNn
funvalue: Int
do
returntext.first.code_point - 'Ⅰ'.code_point + 1
end
end
redefclassNcmd_fw
redeffunaccept(v)
do
varn = n_n.value.to_f
vara = v.angle.to_f / 6.0 * pi
v.x += (a.cos * n).to_i
v.y -= (a.sin * n).to_i
end
end
redefclassNcmd_tl
redeffunaccept(v)
do
varn = n_n.value
v.angle += n
end
end
redefclassNcmd_tr
redeffunaccept(v)
do
varn = n_n.value
v.angle -= n
end
end
redefclassNcmd_rp
redeffunaccept(v)
do
varn = n_n.value
foriin [0..n] dov.enter_visit(n_cmds)
end
end
vartext = args.first.to_path.read_all
varl = newLexer_logolas(text)
vartokens = l.lex
varp = newParser_logolas
p.tokens.add_all(tokens)
varnode = p.parse
vari = newInterp
i.enter_visit(node)
print"({i.x},{i.y})"