本文整理汇总了C#中SymbolTable.AddEntry方法的典型用法代码示例。如果您正苦于以下问题:C# SymbolTable.AddEntry方法的具体用法?C# SymbolTable.AddEntry怎么用?C# SymbolTable.AddEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolTable
的用法示例。
在下文中一共展示了SymbolTable.AddEntry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: matchFunction
// parses one function definition
void matchFunction()
{
match(Token.KwdFunc);
currFunction = new CompiledFunction(sc.TokenText);
// Get the function text
string fnName = sc.TokenText;
match(Token.Ident); // the function name
// check for uniqueness, then add to the function list if unique.
checkUniqueFunction(fnName);
FunctionList.Add(fnName);
currSymbolTable = new SymbolTable();
match(Token.LPar);
if (nextToken != Token.RPar) {
for( ; ; ) {
string argname = sc.TokenText;
match(Token.Ident);
if (!currSymbolTable.AddEntry(argname, currFunction.AddArgument(argname)))
SemanticError("duplicate declaration of argument {0}", argname);
if (nextToken != Token.Comma)
break;
advance();
}
}
match(Token.RPar);
matchBlock();
// the function should end with a return statement. In case ...
currFunction.AddInstruction(OpCode.Stop);
program.Add(currFunction);
currFunction = null;
currSymbolTable = null;
}
示例2: matchFunction
// parses one function definition
void matchFunction()
{
match(Token.KwdFunc);
currFunction = new CompiledFunction(sc.TokenText);
// Add next token to list
string fn = sc.TokenText;
int args = 0;
Function func = new Function(fn, 0);
if (!functionNames.Contains(fn))
functionNames.Add(fn);
else
throw new ParseError("Duplicate function name " + func.name);
match(Token.Ident); // the function name
currSymbolTable = new SymbolTable();
match(Token.LPar);
if (nextToken != Token.RPar) {
for( ; ; ) {
string argname = sc.TokenText;
args++;
match(Token.Ident);
if (!currSymbolTable.AddEntry(argname, currFunction.AddArgument(argname)))
SemanticError("duplicate declaration of argument {0}", argname);
if (nextToken != Token.Comma)
break;
advance();
}
}
func.args = args;
functions.Add(func);
match(Token.RPar);
matchBlock();
// the function should end with a return statement. In case ...
currFunction.AddInstruction(OpCode.Stop);
program.Add(currFunction);
currFunction = null;
currSymbolTable = null;
}