def get_token
      return nil if @token_index >= @arguments.size

      begin
        case chr(@arguments[@token_index])
        when "["
          return "statement", gen_substatement

        when "]"
          return "]"

        when "("
          return "(", "("

        when ")"
          return ")", ")"

        when "n"
          if (chr(@arguments[@token_index + 1]) == "o") && (chr(@arguments[@token_index + 2]) == "t") && ((chr(@arguments[@token_index + 3]) == " ") || (chr(@arguments[@token_index + 3]) == "("))
            @token_index += 2
            return "not", "not"
          else
            gen_statement
          end

        when "!"
          return "not", "not"

        when "a"
          if (chr(@arguments[@token_index + 1]) == "n") && (chr(@arguments[@token_index + 2]) == "d") && ((chr(@arguments[@token_index + 3]) == " ") || (chr(@arguments[@token_index + 3]) == "("))
            @token_index += 2
            return "and", "and"
          else
            gen_statement
          end

        when "&"
          if chr(@arguments[@token_index + 1]) == "&"
            @token_index += 1
            return "and", "and"
          else
            gen_statement
          end

        when "o"
          if (chr(@arguments[@token_index + 1]) == "r") && ((chr(@arguments[@token_index + 2]) == " ") || (chr(@arguments[@token_index + 2]) == "("))
            @token_index += 1
            return "or", "or"
          else
            gen_statement
          end

        when "|"
          if chr(@arguments[@token_index + 1]) == "|"
            @token_index += 1
            return "or", "or"
          else
            gen_statement
          end

        when "+"
          value = ""
          i = @token_index + 1

          begin
            value += chr(@arguments[i])
            i += 1
          end until (i >= @arguments.size) || (chr(@arguments[i]) =~ /\s|\)/)

          @token_index = i - 1
          return "+", value

        when "-"
          value = ""
          i = @token_index + 1

          begin
            value += chr(@arguments[i])
            i += 1
          end until (i >= @arguments.size) || (chr(@arguments[i]) =~ /\s|\)/)

          @token_index = i - 1
          return "-", value

        when " "
          return " ", " "

        else
          gen_statement
        end
      end
    rescue NoMethodError
      raise "Error. Expression cannot be parsed."
    end
def get_token
      return nil if @token_index >= @arguments.size

      begin
        case chr(@arguments[@token_index])
        when "["
          return "statement", gen_substatement

        when "]"
          return "]"

        when "("
          return "(", "("

        when ")"
          return ")", ")"

        when "n"
          if (chr(@arguments[@token_index + 1]) == "o") && (chr(@arguments[@token_index + 2]) == "t") && ((chr(@arguments[@token_index + 3]) == " ") || (chr(@arguments[@token_index + 3]) == "("))
            @token_index += 2
            return "not", "not"
          else
            gen_statement
          end

        when "!"
          return "not", "not"

        when "a"
          if (chr(@arguments[@token_index + 1]) == "n") && (chr(@arguments[@token_index + 2]) == "d") && ((chr(@arguments[@token_index + 3]) == " ") || (chr(@arguments[@token_index + 3]) == "("))
            @token_index += 2
            return "and", "and"
          else
            gen_statement
          end

        when "&"
          if chr(@arguments[@token_index + 1]) == "&"
            @token_index += 1
            return "and", "and"
          else
            gen_statement
          end

        when "o"
          if (chr(@arguments[@token_index + 1]) == "r") && ((chr(@arguments[@token_index + 2]) == " ") || (chr(@arguments[@token_index + 2]) == "("))
            @token_index += 1
            return "or", "or"
          else
            gen_statement
          end

        when "|"
          if chr(@arguments[@token_index + 1]) == "|"
            @token_index += 1
            return "or", "or"
          else
            gen_statement
          end

        when "+"
          value = ""
          i = @token_index + 1

          begin
            value += chr(@arguments[i])
            i += 1
          end until (i >= @arguments.size) || (chr(@arguments[i]) =~ /\s|\)/)

          @token_index = i - 1
          return "+", value

        when "-"
          value = ""
          i = @token_index + 1

          begin
            value += chr(@arguments[i])
            i += 1
          end until (i >= @arguments.size) || (chr(@arguments[i]) =~ /\s|\)/)

          @token_index = i - 1
          return "-", value

        when " "
          return " ", " "

        else
          gen_statement
        end
      end
    rescue NoMethodError
      raise "Error. Expression cannot be parsed."
    end
def get_token return nil if @token_index >= @arguments . size begin case chr ( @arguments [ @token_index ] ) when "[" return "statement" , gen_substatement when "]" return "]" when "(" return "(" , "(" when ")" return ")" , ")" when "n" if ( chr ( @arguments [ @token_index + 1 ] ) == "o" ) && ( chr ( @arguments [ @token_index + 2 ] ) == "t" ) && ( ( chr ( @arguments [ @token_index + 3 ] ) == " " ) || ( chr ( @arguments [ @token_index + 3 ] ) == "(" ) ) @token_index += 2 return "not" , "not" else gen_statement end when "!" return "not" , "not" when "a" if ( chr ( @arguments [ @token_index + 1 ] ) == "n" ) && ( chr ( @arguments [ @token_index + 2 ] ) == "d" ) && ( ( chr ( @arguments [ @token_index + 3 ] ) == " " ) || ( chr ( @arguments [ @token_index + 3 ] ) == "(" ) ) @token_index += 2 return "and" , "and" else gen_statement end when "&" if chr ( @arguments [ @token_index + 1 ] ) == "&" @token_index += 1 return "and" , "and" else gen_statement end when "o" if ( chr ( @arguments [ @token_index + 1 ] ) == "r" ) && ( ( chr ( @arguments [ @token_index + 2 ] ) == " " ) || ( chr ( @arguments [ @token_index + 2 ] ) == "(" ) ) @token_index += 1 return "or" , "or" else gen_statement end when "|" if chr ( @arguments [ @token_index + 1 ] ) == "|" @token_index += 1 return "or" , "or" else gen_statement end when "+" value = "" i = @token_index + 1 begin value += chr ( @arguments [ i ] ) i += 1 end until ( i >= @arguments . size ) || ( chr ( @arguments [ i ] ) =~ / \s \) / ) @token_index = i - 1 return "+" , value when "-" value = "" i = @token_index + 1 begin value += chr ( @arguments [ i ] ) i += 1 end until ( i >= @arguments . size ) || ( chr ( @arguments [ i ] ) =~ / \s \) / ) @token_index = i - 1 return "-" , value when " " return " " , " " else gen_statement end end rescue NoMethodError raise "Error. Expression cannot be parsed." end
Scans the input string and identifies single language tokens
Scans the input string and identifies single language tokens