Class: StructuredSearch::Token

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

Overview

A token generated by the lexer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tok = {}) ⇒ Token

:nodoc:



13
14
15
16
17
18
# File 'lib/structured_search/token.rb', line 13

def initialize(tok = {})
  #send val to key setter
  tok.each do |k, v|
    send "#{k}=", v
  end
end

Instance Attribute Details

#columnObject

token

The token’s type

lexeme

The matched characters that make up the token

column

Column this token was located

line

Line this token was located



10
11
12
# File 'lib/structured_search/token.rb', line 10

def column
  @column
end

#lexemeObject

token

The token’s type

lexeme

The matched characters that make up the token

column

Column this token was located

line

Line this token was located



10
11
12
# File 'lib/structured_search/token.rb', line 10

def lexeme
  @lexeme
end

#lineObject

token

The token’s type

lexeme

The matched characters that make up the token

column

Column this token was located

line

Line this token was located



10
11
12
# File 'lib/structured_search/token.rb', line 10

def line
  @line
end

#tokenObject

token

The token’s type

lexeme

The matched characters that make up the token

column

Column this token was located

line

Line this token was located



10
11
12
# File 'lib/structured_search/token.rb', line 10

def token
  @token
end

Instance Method Details

#to_sObject

Returns a string representation of the token



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

def to_s
  "#{@token}: '#{@lexeme}' (Line #{@line}, Column #{@column})"
end