当前位置: 首页>>代码示例>>C++>>正文


C++ parseValue函数代码示例

本文整理汇总了C++中parseValue函数的典型用法代码示例。如果您正苦于以下问题:C++ parseValue函数的具体用法?C++ parseValue怎么用?C++ parseValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parseValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: scanner

Expression *parseTerm(FILE *source, Expression *lvalue)
{
    Token token = scanner(source);
    Expression *expr;
	int i ;
    switch (token.type){
        case PlusOp:
        case MinusOp:
        case Alphabet:
        case PrintOp:
            for (i = strlen(token.tok) - 1; i >= 0; i--) {
                ungetc(token.tok[i], source);
            }
            return lvalue;
		case MulOp:
            expr = (Expression *)malloc( sizeof(Expression) );
            (expr->v).type = MulNode;
            (expr->v).val.op = Mul;
            expr->leftOperand = lvalue;
            expr->rightOperand = parseValue(source);
            return parseTerm(source, expr);
        case DivOp:
            expr = (Expression *)malloc( sizeof(Expression) );
            (expr->v).type = DivNode;
            (expr->v).val.op = Div;
            expr->leftOperand = lvalue;
            expr->rightOperand = parseValue(source);
            return parseTerm(source, expr);
        default:
            printf("In function parseTerm\n");
            printf("Syntax Error: Expect a numeric value or an identifier %s\n", token.tok);
            exit(1);
    }

}
开发者ID:Joemen,项目名称:CompilerDesign15fall,代码行数:35,代码来源:AcDc.c

示例2: parseGroup

	void parseGroup(filesystem::InputStream &stream, int flags)
	{
		std::string currentLine;
		std::string nextLine;

		readLine(stream, currentLine);
		if(!currentLine.empty() && currentLine[0] == '}')
			return;

		while(readLine(stream, nextLine))
		{
			if(nextLine[0] == '{')
			{
				parseSubGroup(stream, currentLine, flags);
				currentLine = "";
				continue;
			}

			parseValue(currentLine, flags);
			if(nextLine[0] == '}')
				return;

			currentLine.swap(nextLine);		
		}

		parseValue(currentLine, flags);
	}
开发者ID:DeejStar,项目名称:Shadowgrounds-Redux,代码行数:27,代码来源:parser.cpp

示例3: scanner

Expression *parseExpression( FILE *source, Expression *lvalue )//changed
{
    Token token = scanner(source);
    Expression *expr;

    switch(token.type){
        case PlusOp:
            expr = (Expression *)malloc( sizeof(Expression) );
            (expr->v).type = PlusNode;
            (expr->v).val.op = Plus;
            expr->leftOperand = lvalue;
            expr->rightOperand = parseValue(source);
            return parseExpressionTail(source, expr);
        case MinusOp:
            expr = (Expression *)malloc( sizeof(Expression) );
            (expr->v).type = MinusNode;
            (expr->v).val.op = Minus;
            expr->leftOperand = lvalue;
            expr->rightOperand = parseValue(source);
            return parseExpressionTail(source, expr);
        case Alphabet:
        case PrintOp:
			ungetstring(token.tok, source);
            //ungetc(token.tok[0], source);
            return NULL;
        case EOFsymbol:
            return NULL;
        default:
            printf("Syntax Error: Expect a numeric value or an identifier %s\n", token.tok);
            exit(1);
    }
}
开发者ID:haiwei624,项目名称:data,代码行数:32,代码来源:AcDc.c

示例4: scanner

Expression *parseTerm(FILE *source, Expression *lvalue)
{
    Token token = scanner(source);
    Expression *expr;

    switch(token.type){
        case MulOp:
            expr = (Expression *)malloc( sizeof(Expression) );
            (expr->v).type = MulNode;
            (expr->v).val.op = Mul;
            expr->leftOperand = lvalue;
            expr->rightOperand = parseValue(source);
            return parseTermTail(source, expr);
        case DivOp:
            expr = (Expression *)malloc( sizeof(Expression) );
            (expr->v).type = DivNode;
            (expr->v).val.op = Div;
            expr->leftOperand = lvalue;
            expr->rightOperand = parseValue(source);
            return parseTermTail(source, expr);
        case Alphabet:
        case PrintOp:
        case PlusOp:
        case MinusOp:
            ungetToken(token);
            return lvalue;
        case EOFsymbol:
            return lvalue;
        default:
            printf("Syntax Error:(parseTerm) Expect a numeric value or an identifier %s\n", token.tok);
            exit(1);
    }

}
开发者ID:Yee-Lee,项目名称:compiler15_c--,代码行数:34,代码来源:AcDc.c

示例5: parseValue

//-------------------------------------------------------
void coTParser::parseEnumeration()
{
	parseValue();
	while( m_currentToken.m_type == coTLexer::EToken_COMMA)
	{
		consumeToken();
		parseValue();
	}
}
开发者ID:smogpill,项目名称:dataspace,代码行数:10,代码来源:coTParser.cpp

示例6: start_

CrontabSelector::CrontabSelector(
  const dynamic &d,
  int64_t min_val,
  int64_t max_val,
  function<int64_t(const string& lc_str)> str_to_value
) : start_(min_val),
    end_(max_val),
    period_(1),
    minVal_(min_val),
    maxVal_(max_val) {

  switch (d.type()) {
    case dynamic::Type::INT64:
    case dynamic::Type::STRING:
      sortedValues_.emplace_back(parseValue(d, str_to_value));
      break;
    case dynamic::Type::ARRAY:
      for (const auto& val : d) {
        sortedValues_.emplace_back(parseValue(val, str_to_value));
      }
      // If somebody specifies [] for a selector, we have to silently
      // accept it, since PHP's JSON library can morph {} into [], and {}
      // must mean "default selector accepting all values."
      break;
    case dynamic::Type::OBJECT:
      for (const auto& pair : d.items()) {
        // Interval is first so that it doesn't accept strings like "jan"
        if (pair.first == "period") {
          period_ = pair.second.asInt();
          if (period_ < 1 || period_ >= maxVal_ - minVal_) {
            throw runtime_error(format(
              "period not in [1, {}]: {}", maxVal_ - minVal_, period_
            ).str());
          }
          continue;
        }
        // For start & end, we are happy to accept string names
        auto val = parseValue(pair.second, str_to_value);
        if (pair.first == "start") {
          start_ = val;
        } else if (pair.first == "end") {
          end_ = val;
        } else {
          throw runtime_error(format("Unknown key: {}", pair.first).str());
        }
      }
      // If we got an empty object, no problem -- this selector will
      // follow the default of "match everything".
      break;
    default:
      throw runtime_error(format(
        "Bad type for crontab selector: {}", d.typeName()
      ).str());
  }
  sort(sortedValues_.begin(), sortedValues_.end());
}
开发者ID:facebook,项目名称:bistro,代码行数:56,代码来源:CrontabSelector.cpp

示例7: skip

// Build an object from the text.
const char*
aJsonClass::parseObject(aJsonObject *item, const char *value)
{
  aJsonObject *child;
  if (*value != '{')
    return NULL; // not an object!

  item->type = aJson_Object;
  value = skip(value + 1);
  if (*value == '}')
    return value + 1; // empty array.

  item->child = child = newItem();
  if (!item->child)
    return NULL;
  value = skip(parseString(child, skip(value)));
  if (!value)
    return NULL;
  child->name = child->value.valuestring;
  child->value.valuestring = NULL;
  if (*value != ':')
    return NULL; // fail!
  value = skip(parseValue(child, skip(value + 1))); // skip any spacing, get the value.
  if (!value)
    return NULL;

  while (*value == ',')
    {
      aJsonObject *new_item;
      if (!(new_item = newItem()))
        return NULL; // memory fail
      child->next = new_item;
      new_item->prev = child;
      child = new_item;
      value = skip(parseString(child, skip(value + 1)));
      if (!value)
        return NULL;
      child->name = child->value.valuestring;
      child->value.valuestring = NULL;
      if (*value != ':')
        return NULL; // fail!
      value = skip(parseValue(child, skip(value + 1))); // skip any spacing, get the value.
      if (!value)
        return NULL;
    }

  if (*value == '}')
    return value + 1; // end of array
  return NULL; // malformed.
}
开发者ID:kkowar,项目名称:aJson,代码行数:51,代码来源:aJSON.cpp

示例8: audit_parse

/* parse the audit record and create libee structure
 */
static rsRetVal
audit_parse(uchar *buf, struct json_object **jsonRoot)
{
	struct json_object *json;
	struct json_object *jval;
	char name[1024];
	char val[1024];
	DEFiRet;

	*jsonRoot = json_object_new_object();
	if(*jsonRoot == NULL) {
		ABORT_FINALIZE(RS_RET_ERR);
	}
	json = json_object_new_object();
	json_object_object_add(*jsonRoot, "data", json);

	while(*buf) {
		CHKiRet(parseName(&buf, name, sizeof(name)));
		if(*buf != '=') {
			ABORT_FINALIZE(RS_RET_ERR);
		}
		++buf;
		CHKiRet(parseValue(&buf, val, sizeof(val)));
		jval = json_object_new_string(val);
		json_object_object_add(json, name, jval);
	}
	

finalize_it:
	RETiRet;
}
开发者ID:FrogyYen,项目名称:rsyslog,代码行数:33,代码来源:mmaudit.c

示例9: coASSERT

//-------------------------------------------------------
void coTParser::parseProperty()
{
	coASSERT(m_currentToken.m_type == coTLexer::EToken_IDENTIFIER);
	coTSemanticAnalyzer::Property prop;
	prop.m_name = m_currentToken;
	consumeToken();
	if (m_currentToken.m_type != coTLexer::EToken_COLON)
	{
		prop.m_type.clear();
	}
	else
	{
		prop.m_type = m_currentToken;
		consumeToken();
	}
	m_semanticAnalyzer->onProperty(prop);
	switch (m_currentToken.m_type)
	{
	case coTLexer::EToken_EQUAL:
		{
			consumeToken();
			parseValue();
		}
		break;
	case coTLexer::EToken_LBRACE:
		{
			parsePropertyBlock();
		}
		break;
	default:
		{
			coFAIL();
		}
	}
}
开发者ID:smogpill,项目名称:dataspace,代码行数:36,代码来源:coTParser.cpp

示例10: parseColor

bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict)
{
    if (string.isEmpty())
        return false;

    // First try creating a color specified by name, rgba(), rgb() or "#" syntax.
    if (CSSPropertyParser::fastParseColor(color, string, strict))
        return true;

    // In case the fast-path parser didn't understand the color, try the full parser.
    RefPtrWillBeRawPtr<MutableStylePropertySet> stylePropertySet = MutableStylePropertySet::create();
    // FIXME: The old CSS parser is only working in strict mode ignoring the strict parameter.
    // It needs to be investigated why.
    if (!parseValue(stylePropertySet.get(), CSSPropertyColor, string, false, strictCSSParserContext()))
        return false;

    RefPtrWillBeRawPtr<CSSValue> value = stylePropertySet->getPropertyCSSValue(CSSPropertyColor);
    if (!value || !value->isPrimitiveValue())
        return false;

    CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get());
    if (!primitiveValue->isRGBColor())
        return false;

    color = primitiveValue->getRGBA32Value();
    return true;
}
开发者ID:shawngao5,项目名称:blink-crosswalk,代码行数:27,代码来源:CSSParser.cpp

示例11: parseMember

			inline static JSONPair parseMember(const char* string)
			{
				int stringLength = strlen(string) + 1;
				char* memberString = new char[stringLength];
				memcpy(memberString, string, stringLength);
				memberString[stringLength - 1] = '\0';

				char* key = "";
				JSONValue value;

				//We can't parse the member just yet, we need to know its type
				std::vector<std::string> split = StringUtils::splitOnce(memberString, ":");
				if (split.size() == 2)
				{
					const char* memberKeyString = split[0].c_str();
					const char* memberValueString = split[1].c_str();

					int keyStringLen = strlen(memberKeyString);

					value = parseValue(memberValueString);

					key = new char[keyStringLen];
					memcpy(key, memberKeyString, keyStringLen);
					key[keyStringLen - 1] = '\0';
				}
			
				delete[] memberString;
				return JSONPair(key, value);
			}
开发者ID:FlannelViolin,项目名称:Checkers,代码行数:29,代码来源:JSONParser.hpp

示例12: name

void JsonParser::parseArray( JsonScanner & scanner, std::vector<JsonValue *> * values ) {
	static std::string name( "" );
	JsonToken token;
	try {
		token = scanner.getNextToken();
	}
	catch ( const std::exception & e ) {
		throw;
	}

	JsonValue * value;
	try {
		value = parseValue( scanner, token, name );
	} catch( const std::exception & e ) {
		throw;
	}
	values->push_back( value );
	try {
		token = scanner.getNextToken();
	} catch( const std::exception & e ) {
		throw;
	}
	if( token.getType() == JsonTypes::COMMA ) {
		try {
			parseArray( scanner, values );
		} catch( std::exception & e ) {
			throw;
		}
	} else if ( token.getType() == JsonTypes::CLOSE_BRACKET ) {
	} else {
		throw ArrayParsingException();
	}
}
开发者ID:rokthewok,项目名称:Argonaut,代码行数:33,代码来源:JsonParser.cpp

示例13: skipWhitespace

Declaration* CssParser::parseDeclaration () {
  Declaration* declaration = NULL;
  TokenList property;

  if (!parseProperty(&property))
    return NULL;
  
  skipWhitespace();

  declaration = new Declaration(property.toString());
  
  if (tokenizer->getTokenType() != Token::COLON) {
    throw new ParseException(tokenizer->getToken()->str,
                             "colon following property(':')");
  }
  tokenizer->readNextToken();
  skipWhitespace();

  TokenList* value = parseValue();
  if (value == NULL) {
    throw new ParseException(tokenizer->getToken()->str,
                             "value for property");
  }
  declaration->setValue(value);
  return declaration;
}
开发者ID:smalyshev,项目名称:clessc,代码行数:26,代码来源:CssParser.cpp

示例14: parseValue

Expression *parsePreTerm(FILE *source)
{
    Expression *v = parseValue(source);
    Expression *term = parseTerm(source, v);
    return term;

}
开发者ID:Yee-Lee,项目名称:compiler15_c--,代码行数:7,代码来源:AcDc.c

示例15: skipWhitespace

bool LessParser::parseVariable (TokenList &value) {
  if (tokenizer->getTokenType() != Token::COLON)
    return false;
  
  tokenizer->readNextToken();
  skipWhitespace();
    
  if (parseValue(value) == false || value.size() == 0) {
    throw new ParseException(tokenizer->getToken(),
                             "value for variable",
                             tokenizer->getLineNumber(),
                             tokenizer->getColumn(),
                             tokenizer->getSource());
  }
  if (tokenizer->getTokenType() != Token::DELIMITER) {
    throw new ParseException(tokenizer->getToken(),
                             "delimiter (';') at end of @-rule",
                             tokenizer->getLineNumber(),
                             tokenizer->getColumn(),
                             tokenizer->getSource());
  }
  tokenizer->readNextToken();
  skipWhitespace();

  return true;
}
开发者ID:trav-c,项目名称:clessc,代码行数:26,代码来源:LessParser.cpp


注:本文中的parseValue函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。