本文整理汇总了C#中SymbolTable类的典型用法代码示例。如果您正苦于以下问题:C# SymbolTable类的具体用法?C# SymbolTable怎么用?C# SymbolTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SymbolTable类属于命名空间,在下文中一共展示了SymbolTable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Render
public override void Render(SymbolTable symbols, TextWriter tw, object item)
{
foreach (var child in Children)
{
child.Render(symbols, tw, item);
}
}
开发者ID:jeffreyabecker,项目名称:template,代码行数:7,代码来源:Parser.cs
示例2: ProcessExpression
private bool ProcessExpression(SymbolTable symbolTable)
{
// TODO: If there are performance problems, we could find a faster way to detect expressions than doing a full parse
var tokenSequence = new TokenSequence(XValue);
if (tokenSequence.RequiresProcessing)
{
if (tokenSequence.RequiresTemplateArguments)
{
var templateInstance = TemplateInstance;
if (templateInstance == null || templateInstance.Template == null)
{
return false;
}
XValue = tokenSequence.Process(symbolTable, templateInstance.ArgumentDictionary);
}
else
{
XValue = tokenSequence.Process(symbolTable, null);
}
}
return true;
}
开发者ID:japj,项目名称:vulcan,代码行数:25,代码来源:BindingItem.cs
示例3: LoadLocalAddress
internal LoadLocalAddress(SymbolTable symbols, MethodDefinition method, Instruction untyped, int index) : base(untyped, index)
{
switch (untyped.OpCode.Code)
{
case Code.Ldloca_S:
case Code.Ldloca:
VariableDefinition param = untyped.Operand as VariableDefinition;
if (param != null)
{
Variable = param.Index;
Type = param.VariableType;
}
else
{
Variable = (int) untyped.Operand;
Type = method.Body.Variables[Variable].VariableType;
}
Name = symbols.LocalName(method, untyped, Variable);
break;
default:
DBC.Fail(untyped.OpCode.Code + " is not a valid LoadLocalAddress");
break;
}
RealName = symbols.HaveLocalNames(method);
}
开发者ID:dbremner,项目名称:smokey,代码行数:27,代码来源:LoadLocalAddress.cs
示例4: RuleBuilder
/// <summary>
/// Constructs an empty rule builder.
/// </summary>
public RuleBuilder()
{
var rootScope = new SymbolTable();
_dependencyBuilder = new DependencyGroupBuilder(rootScope);
_groupBuilder = new GroupBuilder(rootScope, GroupType.And);
_actionGroupBuilder = new ActionGroupBuilder(rootScope);
}
开发者ID:hebert26,项目名称:NRules,代码行数:10,代码来源:RuleBuilder.cs
示例5: Insert_Lookup_WriteTable_SymbolTableTest
public void Insert_Lookup_WriteTable_SymbolTableTest()
{
var count = 0;
var symTable = new SymbolTable();
symTable.Printer = (val) => { count++; };
symTable.Insert(Token.CreateToken("x", 0), 0);
symTable.Insert(Token.CreateToken("y", 0), 0);
symTable.Insert(Token.CreateToken("z", 0), 0);
symTable.Lookup("x").Content = CreateVariableContent();
symTable.Lookup("y").Content = CreateVariableContent();
symTable.Lookup("z").Content = CreateVariableContent();
symTable.Insert(Token.CreateToken("a", 0), 1);
symTable.Insert(Token.CreateToken("x", 0), 1);
symTable.Insert(Token.CreateToken("y", 0), 1);
symTable.Insert(Token.CreateToken("z", 0), 1);
symTable.Lookup("a").Content = CreateVariableContent();
symTable.Lookup("x").Content = CreateVariableContent();
symTable.Lookup("y").Content = CreateVariableContent();
symTable.Lookup("z").Content = CreateVariableContent();
symTable.WriteTable(0);
Assert.AreEqual(3, count);
count = 0;
symTable.WriteTable(1);
Assert.AreEqual(4, count);
count = 0;
symTable.WriteTable(2);
Assert.AreEqual(0, count);
}
开发者ID:dubeme,项目名称:Lame-Java-Compiler,代码行数:35,代码来源:SymbolTableTests.cs
示例6: NameExpression
public NameExpression(
IExpression identifier,
SymbolTable<string, IValue> symbolTable)
{
_identifier = identifier;
_symbolTable = symbolTable;
}
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:7,代码来源:NameExpression.cs
示例7: AddValue_Correct_Test
public void AddValue_Correct_Test()
{
symbolTable = new SymbolTable();
symbolTable.AddValue(id, new Bool(false));
Assert.IsNotNull(symbolTable.GetValue(id));
}
开发者ID:javachengwc,项目名称:many-ql,代码行数:7,代码来源:SymbolTableTests.cs
示例8: Init
public bool Init(ErrorHandling errorContext, SymbolTable symtable)
{
_runtimeBinderSymbolTable = symtable;
Debug.Assert(_pBSymmgr != null);
#if !CSEE
Debug.Assert(_predefSyms == null);
#else // CSEE
Debug.Assert(predefSyms == null || aidMsCorLib != KAID.kaidNil);
#endif // CSEE
if (_aidMsCorLib == KAID.kaidNil)
{
// If we haven't found mscorlib yet, first look for System.Object. Then use its assembly as
// the location for all other pre-defined types.
AggregateSymbol aggObj = FindPredefinedType(errorContext, PredefinedTypeFacts.GetName(PredefinedType.PT_OBJECT), KAID.kaidGlobal, AggKindEnum.Class, 0, true);
if (aggObj == null)
return false;
_aidMsCorLib = aggObj.GetAssemblyID();
}
_predefSyms = new AggregateSymbol[(int)PredefinedType.PT_COUNT];
Debug.Assert(_predefSyms != null);
return true;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:26,代码来源:PredefinedTypes.cs
示例9: NestedProgram
public NestedProgram(Program containingProgram)
{
IsNested = true;
ContainingProgram = containingProgram;
SymbolTable = new SymbolTable(containingProgram.SymbolTable);
SyntaxTree.Root.SymbolTable = SymbolTable;
}
开发者ID:osmedile,项目名称:TypeCobol,代码行数:7,代码来源:Program.cs
示例10: Instantiate
public void Instantiate(SymbolTable symbolTable, UnboundReferences unboundReferences)
{
var parentEtl = ParentItem as AstEtlRootNode;
var transformationTemplate = Template as AstTransformationTemplateNode;
var clonedMapping = new Dictionary<IFrameworkItem, IFrameworkItem>();
if (transformationTemplate != null && parentEtl != null)
{
var clonedTransformations = new List<AstTransformationNode>();
foreach (var transformation in transformationTemplate.Transformations)
{
clonedTransformations.Add((AstTransformationNode)transformation.Clone(parentEtl, clonedMapping));
}
parentEtl.Transformations.Replace(this, clonedTransformations);
}
foreach (var bindingItem in transformationTemplate.UnboundReferences)
{
var clonedBindingItem = new BindingItem(
bindingItem.BoundProperty,
bindingItem.XObject,
bindingItem.XValue,
clonedMapping[bindingItem.ParentItem],
bindingItem.BimlFile,
this);
unboundReferences.Add(clonedBindingItem);
}
}
开发者ID:japj,项目名称:vulcan,代码行数:28,代码来源:AstTransformationTemplateInstanceNode.cs
示例11: ParseProgramOrClass
public static void ParseProgramOrClass(TextSourceInfo textSourceInfo, ISearchableReadOnlyList<CodeElementsLine> codeElementsLines, TypeCobolOptions compilerOptions, SymbolTable customSymbols, out Program newProgram, out Class newClass, out IList<ParserDiagnostic> diagnostics)
{
// Create an Antlr compatible token source on top a the token iterator
CodeElementsLinesTokenSource tokenSource = new CodeElementsLinesTokenSource(
textSourceInfo.Name,
codeElementsLines);
// Init parser
ITokenStream tokenStream = new TokensLinesTokenStream(tokenSource, Token.CHANNEL_SourceTokens);
ProgramClassParser cobolParser = new ProgramClassParser(tokenStream);
// -> activate full ambiguities detection
//parser.Interpreter.PredictionMode = PredictionMode.LlExactAmbigDetection;
// Register all parse errors in a list in memory
DiagnosticSyntaxErrorListener errorListener = new DiagnosticSyntaxErrorListener();
cobolParser.RemoveErrorListeners();
cobolParser.AddErrorListener(errorListener);
// Try to parse a Cobol program or class
ProgramClassParser.CobolCompilationUnitContext codeElementParseTree = cobolParser.cobolCompilationUnit();
// Visit the parse tree to build a first class object representing a Cobol program or class
ParseTreeWalker walker = new ParseTreeWalker();
CobolNodeBuilder programClassBuilder = new CobolNodeBuilder();
programClassBuilder.CustomSymbols = customSymbols;
programClassBuilder.Dispatcher = new NodeDispatcher();
programClassBuilder.Dispatcher.CreateListeners();
walker.Walk(programClassBuilder, codeElementParseTree);
// Register compiler results
newProgram = programClassBuilder.Program;
newClass = programClassBuilder.Class;
diagnostics = errorListener.Diagnostics;
}
开发者ID:laurentprudhon,项目名称:TypeCobol,代码行数:34,代码来源:ProgramClassParserStep.cs
示例12: ProcessIsNullPatcherTransformations
public static void ProcessIsNullPatcherTransformations(SymbolTable symbolTable)
{
var snapshotSymbolTable = new List<IReferenceableItem>(symbolTable);
foreach (var astNamedNode in snapshotSymbolTable)
{
var nullPatcherNode = astNamedNode as AstIsNullPatcherNode;
if (nullPatcherNode != null && astNamedNode.FirstThisOrParent<ITemplate>() == null)
{
var astDerivedColumnListNode = new AstDerivedColumnListNode(nullPatcherNode.ParentItem)
{
Name = nullPatcherNode.Name,
ValidateExternalMetadata = nullPatcherNode.ValidateExternalMetadata
};
foreach (AstIsNullPatcherColumnNode patchColumn in nullPatcherNode.Columns)
{
var column = new AstDerivedColumnNode(astDerivedColumnListNode)
{
Name = patchColumn.Name,
ReplaceExisting = true,
Expression = String.Format(CultureInfo.InvariantCulture, "ISNULL({0}) ? {1} : {0}", patchColumn.Name, patchColumn.DefaultValue),
DerivedColumnType = VulcanEngine.IR.Ast.ColumnType.Object
};
astDerivedColumnListNode.Columns.Add(column);
}
Utility.Replace(nullPatcherNode, new List<AstTransformationNode> { astDerivedColumnListNode });
}
}
}
开发者ID:japj,项目名称:vulcan,代码行数:30,代码来源:IsNullPatcherLowerer.cs
示例13: Execute
public override object Execute(SymbolTable table)
{
base.Execute(table);
StatementList.Execute(table);
return null;
}
开发者ID:realn0whereman,项目名称:MiniRE,代码行数:7,代码来源:MiniRE.cs
示例14: CreateProgram
public void CreateProgram(string moduleName)
{
AssemblyName name = new AssemblyName(Path.GetFileNameWithoutExtension(moduleName));
var asmb = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Save);
ModuleBuilder modb = asmb.DefineDynamicModule(moduleName);
var type = modb.DefineType("$program");
var symbolTable = new SymbolTable(type);
symbolTable.AddFunctionHeader("$main", MethodAttributes.Static, null, new FunctionDefinition.Argument[] { },"$program");
var il = symbolTable.functionTable["$main"].GetILGenerator();
Program.GenerateIL(il, symbolTable);
il.Emit(OpCodes.Ret);
modb.CreateGlobalFunctions();
asmb.SetEntryPoint(symbolTable.functionTable["$main"].methodDefinition);
symbolTable.typeTable.types[0].typeBuilder.CreateType();
asmb.Save(moduleName);
}
开发者ID:mirhagk,项目名称:IronTuring,代码行数:26,代码来源:Unit.cs
示例15: TypeCheckerVisitor
public TypeCheckerVisitor(ErrorHandler errors, StmtList statements)
{
Errors = errors;
SymbolTable = new SymbolTable();
Checker = new TypeChecker(errors);
RootStmtList = statements;
}
开发者ID:Tuomoz,项目名称:mini-pl-interpreter,代码行数:7,代码来源:TypeCheckerVisitor.cs
示例16: Check
private void Check(CodeElement e, SymbolTable table, FunctionCall call, FunctionDeclaration definition)
{
var parameters = definition.Profile.Parameters;
if (call.InputParameters.Count > parameters.Count) {
var m = System.String.Format("Function {0} only takes {1} parameters", definition.Name, parameters.Count);
DiagnosticUtils.AddError(e, m);
}
for (int c = 0; c < parameters.Count; c++) {
var expected = parameters[c];
if (c < call.InputParameters.Count) {
var actual = call.InputParameters[c];
if (actual.IsLiteral) continue;
var found = table.GetVariable(new URI(actual.Value));
if (found.Count < 1) DiagnosticUtils.AddError(e, "Parameter "+actual.Value+" is not referenced");
if (found.Count > 1) DiagnosticUtils.AddError(e, "Ambiguous reference to parameter "+actual.Value);
if (found.Count!= 1) continue;
var type = found[0] as Typed;
// type check. please note:
// 1- if only one of [actual|expected] types is null, overriden DataType.!= operator will detect it
// 2- if both are null, we WANT it to break: in TypeCobol EVERYTHING should be typed,
// and things we cannot know their type as typed as DataType.Unknown (which is a non-null valid type).
if (type == null || type.DataType != expected.DataType) {
var m = System.String.Format("Function {0} expected parameter {1} of type {2} (actual: {3})", definition.Name, c+1, expected.DataType, type.DataType);
DiagnosticUtils.AddError(e, m);
}
if (type != null && type.Length > expected.Length) {
var m = System.String.Format("Function {0} expected parameter {1} of max length {2} (actual: {3})", definition.Name, c+1, expected.Length, type.Length);
DiagnosticUtils.AddError(e, m);
}
} else {
var m = System.String.Format("Function {0} is missing parameter {1} of type {2}", definition.Name, c+1, expected.DataType);
DiagnosticUtils.AddError(e, m);
}
}
}
开发者ID:laurentprudhon,项目名称:TypeCobol,代码行数:35,代码来源:TypeCobolChecker.cs
示例17: Pascal
public Pascal(String operation, String filePath, String flags)
{
try{
bool intermediate = flags.IndexOf('i') > 1;
bool xref = flags.IndexOf('x') > 1;
source = new Source(new StreamReader(filePath));
source.AddMessageListener(new SourceMessageListener());
parser = FrontEndFactory.CreateParser("pascal","top-down",source);
parser.AddMessageListener(new ParserMessageListener());
backend = BackendFactory.CreateBackend("compile");
backend.AddMessageListener(new BackendMessageListener());
parser.Parse();
source.close();
intermediateCode = parser.IntermediateCode;
symbolTable = Parser.SymbolTable;
backend.Process(intermediateCode,symbolTable);
}
catch(Exception ex){
Console.WriteLine ("Internal translation error");
Console.WriteLine (ex.StackTrace);
}
}
开发者ID:hardvain,项目名称:pascal-compiler,代码行数:27,代码来源:Pascal.cs
示例18: GenerateCode
public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper)
{
AppendNodeComment(fileManager);
// Initialization assignment
this._children[0].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);
// Generate loop start label
string startLabel = codeGeneratorHelper.GenerateNextLabel();
fileManager.Output.Append(Macro.Label(startLabel));
// Check condition and jump out if false
this._children[1].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);
string outLabel = codeGeneratorHelper.GenerateNextLabel();
fileManager.Output.Append(Macro.JumpOnFalse(outLabel));
// Loop body
this._children[3].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);
// Altering assignment
this._children[2].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);
// Jump back to condition check
fileManager.Output.Append(Macro.Jump(startLabel));
// Generate loop end label
fileManager.Output.Append(Macro.Label(outLabel));
}
开发者ID:alirazavi,项目名称:nase-compiler,代码行数:28,代码来源:SyntaxTreeForStatementNode.cs
示例19: evaluate_System_Function
public static EvalResult evaluate_System_Function(SymbolTable symbols, FunCall fun_call)
{
var fun_name = fun_call.value.value;
EvalFunc f = (s,func) => new EvalResult(new Error(fun_call.value.line_num, "Could not match system function!"));
switch (fun_name)
{
case "define": f = add_definition; break;
case "+": f = addition; break;
case "-": f = subtraction; break;
case "*": f = multiplication; break;
case "/": f = division; break;
case "%": f = mod; break;
case "head": f = head; break;
case "tail": f = tail; break;
case "++": f = cons; break;
case "==": f = equality_test; break;
case "not": f = not; break;
case "&&": f = logical_and; break;
case "||": f = logical_or; break;
case "<": f = less_than; break;
case ">": f = greater_than; break;
}
return f(symbols, fun_call);
}
开发者ID:JD95,项目名称:WinLisp,代码行数:26,代码来源:Evaluator.cs
示例20: GenerateCode
public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper)
{
AppendNodeComment(fileManager);
// Check condition
this._children[0].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);
// If the condition is false, jump to the else-statement (exit label if else-statement is null)
string elseLabel = codeGeneratorHelper.GenerateNextLabel();
fileManager.Output.Append(Macro.JumpOnFalse(elseLabel));
// Then-statement
this._children[1].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);
// On existing else-statement jump over it
string outLabel = null;
if (this._children[2] != null)
{
outLabel = codeGeneratorHelper.GenerateNextLabel();
fileManager.Output.Append(Macro.Jump(outLabel));
}
// Generate else label
fileManager.Output.Append(Macro.Label(elseLabel));
// Else-statement and exit label
if (this._children[2] != null)
{
this._children[2].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);
fileManager.Output.Append(Macro.Label(outLabel));
}
}
开发者ID:alirazavi,项目名称:nase-compiler,代码行数:32,代码来源:SyntaxTreeIfStatementNode.cs
注:本文中的SymbolTable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论