本文整理汇总了C#中SymbolTable.Find方法的典型用法代码示例。如果您正苦于以下问题:C# SymbolTable.Find方法的具体用法?C# SymbolTable.Find怎么用?C# SymbolTable.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolTable
的用法示例。
在下文中一共展示了SymbolTable.Find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NTF_Factor2
// <factor2> ::= <indicestar>
// | ( <aparams> )
protected bool NTF_Factor2(int p, SemanticInfo si)
{
bool error = SkipErrors(p, Lexer.Token.TokenType.OpenSquareBracket, Lexer.Token.TokenType.Multiplicative,
Lexer.Token.TokenType.Additive, Lexer.Token.TokenType.Comma, Lexer.Token.TokenType.CloseBracket,
Lexer.Token.TokenType.Comparison, Lexer.Token.TokenType.Semicolon, Lexer.Token.TokenType.OpenBracket);
// first(<factor2>.1)=first(<indicestar>)+follow(<factor2>)
// =[+multop+addop+,+)+;
if (lookahead.Type == Lexer.Token.TokenType.OpenSquareBracket || lookahead.Type == Lexer.Token.TokenType.Multiplicative
|| lookahead.Type == Lexer.Token.TokenType.Additive || lookahead.Type == Lexer.Token.TokenType.Comma
|| lookahead.Type == Lexer.Token.TokenType.CloseBracket || lookahead.Type == Lexer.Token.TokenType.Comparison
|| lookahead.Type == Lexer.Token.TokenType.Semicolon)
{
error |= !NTF_IndiceStar(p, si);
if (p == 2)
{
SymbolTable st = CurrentScope;
SymbolTable.Information info;
si.Offset = 0;
foreach (SemanticInfo.ParameterInfo pi in si.Parameters)
{
info = st.Find(pi.Name, true);
if (info == null || info.Kind != SymbolTable.Information.EKind.Variable)
{
SemanticErrorVariableNotFound(pi.Name);
return false;
}
si.Offset += (int)info.Properties["variable_offset"];
info = Global.Find(info.Properties["variable_type"] as string, false);
if (info == null || info.Kind != SymbolTable.Information.EKind.Class)
{
SemanticErrorWrongType(pi.Name);
return false;
}
st = info.Properties["class_symtable"] as SymbolTable;
}
info = st.Find(si.Name, false);
if (info == null || info.Kind != SymbolTable.Information.EKind.Variable)
{
// fall through if it's not qualified and i'm in a class
if (si.Parameters.Count == 0 && CurrentScope != Global)
{
info = CurrentScope.Parent.Find(si.Name, false);
if (info == null || info.Kind != SymbolTable.Information.EKind.Variable)
{
SemanticErrorFunctionNotFound(si.Name);
return false;
}
else
{
// copy from r12+info.offset into temp variables
int tmp = CompilerStack.Peek().RequestTemp((int)info.Properties["variable_size"]);
for (int k = 0; k < (int)info.Properties["variable_size"]; k += 4)
{
si.Code.Append("addi r2,r12," +
(si.Offset + (int)info.Properties["variable_offset"] + k) + "\nlw r1,stack(r2)\n" +
"addi r2,r14," + (tmp + k) + "\nsw stack(r2),r1\n");
}
si.Offset = tmp;
si.Type = info.Properties["variable_type"] as string;
return error;
}
}
else
{
SemanticErrorFunctionNotFound(si.Name);
return false;
}
}
si.Offset += (int)info.Properties["variable_offset"];
si.Type = (string)info.Properties["variable_type"];
}
if (!error && p == 1)
Log(LogType.Parse, "<factor2> ::= <indicestar>");
}
else if (lookahead.Type == Lexer.Token.TokenType.OpenBracket)
{
error |= !Match(p, Lexer.Token.TokenType.OpenBracket);
SemanticInfo si2 = new SemanticInfo();
error |= !NTF_AParams(p, si2);
if (p == 2)
{
// this is a function call. check the symbol table for the parameters
// and see if they are all ok for starters
// resolve the function call
SymbolTable st = CurrentScope;
SymbolTable.Information info;
//.........这里部分代码省略.........