static void makeFunctionTag (tokenInfo *const token) { vString * fulltag; if ( ! token->ignoreTag ) { fulltag = vStringNew (); if (vStringLength (token->scope) > 0) { vStringCopy(fulltag, token->scope); vStringCatS (fulltag, "."); vStringCatS (fulltag, vStringValue(token->string)); } else { vStringCopy(fulltag, token->string); } vStringTerminate(fulltag); if ( ! stringListHas(FunctionNames, vStringValue (fulltag)) ) { stringListAdd (FunctionNames, vStringNewCopy (fulltag)); makeJsTag (token, JSTAG_FUNCTION); } vStringDelete (fulltag); } }
static void makeClassTag (tokenInfo *const token, vString *const signature) { vString * fulltag; if ( ! token->ignoreTag ) { fulltag = vStringNew (); if (vStringLength (token->scope) > 0) { vStringCopy(fulltag, token->scope); vStringCatS (fulltag, "."); vStringCatS (fulltag, vStringValue(token->string)); } else { vStringCopy(fulltag, token->string); } vStringTerminate(fulltag); if ( ! stringListHas(ClassNames, vStringValue (fulltag)) ) { stringListAdd (ClassNames, vStringNewCopy (fulltag)); makeJsTag (token, JSTAG_CLASS, signature); } vStringDelete (fulltag); } }
static void copyToken (tokenInfo *const dest, tokenInfo *const src) { dest->lineNumber = src->lineNumber; dest->filePosition = src->filePosition; dest->type = src->type; dest->keyword = src->keyword; vStringCopy (dest->string, src->string); vStringCopy (dest->scope, src->scope); }
static void copyToken (tokenInfo* dst, const tokenInfo *src) { dst->type = src->type; dst->keyword = src->keyword; dst->isExported = src->isExported; vStringCopy (dst->string, src->string); vStringCopy (dst->className, src->className); vStringCopy (dst->featureName, src->featureName); }
static void copyToken (tokenInfo *const dest, const tokenInfo *const src, bool scope) { dest->lineNumber = src->lineNumber; dest->filePosition = src->filePosition; dest->type = src->type; vStringCopy (dest->string, src->string); dest->parentKind = src->parentKind; if (scope) vStringCopy (dest->scope, src->scope); }
static void copyToken (tokenInfo *const dest, const tokenInfo *const src, boolean const include_non_read_info) { dest->lineNumber = src->lineNumber; dest->filePosition = src->filePosition; dest->type = src->type; dest->keyword = src->keyword; vStringCopy(dest->string, src->string); if (include_non_read_info) { dest->nestLevel = src->nestLevel; vStringCopy(dest->scope, src->scope); } }
/* `end' points to the equal sign. Parse from right to left to get the * identifier. Assume we're dealing with something of form \s*\w+\s*=> */ static void makeTagFromLeftSide (const char *begin, const char *end, vString *name, vString *package) { tagEntryInfo entry; const char *b, *e; if (! PerlKinds[K_CONSTANT].enabled) return; for (e = end - 1; e > begin && isspace(*e); --e) ; if (e < begin) return; for (b = e; b >= begin && isIdentifier(*b); --b) ; /* Identifier must be either beginning of line of have some whitespace * on its left: */ if (b < begin || isspace(*b) || ',' == *b) ++b; else if (b != begin) return; if (e - b + 1 <= 0) return; /* Left side of => has an invalid identifier. */ vStringClear(name); vStringNCatS(name, b, e - b + 1); initTagEntry(&entry, vStringValue(name), &(PerlKinds[K_CONSTANT])); makeTagEntry(&entry); if (Option.include.qualifiedTags && package && vStringLength(package)) { vStringClear(name); vStringCopy(name, package); vStringNCatS(name, b, e - b + 1); initTagEntry(&entry, vStringValue(name), &(PerlKinds[K_CONSTANT])); makeTagEntry(&entry); } }
static vString *parseNumeric (int c) { static vString *string = NULL; if (string == NULL) string = vStringNew (); vStringCopy (string, parseInteger (c)); c = fileGetc (); if (c == '.') { vStringPut (string, c); vStringCat (string, parseInteger ('\0')); c = fileGetc (); } if (tolower (c) == 'e') { vStringPut (string, c); vStringCat (string, parseInteger ('\0')); } else if (!isspace (c)) fileUngetc (c); vStringTerminate (string); return string; }
static void makeEiffelLocalTag (tokenInfo *const token) { if (EiffelKinds [EKIND_LOCAL].enabled && Option.include.fileScope) { const char *const name = vStringValue (token->string); vString* scope = vStringNew (); tagEntryInfo e; initTagEntry (&e, name); e.isFileScope = TRUE; e.kindName = EiffelKinds [EKIND_LOCAL].name; e.kind = EiffelKinds [EKIND_LOCAL].letter; vStringCopy (scope, token->className); vStringPut (scope, '.'); vStringCat (scope, token->featureName); e.extensionFields.scope [0] = EiffelKinds [EKIND_FEATURE].name; e.extensionFields.scope [1] = vStringValue (scope); makeTagEntry (&e); vStringDelete (scope); } }
static vString *parseNumeric (int c) { vString *string = vStringNew (); vString *integer = parseInteger (c); vStringCopy (string, integer); vStringDelete (integer); c = getcFromInputFile (); if (c == '.') { integer = parseInteger ('\0'); vStringPut (string, c); vStringCat (string, integer); vStringDelete (integer); c = getcFromInputFile (); } if (tolower (c) == 'e') { integer = parseInteger ('\0'); vStringPut (string, c); vStringCat (string, integer); vStringDelete (integer); } else if (!isspace (c)) ungetcToInputFile (c); vStringTerminate (string); return string; }
static void parseFields (vString * const ident, objcToken what) { switch (what) { case Tok_CurlR: toDoNext = &parseMethods; break; case Tok_SQUAREL: case Tok_PARL: toDoNext = &ignoreBalanced; comeAfter = &parseFields; break; /* we got an identifier, keep track of it */ case ObjcIDENTIFIER: vStringCopy (tempName, ident); break; /* our last kept identifier must be our variable name =) */ case Tok_semi: addTag (tempName, K_FIELD); vStringClear (tempName); break; default: /* NOTHING */ break; } }
static void parseClass (tokenInfo *const token) { Assert (isKeyword (token, KEYWORD_class)); readToken (token); if (isType (token, TOKEN_IDENTIFIER)) { #ifndef TYPE_REFERENCE_TOOL makeEiffelClassTag (token); readToken (token); #else vStringCopy (token->className, token->string); vStringUpper (token->className); if (PrintClass) puts (vStringValue (token->className)); if (! PrintReferences) exit (0); readToken (token); #endif } do { if (isType (token, TOKEN_OPEN_BRACKET)) parseGeneric (token, TRUE); else if (! isType (token, TOKEN_KEYWORD)) readToken (token); else switch (token->keyword) { case KEYWORD_inherit: parseInherit (token); break; case KEYWORD_feature: parseFeatureClauses (token); break; default: readToken (token); break; } } while (! isKeyword (token, KEYWORD_end)); }
static void parseProperty (vString * const ident, objcToken what) { switch (what) { case Tok_PARL: toDoNext = &tillToken; comeAfter = &parseProperty; waitedToken = Tok_PARR; break; /* we got an identifier, keep track of it */ case ObjcIDENTIFIER: vStringCopy (tempName, ident); break; /* our last kept identifier must be our variable name =) */ case Tok_semi: addTag (tempName, K_PROPERTY); vStringClear (tempName); toDoNext = &parseMethods; break; default: break; } }
static void makeTag (tokenInfo *const token, const goKind kind) { const char *const name = vStringValue (token->string); tagEntryInfo e; initTagEntry (&e, name); if (!GoKinds [kind].enabled) return; e.lineNumber = token->lineNumber; e.filePosition = token->filePosition; e.kindName = GoKinds [kind].name; e.kind = GoKinds [kind].letter; makeTagEntry (&e); if (scope && Option.include.qualifiedTags) { vString *qualifiedName = vStringNew (); vStringCopy (qualifiedName, scope); vStringCatS (qualifiedName, "."); vStringCat (qualifiedName, token->string); e.name = vStringValue (qualifiedName); makeTagEntry (&e); vStringDelete (qualifiedName); } }
/* Parse something like * typedef .... ident ; * ignoring the defined type but in the case of struct, * in which case struct are parsed. */ static void parseTypedef (vString * const ident, objcToken what) { switch (what) { case ObjcSTRUCT: toDoNext = &parseStruct; comeAfter = &parseTypedef; break; case ObjcENUM: toDoNext = &parseEnum; comeAfter = &parseTypedef; break; case ObjcIDENTIFIER: vStringCopy (tempName, ident); break; case Tok_semi: /* ';' */ addTag (tempName, K_TYPEDEF); vStringClear (tempName); toDoNext = &globalScope; break; default: /* we don't care */ break; } }
static void makeTag (tokenInfo *const token, const goKind kind, tokenInfo *const parent_token, const goKind parent_kind, const char *argList) { const char *const name = vStringValue (token->string); tagEntryInfo e; initTagEntry (&e, name, &(GoKinds [kind])); if (!GoKinds [kind].enabled) return; e.lineNumber = token->lineNumber; e.filePosition = token->filePosition; if (argList) e.extensionFields.signature = argList; if (parent_kind != GOTAG_UNDEFINED && parent_token != NULL) { e.extensionFields.scopeKind = &(GoKinds[parent_kind]); e.extensionFields.scopeName = vStringValue (parent_token->string); } makeTagEntry (&e); if (scope && isXtagEnabled(XTAG_QUALIFIED_TAGS)) { vString *qualifiedName = vStringNew (); vStringCopy (qualifiedName, scope); vStringCatS (qualifiedName, "."); vStringCat (qualifiedName, token->string); e.name = vStringValue (qualifiedName); makeTagEntry (&e); vStringDelete (qualifiedName); } }
static void makeEiffelFeatureTag (tokenInfo *const token) { if (EiffelKinds [EKIND_FEATURE].enabled && (token->isExported || isXtagEnabled(XTAG_FILE_SCOPE))) { const char *const name = vStringValue (token->string); tagEntryInfo e; initTagEntry (&e, name, &(EiffelKinds [EKIND_FEATURE])); e.isFileScope = (boolean) (! token->isExported); if (e.isFileScope) markTagExtraBit (&e, XTAG_FILE_SCOPE); e.extensionFields.scopeKind = &(EiffelKinds [EKIND_CLASS]); e.extensionFields.scopeName = vStringValue (token->className); makeTagEntry (&e); if (isXtagEnabled(XTAG_QUALIFIED_TAGS)) { vString* qualified = vStringNewInit (vStringValue (token->className)); vStringPut (qualified, '.'); vStringCat (qualified, token->string); e.name = vStringValue (qualified); markTagExtraBit (&e, XTAG_QUALIFIED_TAGS); makeTagEntry (&e); vStringDelete (qualified); } } vStringCopy (token->featureName, token->string); }
static void makeEiffelFeatureTag (tokenInfo *const token) { if (EiffelKinds [EKIND_FEATURE].enabled && (token->isExported || Option.include.fileScope)) { const char *const name = vStringValue (token->string); tagEntryInfo e; initTagEntry (&e, name); e.isFileScope = (boolean) (! token->isExported); e.kindName = EiffelKinds [EKIND_FEATURE].name; e.kind = EiffelKinds [EKIND_FEATURE].letter; e.extensionFields.scope [0] = EiffelKinds [EKIND_CLASS].name; e.extensionFields.scope [1] = vStringValue (token->className); makeTagEntry (&e); if (Option.include.qualifiedTags) { vString* qualified = vStringNewInit (vStringValue (token->className)); vStringPut (qualified, '.'); vStringCat (qualified, token->string); e.name = vStringValue (qualified); makeTagEntry (&e); vStringDelete (qualified); } } vStringCopy (token->featureName, token->string); }
static void parseModuleTag (const unsigned char *cp, vString *const module) { vString *const identifier = vStringNew (); parseIdentifier (cp, identifier); makeSimpleTag (identifier, ErlangKinds, K_MODULE); /* All further entries go in the new module */ vStringCopy (module, identifier); vStringDelete (identifier); }
void tokenCopyFull (tokenInfo *dest, tokenInfo *src, void *data) { dest->lineNumber = src->lineNumber; dest->filePosition = src->filePosition; dest->type = src->type; dest->keyword = src->keyword; /* klass */ vStringCopy(dest->string, src->string); if (src->klass->copy) src->klass->copy (dest, src, data); }
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 createContext (tokenInfo *const scope) { if (scope) { vString *contextName = vStringNew (); verbose ("Creating new context %s\n", vStringValue (scope->name)); /* Determine full context name */ if (currentContext->kind != K_UNDEFINED) { vStringCopy (contextName, currentContext->name); vStringCatS (contextName, "."); } vStringCat (contextName, scope->name); /* Create context */ currentContext = pushToken (currentContext, scope); vStringCopy (currentContext->name, contextName); vStringDelete (contextName); } }
static void makeVhdlTag (tokenInfo * const token, const vhdlKind kind) { if (VhdlKinds[kind].enabled) { /* * If a scope has been added to the token, change the token * string to include the scope when making the tag. */ if (vStringLength (token->scope) > 0) { vString *fulltag = vStringNew (); vStringCopy (fulltag, token->scope); vStringPut (fulltag, '.'); vStringCat (fulltag, token->string); vStringCopy (token->string, fulltag); vStringDelete (fulltag); } makeConstTag (token, kind); } }
static void parsePackage (tokenInfo *const token) { readToken (token); if (isType (token, TOKEN_IDENTIFIER)) { makeTag (token, GOTAG_PACKAGE, NULL, GOTAG_UNDEFINED, NULL, NULL); if (!scope && Option.include.qualifiedTags) { scope = vStringNew (); vStringCopy (scope, token->string); } } }
static void makeEiffelClassTag (tokenInfo *const token) { if (EiffelKinds [EKIND_CLASS].enabled) { const char *const name = vStringValue (token->string); tagEntryInfo e; initTagEntry (&e, name, &(EiffelKinds [EKIND_CLASS])); makeTagEntry (&e); } vStringCopy (token->className, token->string); }
static void parsePackage (tokenInfo *const token) { readToken (token); if (isType (token, TOKEN_IDENTIFIER)) { makeTag (token, GOTAG_PACKAGE, NULL, GOTAG_UNDEFINED, NULL); if (!scope && isXtagEnabled(XTAG_QUALIFIED_TAGS)) { scope = vStringNew (); vStringCopy (scope, token->string); } } }
static void makeTexTag (tokenInfo *const token, texKind kind) { vString * fulltag; if (TexKinds [kind].enabled) { /* * If a scope has been added to the token, change the token * string to include the scope when making the tag. */ if ( vStringLength (token->scope) > 0 ) { fulltag = vStringNew (); vStringCopy (fulltag, token->scope); vStringCatS (fulltag, "."); vStringCatS (fulltag, vStringValue (token->string)); vStringTerminate (fulltag); vStringCopy (token->string, fulltag); vStringDelete (fulltag); } makeConstTag (token, kind); } }
/* Push a new context, handle null string */ static void pushContext (contextKind kind, contextType type, parseNext after, vString const *contextName) { int parentIndex; if (stackIndex >= OCAML_MAX_STACK_SIZE) { verbose ("OCaml Maximum depth reached"); return; } stack[stackIndex].kind = kind; stack[stackIndex].type = type; stack[stackIndex].callback = after; parentIndex = getLastNamedIndex (); if (contextName == NULL) { vStringClear (stack[stackIndex++].contextName); return; } if (parentIndex >= 0) { vStringCopy (stack[stackIndex].contextName, stack[parentIndex].contextName); vStringPut (stack[stackIndex].contextName, contextTypeSuffix (stack[parentIndex].type)); vStringCat (stack[stackIndex].contextName, contextName); } else vStringCopy (stack[stackIndex].contextName, contextName); stackIndex++; }
/* Parse type of kind * type bidule = Ctor1 of ... * | Ctor2 * | Ctor3 of ... * or * type bidule = | Ctor1 of ... | Ctor2 * * when type bidule = { ... } is detected, * let typeRecord handle it. */ static void typeSpecification (vString * const ident, ocaToken what) { switch (what) { case OcaIDENTIFIER: if (isUpperAlpha (ident->buffer[0])) { /* here we handle type aliases of type * type foo = AnotherModule.bar * AnotherModule can mistakenly be took * for a constructor. */ if (! OcamlKinds[K_CONSTRUCTOR].enabled) vStringClear (tempIdent); else { vStringCopy (tempIdent, ident); prepareTag (&tempTag, tempIdent, K_CONSTRUCTOR); } toDoNext = &constructorValidation; } else { toDoNext = &tillTokenOrFallback; comeAfter = &typeSpecification; waitedToken = Tok_Pipe; } break; case OcaKEYWORD_and: toDoNext = &typeDecl; break; case Tok_BRL: /* the '[' & ']' are ignored to accommodate */ case Tok_BRR: /* with the revised syntax */ case Tok_Pipe: /* just ignore it */ break; case Tok_CurlL: toDoNext = &typeRecord; break; default: /* don't care */ break; } }
extern void nestingLevelsPush(NestingLevels *nls, const vString *name, int type) { NestingLevel *nl = NULL; if (nls->n >= nls->allocated) { nls->allocated++; nls->levels = xRealloc(nls->levels, nls->allocated, NestingLevel); nls->levels[nls->n].name = vStringNew(); } nl = &nls->levels[nls->n]; nls->n++; vStringCopy(nl->name, name); nl->type = type; }