Class: Atatus::Sql::Tokenizer Private

Inherits:
Object
  • Object
show all
Includes:
Tokens
Defined in:
lib/atatus/sql/tokenizer.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

ALPHA =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/[[:alpha:]]/.freeze
DIGIT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/[[:digit:]]/.freeze
SPACE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/[[:space:]]+/.freeze

Constants included from Tokens

Atatus::Sql::Tokens::AS, Atatus::Sql::Tokens::CALL, Atatus::Sql::Tokens::COMMA, Atatus::Sql::Tokens::COMMENT, Atatus::Sql::Tokens::DELETE, Atatus::Sql::Tokens::FROM, Atatus::Sql::Tokens::IDENT, Atatus::Sql::Tokens::INSERT, Atatus::Sql::Tokens::INTO, Atatus::Sql::Tokens::KEYWORDS, Atatus::Sql::Tokens::KEYWORD_MAX_LENGTH, Atatus::Sql::Tokens::KEYWORD_MIN_LENGTH, Atatus::Sql::Tokens::LPAREN, Atatus::Sql::Tokens::NUMBER, Atatus::Sql::Tokens::OR, Atatus::Sql::Tokens::OTHER, Atatus::Sql::Tokens::PERIOD, Atatus::Sql::Tokens::REPLACE, Atatus::Sql::Tokens::RPAREN, Atatus::Sql::Tokens::SELECT, Atatus::Sql::Tokens::SET, Atatus::Sql::Tokens::STRING, Atatus::Sql::Tokens::TABLE, Atatus::Sql::Tokens::TRUNCATE, Atatus::Sql::Tokens::UPDATE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Tokenizer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Tokenizer.



33
34
35
36
37
38
# File 'lib/atatus/sql/tokenizer.rb', line 33

def initialize(input)
  @input = input

  @scanner = StringScanner.new(input)
  @byte_start = 0
end

Instance Attribute Details

#inputObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/atatus/sql/tokenizer.rb', line 40

def input
  @input
end

#scannerObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/atatus/sql/tokenizer.rb', line 40

def scanner
  @scanner
end

#tokenObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/atatus/sql/tokenizer.rb', line 40

def token
  @token
end

Instance Method Details

#scanObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/atatus/sql/tokenizer.rb', line 46

def scan
  scanner.skip(SPACE)

  @byte_start = scanner.pos
  char = next_char

  return false unless char

  @token = next_token(char)

  true
end

#textObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
# File 'lib/atatus/sql/tokenizer.rb', line 42

def text
  @input.byteslice(@byte_start, @byte_end - @byte_start)
end