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
|
# File 'lib/antlr3/streams/rewrite.rb', line 264
def execute( *range_arguments )
if range_arguments.empty?
range = 0 ... @stream.length
else
range, = cast_range( range_arguments )
end
output = ''
tokens = @stream.tokens
operations = reduce
cursor = range.first
while range.include?( cursor )
if operation = operations.delete( cursor )
cursor = operation.execute( output )
else
token = tokens[ cursor ]
output << token.text if token
cursor += 1
end
end
if operation = operations.delete( cursor ) and
operation.is_a?( InsertBefore )
operation.execute( output )
end
return output
end
|