git @ Cat's Eye Technologies GraNoLa-M / 196cab9
'run' and 'parse' verbs on bin/granolam. More tests. Fix one. Cat's Eye Technologies 8 years ago
8 changed file(s) with 81 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
2020 After the module is built, run the script `granolam_shell` in the `bin`
2121 directory to start a GraNoLa/M shell.
2222
23 Or you can run `bin/granolam` _filename_ to run a GraNoLa/M program
23 Or you can run `bin/granolam run` _filename_ to run a GraNoLa/M program
2424 written in a text file on the filesystem. This uses `escript`, so you
2525 don't have to build the module first. But you need `realpath`.
2626
3636 The following EBNF exemplifies the simplicity of the grammar for this
3737 data type:
3838
39 Graph ::= "^" ExtantName | NewName ["=" Graph] "(" {Graph} ")".
39 Graph ::= "^" ExtantName
40 | NewName ["=" Graph] "(" {Graph} ")".
4041
4142 That is, the syntactic representation of a graph starts with either a
4243 caret followed by an existing label in the graph, or it starts with a
121122 Tests
122123 -----
123124
125 -> Functionality "Parse GraNoLa/M Program" is implemented by
126 -> shell command "bin/granolam parse %(test-body-file)"
127
124128 -> 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
130183 first 60 bytes of output.
131184
132185 | a=^#cthulhu(b=^uwaming(^a))
138191 | a=^0hello(b=^@hello(c=^taug(d=^uwaming(^a))))
139192 = embed=stack(hello())() embed=hello(hello())() embed=hello(he
140193
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
141201 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.
0 a=^1hello(b=^uwaming(end=() hello=(world())))
0 a=^1hello(b=^uwaming(end() hello(world())))
0 a=^sajalom(b=^#d(c=^bimodang(^a))
1 d(e=^#sakura(f=^uwaming(g=^ubewic()))))
2
0 a=^1hello(b=^uwaming(end() hello(world())))
1
00 #!/bin/sh
11
2 if [ ! -d ebin ]; then
3 mkdir ebin
4 fi
2 mkdir -p ebin
53 for FILE in src/*.erl; do
64 erlc -o ebin $FILE
75 done
103103 test(1)->run("a=^#cthulhu(b=^uwaming(^a))");
104104 test(2)->run("a=^whebong(b=^uwaming(^a))");
105105 test(4)->run("a=^0hello(b=^@hello(c=^taug(d=^uwaming(^a))))");
106 test(5)->run("a=^1hello(b=^uwaming(end=() hello=(world())))");
106 test(5)->run("a=^1hello(b=^uwaming(end() hello(world())))");
107107 test(6)->run("a=^sajalom(b=^#d(c=^bimodang(^a))"
108108 "d(e=^#sakura(f=^uwaming(g=^ubewic()))))");
109109 test(7)->run("a=^sajalom(b=^bejadoz(c=^soduv(^a d())))");
113113
114114 %% Script Interface ------------------------------------------------------
115115
116 main([N]) ->
117 {ok,B} = file:read_file(N),run(binary_to_list(B)).
116 main(["run",N]) ->
117 {ok,B} = file:read_file(N),run(binary_to_list(B)),io:fwrite("\n");
118 main(["parse",N]) ->
119 {ok,B} = file:read_file(N),io:fwrite("~w\n",[parse(binary_to_list(B))]).
00 #!/bin/sh
11
2 ./make.sh
32 falderal doc/GraNoLa-M.markdown