Пример #1
0
void transStatement (void) {

	getToken();
	ifTokenGetElseError(TKN_IDENTIFIER, ABL_ERR_MISSING_STATE_IDENTIFIER);

	SymTableNodePtr IdPtr = searchSymTableForState(wordString, SymTableDisplay[1]);
	if (!IdPtr) {
		// New symbol, so let's assume it's a state defined later. We'll make it
		IdPtr = forwardState(wordString);
	}
	if (!IdPtr || (IdPtr->defn.key != DFN_FUNCTION) || ((IdPtr->defn.info.routine.flags & ROUTINE_FLAG_STATE) == 0))
		syntaxError(ABL_ERR_MISSING_STATE_IDENTIFIER);
	crunchSymTableNodePtr(IdPtr);
//	getToken();
}
Пример #2
0
TypePtr factor (void) {

	TypePtr thisType = NULL;
	switch (curToken) {
		case TKN_IDENTIFIER: {
			SymTableNodePtr IdPtr = NULL;
			searchAndFindAllSymTables(IdPtr);
			switch (IdPtr->defn.key) {
				case DFN_FUNCTION:
					crunchSymTableNodePtr(IdPtr);
					getToken();
					thisType = routineCall(IdPtr, 1);
					break;
				case DFN_CONST:
					crunchSymTableNodePtr(IdPtr);
					getToken();
					thisType = (TypePtr)(IdPtr->typePtr);
					break;
				default:
					thisType = (TypePtr)variable(IdPtr);
					break;
			}
			}
			break;
		case TKN_NUMBER: {
			SymTableNodePtr thisNode = searchSymTable(tokenString, SymTableDisplay[1]);
			if (!thisNode)
				thisNode = enterSymTable(tokenString, &SymTableDisplay[1]);
			if (curLiteral.type == LIT_INTEGER) {
				thisNode->typePtr = IntegerTypePtr;
				thisType = (TypePtr)(thisNode->typePtr);
				thisNode->defn.info.constant.value.integer = curLiteral.value.integer;
				}
			else {
				thisNode->typePtr = RealTypePtr;
				thisType = (TypePtr)(thisNode->typePtr);
				thisNode->defn.info.constant.value.real = curLiteral.value.real;
			}
			crunchSymTableNodePtr(thisNode);
			getToken();
			}
			break;
		case TKN_STRING: {
			long length = strlen(curLiteral.value.string);
			if (EnterStateSymbol) {
				SymTableNodePtr stateSymbol = searchSymTableForState(curLiteral.value.string, SymTableDisplay[1]);
				if (!stateSymbol)
					forwardState(curLiteral.value.string);
			}
			SymTableNodePtr thisNode = searchSymTableForString(tokenString, SymTableDisplay[1]);
			if (!thisNode)// {
				thisNode = enterSymTable(tokenString, &SymTableDisplay[1]);
				if (length == 1) {
					thisNode->defn.info.constant.value.character = curLiteral.value.string[0];
					thisType = CharTypePtr;
					}
				else {
					thisNode->typePtr = thisType = makeStringType(length);
					thisNode->info = (char*)ABLSymbolMallocCallback(length + 1);
					if (!thisNode->info)
						ABL_Fatal(0, " ABL: Unable to AblSymTableHeap->malloc string literal ");
					strcpy(thisNode->info, curLiteral.value.string);
				}
			//}
			crunchSymTableNodePtr(thisNode);

			getToken();
			}
			break;
		case TKN_NOT:
			getToken();
			thisType = factor();
			break;
		case TKN_LPAREN:
			getToken();
			thisType = expression();
			ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);
			break;
		default:
			syntaxError(ABL_ERR_SYNTAX_INVALID_EXPRESSION);
			thisType = &DummyType;
			break;
	}
	return(thisType);
}
Пример #3
0
SymTableNodePtr ABLModule::findState(PSTR stateName)
{
    SymTableNodePtr symbol = searchSymTableForState(stateName, ModuleRegistry[handle].moduleIdPtr->defn.info.routine.localSymTable);
    return(symbol);
}