module Safrano::Filter::Parser::Token

Input tokenizer

Constants

BINOARITHM
BINOBOOL
FPRGX
FUNCNAMES
FUNCRGX
NOTRGX
NULLRGX
QSTRINGRGX
QUALITRGX
RGX

Public Instance Methods

each_typed_token(inp) { |found, typ| ... } click to toggle source
# File lib/odata/filter/token.rb, line 22
def each_typed_token(inp)
  typ = nil

  inp.scan(RGX) do |groups|
    idx = nil
    found = nil
    groups.each_with_index do |tok, i|
      if (found = tok)
        idx = i
        break
      end
    end
    typ = case idx
          when 0
            :FuncTree
          when 1
            :NullLiteral
          when 2
            case found
            when '(', ')'
              :Delimiter
            when ','
              :Separator
            end
          when 3
            :BinopBool
          when 4
            :BinopArithm
          when 5
            :UnopTree
          when 6
            :QString
          when 7
            :FPNumber
          when 8
            :Qualit
          when 9
            :Literal
          when 10
            :unmatchedQuote
          end
    yield found, typ
  end
end