Class: Dendroid::Lexical::TokenPosition

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(line, col) ⇒ TokenPosition

Constructor

Parameters:

  • line (Integer)

    The line number where the token begins

  • col (Integer)

    The column number where the token begins



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

#columnInteger (readonly)

Returns The column number where the token begins.

Returns:

  • (Integer)

    The column number where the token begins



11
12
13
# File 'lib/dendroid/lexical/token_position.rb', line 11

def column
  @column
end

#linenoInteger (readonly)

Returns The line number where the token begins.

Returns:

  • (Integer)

    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_sString

Return the position of the start of the token in line:col format

Returns:

  • (String)


23
24
25
# File 'lib/dendroid/lexical/token_position.rb', line 23

def to_s
  "#{lineno}:#{column}"
end