Class: Dendroid::Lexical::TokenPosition
- Inherits:
-
Object
- Object
- Dendroid::Lexical::TokenPosition
- Defined in:
- lib/dendroid/lexical/token_position.rb
Overview
Keeps track of the position of a token in the input stream.
Instance Attribute Summary collapse
-
#column ⇒ Integer
readonly
The column number where the token begins.
-
#lineno ⇒ Integer
readonly
The line number where the token begins.
Instance Method Summary collapse
-
#initialize(line, col) ⇒ TokenPosition
constructor
Constructor.
-
#to_s ⇒ String
Return the position of the start of the token in line:col format.
Constructor Details
#initialize(line, col) ⇒ TokenPosition
Constructor
16 17 18 19 |
# File 'lib/dendroid/lexical/token_position.rb', line 16 def initialize(line, col) @lineno = line @column = col end |
Instance Attribute Details
#column ⇒ Integer (readonly)
Returns The column number where the token begins.
11 12 13 |
# File 'lib/dendroid/lexical/token_position.rb', line 11 def column @column end |
#lineno ⇒ Integer (readonly)
Returns The line number where the token begins.
8 9 10 |
# File 'lib/dendroid/lexical/token_position.rb', line 8 def lineno @lineno end |
Instance Method Details
#to_s ⇒ String
Return the position of the start of the token in line:col format
23 24 25 |
# File 'lib/dendroid/lexical/token_position.rb', line 23 def to_s "#{lineno}:#{column}" end |