Class: Syntax::PseudoSqlTokenizer

Inherits:
Tokenizer
  • Object
show all
Defined in:
lib/zena/code/default_syntax.rb

Instance Method Summary collapse

Instance Method Details

#stepObject



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/zena/code/default_syntax.rb', line 275

def step
  if @state.nil? and method = scan(/\w+/)
    start_group :method, method
    @state = :method
  elsif @state == :in and context = scan(/\w+/)
    start_group :context, context
    @state = :context
  elsif keyword = scan(/\bin\b/)
    start_group :context, keyword
    @state = :in
  elsif keyword = scan(/\bfrom\b/)
    start_group :sub, keyword
    @state = nil
  elsif keyword = scan(/\bwhere|select|group\s+by|having|order|limit|offset|paginate\b/)
    start_group :keyword, keyword
  elsif punct  = scan(/\b>=|<=|<>|<|=|>|not\s+like|like|lt|le|eq|ne|ge|gt\b/)
    start_group :punct, punct
  elsif string = scan(/("|')[^'"]*\1/)
    string =~ /("|')([^'"]*)\1/
    start_group :punct, $1
    start_group :string, $2
    start_group :punct, $1
  else
    start_group :normal, scan(/./m)
  end
end