module ANTLR3::Stream
ANTLR3
Streams¶ ↑
This documentation first covers the general concept of streams as used by ANTLR recognizers, and then discusses the specific ANTLR3::Stream
module.
ANTLR Stream
Classes¶ ↑
ANTLR recognizers need a way to walk through input data in a serialized IO-style fashion. They also need some book-keeping about the input to provide useful information to developers, such as current line number and column. Furthermore, to implement backtracking and various error recovery techniques, recognizers need a way to record various locations in the input at a number of points in the recognition process so the input state may be restored back to a prior state.
ANTLR bundles all of this functionality into a number of Stream
classes, each designed to be used by recognizers for a specific recognition task. Most of the Stream
hierarchy is implemented in antlr3/stream.rb, which is loaded by default when ‘antlr3’ is required.
Attributes
the total number of symbols in the stream
indicates an identifying name for the stream – usually the file path of the input
Public Instance Methods
used to advance a stream one unit (such as character or token)
# File lib/antlr3/streams.rb, line 173 abstract :consume
returns the current position of the stream
# File lib/antlr3/streams.rb, line 197 abstract :index
used to retreive the full object of interest at lookahead position specified by k
(such as a character string or a token structure)
# File lib/antlr3/streams.rb, line 186 abstract :look
saves the current position for the purposes of backtracking and returns a value to pass to rewind at a later time
# File lib/antlr3/streams.rb, line 192 abstract :mark
used to quickly retreive the object of interest to a recognizer at lookahead position specified by k
(such as integer value of a character or an integer token type)
# File lib/antlr3/streams.rb, line 180 abstract :peek
clears the saved state information associated with the given marker value
# File lib/antlr3/streams.rb, line 208 abstract :release
restores the stream position using the state information previously saved by the given marker
# File lib/antlr3/streams.rb, line 203 abstract :rewind
move the stream to the given absolute index given by position
# File lib/antlr3/streams.rb, line 213 abstract :seek