-
Notifications
You must be signed in to change notification settings - Fork 0
/
informalAndInternal.txt
219 lines (108 loc) · 5.89 KB
/
informalAndInternal.txt
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
3D CAD
A: Informal language specification
==================================
The language HolloRay can perform 3D rendering of simple shapes and call back end JavaFX 3D functions.
S.1 Programs
------------
A HolloRay program is one or more statements
Statements are separated by the ; and-also operator. There is no statement terminator.
A sequence of whitespace characters can be used wherever one whitespace is valid.
S.2 Arithmetic and expressions
------------------------------
HolloRay has only 32-bit integer and real arithmetic
Non-keyword alphanumeric identifiers denote variables that may have integers and reals bound to them.
Operations provided are addition, subtraction, multiplication and division over constant integers and reals, and variables such as $x+y$, $x-3$, $3.1*4$, or $3/x$.
The modulo operator is also provided for integers.
S.3 Predicates
--------------
HolloRay allows comparison of 32-bit integers using relational operators that return a boolean result
x > y x greater than y
x != y x not equal to y
x == y x equal to y
S.4 Selection statements
------------------------
HolloRay provides two selection statements
if _pred then _statement else _statement
if _pred then _statement
where _pred is a predicate as defined in section S.3, and _statement is any statement
S.5 Iteration statements
------------------------
HolloRay provides two iteration statements
while _pred do _statement
for _pred do _statement
where _pred is a predicate as defined in section S.4, and _statement is any statement
S.6 Domain specific types
-------------------------
HolloRay has the following domain specific types representing common shapes:
box
cube
sphere
cylinder
cone
torus
tetrahedron
pyramid
S.7 Domain specific operations
------------------------------
HolloRay provides the following DSL-type statements for manipulating solids:
translate(_solid:solid, _x:real64, _y:real64, _z:real64)
rotate(_solid:_solid, _x:real64, _y:real64, _z:real64, _angle:real64)
scale(_solid:solid, _x:real64, _y:real64, _z:real64)
and the following for managing JavaFX's lifecycle:
init(_w:int32, _h:int32) initialize the JavaFX window with width _w and height _h
paint() render the scene
B: Internal syntax constructors and arities
===========================================
seq(_C1, _C2) execute command C_1 followed by command C_2
gt(_E1:__int32, _E2:__int32):__boolean integer greater-than E_1 > E_2
gt(_E1:__real64, _E2:__real64):__boolean real greater-than E_1 > E_2
ge(_E1:__int32, _E2:__int32):__boolean integer greater-than-or-equals E_1 >= E_2
ge(_E1:__real64, _E2:__real64):__boolean real greater-than-or-equals E_1 >= E_2
lt(_E1:__int32, _E2:__int32):__boolean integer less-than E_1 < E_2
lt(_E1:__real64, _E2:__real64):__boolean real less-than E_1 < E_2
le(_E1:__int32, _E2:__int32):__boolean integer less-than-or-equals E_1 <= E_2
le(_E1:__real64, _E2:__real64):__boolean real less-than-or-equals E_1 <= E_2
ne(_E1:__int32, _E2:__int32):__boolean integer not-equals E_1 != E_2
ne(_E1:__real64, _E2:__real64):__boolean real not-equals E_1 != E_2
ne(_E1:__bool, _E2:__bool):__boolean boolean not-equals E_1 != E_2
eq(_E1:__int32, _E2:__int32):__boolean integer equals E_1 == E_2
eq(_E1:__real64, _E2:__real64):__boolean real equals E_1 == E_2
eq(_E1:__bool, _E2:__bool):__boolean boolean equals E_1 == E_2
and(_P1:__bool, _P2:__bool):__bool boolean and P_1 && P_2
or(_P1:__bool, _P2:__bool):__bool boolean or P_1 || P_2
not(_P:__bool):__bool boolean not !P
xor(_P1:__bool, _P2:__bool):__bool boolean xor P_1 ^ P_2
assign(_N:__int32, _E:__int32) bind _E to name _N in variables map
assign(_N:__real64, _E:__real64) bind _E to name _N in variables map
assign(_N:__bool, _E:__bool) bind _E to name _N in variables map
assign(_N:_solid, _E:_solid) bind _E to name _N in variables map
compassign(_N:__int32, _V:__int32) bind _V plus value of _N to name _N in variables map
compassign(_N:__real64, _V:__real64) bind _V plus value of _N to name _N in variables map
deref(_N) retrieve binding for name _N in variables map
if(_P:__bool, _C1, _C2) select if _P then execute C_2 else execute C_3
if(_P:__bool, _C1) select if _P then execute C_2
while(_P:__bool, _C1) iterate while _P then execute C_1
sub(_E1:__int32, _E2:__int32):__int32 integer subtraction: E_1 - E_2
sub(_E1:__real64, _E2:__real64):__real64 real subtraction: E_1 - E_2
add(_E1:__int32, _E2:__int32):__int32 integer addition: E_1 + E_2
add(_E1:__real64, _E2:__real64):__real64 real addition: E_1 + E_2
mul(_E1:__int32, _E2:__int32):__int32 integer multiplication: E_1 * E_2
mul(_E1:__real64, _E2:__real64):__real64 real multiplication: E_1 * E_2
div(_E1:__int32, _E2:__int32):__int32 integer division: E_1 / E_2
div(_E1:__real64, _E2:__real64):__real64 real division: E_1 / E_2
mod(_E1:__int32, _E2:__int32):__int32 integer modulus: E_1 % E_2
neg(_E:__int32):__int32 integer negation: -E
neg(_E:__real64):__real64 real negation: -E
exp(_E1:__int32, _E2:__int32):__int32 integer exponentiation: E_1 ** E_2
exp(_E1:__real64, _E2:__real64):__real64 real exponentiation: E_1 ** E_2
box(_x:real64, _y:real64, _z:real64) create a box of dimension (_x, _y, _z)
cube(_e:real64) create a cube of edge length _e
sphere(_r:real64) create a sphere of radius _r
cylinder(_r:real64, _h:real64) create a cylinder of radius _r and height _h
cone(_r:real64, _h:real64) create a cone of radius _r and height _h
torus(_r:real64, _R:real64) create a torus of radius _r and major radius _R
tetrahedron(_e:real64) create a tetrahedron of edge length _e
pyramid(_e:real64, _h:real64) create a pyramid of edge length _e and height _h
translate(_solid:solid, _x:real64, _y:real64, _z:real64) translate a solid by (_x, _y, _z)
rotate(_solid:solid, _x:real64, _y:real64, _z:real64) rotate a solid by (_x, _y, _z) degrees around the the respecitive axis
scale(_solid:solid, _x:real64, _y:real64, _z:real64) scale a solid by (_x, _y, _z) factors in the respective axis