-
Notifications
You must be signed in to change notification settings - Fork 0
/
logo_semantics.gSemantics
90 lines (77 loc) · 1.92 KB
/
logo_semantics.gSemantics
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
78
79
80
81
82
83
84
85
86
87
88
89
90
semantics logo_semantics :
import "logo_options.gOption" ;
# On crée nos classes d'instructions
abstract class @instruction {
}
class @penUp extends @instruction {
}
class @penDown extends @instruction {
}
class @forward extends @instruction {
@luint mLength ;
}
class @rotate extends @instruction {
@luint mAngle ;
}
# On crée une liste d'instructions
list @instructionList {
@instruction mInstruction ;
}
# On crée une table des routines
map @routineMap {
@instructionList mInstructionList ;
insert insertKey error message "the '%K' routine has been already declared" ;
search searchKey error message "the '%K' routine is not declared";
}
abstract method @instruction codeDisplay
?!@bool ioPenDown
?!@double ioX
?!@double ioY
?!@double ioAngle
?!@string SVGInstructionString
;
override method @penUp codeDisplay
?!@bool ioPenDown
?!@double unused ioX
?!@double unused ioY
?!@double unused ioAngle
?!@string unused SVGInstructionString
:
ioPenDown := false ;
end method ;
override method @penDown codeDisplay
?!@bool ioPenDown
?!@double unused ioX
?!@double unused ioY
?!@double unused ioAngle
?!@string unused SVGInstructionString
:
ioPenDown := true ;
end method ;
override method @rotate codeDisplay
?!@bool unused ioPenDown
?!@double unused ioX
?!@double unused ioY
?!@double ioAngle
?!@string unused SVGInstructionString
:
ioAngle := ioAngle + [[mAngle uint] double] ;
end method ;
override method @forward codeDisplay
?!@bool ioPenDown
?!@double ioX
?!@double ioY
?!@double ioAngle
?!@string SVGInstructionString
:
const @double x := ioX + [mLength double] * [ioAngle cosDegree] ;
const @double y := ioY + [mLength double] * [ioAngle sinDegree] ;
if ioPenDown then
@string mess := "<line x1=\"".ioX."\" y1=\"".ioY."\" x2=\"".x."\" y2=\"".y."\" style=\"stroke:#1F56D2\" /> \n";
SVGInstructionString .= mess ;
message mess;
end if ;
ioX := x ;
ioY := y ;
end method ;
end semantics ;