本文整理汇总了C++中parseIdentifier函数的典型用法代码示例。如果您正苦于以下问题:C++ parseIdentifier函数的具体用法?C++ parseIdentifier怎么用?C++ parseIdentifier使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseIdentifier函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: peekChar
// Parse one simple selector, e.g.: `type#id.class1.class2.class3`
SimpleSelector CSSParser::parseSimpleSelector(){
QString tagName;
QString id;
QVector<QString> classes;
if(!eof()){
QChar c = peekChar();
if(c == '#'){
consumeChar('#');
id = parseIdentifier();
qDebug() << "#";
} else if(c == '.') {
consumeChar('.');
classes.append(parseIdentifier());
qDebug() << ".";
} else if(c == '*'){
consumeChar('*');//TODO
qDebug() << "*";
} else if(isVaidIdentifier(c)){
//h1 div.note
tagName = parseIdentifier();
}
}
SimpleSelector ret{tagName, id, classes};
#ifdef CSS_DEBUG
qDebug() << Q_FUNC_INFO;
#endif /* CSS_DEBUG */
return ret;
}
示例2: parseCommands
static std::vector<AlterMetaDataCommand> parseCommands( const std::string& source)
{
std::vector<AlterMetaDataCommand> rt;
std::string::const_iterator si = source.begin(), se = source.end();
for (si = skipSpaces( si, se); si != se; si = skipSpaces( si, se))
{
std::string cmd( parseIdentifier( si, se, _TXT("command name")));
if (strus::utils::caseInsensitiveEquals( cmd, "Alter"))
{
std::string name( parseIdentifier( si, se, _TXT("old element name")));
std::string newname( parseIdentifier( si, se, _TXT("new element name")));
std::string type( parseIdentifier( si, se, _TXT("new element type")));
rt.push_back( AlterMetaDataCommand::AlterElement( name, newname, type));
}
else if (strus::utils::caseInsensitiveEquals( cmd, "Add"))
{
std::string name( parseIdentifier( si, se, _TXT("element name")));
std::string type( parseIdentifier( si, se, _TXT("element type name")));
rt.push_back( AlterMetaDataCommand::AddElement( name, type));
}
else if (strus::utils::caseInsensitiveEquals( cmd, "Rename"))
{
std::string name( parseIdentifier( si, se, _TXT("old element name")));
std::string newname( parseIdentifier( si, se, _TXT("new element name")));
rt.push_back( AlterMetaDataCommand::RenameElement( name, newname));
}
else if (strus::utils::caseInsensitiveEquals( cmd, "Delete"))
{
std::string name( parseIdentifier( si, se, _TXT("element name")));
rt.push_back( AlterMetaDataCommand::DeleteElement( name));
}
else if (strus::utils::caseInsensitiveEquals( cmd, "Clear"))
{
std::string name( parseIdentifier( si, se, _TXT("element name")));
rt.push_back( AlterMetaDataCommand::ClearValue( name));
}
si = skipSpaces( si, se);
if (si == se)
{
break;
}
else if (*si == ';')
{
++si;
}
else
{
std::string str( si, si+30);
throw strus::runtime_error( _TXT( "semicolon expected as separator of commands at '..."), str.c_str());
}
}
return rt;
}
示例3: parseIdentifier
bool
PluginIdentifier::areIdentifiersSimilar(QString id1, QString id2)
{
QString type1, type2, soName1, soName2, label1, label2;
parseIdentifier(id1, type1, soName1, label1);
parseIdentifier(id2, type2, soName2, label2);
if (type1 != type2 || label1 != label2)
return false;
bool similar = (soName1.section('/', -1).section('.', 0, 0) ==
soName2.section('/', -1).section('.', 0, 0));
return similar;
}
示例4: parseIdentifier
//----------------------------------------------------------------------------
bool XmlConfig::setParameter( const std::string& key,
const std::string& val,
const std::string& type )
{
if( !_config )
return false;
std::cout << "setParameter(key = " << key
<< ", val = " << val
<< ", type = " << type
<< ")"
<< std::endl;
//resolve parts of identifier (Renderer:FeatureX) and find in config
std::string valname;
TiXmlNode* container = parseIdentifier(key, valname, true);
if( key.length() > valname.length() + 1 )
{
std::string component_name =
key.substr(0, key.length() - valname.length() - 1);
Configurable* comp = findComponent(component_name);
if( !comp )
LOG_ERROR("No such component: " << component_name);
else
comp->setParameter(valname, val, type);
}
//check if exists
TiXmlNode* node = container->FirstChild(valname);
TiXmlElement* arg = 0;
if( node )
{
arg = node->ToElement();
//check if it matches
int res = checkTypeMatch(key, arg, type);
if(res == 1)
arg->SetAttribute("type", type);
else if(res == 0)
return false;
}
else
{
//create new one
arg = new TiXmlElement( valname );
container->LinkEndChild(arg);
arg->SetAttribute("type", type);
}
arg->SetAttribute("val", val);
_dirty_write = true;
saveFile(); // TODO check if multiple variables changed within small
// time window
return true;
}
示例5: assert
//----------------------------------------------------------------------------
XmlConfig::NodePtr XmlConfig::parseIdentifier( const std::string& identifier,
size_t pos,
NodePtr container,
std::string& valname,
bool create )
{
size_t p = identifier.find_first_of(':', pos);
if(p == std::string::npos)
{
valname = identifier.substr(pos);
return container;
}
assert(container);
std::string containername = identifier.substr(pos, p-pos);
TiXmlElement* child = 0;
TiXmlNode* node = container->FirstChild(containername);
if( !node )
{
if( !create )
return 0;
child = new TiXmlElement( containername );
container->LinkEndChild(child);
}
else
child = node->ToElement();
return parseIdentifier(identifier, p+1, child, valname, create);
}
示例6: parseSimpleTag
static void parseSimpleTag (const unsigned char *cp, erlangKind kind)
{
vString *const identifier = vStringNew ();
parseIdentifier (cp, identifier);
makeSimpleTag (identifier, ErlangKinds, kind);
vStringDelete (identifier);
}
示例7: lookForNextToken
char *OpenDDLParser::parseName( char *in, char *end, Name **name ) {
*name = ddl_nullptr;
if( ddl_nullptr == in || in == end ) {
return in;
}
// ignore blanks
in = lookForNextToken( in, end );
if( *in != '$' && *in != '%' ) {
return in;
}
NameType ntype( GlobalName );
if( *in == '%' ) {
ntype = LocalName;
}
in++;
Name *currentName( ddl_nullptr );
Text *id( ddl_nullptr );
in = parseIdentifier( in, end, &id );
if( id ) {
currentName = new Name( ntype, id );
if( currentName ) {
*name = currentName;
}
}
return in;
}
示例8: parseFunctionTag
static void parseFunctionTag (const unsigned char *cp, vString *const module)
{
vString *const identifier = vStringNew ();
parseIdentifier (cp, identifier);
makeMemberTag (identifier, K_FUNCTION, module);
vStringDelete (identifier);
}
示例9: visit
boost::any visit( FunctionDeclaration functionDeclaration ) {
extractToken( TokenType::KeywordFunction );
functionDeclaration->identifier = parseIdentifier();
extractToken( TokenType::PunctuatorOpeningParenthesis );
while( !currentTokenIs(TokenType::PunctuatorClosingParenthesis) ) {
if( !functionDeclaration->arguments.empty() )
extractToken( TokenType::PunctuatorComma );
functionDeclaration->arguments.emplace_back(
parse<_FunctionArgument>() );
}
extractToken( TokenType::PunctuatorClosingParenthesis );
if( !currentTokenIs(TokenType::PunctuatorOpeningBrace) )
functionDeclaration->returnType = parse<_Type>();
functionDeclaration->block = parse<_Block>();
return boost::any();
}
示例10: skipWhitespace
Token Lexer::parseNext() {
//skip whitespace of the current character
skipWhitespace();
//return eof if we are at the end
if (curChar() == '\0') {
return Token::Eof;
}
Token ret;
//first check if it is a keyword and return it
ret = parseKeyword();
if (ret != Token::None)
return ret;
ret = parseSymbol();
if (ret != Token::None)
return ret;
ret = parseIdentifier();
if (ret != Token::None)
return ret;
ret = parseNumeric();
if (ret != Token::None)
return ret;
//if nothing was able to parse it, it must be a character and we return it
value.character = eatChar();
return Token::Character;
}
示例11: parseDirective
/*
* Directives are of the form:
* def defp
* defmacro defmacrop
* defrecord
* defmodule
* defprotocol
* defimpl
*/
static void parseDirective (const unsigned char *cp, vString *const module)
{
vString *const directive = vStringNew ();
const char *const drtv = vStringValue (directive);
cp = parseIdentifier (cp, directive);
skipWhitespace (&cp);
/* if (*cp == '(') */
/* ++cp; */
if (strcmp (drtv, "def") == 0 || strcmp (drtv, "defp") == 0)
parseSimpleTag (cp, K_FUNCTION);
else if (strcmp (drtv, "defmacro") == 0 || strcmp (drtv, "defmacrop") == 0)
parseSimpleTag (cp, K_MACRO);
else if (strcmp (drtv, "defrecord") == 0)
parseSimpleTag (cp, K_RECORD);
else if (strcmp (drtv, "defmodule") == 0)
parseSimpleTag (cp, K_MODULE);
else if (strcmp (drtv, "defprotocol") == 0)
parseSimpleTag(cp, K_PROTOCOL);
else if (strcmp (drtv, "defimpl") == 0)
parseSimpleTag(cp, K_IMPL);
/* Otherwise, it was an import, require, etc. */
vStringDelete (directive);
}
示例12: parseDirective
/*
* Directives are of the form:
* -module(foo)
* -define(foo, bar)
* -record(graph, {vtab = notable, cyclic = true}).
* -type some_type() :: any().
* -opaque some_opaque_type() :: any().
*/
static void parseDirective (const unsigned char *cp, vString *const module)
{
/*
* A directive will be either a record definition or a directive.
* Record definitions are handled separately
*/
vString *const directive = vStringNew ();
const char *const drtv = vStringValue (directive);
cp = parseIdentifier (cp, directive);
cp = skipSpace (cp);
if (*cp == '(')
++cp;
if (strcmp (drtv, "record") == 0)
parseSimpleTag (cp, K_RECORD);
else if (strcmp (drtv, "define") == 0)
parseSimpleTag (cp, K_MACRO);
else if (strcmp (drtv, "type") == 0)
parseSimpleTag (cp, K_TYPE);
else if (strcmp (drtv, "opaque") == 0)
parseSimpleTag (cp, K_TYPE);
else if (strcmp (drtv, "module") == 0)
parseModuleTag (cp, module);
/* Otherwise, it was an import, export, etc. */
vStringDelete (directive);
}
示例13: parseMarkupDescriptions
std::vector<MarkupDescription> parseMarkupDescriptions( const std::string& src)
{
char const* si = src.c_str();
try
{
std::vector<MarkupDescription> rt;
while (*si)
{
si = skipNextNonSpace( si);
if (!isDigit(*si)) throw std::runtime_error("position number expected as 1st argument of markup description)");
unsigned int position = parseUintValue( si);
si = skipNextNonSpace( si);
unsigned int offset = parseUintValue( si);
si = skipNextNonSpace( si);
char type = *si++;
if (type != '>' && type != '<' && type != '@') throw std::runtime_error("expected '<' or '>' or '@' as type (2nd argument of markup description)");
si = skipNextNonSpace( si);
if (!isAlpha(*si)) throw std::runtime_error("identifier expected as 3rd argument of markup description");
std::string name = parseIdentifier( si);
si = skipNextNonSpace( si);
char const* expr = si;
si = skipEoln( si);
std::string value( expr, si - expr);
rt.push_back( MarkupDescription( position, offset, type, name, value));
++si;
}
return rt;
}
catch (const std::runtime_error& err)
{
std::ostringstream msg;
msg << "error on line " << getLine( src.c_str(), si) << " of markup description file: " << err.what();
throw std::runtime_error( msg.str());
}
}
示例14: parseAtom
QVariant
parseAtom(ParserState &st)
{
checkEndOfFile(st);
if (isalpha(*st.ptr))
{
return parseIdentifier(st);
}
else if (isdigit(*st.ptr))
{
return parseNumber(st);
}
else if (*st.ptr == '-')
{
st.ptr++;
return -parseNumber(st);
}
else if (*st.ptr == '"')
{
return parseString(st);
}
else
{
throw ParserError(QString("unexpected character '%1'").arg(*st.ptr));
}
}
示例15: parseIdentifier
PARSENODE_PTR SQLParser::parseExpression() {
PARSENODE_PTR columnNode = parseIdentifier();
PARSENODE_PTR opNode = parseOperator();
PARSENODE_PTR valueNode = parseLiteral();
opNode->children.push_back(columnNode);
opNode->children.push_back(valueNode);
return opNode;
}