char * TokenSearch(char *token, char *theFilePtr, char **eof) { char *ptr; PushTokenPtr(theFilePtr, 1); while(1) { if (*FilePtr == 0) { break; } SkipWhiteSpace(); if (*FilePtr == '.') { if (NextToken(token)) { ptr = FilePtr; // Restore file ptr PopTokenPtr(); return ptr; // Found something } } SkipLine(); } if (eof) *eof = FilePtr; PopTokenPtr(); // Say nothing found return 0; }
int GetEnumValue(char *ThisName) { SYMBOL *theSym; int scope; ClearLastSymbolRef(); // Test to see if this symbol is a thunk alias if (ThisName[0] == '%') { int v; PushTokenPtr(ThisName, 0); if (!Token("%")) Error(Error_Fatal, "Missing Thunk Delimiter"); v = GetDecNum(5); if (GetDecNumDigitCount() == 0) Error(Error_Fatal, "Missing Thunk Number"); PopTokenPtr(); theSym = GetThunk(v); if (!theSym) { if (Pass == 1) return 0; printf("Bad thunk!!\n"); doCannotEvaluate(ThisName+1); return 0; } SetLastSymbolRef(theSym); return theSym->Value; } // Now deal with all other symbols theSym = FindSymbols(ThisName,section_Enum,section_Enum, LocalScope); if (theSym) // Variable was found in local scope { // Add one more reference to this symbol //theSym->Ref++; SetLastSymbolRef(theSym); // Save the symbols label type //EnumFunction = theSym->LabelType; return theSym->Value; } else { // Variable wasnt found is local scope, so check global scope theSym = FindSymbols(ThisName,section_Enum,section_Enum, 0); if (theSym) { // Found a global, so extract the scope of this global scope = theSym->Value; theSym = FindSymbols(ThisName,section_Enum,section_Enum, scope); if (theSym) { // Add one more reference to this symbol //theSym->Ref++; SetLastSymbolRef(theSym); // Save the symbols label type //EnumFunction = theSym->LabelType; return theSym->Value; } } } // Dont worry if a global doesnt exist in pass 1 if (Pass == 1) return 0; // Do worry in other passes doCannotEvaluate(ThisName); return 0; }