• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parseValue函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: RuntimeException

void XmlRpc::parseCall(const QByteArray& call, QByteArray& function, QList<QVariant>& args)
{
	QDomDocument doc;
	QDomElement root;
	QString msg;
	QList<QVariant> values;

	if(!doc.setContent(call, false, &msg))
		throw RuntimeException(msg);

	root = doc.documentElement();
	if(root.tagName() != "methodCall")
		throw RuntimeException(QObject::tr("Not a XML-RPC call"));

	QDomElement methodName = root.firstChildElement("methodName");
	if(methodName.isNull())
		throw RuntimeException(QObject::tr("Not a valid XML-RPC call"));
	function = methodName.firstChild().toText().data().toAscii();

	QDomElement e = root.firstChildElement("params");
	if(!e.isNull())
	{
		QDomElement p = e.firstChildElement("param");
		while(!p.isNull())
		{
			QDomElement value = p.firstChildElement("value");
			if(value.isNull())
				throw RuntimeException(QObject::tr("Invalid XML-RPC call"));

			args << parseValue(value);

			p = p.nextSiblingElement("param");
		}
	}
}
开发者ID:ActionLuzifer,项目名称:fatrat,代码行数:35,代码来源:XmlRpc.cpp


示例17: skip

const wchar_t* TcJSONObject::fromObject(const QString&, const wchar_t* ptr)
{
    ptr = skip(ptr);
    if (*ptr == L'{')
    {
        setType(vtfObject);
        do
        {
            ptr = skip(++ptr);
            QString Key;
            ptr = skip(parseKey(Key, ptr));
            if (*ptr == L':')
            {
                ptr = skip(++ptr);

                ptr = parseValue(Key, ptr);
            }
            ptr = skip(ptr);
        } while (ptr && *ptr && *ptr == ',');
        if (ptr && *ptr == L'}')
        {
            ptr = skip(++ptr);
        }
        else
        {
            ptr = 0;
        }
    }
    return ptr;
}
开发者ID:CalciferLorain,项目名称:tianchi,代码行数:30,代码来源:tcjson.cpp


示例18: skipSpace

QPair<QStringRef,QStringRef> QDeclarativeStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
{
    skipSpace(ch);

    int attrStart = ch - textIn.constData();
    int attrLength = 0;
    while (!ch->isNull()) {
        if (*ch == greaterThan) {
            break;
        } else if (*ch == equals) {
            ++ch;
            if (*ch != singleQuote && *ch != doubleQuote) {
                while (*ch != greaterThan && !ch->isNull())
                    ++ch;
                break;
            }
            ++ch;
            if (!attrLength)
                break;
            QStringRef attr(&textIn, attrStart, attrLength);
            QStringRef val = parseValue(ch, textIn);
            if (!val.isEmpty())
                return QPair<QStringRef,QStringRef>(attr,val);
            break;
        } else {
            ++attrLength;
        }
        ++ch;
    }

    return QPair<QStringRef,QStringRef>();
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:32,代码来源:qdeclarativestyledtext.cpp


示例19: trim

MVJSONNode* MVJSONReader::parse(string text)
{
	string s = trim(text);
	if (s.length() < 2) return NULL;

	// object
	if ((s[0] == '{') && (s[s.length() - 1] == '}'))
	{
		// erase last and first symbols
		s.erase(0, 1);
		s.erase(s.length() - 1, 1);

		vector<string> parts;
		splitList(s, parts);

		MVJSONNode* node = new MVJSONNode();

		for (int i = 0; i < parts.size(); i++)
			node->values.push_back(parseValue(parts.at(i), false));

		return node;
	}

	return NULL;
}
开发者ID:avsbot,项目名称:Nucleo,代码行数:25,代码来源:JsonParser.cpp


示例20: parseStatement

Statement parseStatement( FILE *source, Token token )
{
    Token next_token;
    Expression *value, *term,*expr;

    switch(token.type){
        case Alphabet:
            next_token = scanner(source);
            if(next_token.type == AssignmentOp){
                value = parseValue(source);
                term = parseTerm(source, value);
                expr = parseExpression(source, term);
                return makeAssignmentNode(token.tok, value, expr);
            }
            else{
                printf("Syntax Error: Expect an assignment op %s\n", next_token.tok);
                exit(1);
            }
        case PrintOp:
            next_token = scanner(source);
            if(next_token.type == Alphabet)
                return makePrintNode(next_token.tok);
            else{
                printf("Syntax Error: Expect an identifier %s\n", next_token.tok);
                exit(1);
            }
            break;
        default:
            printf("Syntax Error: Expect a statement %s\n", token.tok);
            exit(1);
    }
}
开发者ID:Joemen,项目名称:CompilerDesign15fall,代码行数:32,代码来源:AcDc.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parse_address函数代码示例发布时间:2022-05-30
下一篇:
C++ parseUrl函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap