Exemplo n.º 1
0
DEFINE_THIS_FILE

/***********************************************************************************************
	Forward declarations
***********************************************************************************************/

/***********************************************************************************************
	Local Constants and static variables
***********************************************************************************************/

/***********************************************************************************************
	Methods
***********************************************************************************************/

bool GrcManager::PostParse()
{
	//	Add the system-defined "lang" feature whose values are 4-byte language ID codes.
	//	This feature always has an ID = 1 (kfidStdLang).
	Symbol psymFeat = SymbolTable()->AddFeatureSymbol(GrcStructName("lang"),
		GrpLineAndFile(0, 0, ""));
	GdlFeatureDefn * pfeat = psymFeat->FeatureDefnData();
	Assert(pfeat);
	pfeat->SetName("lang");
	pfeat->MarkAsLanguageFeature();
	m_prndr->AddFeature(pfeat);

	g_cman.ProcessMasterTables();

	if (!m_prndr->ReplaceAliases())
		return false;

	if (!m_prndr->HandleOptionalItems())
		return false;

	if (!m_prndr->CheckSelectors())
		return false;

	return true;
}
Exemplo n.º 2
0
bool GdlLangClass::PreCompile(GrcManager * pcman)
{
	// Each item in the vectors corresponds to a feature assignment.
	for (int ifasgn = 0; ifasgn < m_vstaFeat.Size(); ifasgn++)
	{
		Symbol psymFeat = pcman->SymbolTable()->FindSymbol(m_vstaFeat[ifasgn]);
		if (!psymFeat)
		{
			g_errorList.AddError(3154, NULL, "Undefined feature: ", m_vstaFeat[ifasgn], m_vlnf[ifasgn]);
			continue;
		}

		GdlFeatureDefn * pfeat = psymFeat->FeatureDefnData();
		Assert(pfeat);
		StrAnsi staValue = m_vstaVal[ifasgn];
		GdlExpression * pexpVal = m_vpexpVal[ifasgn];
		int nVal;
		GdlFeatureSetting * pfset;
		if (pexpVal)
		{
			if (!pexpVal->ResolveToInteger(&nVal, false))
			{
				g_errorList.AddError(3155, pexpVal,
					"Feature value cannot be evaluated", m_vlnf[ifasgn]);
				continue;
			}
			else
			{
				pfset = pfeat->FindSettingWithValue(nVal);
				if (!pfset)
				{
					char rgchValue[20];
					itoa(nVal, rgchValue, 10);
					g_errorList.AddWarning(3523, NULL,
						"Feature ", pfeat->Name(), " has no defined setting corresponding to value ",
						rgchValue,
						m_vlnf[ifasgn]);
				}
			}
		}
		else
		{
			// Feature setting identifier
			pfset = pfeat->FindSetting(staValue);
			if (!pfset)
			{
				g_errorList.AddError(3156, NULL, "Undefined feature setting: ", staValue, m_vlnf[ifasgn]);
				continue;
			}
			nVal = pfset->Value();
		}

		// Store the feature values in the language items.
		for (int ilang = 0; ilang < m_vplang.Size(); ilang++)
			m_vplang[ilang]->AddFeatureValue(pfeat, pfset, nVal, m_vlnf[ifasgn]);

		if (m_vplang.Size() == 0 && ifasgn == 0)
		{
			g_errorList.AddWarning(3524, NULL, "No languages specified for language group '", m_staLabel,
				"'; settings will have no effect",
				m_vlnf[0]);
		}
	}
	return true;
}