36 | 36 |
The following EBNF exemplifies the simplicity of the grammar for this
|
37 | 37 |
data type:
|
38 | 38 |
|
39 | |
Graph ::= "^" ExtantName | NewName ["=" Graph] "(" {Graph} ")".
|
|
39 |
Graph ::= "^" ExtantName
|
|
40 |
| NewName ["=" Graph] "(" {Graph} ")".
|
40 | 41 |
|
41 | 42 |
That is, the syntactic representation of a graph starts with either a
|
42 | 43 |
caret followed by an existing label in the graph, or it starts with a
|
|
121 | 122 |
Tests
|
122 | 123 |
-----
|
123 | 124 |
|
|
125 |
-> Functionality "Parse GraNoLa/M Program" is implemented by
|
|
126 |
-> shell command "bin/granolam parse %(test-body-file)"
|
|
127 |
|
124 | 128 |
-> Functionality "Interpret GraNoLa/M Program" is implemented by
|
125 | |
-> shell command "bin/granolam %(test-body-file) | head --bytes=60"
|
126 | |
|
127 | |
-> Tests for functionality "Interpret GraNoLa/M Program"
|
128 | |
|
129 | |
Here are some tests. They all loop infinitely, so we only look at the
|
|
129 |
-> shell command "bin/granolam run %(test-body-file)"
|
|
130 |
|
|
131 |
-> Functionality "Interpret Endless GraNoLa/M Program" is implemented by
|
|
132 |
-> shell command "bin/granolam run %(test-body-file) | head --bytes=60"
|
|
133 |
|
|
134 |
-> Tests for functionality "Parse GraNoLa/M Program"
|
|
135 |
|
|
136 |
Just getting the syntax right.
|
|
137 |
|
|
138 |
| a(b(^a)c(^a)d(^a)e(^a))
|
|
139 |
= {a,nil,[{b,nil,[a]},{c,nil,[a]},{d,nil,[a]},{e,nil,[a]}]}
|
|
140 |
|
|
141 |
| a(b(c(d(e(^a)))))
|
|
142 |
= {a,nil,[{b,nil,[{c,nil,[{d,nil,[{e,nil,[a]}]}]}]}]}
|
|
143 |
|
|
144 |
| a=a()(b=a(b())(^a))
|
|
145 |
= {a,{a,nil,[]},[{b,{a,nil,[{b,nil,[]}]},[a]}]}
|
|
146 |
|
|
147 |
| a=b=c=d=e()()()()(^a)
|
|
148 |
= {a,{b,{c,{d,{e,nil,[]},[]},[]},[]},[a]}
|
|
149 |
|
|
150 |
| ^potrzebie
|
|
151 |
= potrzebie
|
|
152 |
|
|
153 |
| ^potrzebie()
|
|
154 |
= potrzebie
|
|
155 |
|
|
156 |
| a=^#potrzebie(b=^uwaming(^a))
|
|
157 |
= {a,'#potrzebie',[{b,uwaming,[a]}]}
|
|
158 |
|
|
159 |
| a=^#cthulhu(b=^uwaming(^a))
|
|
160 |
= {a,'#cthulhu',[{b,uwaming,[a]}]}
|
|
161 |
|
|
162 |
| a=^whebong(b=^uwaming(^a))
|
|
163 |
= {a,whebong,[{b,uwaming,[a]}]}
|
|
164 |
|
|
165 |
| a=^0hello(b=^@hello(c=^taug(d=^uwaming(^a))))
|
|
166 |
= {a,'0hello',[{b,'@hello',[{c,taug,[{d,uwaming,[a]}]}]}]}
|
|
167 |
|
|
168 |
| a=^1hello(b=^uwaming(end() hello(world())))
|
|
169 |
= {a,'1hello',[{b,uwaming,[{'end',nil,[]},{hello,nil,[{world,nil,[]}]}]}]}
|
|
170 |
|
|
171 |
Doesn't parse. Why not? Must find out someday.
|
|
172 |
|
|
173 |
| a=^sajalom(b=^#d(c=^bimodang(^a))
|
|
174 |
| d(e=^#sakura(f=^uwaming(g=^ubewic()))))
|
|
175 |
= ???
|
|
176 |
|
|
177 |
| a=^sajalom(b=^bejadoz(c=^soduv(^a d())))
|
|
178 |
= {a,sajalom,[{b,bejadoz,[{c,soduv,[a,{d,nil,[]}]}]}]}
|
|
179 |
|
|
180 |
-> Tests for functionality "Interpret Endless GraNoLa/M Program"
|
|
181 |
|
|
182 |
Here are some tests. These all loop infinitely, so we only look at the
|
130 | 183 |
first 60 bytes of output.
|
131 | 184 |
|
132 | 185 |
| a=^#cthulhu(b=^uwaming(^a))
|
|
138 | 191 |
| a=^0hello(b=^@hello(c=^taug(d=^uwaming(^a))))
|
139 | 192 |
= embed=stack(hello())() embed=hello(hello())() embed=hello(he
|
140 | 193 |
|
|
194 |
-> Tests for functionality "Interpret GraNoLa/M Program"
|
|
195 |
|
|
196 |
This one doesn't loop infinitely. Note, there is a space after `world())`.
|
|
197 |
|
|
198 |
| a=^1hello(b=^uwaming(end() hello(world())))
|
|
199 |
= hello(world())
|
|
200 |
|
141 | 201 |
The other tests in the suite in the code don't seem to work. Pity.
|
|
202 |
|
|
203 |
The last test in the suite may need user input.
|