Class: ElasticAPM::Sql::Tokenizer Private

Inherits:
Object
  • Object
show all
Includes:
Tokens
Defined in:
lib/elastic_apm/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

ElasticAPM::Sql::Tokens::AS, ElasticAPM::Sql::Tokens::CALL, ElasticAPM::Sql::Tokens::COMMA, ElasticAPM::Sql::Tokens::COMMENT, ElasticAPM::Sql::Tokens::DELETE, ElasticAPM::Sql::Tokens::FROM, ElasticAPM::Sql::Tokens::IDENT, ElasticAPM::Sql::Tokens::INSERT, ElasticAPM::Sql::Tokens::INTO, ElasticAPM::Sql::Tokens::KEYWORDS, ElasticAPM::Sql::Tokens::KEYWORD_MAX_LENGTH, ElasticAPM::Sql::Tokens::KEYWORD_MIN_LENGTH, ElasticAPM::Sql::Tokens::LPAREN, ElasticAPM::Sql::Tokens::NUMBER, ElasticAPM::Sql::Tokens::OR, ElasticAPM::Sql::Tokens::OTHER, ElasticAPM::Sql::Tokens::PERIOD, ElasticAPM::Sql::Tokens::REPLACE, ElasticAPM::Sql::Tokens::RPAREN, ElasticAPM::Sql::Tokens::SELECT, ElasticAPM::Sql::Tokens::SET, ElasticAPM::Sql::Tokens::STRING, ElasticAPM::Sql::Tokens::TABLE, ElasticAPM::Sql::Tokens::TRUNCATE, ElasticAPM::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/elastic_apm/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/elastic_apm/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/elastic_apm/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/elastic_apm/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/elastic_apm/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/elastic_apm/sql/tokenizer.rb', line 42

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