Class: LanguageParser::SQLTokenizer

Inherits:
Tokenizer
  • Object
show all
Defined in:
lib/cgialib/lp/SQLTokenizer.rb

Overview

class : SQLTokenizer

The main entry class that parses SQL text into a set of tokens

Instance Attribute Summary

Attributes inherited from Tokenizer

#tokens

Instance Method Summary collapse

Methods inherited from Tokenizer

#initialize

Constructor Details

This class inherits a constructor from LanguageParser::Tokenizer

Instance Method Details

#parse(text) ⇒ Object

parse( text )

text - The SQL text

Parses the SQL text string into tokens



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/cgialib/lp/SQLTokenizer.rb', line 339

def parse( text )
  
  # Set the current state to the normal state
  
  @state = SQLT_NormalState.new(
    method( :newstate ),
    method( :addtoken ) )
  
  # Iterate through the text
  
  index = 0
  
  while index < text.length
  
    # Dispatch the character to the current state
  
    if ( @state.next( text[ index ].chr() ) )
  
      index += 1
  
    end
  
  end
  
end