ceml 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ceml/tt/instructions.rb +92 -3
- data/lib/ceml/tt/instructions.treetop +6 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/ceml/tt/instructions.rb
CHANGED
@@ -58,7 +58,7 @@ module Instructions
|
|
58
58
|
def key; var || text; end
|
59
59
|
def cmd;
|
60
60
|
text_value =~ /^ask/ and return :ask
|
61
|
-
text_value =~ /^tell/ and return :tell
|
61
|
+
text_value =~ /^(tell|assign)/ and return :tell
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -81,8 +81,14 @@ module Instructions
|
|
81
81
|
r0 = r2
|
82
82
|
r0.extend(Instruction0)
|
83
83
|
else
|
84
|
-
|
85
|
-
|
84
|
+
r3 = _nt_assign_stmt
|
85
|
+
if r3
|
86
|
+
r0 = r3
|
87
|
+
r0.extend(Instruction0)
|
88
|
+
else
|
89
|
+
@index = i0
|
90
|
+
r0 = nil
|
91
|
+
end
|
86
92
|
end
|
87
93
|
end
|
88
94
|
|
@@ -174,6 +180,89 @@ module Instructions
|
|
174
180
|
r0
|
175
181
|
end
|
176
182
|
|
183
|
+
module AssignStmt0
|
184
|
+
def ws
|
185
|
+
elements[1]
|
186
|
+
end
|
187
|
+
|
188
|
+
def id
|
189
|
+
elements[2]
|
190
|
+
end
|
191
|
+
|
192
|
+
def text
|
193
|
+
elements[5]
|
194
|
+
end
|
195
|
+
|
196
|
+
def nl
|
197
|
+
elements[6]
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def _nt_assign_stmt
|
202
|
+
start_index = index
|
203
|
+
if node_cache[:assign_stmt].has_key?(index)
|
204
|
+
cached = node_cache[:assign_stmt][index]
|
205
|
+
@index = cached.interval.end if cached
|
206
|
+
return cached
|
207
|
+
end
|
208
|
+
|
209
|
+
i0, s0 = index, []
|
210
|
+
if has_terminal?('assign', false, index)
|
211
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 6))
|
212
|
+
@index += 6
|
213
|
+
else
|
214
|
+
terminal_parse_failure('assign')
|
215
|
+
r1 = nil
|
216
|
+
end
|
217
|
+
s0 << r1
|
218
|
+
if r1
|
219
|
+
r2 = _nt_ws
|
220
|
+
s0 << r2
|
221
|
+
if r2
|
222
|
+
r3 = _nt_id
|
223
|
+
s0 << r3
|
224
|
+
if r3
|
225
|
+
if has_terminal?(':', false, index)
|
226
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
227
|
+
@index += 1
|
228
|
+
else
|
229
|
+
terminal_parse_failure(':')
|
230
|
+
r4 = nil
|
231
|
+
end
|
232
|
+
s0 << r4
|
233
|
+
if r4
|
234
|
+
r6 = _nt_ws
|
235
|
+
if r6
|
236
|
+
r5 = r6
|
237
|
+
else
|
238
|
+
r5 = instantiate_node(SyntaxNode,input, index...index)
|
239
|
+
end
|
240
|
+
s0 << r5
|
241
|
+
if r5
|
242
|
+
r7 = _nt_text
|
243
|
+
s0 << r7
|
244
|
+
if r7
|
245
|
+
r8 = _nt_nl
|
246
|
+
s0 << r8
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
if s0.last
|
254
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
255
|
+
r0.extend(AssignStmt0)
|
256
|
+
else
|
257
|
+
@index = i0
|
258
|
+
r0 = nil
|
259
|
+
end
|
260
|
+
|
261
|
+
node_cache[:assign_stmt][start_index] = r0
|
262
|
+
|
263
|
+
r0
|
264
|
+
end
|
265
|
+
|
177
266
|
module AskStmt0
|
178
267
|
def ws1
|
179
268
|
elements[0]
|
@@ -7,7 +7,7 @@ grammar Instructions
|
|
7
7
|
end
|
8
8
|
|
9
9
|
rule instruction
|
10
|
-
(ask_stmt / tell_stmt) {
|
10
|
+
(ask_stmt / tell_stmt / assign_stmt) {
|
11
11
|
|
12
12
|
INTERPOLATE_REGEX = /\|(\w+)\.?(\w+)?\|/
|
13
13
|
|
@@ -25,7 +25,7 @@ grammar Instructions
|
|
25
25
|
def key; var || text; end
|
26
26
|
def cmd;
|
27
27
|
text_value =~ /^ask/ and return :ask
|
28
|
-
text_value =~ /^tell/ and return :tell
|
28
|
+
text_value =~ /^(tell|assign)/ and return :tell
|
29
29
|
end
|
30
30
|
}
|
31
31
|
end
|
@@ -34,6 +34,10 @@ grammar Instructions
|
|
34
34
|
'tell' ws id ':' ws? text nl
|
35
35
|
end
|
36
36
|
|
37
|
+
rule assign_stmt
|
38
|
+
'assign' ws id ':' ws? text nl
|
39
|
+
end
|
40
|
+
|
37
41
|
rule ask_stmt
|
38
42
|
'ask' ws id about:(ws 're' ws varname:id)? ':' ws? text nl
|
39
43
|
end
|