Module: CEML::Scripts

Includes:
Casting, Instructions, Lexer, Treetop::Runtime
Included in:
ScriptsParser
Defined in:
lib/ceml/tt/scripts.rb

Defined Under Namespace

Modules: ScriptWithInstructions0, ScriptWithTitle0, Title0, Title1, Title2

Instance Method Summary collapse

Methods included from Instructions

#_nt_ask_stmt, #_nt_assign_stmt, #_nt_instruction, #_nt_instructions, #_nt_tell_stmt, #asks, #for, #roles, #tell, #validate!

Methods included from Lexer

#_nt_comment, #_nt_eol, #_nt_id, #_nt_nl, #_nt_number, #_nt_text, #_nt_ws

Methods included from Casting

#_nt_casting_method, #_nt_casting_statement, #_nt_distance, #_nt_range, #_nt_role, #_nt_roles_phrase

Instance Method Details

#_nt_scriptObject



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
# File 'lib/ceml/tt/scripts.rb', line 47

def _nt_script
  start_index = index
  if node_cache[:script].has_key?(index)
    cached = node_cache[:script][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0 = index
  r1 = _nt_script_with_title
  if r1
    r0 = r1
    r0.extend(Script)
  else
    r2 = _nt_script_with_instructions
    if r2
      r0 = r2
      r0.extend(Script)
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:script][start_index] = r0

  r0
end

#_nt_script_with_instructionsObject



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
# File 'lib/ceml/tt/scripts.rb', line 155

def _nt_script_with_instructions
  start_index = index
  if node_cache[:script_with_instructions].has_key?(index)
    cached = node_cache[:script_with_instructions][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0, s0 = index, []
  r2 = _nt_nl
  if r2
    r1 = r2
  else
    r1 = instantiate_node(SyntaxNode,input, index...index)
  end
  s0 << r1
  if r1
    r4 = _nt_title
    if r4
      r3 = r4
    else
      r3 = instantiate_node(SyntaxNode,input, index...index)
    end
    s0 << r3
    if r3
      r6 = _nt_casting_statement
      if r6
        r5 = r6
      else
        r5 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r5
      if r5
        r7 = _nt_instructions
        s0 << r7
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(ScriptWithInstructions0)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:script_with_instructions][start_index] = r0

  r0
end

#_nt_script_with_titleObject



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
# File 'lib/ceml/tt/scripts.rb', line 90

def _nt_script_with_title
  start_index = index
  if node_cache[:script_with_title].has_key?(index)
    cached = node_cache[:script_with_title][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0, s0 = index, []
  r2 = _nt_nl
  if r2
    r1 = r2
  else
    r1 = instantiate_node(SyntaxNode,input, index...index)
  end
  s0 << r1
  if r1
    r3 = _nt_title
    s0 << r3
    if r3
      r5 = _nt_casting_statement
      if r5
        r4 = r5
      else
        r4 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r4
      if r4
        r7 = _nt_instructions
        if r7
          r6 = r7
        else
          r6 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r6
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(ScriptWithTitle0)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:script_with_title][start_index] = r0

  r0
end

#_nt_scriptsObject



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
# File 'lib/ceml/tt/scripts.rb', line 18

def _nt_scripts
  start_index = index
  if node_cache[:scripts].has_key?(index)
    cached = node_cache[:scripts][index]
    @index = cached.interval.end if cached
    return cached
  end

  s0, i0 = [], index
  loop do
    r1 = _nt_script
    if r1
      s0 << r1
    else
      break
    end
  end
  if s0.empty?
    @index = i0
    r0 = nil
  else
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
  end

  node_cache[:scripts][start_index] = r0

  r0
end

#_nt_titleObject



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/ceml/tt/scripts.rb', line 225

def _nt_title
  start_index = index
  if node_cache[:title].has_key?(index)
    cached = node_cache[:title][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0, s0 = index, []
  if has_terminal?('"', false, index)
    r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure('"')
    r1 = nil
  end
  s0 << r1
  if r1
    s2, i2 = [], index
    loop do
      i3 = index
      if has_terminal?('\\"', false, index)
        r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
        @index += 2
      else
        terminal_parse_failure('\\"')
        r4 = nil
      end
      if r4
        r3 = r4
      else
        i5, s5 = index, []
        i6 = index
        if has_terminal?('"', false, index)
          r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure('"')
          r7 = nil
        end
        if r7
          r6 = nil
        else
          @index = i6
          r6 = instantiate_node(SyntaxNode,input, index...index)
        end
        s5 << r6
        if r6
          if index < input_length
            next_character = index + input[index..-1].match(/\A(.)/um).end(1)
            r8 = instantiate_node(SyntaxNode,input, index...next_character)
            @index = next_character
          else
            terminal_parse_failure("any character")
            r8 = nil
          end
          s5 << r8
        end
        if s5.last
          r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
          r5.extend(Title0)
        else
          @index = i5
          r5 = nil
        end
        if r5
          r3 = r5
        else
          @index = i3
          r3 = nil
        end
      end
      if r3
        s2 << r3
      else
        break
      end
    end
    if s2.empty?
      @index = i2
      r2 = nil
    else
      r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
    end
    s0 << r2
    if r2
      if has_terminal?('"', false, index)
        r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure('"')
        r9 = nil
      end
      s0 << r9
      if r9
        r10 = _nt_nl
        s0 << r10
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(Title1)
    r0.extend(Title2)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:title][start_index] = r0

  r0
end

#rootObject



8
9
10
# File 'lib/ceml/tt/scripts.rb', line 8

def root
  @root || :scripts
end