eFlag Tree::extractUsedSets(Sit S, Element *e) { Attribute *a = e -> atts.find(XSLA_USE_ATTR_SETS); if (a) { QNameList *names = e -> attSetNames(TRUE); names -> freeall(FALSE); char *p, *q; q = (char*) (a -> cont); skipWhite(q); p = q; int i = strcspn(q, theWhitespace); while (*q && i) { q += i; char save = *q; *q = 0; Str token = p; GP( QName ) name = new QName; E( e -> setLogical(S, *name, token, FALSE) ); names -> append( name.keep() ); *q = save; skipWhite(q); p = q; i = strcspn(q, theWhitespace); } } return OK; }
eFlag Tree::getSpaceNames(Sit S, Element &e, Str &str, SpaceNameList &where) { char *p, *q; q = (char*)str; skipWhite(q); p = q; int i = strcspn(q, theWhitespace); while (*q && i) { q += i; char save = *q; *q = 0; Str token = p; QName name; E( e.setLogical(S, name, token, FALSE) ); GP(EQName) ename = new EQName; expandQ(name, *ename); where.append(ename.keep()); *q = save; skipWhite(q); p = q; i = strcspn(q, theWhitespace); } return OK; }
static void findTag (vString *const name) { const verilogKind kind = (verilogKind) lookupKeyword (vStringValue (name), Lang_verilog); if (kind != K_UNDEFINED) { int c = skipWhite (vGetc ()); /* Many keywords can have bit width. * reg [3:0] net_name; * inout [(`DBUSWIDTH-1):0] databus; */ if (c == '(') c = skipPastMatch ("()"); c = skipWhite (c); if (c == '[') c = skipPastMatch ("[]"); c = skipWhite (c); if (c == '#') { c = vGetc (); if (c == '(') c = skipPastMatch ("()"); } c = skipWhite (c); if (isIdentifierCharacter (c)) tagNameList (kind, c); } }
QVariant parseKeyword() { if(source.mid(pos, 4) == "true") { pos += 4; skipWhite(); return QVariant(true); } else if(source.mid(pos, 5) == "false") { pos += 5; skipWhite(); return QVariant(false); } else if(source.mid(pos, 4) == "null") { pos += 4; skipWhite(); return QVariant(0); } else { error("unknown keyword"); } return QVariant(); }
eFlag Tree::pushNamespacePrefixes(Sit S, Str& prefixes, XSL_ATT att) { if (!XSLTree) return OK; PList<Str*> tokens; char *p, *q; q = (char*) prefixes; skipWhite(q); p = q; int i = strcspn(q, theWhitespace); while (*q && i) { q += i; char save = *q; *q = 0; Str* aux = new Str(p); tokens.append(aux); *q = save; skipWhite(q); p = q; i = strcspn(q, theWhitespace); } //add to list SubtreeInfo *info = getCurrentInfo(); for (i = 0; i < tokens.number(); i++) { Str tok = *(tokens[i]); Phrase prefix = tok == (const char*) "#default" ? UNDEF_PHRASE : unexpand(tok); int idx = pendingNS().findNdx(prefix); if (idx != -1) { switch (att) { case XSLA_EXT_ELEM_PREFIXES: { info -> getExtensionNS().append(toNS(pendingNS()[idx]) -> uri); }; //no break case XSLA_EXCL_RES_PREFIXES: { info -> getExcludedNS().append(toNS(pendingNS()[idx]) -> uri); }; break; } } else { Str aux = *(tokens[i]); tokens.freeall(FALSE); Err1(S, E_EX_NAMESPACE_UNKNOWN, (char*) aux); } } tokens.freeall(FALSE); //printf("----------------------------\n"); return OK; }
static void findTag (vString *const name) { int c = '\0'; vhdlKind kind; vStringCopyToLower (Keyword, name); kind = (vhdlKind)lookupKeyword (vStringValue (Keyword), Lang_vhdl); if (kind == K_UNDEFINED) { c = skipWhite (vGetc ()); vStringCopyS(Lastname,vStringValue(name)); if (c == ':') { c = skipWhite (vGetc ()); if (isIdentifierCharacter (c)) { readIdentifier (name, c); vStringCopyToLower (Keyword, name); lookupKeyword (vStringValue (Keyword), Lang_vhdl); kind = (vhdlKind)lookupKeyword (vStringValue (Keyword), Lang_vhdl); if (kind == K_PROCESS || kind == K_BLOCK || kind == K_PORT) { makeSimpleTag (Lastname, VhdlKinds, kind); } } } else { vUngetc (c); } } else { if (kind == K_SIGNAL) { while (c!=':') { c = skipWhite (vGetc ()); if (c==',') c = vGetc (); if (isIdentifierCharacter (c)) tagNameList (kind, c); else break; c = vGetc (); } } else if (kind == K_PROCESS || kind == K_BLOCK) { vStringCopyS(TagName,"unnamed"); makeSimpleTag (TagName, VhdlKinds, kind); } else { c = skipWhite (vGetc ()); if (c=='\"') c = vGetc (); if (isIdentifierCharacter (c)) tagNameList (kind, c); } } }
static boolean findBlockName (tokenInfo *const token) { int c; c = skipWhite (vGetc ()); if (c == ':') { c = skipWhite (vGetc ()); readIdentifier (token, c); return (boolean) (vStringLength (token->name) > 0); } else vUngetc (c); return FALSE; }
QVariant parseObject() { QVariantMap result; QChar c = next(); DENG2_ASSERT(c == '{'); forever { QString name = parseString().toString(); c = next(); if(c != ':') error("object keys and values must be separated by a colon"); QVariant value = parse(); // Add to the result. result.insert(name, value); // Move forward. skipWhite(); c = next(); if(c == '}') { // End of object. break; } else if(c != ',') { LOG_DEBUG(de::String("got %1 instead of ,").arg(c)); error("key/value pairs must be separated by comma"); } } return result; }
/* verifica se entrada combina com o esperado */ void match(char c){ if (look != c) expected("'%c'", c); nextChar(); skipWhite(); }
static boolean parseLineDirective (void) { boolean result = FALSE; int c = skipWhite (); DebugStatement ( const char* lineStr = ""; ) if (isdigit (c))
bool StreamSource::parseInt( int& val) { val = 0; bool pos = true; skipWhite(); if (**this == '-') { pos = false; ++*this; } if (**this == '+') { ++*this; } bool ok = **this >= '0' && **this <= '9'; int d; while (**this >= '0' && **this <= '9') { d = **this - '0'; assert((val < (INT_MAX/10) || ((val==(INT_MAX/10)) && ((INT_MAX-(val*10))>=d))) && "Integer overflow while parsing"); val *= 10; val += d; ++*this; } val = pos ? val : -val; return ok; }
void stripWhite(char *s) { const char *t = s; skipWhite(&t); if (t > s) strmove(s, t); trimWhite(s); } /* stripWhite */
static bool parseLineDirective (char *s) { bool result = false; skipWhite (&s); DebugStatement ( const char* lineStr = ""; ) if (isdigit (*s))
//string parsing Bool getWhDelimString(char *&list, Str& firstPart) { skipWhite(list); if (!*list) return FALSE; char *list_was = list; for(; *list && !isWhite(*list); list++); firstPart.nset(list_was, (int)(list - list_was)); return TRUE; }
// assume called when tokenEnd on close quote of name bool JsonScanner::thisValue(char type) { restoreString(); char *at = skipWhite(tokenEnd + 1); if(*at == ':') { at = skipWhite(at + 1); if(*at == type) { if(type == STRING_TYPE) { return scanString(at); } else { // array tokenStart = at; return true; } } } return false; }
static void processFunction (tokenInfo *const token) { int c; tokenInfo *classType; /* Search for function name * Last identifier found before a '(' or a ';' is the function name */ c = skipWhite (vGetc ()); do { readIdentifier (token, c); c = skipWhite (vGetc ()); /* Identify class type prefixes and create respective context*/ if (isLanguage (Lang_systemverilog) && c == ':') { c = vGetc (); if (c == ':') { verbose ("Found function declaration with class type %s\n", vStringValue (token->name)); classType = newToken (); vStringCopy (classType->name, token->name); classType->kind = K_CLASS; createContext (classType); currentContext->classScope = TRUE; } else { vUngetc (c); } } } while (c != '(' && c != ';' && c != EOF); if ( vStringLength (token->name) > 0 ) { verbose ("Found function: %s\n", vStringValue (token->name)); /* Create tag */ createTag (token); /* Get port list from function */ processPortList (c); } }
static void tagNameList (const verilogKind kind, int c) { vString *name = vStringNew (); bool repeat; Assert (isIdentifierCharacter (c)); do { repeat = false; if (isIdentifierCharacter (c)) { readIdentifier (name, c); makeSimpleTag (name, VerilogKinds, kind); } else break; c = skipWhite (vGetc ()); if (c == '[') c = skipPastMatch ("[]"); c = skipWhite (c); if (c == '=') { c = skipWhite (vGetc ()); if (c == '{') skipPastMatch ("{}"); else { do c = vGetc (); while (c != ',' && c != ';'); } } if (c == ',') { c = skipWhite (vGetc ()); repeat = true; } else repeat = false; } while (repeat); vStringDelete (name); vUngetc (c); }
char * MIFrfile::getWord() { static char Word[LineMax]; char *cptr = Word; int ch; skipWhite(); while ((ch = getChar()) != EOF) { if (isalnum(ch)) *cptr++ = ch; else { ungetChar(ch); break; } } *cptr = '\0'; skipWhite(); return Word; }
static void findVerilogTags (void) { tokenInfo *const token = newToken (); int c = '\0'; currentContext = newToken (); while (c != EOF) { c = vGetc (); c = skipWhite (c); switch (c) { /* Store current block name whenever a : is found * This is used later by any tag type that requires this information * */ case ':': vStringCopy (currentContext->blockName, token->name); break; /* Skip interface modport port declarations */ case '(': if (currentContext && currentContext->lastKind == K_MODPORT) { skipPastMatch ("()"); } break; /* Drop context on prototypes because they don't have an end * statement */ case ';': if (currentContext->scope && currentContext->scope->prototype) { verbose ("Dropping context %s\n", vStringValue (currentContext->name)); currentContext = popToken (currentContext); currentContext->prototype = FALSE; } /* Prototypes end at the end of statement */ if (currentContext->prototype) { currentContext->prototype = FALSE; } break; default : if (isIdentifierCharacter (c)) { readIdentifier (token, c); updateKind (token); findTag (token); } } } deleteToken (token); pruneTokens (currentContext); currentContext = NULL; }
static void findTag (vString *const name) { const verilogKind kind = (verilogKind) lookupKeyword (vStringValue (name), Lang_verilog); if (kind == K_CONSTANT && vStringItem (name, 0) == '`') { /* Bug #961001: Verilog compiler directives are line-based. */ int c = skipWhite (vGetc ()); readIdentifier (name, c); makeSimpleTag (name, VerilogKinds, kind); /* Skip the rest of the line. */ do { c = vGetc(); } while (c != '\n'); vUngetc (c); } else if (kind != K_UNDEFINED) { int c = skipWhite (vGetc ()); /* Many keywords can have bit width. * reg [3:0] net_name; * inout [(`DBUSWIDTH-1):0] databus; */ if (c == '(') c = skipPastMatch ("()"); c = skipWhite (c); if (c == '[') c = skipPastMatch ("[]"); c = skipWhite (c); if (c == '#') { c = vGetc (); if (c == '(') c = skipPastMatch ("()"); } c = skipWhite (c); if (isIdentifierCharacter (c)) tagNameList (kind, c); } }
static asynStatus create(void *drvPvt,asynUser *pasynUser, const char *drvInfo, const char **pptypeName,size_t *psize) { const char *pnext; long reason = 0; if(!drvInfo) { reason = 0; } else { char *endp; pnext = skipWhite(drvInfo); if(strlen(pnext)==0) { reason = 0; } else { pnext = strstr(pnext,"reason"); if(!pnext) goto error; pnext += strlen("reason"); pnext = skipWhite(pnext); if(*pnext!='(') goto error; pnext++; pnext = skipWhite(pnext); errno = 0; reason = strtol(pnext,&endp,0); if(errno) { printf("strtol failed %s\n",strerror(errno)); goto error; } } } pasynUser->reason = reason; if(pptypeName) *pptypeName = testDriverReason; if(psize) *psize = sizeof(int); return asynSuccess; error: printf("asynDrvUser failed. got |%s| expecting reason(<int>)\n",drvInfo); epicsSnprintf(pasynUser->errorMessage,pasynUser->errorMessageSize, "asynDrvUser failed. got |%s| expecting reason(<int>)",drvInfo); return asynError; }
QVariant parseNumber() { QVarLengthArray<QChar> str; QChar c = next(); if(c == '-') { str.append(c); c = nextNoSkip(); } for(; c.isDigit(); c = nextNoSkip()) { str.append(c); } bool hasDecimal = false; if(c == '.') { str.append(c); hasDecimal = true; c = nextNoSkip(); for(; c.isDigit(); c = nextNoSkip()) { str.append(c); } } if(c == 'e' || c == 'E') { // Exponent. str.append(c); c = nextNoSkip(); if(c == '+' || c == '-') { str.append(c); c = nextNoSkip(); } for(; c.isDigit(); c = nextNoSkip()) { str.append(c); } } // Rewind one char (the loop was broken when a non-digit was read). pos--; skipWhite(); double value = QString(str.constData(), str.size()).toDouble(); if(hasDecimal) { return QVariant(value); } else { return QVariant(int(value)); } }
static int skipMacro (int c) { tokenInfo *token = newToken ();; if (c == '`') { /* Skip keyword */ if (isIdentifierCharacter (c = vGetc ())) { readIdentifier (token, c); c = vGetc (); /* Skip next keyword if macro is `ifdef or `ifndef or `elsif*/ if (strcmp (vStringValue (token->name), "ifdef") == 0 || strcmp (vStringValue (token->name), "ifndef") == 0 || strcmp (vStringValue (token->name), "elsif") == 0) { verbose ("%c\n", c); c = skipWhite (c); readIdentifier (token, c); c = vGetc (); verbose ("Skipping conditional macro %s\n", vStringValue (token->name)); } /* Skip macro functions */ else { c = skipWhite (c); if (c == '(') { c = skipPastMatch ("()"); } } } } deleteToken (token); return c; }
static unsigned long readLineNumber (void) { unsigned long lNum = 0; int c = skipWhite (); while (c != EOF && isdigit (c)) { lNum = (lNum * 10) + (c - '0'); c = readNextChar (); } pushBackChar (c); if (c != ' ' && c != '\t') lNum = 0; return lNum; }
static unsigned long readLineNumber (void) { unsigned long lNum = 0; int c = skipWhite (); while (c != EOF && isdigit (c)) { lNum = (lNum * 10) + (c - '0'); c = getc (File.fp); } ungetc (c, File.fp); if (c != ' ' && c != '\t') lNum = 0; return lNum; }
/* obtain comment as the n'th whitespace-delimited field */ static char *commentAsNthField( const unsigned char *key, unsigned keyLen, unsigned n) { unsigned dex; skipWhite(key, keyLen); if(keyLen == 0) { return NULL; } for(dex=0; dex<(n-1); dex++) { key = findNextWhite(key, keyLen); if(keyLen == 0) { return NULL; } skipWhite(key, keyLen); if(keyLen == 0) { return NULL; } } /* cp points to start of nth field */ char *rtnStr = (char *)malloc(keyLen + 1); memmove(rtnStr, key, keyLen); if(rtnStr[keyLen - 1] == '\n') { /* normal terminator - snip it off */ rtnStr[keyLen - 1] = '\0'; } else { rtnStr[keyLen] = '\0'; } return rtnStr; }
static void processFunction (tokenInfo *const token) { int c; /* Search for function name * Last identifier found before a '(' or a ';' is the function name */ c = skipWhite (vGetc ()); do { readIdentifier (token, c); c = skipWhite (vGetc ()); } while (c != '(' && c != ';' && c != EOF); if ( vStringLength (token->name) > 0 ) { verbose ("Found function: %s\n", vStringValue (token->name)); /* Create tag */ createTag (token); /* Get port list from function */ processPortList (c); } }
static int scanNumbers(char *string, double *numbers, int max) { char *ptr = string; int count = 0; while (count < max) { if (1 != sscanf(ptr, "%lf", &numbers[count])) { return count; } count++; ptr = skipNonwhite(ptr); ptr = skipWhite(ptr); } return count; }
static unsigned long readLineNumber (char **str) { char *s; unsigned long lNum = 0; skipWhite (str); s = *str; while (*s != '\0' && isdigit (*s)) { lNum = (lNum * 10) + (*s - '0'); s++; } if (*s != ' ' && *s != '\t') lNum = 0; *str = s; return lNum; }
static char_t *strtokcmp(char_t *s1, char_t *s2) { int len; s1 = skipWhite(s1); len = gstrlen(s2); for (len = gstrlen(s2); len > 0 && (tolower(*s1) == tolower(*s2)); len--) { if (*s2 == '\0') { return s1; } s1++; s2++; } if (len == 0) { return s1; } return NULL; }