Class: Peruby::Lexer::Token

Inherits:
Data
  • Object
show all
Defined in:
lib/peruby/lexer/token.rb

Overview

One lexical token and its source location.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column

Returns:

  • (Object)

    the current value of column



6
7
8
# File 'lib/peruby/lexer/token.rb', line 6

def column
  @column
end

#fileObject (readonly)

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



6
7
8
# File 'lib/peruby/lexer/token.rb', line 6

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



6
7
8
# File 'lib/peruby/lexer/token.rb', line 6

def line
  @line
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



6
7
8
# File 'lib/peruby/lexer/token.rb', line 6

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



6
7
8
# File 'lib/peruby/lexer/token.rb', line 6

def value
  @value
end

Instance Method Details

#to_aObject



7
8
9
# File 'lib/peruby/lexer/token.rb', line 7

def to_a
  [type, value]
end

#to_sObject



11
12
13
# File 'lib/peruby/lexer/token.rb', line 11

def to_s
  "#{file}:#{line}:#{column} #{type} #{value.inspect}"
end