Пример #1
0
bool DataTypeClassNameParser::Parser::read_raw_arguments(std::string* args) {
  skip_blank();

  if (is_eos() || str_[index_] == ')' || str_[index_] == ',') {
    *args = "";
    return true;
  }

  if (str_[index_] != '(') {
    parse_error(str_, index_, "Expected '('");
    return false;
  }

  int i = index_;
  int open = 1;
  while (open > 0) {
    ++index_;

    if (is_eos()) {
      parse_error(str_, index_, "Expected ')'");
      return false;
    }

    if (str_[index_] == '(') {
      open++;
    } else if (str_[index_] == ')') {
      open--;
    }
  }

  ++index_; // Skip ')'
  *args = str_.substr(i, index_);
  return true;
}
Пример #2
0
bool DataTypeClassNameParser::Parser::get_type_params(TypeParamsVec* params) {
  if (is_eos()) {
    params->clear();
    return true;
  }

  if (str_[index_] != '(') {
    parse_error(str_, index_,  "Expected '(' before type parameters");
    return false;
  }

  ++index_; // Skip '('

  while (skip_blank_and_comma()) {
    if (str_[index_] == ')') {
      ++index_;
      return true;
    }

    std::string param;
    if (!read_one(&param)) {
      return false;
    }
    params->push_back(param);
  }

  parse_error(str_, index_,  "Unexpected end of string");
  return false;
}
Пример #3
0
void DataTypeCqlNameParser::Parser::parse_type_parameters(TypeParamsVec* params) {
  params->clear();

  if (is_eos()) return;

  skip_blank_and_comma();

  if (str_[index_] != '<') {
    LOG_ERROR("Expecting char %u of %s to be '<' but '%c' found",
              (unsigned int)index_, str_.c_str(), str_[index_]);
    return;
  }

  ++index_; // Skip '<'

  std::string name;
  std::string args;
  while (skip_blank_and_comma()) {
    if (str_[index_] == '>') {
      ++index_;
      return;
    }
    parse_type_name(&name);
    if (!read_raw_type_parameters(&args))
      return;
    params->push_back(name + args);
  }
}
Пример #4
0
bool DataTypeCqlNameParser::Parser::read_raw_type_parameters(std::string* params) {
  skip_blank();

  params->clear();

  if (is_eos() || str_[index_] == '>' || str_[index_] == ',') return true;

  if (str_[index_] != '<') {
    LOG_ERROR("Expecting char %u of %s to be '<' but '%c' found",
              (unsigned int)index_, str_.c_str(), str_[index_]);
    return false;
  }

  size_t start_index = index_;
  int open = 1;
  bool in_quotes = false;
  while (open > 0) {
    ++index_;

    if (is_eos()) {
      LOG_ERROR("Angle brackets not closed in type %s", str_.c_str());
      return false;
    }

    if (!in_quotes) {
      if (str_[index_] == '"') {
        in_quotes = true;
      } else if (str_[index_] == '<') {
        open++;
      } else if (str_[index_] == '>') {
        open--;
      }
    } else if (str_[index_] == '"') {
      in_quotes = false;
    }
  }

  ++index_; // Move past the  trailing '>'
  params->assign(str_.begin() + start_index, str_.begin() + index_);
  return true;
}
Пример #5
0
void DataTypeClassNameParser::Parser::read_next_identifier(std::string* name) {
  size_t i = index_;
  while (!is_eos() && is_identifier_char(str_[index_]))
    ++index_;
  if (name != NULL) {
    if (index_ > i) {
      *name = str_.substr(i, index_ - i);
    } else{
      name->clear();
    }
  }
}
Пример #6
0
void DataTypeCqlNameParser::Parser::read_next_identifier(std::string* name) {
  size_t start_index = index_;
  if (str_[start_index] == '"') {
    ++index_;
    while (!is_eos()) {
      bool is_quote = str_[index_] == '"';
      ++index_;
      if (is_quote) {
        if  (!is_eos() && str_[index_] == '"') {
          ++index_;
        } else {
          break;
        }
      }
    }
  } else {
    while (!is_eos() && (is_identifier_char(str_[index_]) || str_[index_] == '"')) {
      ++index_;
    }
  }
  name->assign(str_.begin() + start_index, str_.begin() + index_);
}
Пример #7
0
bool DataTypeClassNameParser::Parser::get_collection_params(NameAndTypeParamsVec* params) {
  if (is_eos()) {
    params->clear();
    return true;
  }

  if (str_[index_] != '(') {
    parse_error(str_, index_,  "Expected '(' before collection parameters");
    return false;
  }

  ++index_; // Skip '('

  return get_name_and_type_params(params);
}
// https://www.w3.org/TR/SVG/linking.html#IRIReference
bool SkSVGAttributeParser::parseIRI(SkSVGStringType* iri) {
    // consume preceding whitespace
    this->parseWSToken();

    // we only support local fragments
    if (!this->parseExpectedStringToken("#")) {
        return false;
    }
    const auto* start = fCurPos;
    this->advanceWhile([](char c) -> bool { return !is_eos(c) && c != ')'; });
    if (start == fCurPos) {
        return false;
    }
    *iri = SkString(start, fCurPos - start);
    return true;
}
Пример #9
0
 bool skip_blank_and_comma() {
   bool comma_found = false;
   while (!is_eos()) {
     int c = str_[index_];
     if (c == ',') {
       if (comma_found) {
         return true;
       } else {
         comma_found = true;
       }
     } else if (!is_blank(c)) {
       return true;
     }
     ++index_;
   }
   return false;
 }
inline bool SkSVGAttributeParser::parseEOSToken() {
    return is_eos(*fCurPos);
}
Пример #11
0
 void skip_blank() {
   while (!is_eos() && is_blank(str_[index_])) {
     ++index_;
   }
 }