Class: ANTLR3::Rewrite::RewriteOperation

Inherits:
Struct
  • Object
show all
Extended by:
ClassMacros
Defined in:
lib/antlr3/streams/rewrite.rb,
lib/antlr3/streams/rewrite.rb

Overview

RewiteOperation objects represent some particular editing command that should be executed by a token rewrite stream at some time in future when the stream is rendering a rewritten stream.

To perform token stream rewrites safely and efficiently, the rewrites are executed lazily (that is, only when the rewritten text is explicitly requested). Rewrite streams implement lazy rewriting by storing the parameters of edit-inducing methods like delete and insert as RewriteOperation objects in a rewrite program list.

The three subclasses of RewriteOperation, InsertBefore, Delete, and Replace, define specific implementations of stream edits.

Direct Known Subclasses

InsertBefore, Replace

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.operation_nameObject (readonly)

the printable name of operations represented by the class – used for inspection


65
66
67
# File 'lib/antlr3/streams/rewrite.rb', line 65

def operation_name
  @operation_name
end

Instance Attribute Details

#locationObject

Returns the value of attribute location


38
39
40
# File 'lib/antlr3/streams/rewrite.rb', line 38

def location
  @location
end

#streamObject

Returns the value of attribute stream


38
39
40
# File 'lib/antlr3/streams/rewrite.rb', line 38

def stream
  @stream
end

#textObject

Returns the value of attribute text


38
39
40
# File 'lib/antlr3/streams/rewrite.rb', line 38

def text
  @text
end

Instance Method Details

#executeObject

:method: execute( buffer ) run the rewrite operation represented by this object and append the output to buffer


71
# File 'lib/antlr3/streams/rewrite.rb', line 71

abstract :execute

#inspectObject

return a compact, readable representation of this operation


81
82
83
# File 'lib/antlr3/streams/rewrite.rb', line 81

def inspect
  return "(%s @ %p : %p)" % [ name, location, text ]
end

#nameObject

return the name of this operation as set by its class


75
76
77
# File 'lib/antlr3/streams/rewrite.rb', line 75

def name
  self.class.operation_name
end