Class: ANTLR3::Rewrite::Replace
- Inherits:
-
RewriteOperation
- Object
- Struct
- RewriteOperation
- ANTLR3::Rewrite::Replace
- Defined in:
- lib/antlr3/streams/rewrite.rb
Overview
Represents rewrite operation:
add text op.text
to the rewrite buffer in lieu of the text of tokens indexed within the range op.index .. op.last_index
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from RewriteOperation
Instance Method Summary collapse
- #execute(buffer) ⇒ Object
- #index ⇒ Object
-
#initialize(stream, location, text) ⇒ Replace
constructor
A new instance of Replace.
- #location=(val) ⇒ Object
Methods inherited from RewriteOperation
Constructor Details
#initialize(stream, location, text) ⇒ Replace
Returns a new instance of Replace.
122 123 124 125 |
# File 'lib/antlr3/streams/rewrite.rb', line 122 def initialize( stream, location, text ) super( stream, nil, text ) self.location = location end |
Instance Method Details
#execute(buffer) ⇒ Object
136 137 138 139 |
# File 'lib/antlr3/streams/rewrite.rb', line 136 def execute( buffer ) buffer << text.to_s unless text.nil? return( location.end + 1 ) end |
#index ⇒ Object
141 142 143 |
# File 'lib/antlr3/streams/rewrite.rb', line 141 def index location.first end |
#location=(val) ⇒ Object
127 128 129 130 131 132 133 134 |
# File 'lib/antlr3/streams/rewrite.rb', line 127 def location=( val ) case val when Range then super( val ) else val = val.to_i super( val..val ) end end |