Class: RLTK::StreamPosition

Inherits:
Object show all
Defined in:
lib/rltk/token.rb

Overview

The StreamPosition class is used to indicate the position of a token or other text inside a stream.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream_offset = 0, line_number = 0, line_offset = 0, length = 0, file_name = nil) ⇒ StreamPosition

Instantiates a new StreamPosition object with the values specified.

Parameters:

  • stream_offset (Integer) (defaults to: 0)

    The position from the beginning of the stream.

  • line_number (Integer) (defaults to: 0)

    The number of newlines since the beginning of the file.

  • line_offset (Integer) (defaults to: 0)

    The offset of this token from the beginning of the current line.

  • length (Integer) (defaults to: 0)

    The length of the text of the token.

  • file_name (String, nil) (defaults to: nil)

    The name of the file being lexed.



39
40
41
42
43
44
45
# File 'lib/rltk/token.rb', line 39

def initialize(stream_offset = 0, line_number = 0, line_offset = 0, length = 0, file_name = nil)
	@stream_offset	= stream_offset
	@line_number	= line_number
	@line_offset	= line_offset
	@length		= length
	@file_name	= file_name
end

Instance Attribute Details

#file_nameString

Returns:

  • (String)


28
29
30
# File 'lib/rltk/token.rb', line 28

def file_name
  @file_name
end

#lengthInteger

Returns:



25
26
27
# File 'lib/rltk/token.rb', line 25

def length
  @length
end

#line_numberInteger

Returns:



19
20
21
# File 'lib/rltk/token.rb', line 19

def line_number
  @line_number
end

#line_offsetInteger Also known as: start

Returns:



22
23
24
# File 'lib/rltk/token.rb', line 22

def line_offset
  @line_offset
end

#stream_offsetInteger

Returns:



16
17
18
# File 'lib/rltk/token.rb', line 16

def stream_offset
  @stream_offset
end