/// <summary> /// Creates a new immutable header from the given node factory, symbol table and template table. /// </summary> /// <param name="nodeFactory"></param> /// <param name="symbolTable"></param> /// <param name="templateTable"></param> public ReaderState(LNodeFactory nodeFactory, IReadOnlyList<string> symbolTable, IReadOnlyList<NodeTemplate> templateTable) { this.NodeFactory = nodeFactory; this.SymbolTable = symbolTable; this.SymbolPool = SymbolPool.@new(); this.TemplateTable = templateTable; }
public GenerateCodeVisitor(LLParserGenerator llpg) { LLPG = llpg; F = new LNodeFactory(llpg._sourceFile); _classBody = llpg._classBody; }
public CodeGenHelperBase() { F = new LNodeFactory(EmptySourceFile.Unknown); ListType = F.Of(F.Id("List"), F.Id(_T)); ListInitializer = F.Call(S.New, F.Call(ListType)); }
public virtual void Done() { _classBody = null; F = null; _setDeclNames = null; _currentRule = null; }
public virtual void Begin(RWList<LNode> classBody, ISourceFile sourceFile) { _classBody = classBody; F = new LNodeFactory(sourceFile); _setDeclNames = new Dictionary<IPGTerminalSet, Symbol>(); }
private IReadOnlyList<LNode> GenerateRandomNodeList(LNodeFactory Factory, Random Rand, int Depth) { var results = new LNode[(int)System.Math.Sqrt(Rand.Next(100))]; for (int i = 0; i < results.Length; i++) { results[i] = GenerateRandomNode(Factory, Rand, Depth); } return results; }
private LNode GenerateRandomNode(LNodeFactory Factory, Random Rand, int Depth) { int index = Rand.Next(5); switch (Depth <= 0 && index > 1 ? Rand.Next(2) : index) { case 0: return Factory.Literal(GenerateRandomLiteral(Rand)); case 1: return Factory.Id(GenerateRandomSymbol(Rand)); case 2: return Factory.Attr(GenerateRandomNode(Factory, Rand, Depth - 1), GenerateRandomNode(Factory, Rand, Depth - 1)); case 3: return Factory.Call(GenerateRandomSymbol(Rand), GenerateRandomNodeList(Factory, Rand, Depth - 1)); default: return Factory.Call(GenerateRandomNode(Factory, Rand, Depth - 1), GenerateRandomNodeList(Factory, Rand, Depth - 1)); } }