Class: RLTK::StreamPosition

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



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

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)


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

def file_name
  @file_name
end

#lengthInteger

Returns:

  • (Integer)


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

def length
  @length
end

#line_numberInteger

Returns:

  • (Integer)


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

def line_number
  @line_number
end

#line_offsetInteger Also known as: start

Returns:

  • (Integer)


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

def line_offset
  @line_offset
end

#stream_offsetInteger

Returns:

  • (Integer)


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

def stream_offset
  @stream_offset
end