modl 0.3.14 → 0.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/grammar_tests/error_tests.json +676 -76
- data/lib/modl/parser/modl_method.rb +19 -15
- data/lib/modl/parser/parsed.rb +6 -3
- data/lib/modl/parser/parser.rb +1 -1
- data/lib/modl/parser/ref_processor.rb +8 -3
- data/lib/modl/parser/throwing_error_listener.rb +1 -1
- data/lib/modl/parser/version.rb +1 -1
- data/modl.gemspec +1 -2
- metadata +4 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19862a8b989bb41687946af65e7368ee2c9ab88794498d9bc0383dba94bbd1ad
|
|
4
|
+
data.tar.gz: e1b01ea144720b3b96f7ee412c843154fdb10acf6f84ebd72e24e23a5aef7f25
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eea7c86691b1e027737cbefbb92644731f96d049fbdf2bf894c0ea971679536f9111ff0c670ce2785b6346664df90e813bd5cce2c3f8b6360e1d91e2cbe94446
|
|
7
|
+
data.tar.gz: e059d05d456ab4f73bc11b5dc62f50e7a291d00158063c4cc43ca7d3a3f5b9b1da09457bf3bf3f44d41d896576e3879efb49398434aa088b3229b64d50a12882
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
0.3.15
|
|
2
|
+
===
|
|
3
|
+
- Interpreter Error: undefined method `text' for nil:NilClass. GitHub issue #23
|
|
4
|
+
- Fixed some NOT IMPLEMENTED sections for *method interpretation. GitHub issue #25
|
|
5
|
+
- Standardise the error messages to match the Java interpreter.
|
|
6
|
+
|
|
1
7
|
0.3.14
|
|
2
8
|
===
|
|
3
9
|
- MODL Syntax Versioning errors update. GitHub issue #11
|
|
@@ -1,77 +1,677 @@
|
|
|
1
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
|
-
|
|
2
|
+
{
|
|
3
|
+
"id": 1,
|
|
4
|
+
"input": "*VERSION=100;\"123\"=1",
|
|
5
|
+
"expected_output": "Interpreter Error: Invalid key - \"123\" - entirely numeric keys are not allowed: 123 - MODL Version 1 interpreter cannot process this MODL Version 100 file.",
|
|
6
|
+
"tested_features": [
|
|
7
|
+
"errors"
|
|
8
|
+
],
|
|
9
|
+
"minimised_modl": "*VERSION=100;\"123\"=1"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": 2,
|
|
13
|
+
"input": "b=(c=(d=(e=(f=(g=(h=(i=(j=1))))))));a=%b.c.e.f.g.h.i.j",
|
|
14
|
+
"expected_output": "Interpreter Error: Invalid object reference: \"%b.c.e.f.g.h.i.j\"",
|
|
15
|
+
"tested_features": [
|
|
16
|
+
"errors"
|
|
17
|
+
],
|
|
18
|
+
"minimised_modl": "b=(c=(d=(e=(f=(g=(h=(i=(j=1))))))));a=%b.c.e.f.g.h.i.j"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"id": 3,
|
|
22
|
+
"input": "*method(*id=hy;*name=hyp1;*transform=replace< ,->);*method(*id=hy;*name=hyp2;*transform=replace< ,->)",
|
|
23
|
+
"expected_output": "Interpreter Error: Duplicate method name or id: hy",
|
|
24
|
+
"tested_features": [
|
|
25
|
+
"errors"
|
|
26
|
+
],
|
|
27
|
+
"minimised_modl": "*method(*id=hy;*name=hyp1;*transform=replace< ,->);*method(*id=hy;*name=hyp2;*transform=replace< ,->)"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": 4,
|
|
31
|
+
"input": "*method(*id=hy;*name=hyp1;*transform=replace< ,->);*method(*id=hy1;*name=hyp1;*transform=replace< ,->)",
|
|
32
|
+
"expected_output": "Interpreter Error: Duplicate method name or id: hyp1",
|
|
33
|
+
"tested_features": [
|
|
34
|
+
"errors"
|
|
35
|
+
],
|
|
36
|
+
"minimised_modl": "*method(*id=hy;*name=hyp1;*transform=replace< ,->);*method(*id=hy1;*name=hyp1;*transform=replace< ,->)"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": 5,
|
|
40
|
+
"input": "*method(*id=hy;*name=hyp;*transform=replace< ,->);*method(*id=hyp1;*name=hy;*transform=replace< ,->)",
|
|
41
|
+
"expected_output": "Interpreter Error: Duplicate method name or id: hy",
|
|
42
|
+
"tested_features": [
|
|
43
|
+
"errors"
|
|
44
|
+
],
|
|
45
|
+
"minimised_modl": "*method(*id=hy;*name=hyp;*transform=replace< ,->);*method(*id=hyp1;*name=hy;*transform=replace< ,->)"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": 6,
|
|
49
|
+
"input": "*method(*id=hy;*name=hyp;*transform=replace< ,->);*method(*id=hyp;*name=hyp1;*transform=replace< ,->)",
|
|
50
|
+
"expected_output": "Interpreter Error: Duplicate method name or id: hyp",
|
|
51
|
+
"tested_features": [
|
|
52
|
+
"errors"
|
|
53
|
+
],
|
|
54
|
+
"minimised_modl": "*method(*id=hy;*name=hyp;*transform=replace< ,->);*method(*id=hyp;*name=hyp1;*transform=replace< ,->)"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": 7,
|
|
58
|
+
"input": "*class(*id=t;*name=test;*assign=[[a;b];[a]])",
|
|
59
|
+
"expected_output": "Interpreter Error: Error: Key lists in *assign are not in ascending order of list length: [\"a\"]",
|
|
60
|
+
"tested_features": [
|
|
61
|
+
"errors"
|
|
62
|
+
],
|
|
63
|
+
"minimised_modl": "*class(*id=t;*name=test;*assign=[[a;b];[a]])"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": 8,
|
|
67
|
+
"input": "*class(*id=t;*name=test;*assign=[[a;b]]);test=1:2:3",
|
|
68
|
+
"expected_output": "Interpreter Error: No key list of the correct length in class t - looking for one of length 3",
|
|
69
|
+
"tested_features": [
|
|
70
|
+
"errors"
|
|
71
|
+
],
|
|
72
|
+
"minimised_modl": "*class(*id=t;*name=test;*assign=[[a;b]]);test=1:2:3"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": 9,
|
|
76
|
+
"input": "*class(*id=t;*name=test);*class(*id=tt;*name=test)",
|
|
77
|
+
"expected_output": "Interpreter Error: Class name or id already defined - cannot redefine: tt, test",
|
|
78
|
+
"tested_features": [
|
|
79
|
+
"errors"
|
|
80
|
+
],
|
|
81
|
+
"minimised_modl": "*class(*id=t;*name=test);*class(*id=tt;*name=test)"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"id": 10,
|
|
85
|
+
"input": "*class(*id=test;*name=t);*class(*id=tt;*name=test)",
|
|
86
|
+
"expected_output": "Interpreter Error: Class name or id already defined - cannot redefine: tt, test",
|
|
87
|
+
"tested_features": [
|
|
88
|
+
"errors"
|
|
89
|
+
],
|
|
90
|
+
"minimised_modl": "*class(*id=test;*name=t);*class(*id=tt;*name=test)"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": 11,
|
|
94
|
+
"input": "*class(*id=test;*name=t);*class(*id=test;*name=tt)",
|
|
95
|
+
"expected_output": "Interpreter Error: Class name or id already defined - cannot redefine: test, tt",
|
|
96
|
+
"tested_features": [
|
|
97
|
+
"errors"
|
|
98
|
+
],
|
|
99
|
+
"minimised_modl": "*class(*id=test;*name=t);*class(*id=test;*name=tt)"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": 12,
|
|
103
|
+
"input": "*class(*name=test;*id=t);*class(*id=test;*name=tt)",
|
|
104
|
+
"expected_output": "Interpreter Error: Class name or id already defined - cannot redefine: test, tt",
|
|
105
|
+
"tested_features": [
|
|
106
|
+
"errors"
|
|
107
|
+
],
|
|
108
|
+
"minimised_modl": "*class(*name=test;*id=t);*class(*id=test;*name=tt)"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"id": 13,
|
|
112
|
+
"input": "*L=grammar_tests/1;*l=grammar_tests/1;a=1",
|
|
113
|
+
"expected_output": "Interpreter Error: Cannot load multiple files after *LOAD instruction",
|
|
114
|
+
"tested_features": [
|
|
115
|
+
"errors"
|
|
116
|
+
],
|
|
117
|
+
"minimised_modl": "*L=grammar_tests/1;*l=grammar_tests/1;a=1"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"id": 14,
|
|
121
|
+
"input": "*L=grammar_tests/1;*L=grammar_tests/1",
|
|
122
|
+
"expected_output": "Interpreter Error: Cannot load multiple files after *LOAD instruction",
|
|
123
|
+
"tested_features": [
|
|
124
|
+
"errors"
|
|
125
|
+
],
|
|
126
|
+
"minimised_modl": "*L=grammar_tests/1;*L=grammar_tests/1"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": 15,
|
|
130
|
+
"input": "*class(\n *id=g;\n *name=glossary;\n *superclass=map\n);\n*class(\n *id=t;\n *name=title;\n *superclass=str\n);\n*class(\n *id=d;\n *name=GlossDiv;\n *superclass=map\n);\n*class(\n *id=l;\n *name=GlossList;\n *superclass=map\n);\n*class(\n *id=e;\n *name=GlossEntry;\n *superclass=map;\n *assign[\n [i;s;gt;a;ab;gd;gs]\n ]\n);\n*class(\n *id=i;\n *name=ID;\n *superclass=str\n);\n*class(\n *id=s;\n *name=SortAs;\n *superclass=str\n);\n*class(\n *id=gt;\n *name=GlossTerm;\n *superclass=str\n);\n*class(\n *id=a;\n *name=Acronym;\n *superclass=str\n);\n*class(\n *id=ab;\n *name=Abbrev;\n *superclass=str\n);\n*class(\n *id=gd;\n *name=GlossDef;\n *superclass=map;\n *assign=[\n [p];\n [p;sa]\n ]\n);\n*CLASS(\n *id=p;\n *name=para;\n *superclass=str\n);\n*class(\n *id=sa;\n *name=SeeAlso;\n *superclass=arr\n);\n*class(\n *id=gs;\n *name=GlossSee;\n *superclass=str\n);\n\ng(\n ?=[SGML;markup;language];\n t=example glossary;\n d(\n t=S;\n l(\n e(\n i=%0;\n s=%0;\n gt=Standard Generalized %1.s %2.s;\n a=%0;\n ab=ISO 8879\\:1986;\n gd=A meta-%1 %2, used to create %1 %2s such as DocBook.\n :[GML;XML];\n gs=%1\n )\n )\n )\n)",
|
|
131
|
+
"expected_output": "Interpreter Error: Already defined *class as final.",
|
|
132
|
+
"tested_features": [
|
|
133
|
+
"errors"
|
|
134
|
+
],
|
|
135
|
+
"minimised_modl": "*class(\n *id=g;\n *name=glossary;\n *superclass=map\n);\n*class(\n *id=t;\n *name=title;\n *superclass=str\n);\n*class(\n *id=d;\n *name=GlossDiv;\n *superclass=map\n);\n*class(\n *id=l;\n *name=GlossList;\n *superclass=map\n);\n*class(\n *id=e;\n *name=GlossEntry;\n *superclass=map;\n *assign[\n [i;s;gt;a;ab;gd;gs]\n ]\n);\n*class(\n *id=i;\n *name=ID;\n *superclass=str\n);\n*class(\n *id=s;\n *name=SortAs;\n *superclass=str\n);\n*class(\n *id=gt;\n *name=GlossTerm;\n *superclass=str\n);\n*class(\n *id=a;\n *name=Acronym;\n *superclass=str\n);\n*class(\n *id=ab;\n *name=Abbrev;\n *superclass=str\n);\n*class(\n *id=gd;\n *name=GlossDef;\n *superclass=map;\n *assign=[\n [p];\n [p;sa]\n ]\n);\n*CLASS(\n *id=p;\n *name=para;\n *superclass=str\n);\n*class(\n *id=sa;\n *name=SeeAlso;\n *superclass=arr\n);\n*class(\n *id=gs;\n *name=GlossSee;\n *superclass=str\n);\n\ng(\n ?=[SGML;markup;language];\n t=example glossary;\n d(\n t=S;\n l(\n e(\n i=%0;\n s=%0;\n gt=Standard Generalized %1.s %2.s;\n a=%0;\n ab=ISO 8879\\:1986;\n gd=A meta-%1 %2, used to create %1 %2s such as DocBook.\n :[GML;XML];\n gs=%1\n )\n )\n )\n)"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": 16,
|
|
139
|
+
"input": "*class(*id=n;*name=name;*superclass=num);n=Elliott",
|
|
140
|
+
"expected_output": "Superclass of \"n\" is num - cannot assign value \"Elliott\"",
|
|
141
|
+
"tested_features": [
|
|
142
|
+
"errors"
|
|
143
|
+
],
|
|
144
|
+
"minimised_modl": "*class(*id=n;*name=name;*superclass=num);n=Elliott"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"id": 17,
|
|
148
|
+
"input": "*class(*id=newstr;*superclass=str);*class(*id=a;*name=age;*superclass=anotherstr);a=10",
|
|
149
|
+
"expected_output": "Interpreter Error: Invalid superclass: anotherstr",
|
|
150
|
+
"tested_features": [
|
|
151
|
+
"errors"
|
|
152
|
+
],
|
|
153
|
+
"minimised_modl": "*class(*id=newstr;*superclass=str);*class(*id=a;*name=age;*superclass=anotherstr);a=10"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": 18,
|
|
157
|
+
"input": "!a=1",
|
|
158
|
+
"expected_output": "Interpreter Error: Invalid key - \"!\" character not allowed: !a",
|
|
159
|
+
"tested_features": [
|
|
160
|
+
"errors"
|
|
161
|
+
],
|
|
162
|
+
"minimised_modl": "!a=1"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"id": 19,
|
|
166
|
+
"input": "a!=1",
|
|
167
|
+
"expected_output": "Interpreter Error: Invalid key - \"!\" character not allowed: a!",
|
|
168
|
+
"tested_features": [
|
|
169
|
+
"errors"
|
|
170
|
+
],
|
|
171
|
+
"minimised_modl": "a!=1"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"id": 20,
|
|
175
|
+
"input": "!a!=1",
|
|
176
|
+
"expected_output": "Interpreter Error: Invalid key - \"!\" character not allowed: !a!",
|
|
177
|
+
"tested_features": [
|
|
178
|
+
"errors"
|
|
179
|
+
],
|
|
180
|
+
"minimised_modl": "!a!=1"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"id": 21,
|
|
184
|
+
"input": "!~a~!=1",
|
|
185
|
+
"expected_output": "Parser Error: line 1:1 token recognition error at: '~a'",
|
|
186
|
+
"tested_features": [
|
|
187
|
+
"errors"
|
|
188
|
+
],
|
|
189
|
+
"minimised_modl": "!~a~!=1"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"id": 22,
|
|
193
|
+
"input": "£x=y",
|
|
194
|
+
"expected_output": "Interpreter Error: Invalid key - \"£\" character not allowed: £x",
|
|
195
|
+
"tested_features": [
|
|
196
|
+
"errors"
|
|
197
|
+
],
|
|
198
|
+
"minimised_modl": "£x=y"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"id": 23,
|
|
202
|
+
"input": "$x=y",
|
|
203
|
+
"expected_output": "Interpreter Error: Invalid key - \"$\" character not allowed: $x",
|
|
204
|
+
"tested_features": [
|
|
205
|
+
"errors"
|
|
206
|
+
],
|
|
207
|
+
"minimised_modl": "$x=y"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"id": 24,
|
|
211
|
+
"input": "@x=y",
|
|
212
|
+
"expected_output": "Interpreter Error: Invalid key - \"@\" character not allowed: @x",
|
|
213
|
+
"tested_features": [
|
|
214
|
+
"errors"
|
|
215
|
+
],
|
|
216
|
+
"minimised_modl": "@x=y"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"id": 25,
|
|
220
|
+
"input": "-x=y",
|
|
221
|
+
"expected_output": "Interpreter Error: Invalid key - \"-\" character not allowed: -x",
|
|
222
|
+
"tested_features": [
|
|
223
|
+
"errors"
|
|
224
|
+
],
|
|
225
|
+
"minimised_modl": "-x=y"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"id": 26,
|
|
229
|
+
"input": "+x=y",
|
|
230
|
+
"expected_output": "Interpreter Error: Invalid key - \"+\" character not allowed: +x",
|
|
231
|
+
"tested_features": [
|
|
232
|
+
"errors"
|
|
233
|
+
],
|
|
234
|
+
"minimised_modl": "+x=y"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"id": 27,
|
|
238
|
+
"input": "'x'=y",
|
|
239
|
+
"expected_output": "Interpreter Error: Invalid key - \"'\" character not allowed: 'x'",
|
|
240
|
+
"tested_features": [
|
|
241
|
+
"errors"
|
|
242
|
+
],
|
|
243
|
+
"minimised_modl": "'x'=y"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"id": 28,
|
|
247
|
+
"input": "'x?=y",
|
|
248
|
+
"expected_output": "Interpreter Error: Invalid key - \"'\" character not allowed: 'x?",
|
|
249
|
+
"tested_features": [
|
|
250
|
+
"errors"
|
|
251
|
+
],
|
|
252
|
+
"minimised_modl": "'x?=y"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"id": 29,
|
|
256
|
+
"input": "a=1:2:3;;\nb=4:5:6",
|
|
257
|
+
"expected_output": "Parser Error: line 1:8 no viable alternative at input ';;'",
|
|
258
|
+
"tested_features": [
|
|
259
|
+
"errors"
|
|
260
|
+
],
|
|
261
|
+
"minimised_modl": "a=1:2:3;;\nb=4:5:6"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"id": 30,
|
|
265
|
+
"input": "a=1:2:3;\n;\nb=4:5:6",
|
|
266
|
+
"expected_output": "Parser Error: line 2:0 no viable alternative at input ';;'",
|
|
267
|
+
"tested_features": [
|
|
268
|
+
"errors"
|
|
269
|
+
],
|
|
270
|
+
"minimised_modl": "a=1:2:3;\n;\nb=4:5:6"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"id": 31,
|
|
274
|
+
"input": "a=1:2:3\n;\n;\nb=4:5:6",
|
|
275
|
+
"expected_output": "Parser Error: line 3:0 no viable alternative at input ';;'",
|
|
276
|
+
"tested_features": [
|
|
277
|
+
"errors"
|
|
278
|
+
],
|
|
279
|
+
"minimised_modl": "a=1:2:3\n;\n;\nb=4:5:6"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"id": 32,
|
|
283
|
+
"input": "a=1:2:3\n;;\nb=4:5:6",
|
|
284
|
+
"expected_output": "Parser Error: line 2:1 no viable alternative at input ';;'",
|
|
285
|
+
"tested_features": [
|
|
286
|
+
"errors"
|
|
287
|
+
],
|
|
288
|
+
"minimised_modl": "a=1:2:3\n;;\nb=4:5:6"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"id": 33,
|
|
292
|
+
"input": "a=1:2:3\n;\nb=4:5:6\n;\n;\n",
|
|
293
|
+
"expected_output": "Parser Error: line 5:0 no viable alternative at input ';;'",
|
|
294
|
+
"tested_features": [
|
|
295
|
+
"errors"
|
|
296
|
+
],
|
|
297
|
+
"minimised_modl": "a=1:2:3\n;\nb=4:5:6\n;\n;\n"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"id": 34,
|
|
301
|
+
"input": "a=1:2:3\n;\nb=4:5:6\n;;\n",
|
|
302
|
+
"expected_output": "Parser Error: line 4:1 no viable alternative at input ';;'",
|
|
303
|
+
"tested_features": [
|
|
304
|
+
"errors"
|
|
305
|
+
],
|
|
306
|
+
"minimised_modl": "a=1:2:3\n;\nb=4:5:6\n;;\n"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
"id": 35,
|
|
310
|
+
"input": "*nonsense=1",
|
|
311
|
+
"expected_output": "Interpreter Error: Invalid keyword: *nonsense",
|
|
312
|
+
"tested_features": [
|
|
313
|
+
"errors"
|
|
314
|
+
],
|
|
315
|
+
"minimised_modl": "*nonsense=1"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"id": 36,
|
|
319
|
+
"input": "?=1:2:3:4;_12%3=1",
|
|
320
|
+
"expected_output": "Interpreter Error: Invalid key - \"124\" - entirely numeric keys are not allowed: _124",
|
|
321
|
+
"tested_features": [
|
|
322
|
+
"errors"
|
|
323
|
+
],
|
|
324
|
+
"minimised_modl": "?=1:2:3:4;_12%3=1"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"id": 37,
|
|
328
|
+
"input": "_123=1",
|
|
329
|
+
"expected_output": "Interpreter Error: Invalid key - \"123\" - entirely numeric keys are not allowed: _123",
|
|
330
|
+
"tested_features": [
|
|
331
|
+
"errors"
|
|
332
|
+
],
|
|
333
|
+
"minimised_modl": "_123=1"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
"id": 38,
|
|
337
|
+
"input": "_12*3=1",
|
|
338
|
+
"expected_output": "Interpreter Error: Invalid key - \"*\" character not allowed: _12*3",
|
|
339
|
+
"tested_features": [
|
|
340
|
+
"errors"
|
|
341
|
+
],
|
|
342
|
+
"minimised_modl": "_12*3=1"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"id": 39,
|
|
346
|
+
"input": "_12!3=1",
|
|
347
|
+
"expected_output": "Interpreter Error: Invalid key - \"!\" character not allowed: _12!3",
|
|
348
|
+
"tested_features": [
|
|
349
|
+
"errors"
|
|
350
|
+
],
|
|
351
|
+
"minimised_modl": "_12!3=1"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
"id": 40,
|
|
355
|
+
"input": "_12@3=1",
|
|
356
|
+
"expected_output": "Interpreter Error: Invalid key - \"@\" character not allowed: _12@3",
|
|
357
|
+
"tested_features": [
|
|
358
|
+
"errors"
|
|
359
|
+
],
|
|
360
|
+
"minimised_modl": "_12@3=1"
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
"id": 41,
|
|
364
|
+
"input": "_12#3=1",
|
|
365
|
+
"expected_output": "Interpreter Error: Invalid key - \"#\" character not allowed: _12#3",
|
|
366
|
+
"tested_features": [
|
|
367
|
+
"errors"
|
|
368
|
+
],
|
|
369
|
+
"minimised_modl": "_12#3=1"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"id": 42,
|
|
373
|
+
"input": "_12$3=1",
|
|
374
|
+
"expected_output": "Interpreter Error: Invalid key - \"$\" character not allowed: _12$3",
|
|
375
|
+
"tested_features": [
|
|
376
|
+
"errors"
|
|
377
|
+
],
|
|
378
|
+
"minimised_modl": "_12$3=1"
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"id": 43,
|
|
382
|
+
"input": "_12^3=1",
|
|
383
|
+
"expected_output": "Interpreter Error: Invalid key - \"^\" character not allowed: _12^3",
|
|
384
|
+
"tested_features": [
|
|
385
|
+
"errors"
|
|
386
|
+
],
|
|
387
|
+
"minimised_modl": "_12^3=1"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"id": 44,
|
|
391
|
+
"input": "_12&3=1",
|
|
392
|
+
"expected_output": "Interpreter Error: Invalid key - \"&\" character not allowed: _12&3",
|
|
393
|
+
"tested_features": [
|
|
394
|
+
"errors"
|
|
395
|
+
],
|
|
396
|
+
"minimised_modl": "_12&3=1"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"id": 45,
|
|
400
|
+
"input": "_12(3=1",
|
|
401
|
+
"expected_output": "Parser Error: line 1:4 no viable alternative at input '_12(3'",
|
|
402
|
+
"tested_features": [
|
|
403
|
+
"errors"
|
|
404
|
+
],
|
|
405
|
+
"minimised_modl": "_12(3=1"
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"id": 46,
|
|
409
|
+
"input": "_12)3=1",
|
|
410
|
+
"expected_output": "Parser Error: line 1:3 no viable alternative at input '_12)'",
|
|
411
|
+
"tested_features": [
|
|
412
|
+
"errors"
|
|
413
|
+
],
|
|
414
|
+
"minimised_modl": "_12)3=1"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
"id": 47,
|
|
418
|
+
"input": "123=456",
|
|
419
|
+
"expected_output": "Parser Error: line 1:0 mismatched input '123' expecting {<EOF>, LBRAC, LSBRAC, QUOTED, STRING, '{'}",
|
|
420
|
+
"tested_features": [
|
|
421
|
+
"errors"
|
|
422
|
+
],
|
|
423
|
+
"minimised_modl": "123=456"
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
"id": 48,
|
|
427
|
+
"input": "_test=(\n first=(\"v1\"=(one=(two=three)))\n);\n \ntesting = %test.first.v1.one.0",
|
|
428
|
+
"expected_output": "Interpreter Error: Found a map when expecting an array",
|
|
429
|
+
"tested_features": [
|
|
430
|
+
"errors"
|
|
431
|
+
],
|
|
432
|
+
"minimised_modl": "_test=(\n first=(\"v1\"=(one=(two=three)))\n);\n \ntesting = %test.first.v1.one.0"
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"id": 49,
|
|
436
|
+
"input": "_test=(\n first=(\"v1\"=(one=(two=three)))\n);\n \ntesting = %test.first.v1.0.two",
|
|
437
|
+
"expected_output": "Interpreter Error: Invalid object reference: \"%test.first.v1.0.two\"",
|
|
438
|
+
"tested_features": [
|
|
439
|
+
"errors"
|
|
440
|
+
],
|
|
441
|
+
"minimised_modl": "_test=(\n first=(\"v1\"=(one=(two=three)))\n);\n \ntesting = %test.first.v1.0.two"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"id": 50,
|
|
445
|
+
"input": "_test=(\n first=(\"v1\"=(one=(two=three)))\n);\n \ntesting = %test.first.v1.0.0",
|
|
446
|
+
"expected_output": "Interpreter Error: Found a map when expecting an array",
|
|
447
|
+
"tested_features": [
|
|
448
|
+
"errors"
|
|
449
|
+
],
|
|
450
|
+
"minimised_modl": "_test=(\n first=(\"v1\"=(one=(two=three)))\n);\n \ntesting = %test.first.v1.0.0"
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"id": 51,
|
|
454
|
+
"input": "_test=(\n numbers=(\"one\"=1)\n);\n\ntesting = this is a string that includes a reference with a letter s after it %test.numbers.ones",
|
|
455
|
+
"expected_output": "Interpreter Error: Invalid object reference: \"this is a string that includes a reference with a letter s after it %test.numbers.ones\"",
|
|
456
|
+
"tested_features": [
|
|
457
|
+
"errors"
|
|
458
|
+
],
|
|
459
|
+
"minimised_modl": "_test=(\n numbers=(\"one\"=1)\n);\n\ntesting = this is a string that includes a reference with a letter s after it %test.numbers.ones"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"id": 52,
|
|
463
|
+
"input": "true=test",
|
|
464
|
+
"expected_output": "Parser Error: line 1:0 mismatched input 'true' expecting {<EOF>, LBRAC, LSBRAC, QUOTED, STRING, '{'}",
|
|
465
|
+
"tested_features": [
|
|
466
|
+
"errors"
|
|
467
|
+
],
|
|
468
|
+
"minimised_modl": "true=test"
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
"id": 53,
|
|
472
|
+
"input": "false=test",
|
|
473
|
+
"expected_output": "Parser Error: line 1:0 mismatched input 'false' expecting {<EOF>, LBRAC, LSBRAC, QUOTED, STRING, '{'}",
|
|
474
|
+
"tested_features": [
|
|
475
|
+
"errors"
|
|
476
|
+
],
|
|
477
|
+
"minimised_modl": "false=test"
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
"id": 54,
|
|
481
|
+
"input": "null=test",
|
|
482
|
+
"expected_output": "Parser Error: line 1:0 mismatched input 'null' expecting {<EOF>, LBRAC, LSBRAC, QUOTED, STRING, '{'}",
|
|
483
|
+
"tested_features": [
|
|
484
|
+
"errors"
|
|
485
|
+
],
|
|
486
|
+
"minimised_modl": "null=test"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"id": 55,
|
|
490
|
+
"input": "*class(*id=arr)",
|
|
491
|
+
"expected_output": "Interpreter Error: Reserved class id - cannot redefine: arr",
|
|
492
|
+
"tested_features": [
|
|
493
|
+
"errors"
|
|
494
|
+
],
|
|
495
|
+
"minimised_modl": "*class(*id=arr)"
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
"id": 56,
|
|
499
|
+
"input": "*class(*id=num)",
|
|
500
|
+
"expected_output": "Interpreter Error: Reserved class id - cannot redefine: num",
|
|
501
|
+
"tested_features": [
|
|
502
|
+
"errors"
|
|
503
|
+
],
|
|
504
|
+
"minimised_modl": "*class(*id=num)"
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
"id": 57,
|
|
508
|
+
"input": "*class(*id=map)",
|
|
509
|
+
"expected_output": "Interpreter Error: Reserved class id - cannot redefine: map",
|
|
510
|
+
"tested_features": [
|
|
511
|
+
"errors"
|
|
512
|
+
],
|
|
513
|
+
"minimised_modl": "*class(*id=map)"
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
"id": 58,
|
|
517
|
+
"input": "*class(*id=str)",
|
|
518
|
+
"expected_output": "Interpreter Error: Reserved class id - cannot redefine: str",
|
|
519
|
+
"tested_features": [
|
|
520
|
+
"errors"
|
|
521
|
+
],
|
|
522
|
+
"minimised_modl": "*class(*id=str)"
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
"id": 59,
|
|
526
|
+
"input": "*class(*name=arr)",
|
|
527
|
+
"expected_output": "Interpreter Error: Reserved class name - cannot redefine: arr",
|
|
528
|
+
"tested_features": [
|
|
529
|
+
"errors"
|
|
530
|
+
],
|
|
531
|
+
"minimised_modl": "*class(*name=arr)"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
"id": 60,
|
|
535
|
+
"input": "*class(*name=num)",
|
|
536
|
+
"expected_output": "Interpreter Error: Reserved class name - cannot redefine: num",
|
|
537
|
+
"tested_features": [
|
|
538
|
+
"errors"
|
|
539
|
+
],
|
|
540
|
+
"minimised_modl": "*class(*name=num)"
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
"id": 61,
|
|
544
|
+
"input": "*class(*name=map)",
|
|
545
|
+
"expected_output": "Interpreter Error: Reserved class name - cannot redefine: map",
|
|
546
|
+
"tested_features": [
|
|
547
|
+
"errors"
|
|
548
|
+
],
|
|
549
|
+
"minimised_modl": "*class(*name=map)"
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
"id": 62,
|
|
553
|
+
"input": "*class(*name=str)",
|
|
554
|
+
"expected_output": "Interpreter Error: Reserved class name - cannot redefine: str",
|
|
555
|
+
"tested_features": [
|
|
556
|
+
"errors"
|
|
557
|
+
],
|
|
558
|
+
"minimised_modl": "*class(*name=str)"
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
"id": 63,
|
|
562
|
+
"input": "IMMUTABLE=true;IMMUTABLE=false",
|
|
563
|
+
"expected_output": "Interpreter Error: Already defined IMMUTABLE as final.",
|
|
564
|
+
"tested_features": [
|
|
565
|
+
"errors"
|
|
566
|
+
],
|
|
567
|
+
"minimised_modl": "IMMUTABLE=true;IMMUTABLE=false"
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
"id": 64,
|
|
571
|
+
"input": "*VERSION=test",
|
|
572
|
+
"expected_output": "Interpreter Error: Invalid MODL version: test",
|
|
573
|
+
"tested_features": [
|
|
574
|
+
"errors"
|
|
575
|
+
],
|
|
576
|
+
"minimised_modl": "*VERSION=test"
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
"id": 65,
|
|
580
|
+
"input": "*V=test",
|
|
581
|
+
"expected_output": "Interpreter Error: Invalid MODL version: test",
|
|
582
|
+
"tested_features": [
|
|
583
|
+
"errors"
|
|
584
|
+
],
|
|
585
|
+
"minimised_modl": "*V=test"
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
"id": 66,
|
|
589
|
+
"input": "*VERSION=0",
|
|
590
|
+
"expected_output": "Interpreter Error: Invalid MODL version: 0",
|
|
591
|
+
"tested_features": [
|
|
592
|
+
"errors"
|
|
593
|
+
],
|
|
594
|
+
"minimised_modl": "*VERSION=0"
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
"id": 67,
|
|
598
|
+
"input": "*VERSION=0.1",
|
|
599
|
+
"expected_output": "Interpreter Error: Invalid MODL version: 0.1",
|
|
600
|
+
"tested_features": [
|
|
601
|
+
"errors"
|
|
602
|
+
],
|
|
603
|
+
"minimised_modl": "*VERSION=0.1"
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
"id": 68,
|
|
607
|
+
"input": "a=b;*VERSION=1",
|
|
608
|
+
"expected_output": "Interpreter Error: MODL version should be on the first line if specified.",
|
|
609
|
+
"tested_features": [
|
|
610
|
+
"errors"
|
|
611
|
+
],
|
|
612
|
+
"minimised_modl": "a=b;*VERSION=1"
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
"id": 69,
|
|
616
|
+
"input": "*class(*id=a;*name=alpha;*superclass=str);a=null",
|
|
617
|
+
"expected_output": "Interpreter Error: Cannot convert null value to string.",
|
|
618
|
+
"tested_features": [
|
|
619
|
+
"errors"
|
|
620
|
+
],
|
|
621
|
+
"minimised_modl": "*class(*id=a;*name=alpha;*superclass=str);a=null"
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
"id": 70,
|
|
625
|
+
"input": "*class(*id=a;*name=alpha;*superclass=num);a=null",
|
|
626
|
+
"expected_output": "Superclass of \"a\" is num - cannot assign value \"\"",
|
|
627
|
+
"tested_features": [
|
|
628
|
+
"errors"
|
|
629
|
+
],
|
|
630
|
+
"minimised_modl": "*class(*id=a;*name=alpha;*superclass=num);a=null"
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
"id": 71,
|
|
634
|
+
"input": "*class(*id=a;*name=alpha;*superclass=num);a=x",
|
|
635
|
+
"expected_output": "Superclass of \"a\" is num - cannot assign value \"x\"",
|
|
636
|
+
"tested_features": [
|
|
637
|
+
"errors"
|
|
638
|
+
],
|
|
639
|
+
"minimised_modl": "*class(*id=a;*name=alpha;*superclass=num);a=x"
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
"id": 72,
|
|
643
|
+
"input": "*class(*id=a;*name=alpha;*superclass=num);a=null",
|
|
644
|
+
"expected_output": "Superclass of \"a\" is num - cannot assign value \"\"",
|
|
645
|
+
"tested_features": [
|
|
646
|
+
"errors"
|
|
647
|
+
],
|
|
648
|
+
"minimised_modl": "*class(*id=a;*name=alpha;*superclass=num);a=null"
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
"id": 73,
|
|
652
|
+
"input": "*class(*id=a;*name=alpha;*superclass=map);a=[1;2;3]",
|
|
653
|
+
"expected_output": "Interpreter Error: Cannot convert array to map: [1, 2, 3]",
|
|
654
|
+
"tested_features": [
|
|
655
|
+
"errors"
|
|
656
|
+
],
|
|
657
|
+
"minimised_modl": "*class(*id=a;*name=alpha;*superclass=map);a=[1;2;3]"
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
"id": 74,
|
|
661
|
+
"input": "*class(*id=a;*name=alpha;*superclass=arr);a=(c=d)",
|
|
662
|
+
"expected_output": "Interpreter Error: Cannot convert map to array: {\"c\"=>\"d\"}",
|
|
663
|
+
"tested_features": [
|
|
664
|
+
"errors"
|
|
665
|
+
],
|
|
666
|
+
"minimised_modl": "*class(*id=a;*name=alpha;*superclass=arr);a=(c=d)"
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
"id": 75,
|
|
670
|
+
"input": "*L=grammar_tests/test_import_dir/nested_import1.txt;files=%*load",
|
|
671
|
+
"expected_output": "Interpreter Error: Cannot load multiple files after *LOAD instruction",
|
|
672
|
+
"tested_features": [
|
|
673
|
+
"errors"
|
|
674
|
+
],
|
|
675
|
+
"minimised_modl": "*L=grammar_tests/test_import_dir/nested_import1.txt;files=%*load"
|
|
676
|
+
}
|
|
677
|
+
]
|
|
@@ -39,31 +39,35 @@ module MODL
|
|
|
39
39
|
# Consume the elements of the transform spec until there are none left.
|
|
40
40
|
transform = @transform
|
|
41
41
|
while transform && transform.length > 0
|
|
42
|
-
if transform.start_with?
|
|
42
|
+
if transform.start_with?('replace<') || transform.start_with?('r<')
|
|
43
43
|
close_bracket = transform.index('>')
|
|
44
44
|
m = Sutil.head(transform, close_bracket + 1).sub!('replace', 'r')
|
|
45
45
|
str = StandardMethods.run_method(m, str)
|
|
46
46
|
# Consume the subst clause
|
|
47
47
|
close_bracket = transform.index('>')
|
|
48
48
|
transform = Sutil.tail(transform, close_bracket + 2)
|
|
49
|
-
elsif transform.start_with?
|
|
49
|
+
elsif transform.start_with?('trim') || transform.start_with?('t<')
|
|
50
50
|
close_bracket = transform.index('>')
|
|
51
51
|
m = Sutil.head(transform, close_bracket + 1).sub!('trim', 't')
|
|
52
52
|
str = StandardMethods.run_method(m, str)
|
|
53
53
|
# Consume the trunc clause
|
|
54
54
|
close_bracket = transform.index('>')
|
|
55
55
|
transform = Sutil.tail(transform, close_bracket + 2)
|
|
56
|
-
elsif transform.start_with?
|
|
57
|
-
str =
|
|
58
|
-
transform = Sutil.
|
|
59
|
-
elsif transform.start_with?
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
elsif transform.start_with? '
|
|
66
|
-
|
|
56
|
+
elsif transform.start_with?('initcap') || transform.start_with?('i')
|
|
57
|
+
str = StandardMethods.run_method('i', str)
|
|
58
|
+
transform = Sutil.after(transform, '.')
|
|
59
|
+
elsif transform.start_with?('upcase') || transform.start_with?('u')
|
|
60
|
+
str = StandardMethods.run_method('u', str)
|
|
61
|
+
transform = Sutil.after(transform, '.')
|
|
62
|
+
elsif transform.start_with?('downcase') || transform.start_with?('d')
|
|
63
|
+
str = StandardMethods.run_method('d', str)
|
|
64
|
+
transform = Sutil.after(transform, '.')
|
|
65
|
+
elsif transform.start_with?('sentence') || transform.start_with?('s')
|
|
66
|
+
str = StandardMethods.run_method('s', str)
|
|
67
|
+
transform = Sutil.after(transform, '.')
|
|
68
|
+
elsif transform.start_with?('urlencode') || transform.start_with?('e')
|
|
69
|
+
str = StandardMethods.run_method('e', str)
|
|
70
|
+
transform = Sutil.after(transform, '.')
|
|
67
71
|
else
|
|
68
72
|
raise InterpreterError, 'NOT IMPLEMENTED'
|
|
69
73
|
end
|
|
@@ -99,8 +103,8 @@ module MODL
|
|
|
99
103
|
|
|
100
104
|
raise InterpreterError, 'Missing id for method' if mthd.id.nil?
|
|
101
105
|
raise InterpreterError, 'Missing name for method' if mthd.name.nil?
|
|
102
|
-
raise InterpreterError, 'Duplicate method name: ' + mthd.name if global.has_user_method?(mthd.name)
|
|
103
|
-
raise InterpreterError, 'Duplicate method id: ' + mthd.id if global.has_user_method?(mthd.id)
|
|
106
|
+
raise InterpreterError, 'Duplicate method name or id: ' + mthd.name if global.has_user_method?(mthd.name)
|
|
107
|
+
raise InterpreterError, 'Duplicate method name or id: ' + mthd.id if global.has_user_method?(mthd.id)
|
|
104
108
|
|
|
105
109
|
# store the methods by id and name to make them easier to find later
|
|
106
110
|
global.user_method_id(mthd.id, mthd)
|
data/lib/modl/parser/parsed.rb
CHANGED
|
@@ -304,6 +304,7 @@ module MODL
|
|
|
304
304
|
if @key.include?('%') || @key.include?('`')
|
|
305
305
|
@key, new_value = RefProcessor.deref @key, @global
|
|
306
306
|
unless @key.is_a?(String)
|
|
307
|
+
raise InterpreterError, "Error: '" + @key.to_s + "' is an invalid key." if new_value.nil?
|
|
307
308
|
@key = new_value.is_a?(String) ? new_value : new_value.text
|
|
308
309
|
end
|
|
309
310
|
raise InterpreterError, "Error: '" + @key.to_s + "' should de-ref to a string." unless key.is_a?(String)
|
|
@@ -349,7 +350,7 @@ module MODL
|
|
|
349
350
|
when 'version'
|
|
350
351
|
extract_value
|
|
351
352
|
|
|
352
|
-
raise InterpreterError, 'Invalid MODL version:
|
|
353
|
+
raise InterpreterError, 'Invalid MODL version: ' + @valueItem.value.primitive.text if @valueItem.value.primitive.number.nil?
|
|
353
354
|
raise InterpreterError, 'Invalid MODL version: ' + @valueItem.value.primitive.number.num.to_s if @valueItem.value.primitive.number.num.is_a? Float
|
|
354
355
|
raise InterpreterError, 'Invalid MODL version: ' + @valueItem.value.primitive.number.num.to_s if @valueItem.value.primitive.number.num.zero?
|
|
355
356
|
raise InterpreterError, 'MODL version should be on the first line if specified.' if @global.has_pairs?
|
|
@@ -376,12 +377,14 @@ module MODL
|
|
|
376
377
|
if @key.start_with? '_'
|
|
377
378
|
k = Sutil.tail(@key)
|
|
378
379
|
existing = @global.pair(k)
|
|
379
|
-
raise InterpreterError, 'Already defined ' + k + ' as final.' if existing&.final
|
|
380
|
+
raise InterpreterError, 'Already defined ' + k + ' as final.' if existing&.final && @type != "import"
|
|
381
|
+
raise InterpreterError, 'Cannot load multiple files after *LOAD instruction' if existing&.final && @type == "import"
|
|
380
382
|
|
|
381
383
|
@global.pair(k, self)
|
|
382
384
|
end
|
|
383
385
|
existing = @global.pair(@key)
|
|
384
|
-
raise InterpreterError, 'Already defined ' + @key + ' as final.' if existing&.final
|
|
386
|
+
raise InterpreterError, 'Already defined ' + @key + ' as final.' if existing&.final && @type != "import"
|
|
387
|
+
raise InterpreterError, 'Cannot load multiple files after *LOAD instruction' if existing&.final && @type == "import"
|
|
385
388
|
|
|
386
389
|
@global.pair(@key, self)
|
|
387
390
|
end
|
data/lib/modl/parser/parser.rb
CHANGED
|
@@ -61,7 +61,7 @@ module MODL
|
|
|
61
61
|
|
|
62
62
|
def self.check_modl_version(global, e)
|
|
63
63
|
if global.syntax_version > global.interpreter_syntax_version
|
|
64
|
-
raise InterpreterError, e.message + ' - MODL Version ' +
|
|
64
|
+
raise InterpreterError, 'Interpreter Error: ' + e.message + ' - MODL Version ' +
|
|
65
65
|
global.interpreter_syntax_version.to_s +
|
|
66
66
|
' interpreter cannot process this MODL Version ' +
|
|
67
67
|
global.syntax_version.to_s + ' file.'
|
|
@@ -110,7 +110,7 @@ module MODL
|
|
|
110
110
|
end
|
|
111
111
|
else
|
|
112
112
|
new_value = nil
|
|
113
|
-
raise InterpreterError, '
|
|
113
|
+
raise InterpreterError, 'Invalid object reference: "' + str + '"' if str == original
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
116
|
return new_value, str
|
|
@@ -142,7 +142,12 @@ module MODL
|
|
|
142
142
|
result = if n.to_s == p
|
|
143
143
|
# Numeric ref
|
|
144
144
|
if !result.nil? && !result.respond_to?(:find_property)
|
|
145
|
-
|
|
145
|
+
if !result.is_a?(Parsed::ParsedArrayValueItem)
|
|
146
|
+
t = result.class
|
|
147
|
+
t = 'map' if result.is_a? Parsed::ParsedMapItem
|
|
148
|
+
raise InterpreterError, 'Found a ' + t + ' when expecting an array'
|
|
149
|
+
end
|
|
150
|
+
raise InterpreterError, 'Invalid object reference: "' + degraved + '"'
|
|
146
151
|
end
|
|
147
152
|
result.nil? ? global.index_value(n, degraved) : result.find_property(n)
|
|
148
153
|
else
|
|
@@ -198,7 +203,7 @@ module MODL
|
|
|
198
203
|
nil
|
|
199
204
|
else
|
|
200
205
|
if !result.nil? && !result.respond_to?(:find_property)
|
|
201
|
-
raise InterpreterError, 'Invalid object reference: ' + degraved
|
|
206
|
+
raise InterpreterError, 'Invalid object reference: "' + degraved + '"'
|
|
202
207
|
end
|
|
203
208
|
if result.nil?
|
|
204
209
|
unless ref.start_with?('%`')
|
|
@@ -29,7 +29,7 @@ module MODL::Parser
|
|
|
29
29
|
include Singleton
|
|
30
30
|
|
|
31
31
|
def syntax_error(_recognizer, _offending_symbol, _line, _char_position_in_line, _msg, _e)
|
|
32
|
-
raise Antlr4::Runtime::ParseCancellationException, 'line' + _line.to_s + ':' + _char_position_in_line.to_s + ' ' + _msg.to_s
|
|
32
|
+
raise Antlr4::Runtime::ParseCancellationException, 'line ' + _line.to_s + ':' + _char_position_in_line.to_s + ' ' + _msg.to_s
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def report_ambiguity(_recognizer, _dfa, _start_index, _stop_index, _exact, _ambig_ilts, _configs)
|
data/lib/modl/parser/version.rb
CHANGED
data/modl.gemspec
CHANGED
|
@@ -23,9 +23,8 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
24
|
spec.require_paths = ['lib']
|
|
25
25
|
|
|
26
|
-
spec.add_development_dependency 'antlr4-runtime', '>= 0.0.1'
|
|
27
26
|
spec.add_development_dependency 'rake', '~> 10.0'
|
|
28
27
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
29
|
-
spec.add_runtime_dependency 'antlr4-runtime', '= 0.2.
|
|
28
|
+
spec.add_runtime_dependency 'antlr4-runtime', '= 0.2.8'
|
|
30
29
|
spec.add_runtime_dependency 'punycode4r', '>= 0.2.0'
|
|
31
30
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: modl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tony Walmsley
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-07-
|
|
11
|
+
date: 2019-07-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: antlr4-runtime
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.0.1
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.0.1
|
|
27
13
|
- !ruby/object:Gem::Dependency
|
|
28
14
|
name: rake
|
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,14 +44,14 @@ dependencies:
|
|
|
58
44
|
requirements:
|
|
59
45
|
- - '='
|
|
60
46
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 0.2.
|
|
47
|
+
version: 0.2.8
|
|
62
48
|
type: :runtime
|
|
63
49
|
prerelease: false
|
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
51
|
requirements:
|
|
66
52
|
- - '='
|
|
67
53
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 0.2.
|
|
54
|
+
version: 0.2.8
|
|
69
55
|
- !ruby/object:Gem::Dependency
|
|
70
56
|
name: punycode4r
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|