Class: ANTLR3::Rewrite::RewriteOperation
- Inherits:
-
Struct
- Object
- Struct
- ANTLR3::Rewrite::RewriteOperation
- 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
Class Attribute Summary collapse
-
.operation_name ⇒ Object
readonly
the printable name of operations represented by the class – used for inspection.
Instance Attribute Summary collapse
-
#location ⇒ Object
Returns the value of attribute location.
-
#stream ⇒ Object
Returns the value of attribute stream.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#execute ⇒ Object
:method: execute( buffer ) run the rewrite operation represented by this object and append the output to
buffer
. -
#inspect ⇒ Object
return a compact, readable representation of this operation.
-
#name ⇒ Object
return the name of this operation as set by its class.
Class Attribute Details
.operation_name ⇒ Object (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
#location ⇒ Object
Returns the value of attribute location
38 39 40 |
# File 'lib/antlr3/streams/rewrite.rb', line 38 def location @location end |
#stream ⇒ Object
Returns the value of attribute stream
38 39 40 |
# File 'lib/antlr3/streams/rewrite.rb', line 38 def stream @stream end |
#text ⇒ Object
Returns the value of attribute text
38 39 40 |
# File 'lib/antlr3/streams/rewrite.rb', line 38 def text @text end |
Instance Method Details
#execute ⇒ Object
: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 |
#inspect ⇒ Object
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 |
#name ⇒ Object
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 |