本文整理汇总了C++中Symbol::FitsSymbolType方法的典型用法代码示例。如果您正苦于以下问题:C++ Symbol::FitsSymbolType方法的具体用法?C++ Symbol::FitsSymbolType怎么用?C++ Symbol::FitsSymbolType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symbol
的用法示例。
在下文中一共展示了Symbol::FitsSymbolType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindRuleTable
/*----------------------------------------------------------------------------------------------
Return the rule table with the given name; create it if it does not exist. Assumes that
the name is a valid one for tables, but not necessarily for rule tables.
----------------------------------------------------------------------------------------------*/
GdlRuleTable * GdlRenderer::GetRuleTable(GrpLineAndFile & lnf, StrAnsi staTableName)
{
GdlRuleTable * prultbl = FindRuleTable(staTableName);
if (prultbl)
return prultbl;
// Create a new one, if permissible.
Symbol psymTableName = g_cman.SymbolTable()->FindSymbol(staTableName);
Assert(psymTableName);
if (!psymTableName || !psymTableName->FitsSymbolType(ksymtTableRule))
{
g_errorList.AddError(2162, NULL,
"The ",
staTableName,
" table cannot hold rules",
lnf);
return NULL;
}
prultbl = new GdlRuleTable(psymTableName);
prultbl->SetLineAndFile(lnf);
m_vprultbl.Push(prultbl);
return prultbl;
}
示例2: if
GdlRuleItem * GdlRule::ContextItemAt(GrpLineAndFile & lnf, int irit,
StrAnsi staInput, StrAnsi staAlias)
{
Assert(irit <= m_vprit.Size());
if (irit == m_vprit.Size())
{
Symbol psymClass = g_cman.SymbolTable()->FindSymbol(staInput);
GdlRuleItem * prit;
if (psymClass && psymClass->FitsSymbolType(ksymtSpecialLb))
prit = new GdlLineBreakItem(psymClass);
else if (psymClass && psymClass->FitsSymbolType(ksymtSpecialUnderscore))
// place holder
prit = new GdlSetAttrItem(psymClass);
else
{
if (!psymClass || !psymClass->FitsSymbolType(ksymtClass))
{
g_errorList.AddError(3134, this,
"Undefined class name: ",
staInput,
lnf);
psymClass = g_cman.SymbolTable()->FindSymbol(GdlGlyphClassDefn::Undefined());
}
prit = new GdlRuleItem(psymClass);
}
prit->SetLineAndFile(lnf);
prit->m_iritContextPos = m_vprit.Size();
prit->m_iritContextPosOrig = prit->m_iritContextPos;
m_vprit.Push(prit);
// record the 1-based slot-alias value, if any
if (staAlias != "")
m_vpalias.Push(new GdlAlias(staAlias, prit->m_iritContextPos + 1));
}
return m_vprit[irit];
}
示例3: SortKey
/*----------------------------------------------------------------------------------------------
The sort key is the number of items matched in the rule (minus the prepended ANYs).
So we take the original total number of items and substract the insertions.
----------------------------------------------------------------------------------------------*/
int GdlRule::SortKey()
{
// Count insertions.
int critIns = 0;
for (int irit = 0; irit < m_vprit.Size(); irit++)
{
GdlSubstitutionItem * pritSub = dynamic_cast<GdlSubstitutionItem *>(m_vprit[irit]);
if (pritSub)
{
Symbol psym = m_vprit[irit]->m_psymInput;
if (psym && psym->FitsSymbolType(ksymtSpecialUnderscore))
critIns++;
}
}
return m_critOriginal - critIns; // original length of rule
}
示例4: GdlAlias
/*----------------------------------------------------------------------------------------------
Return the irit'th item in the LHS.
Assumes that all items have been created for the context and right-hand side, so there
should be no need to create one here.
Caller is responsible for checking that there is exactly an equal number of items in the
left- and right-hand sides.
Arguments:
lnf - line on which the item appears
irit - item number (0-based)
staInput - input class name, "_", or "#"
----------------------------------------------------------------------------------------------*/
GdlRuleItem * GdlRule::LhsItemAt(GrpLineAndFile & lnf, int irit,
StrAnsi staInput, StrAnsi staAlias)
{
bool fContext = false;
int critLhs = 0;
Symbol psymClassOrPlaceHolder = g_cman.SymbolTable()->FindSymbol(staInput);
for (int iritT = 0; iritT < m_vprit.Size(); iritT++)
{
GdlSetAttrItem * pritset = dynamic_cast<GdlSetAttrItem*>(m_vprit[iritT]);
if (!pritset)
fContext = true;
else
{
if (irit == critLhs)
{
if (!psymClassOrPlaceHolder ||
(!psymClassOrPlaceHolder->FitsSymbolType(ksymtClass) &&
!psymClassOrPlaceHolder->FitsSymbolType(ksymtSpecialUnderscore) &&
!psymClassOrPlaceHolder->FitsSymbolType(ksymtSpecialLb)))
{
g_errorList.AddError(3141, this,
"Undefined class name: ",
staInput,
lnf);
psymClassOrPlaceHolder =
g_cman.SymbolTable()->FindSymbol(GdlGlyphClassDefn::Undefined());
}
GdlSubstitutionItem * pritsub = dynamic_cast<GdlSubstitutionItem*>(pritset);
if (pritsub)
{
// for instance, there was a @ in the rhs
}
else
{
pritsub = new GdlSubstitutionItem(*pritset);
// output has been set to input
delete pritset;
}
pritsub->SetLineAndFile(lnf);
m_vprit[iritT] = pritsub;
pritsub->m_psymInput = psymClassOrPlaceHolder; // possibly invalid
// Record the 1-based slot-alias value, if any
if (staAlias != "")
m_vpalias.Push(
new GdlAlias(staAlias, pritsub->m_iritContextPos + 1));
if (psymClassOrPlaceHolder &&
psymClassOrPlaceHolder->FitsSymbolType(ksymtSpecialLb))
{
goto LLbError;
}
return m_vprit[iritT];
}
else
critLhs++;
}
}
// Need to add an item
LLbError:
if (staInput == "#")
{
g_errorList.AddError(3142, this,
StrAnsi("Line break indicator # cannot appear in the left-hand-side"));
return NULL;
}
if (!psymClassOrPlaceHolder ||
(!psymClassOrPlaceHolder->FitsSymbolType(ksymtClass) &&
!psymClassOrPlaceHolder->FitsSymbolType(ksymtSpecialUnderscore)))
{
g_errorList.AddError(3143, this,
"Undefined class name: ",
staInput,
lnf);
psymClassOrPlaceHolder = g_cman.SymbolTable()->FindSymbol(GdlGlyphClassDefn::Undefined());
}
if (fContext)
g_errorList.AddError(3144, this,
StrAnsi("Context does not account for all items in the left-hand-side"));
else
//.........这里部分代码省略.........