public void Dispose() { SubParseResult = SubParseResult.DisposeExchange(); CallSubParserContext.ReleaseReference(); CallSubParserContext = null; _poolCollection.ForkBranchPool.Release(this); }
public void BuildExecutionGraph() { if (_executionGraphBuilt) { return; } _executionGraphBuilt = true; //InitNode.EnsureReady(); //EnterNode.SubGraph.Graph.BeginNode.EnsureReady(); if (Graph.BeginNode.ReturnPath.IsInvalid) { return; } EmptyPath = new ExecutionPath(InitNode, new[] { EnterNode, Graph.BeginNode, }.Concat(Graph.BeginNode.ReturnPath.Nodes).ToArray(), -1); Automata.RegisterExecutionPath(EmptyPath); }
public CallSubParserForkBranch <TSubGrammar, TSubToken> Mount(CallSubParserContext <TSubGrammar, TSubToken> callSubParserContext, Automata <Lexeme <TSubToken>, TSubToken> .ForkAutomataResult subParseResult, bool finish) { CallSubParserContext = callSubParserContext.AddReference(); SubParseResult = subParseResult.AddReference(); _finish = finish; return(this); }
public override InstructionStream Advance(int instructionPointer, Automata <Lexeme <TToken>, TToken> automata) { var copy = (LexemeStream)Pool.Get().Mount(InstructionReader, automata); copy.AdvanceInstructionPosition(this, instructionPointer); return(copy); }
public ExecutionPathGroupBuilder(Automata <TInstruction, TOperand> automata, IPool <ExecutionPathGroupBuilder> pool) : base(pool) { _automata = automata; for (var i = 0; i < ExecutionPathBuilders.Length; i++) { ExecutionPathBuilders[i] = new ExecutionPathQueueBuilder(this); } }
protected SubGraph(Automata <TInstruction, TOperand> automata, FiniteState state, Graph invokingGraph) : base(state) { Automata = automata; automata.RegisterSubGraph(this); Graph = automata.EnsureGraph(state); InvokingGraph = invokingGraph; EnterNode = new EnterStateNode(automata, invokingGraph, this); LeaveNode = new LeaveStateNode(automata, invokingGraph, this); DfaBarrier = Graph.DfaBarrier; }
public EntryPointSubGraph(Automata <TInstruction, TOperand> automata, FiniteState state) : base(automata, state, null) { InitNode = new InitStateNode(automata, this); EndNode = new EndStateNode(automata, this); InitNode.OutEdges.Add(new Edge(InitNode, EnterNode)); LeaveNode.OutEdges.Add(new Edge(LeaveNode, EndNode)); EndPath = new ExecutionPath(LeaveNode, new Node[] { EndNode }, -1); Automata.RegisterExecutionPath(EndPath); //EndNode.EnsureReady(); }
private AutomataStack(AutomataStack source) : base(source.Pool) { _automata = source._automata; _automataSubGraphRegistry = _automata._subGraphRegistry; _hashCode = source.GetHashCode(); Count = source._hashCodeDepth; Array = new int[Count]; _hashCodeDirty = false; _hashCodeDepth = Count; _returnDepth = source._returnDepth; System.Array.Copy(source.Array, source.Count - Count, Array, 0, Count); }
private Node(Automata <TInstruction, TOperand> automata) { _automata = automata; automata.RegisterNode(this); if (this is EnterStateNode || this is LeaveStateNode) { Flags |= EnterReturn; } if (this is LazyNode) { Flags |= Lazy; } }
public ExecutionPathMethodCollection(IILBuilder ilBuilder, Automata <TInstruction, TOperand> automata) { _ilBuilder = ilBuilder; _automata = automata; var length = 128; while (length < automata._executionPathRegistry.Count) { length *= 2; } _executionPaths = new ExecutionPathMethod[length]; for (var i = 0; i < length; i++) { _executionPaths[i] = new ExecutionPathMethod(_ilBuilder, automata, i); } }
public ExecutionPathMethod(IILBuilder builder, Automata <TInstruction, TOperand> automata, int index) { _mainDelegate = (process, threadStack, closure) => { var executionPath = automata._executionPathRegistry[index]; _mainDelegate = builder.BuildMain(executionPath, out _mainClosure); return(_mainDelegate(process, threadStack, _mainClosure)); }; _parallelDelegate = (process, threadStack, closure) => { var executionPath = automata._executionPathRegistry[index]; _parallelDelegate = builder.BuildParallel(executionPath, out _parallelClosure); return(_parallelDelegate(process, threadStack, _parallelClosure)); }; }
protected DfaBuilder(IEnumerable <FiniteState> states, Automata <TInstruction, TOperand> automata) { _initialStateNodes = new List <DfaNode>(); _noOpInitialStateNodes = new List <DfaNode>(); foreach (var subGraph in states.Select(automata.EnsureSubGraph)) { if (subGraph.Graph.CanSimulateDfa == false) { throw new InvalidOperationException($"FiniteState {subGraph.State} can not be simulated as DFA"); } if (subGraph.Graph.HasOperandNodes == false) { _noOpInitialStateNodes.Add(CreateDfaNode(subGraph.Graph.BeginNode, new DfaTransition(subGraph, _transitionCount), null)); } else { _initialStateNodes.Add(CreateDfaNode(subGraph.Graph.BeginNode, new DfaTransition(subGraph, _transitionCount), null)); } _transitionCount++; } FastLookup = _initialStateNodes.Count < 100; var builderKey = GetBuilderKey(); InitialState = builderKey.Build(_initialStateNodes); NoOpInitialState = builderKey.Build(_noOpInitialStateNodes); ReleaseBuilderKey(builderKey); if (FastLookup) { BuildFastLookup(InitialState); } }
public EndProductionNode(Automata <TInstruction, TOperand> automata, Graph graph, Production production) : base(automata, graph, production) { }
protected ProductionNode(Automata <TInstruction, TOperand> automata, Graph graph, Production production) : base(automata, graph) { Production = production; }
public ReturnStateNode(Automata <TInstruction, TOperand> automata, Graph graph) : base(automata, graph) { }
public PredicateNode(Automata <TInstruction, TOperand> automata, IPool <PredicateNode> pool) : base(automata, null) { _pool = pool; }
public ActionNode(Automata <TInstruction, TOperand> automata, Graph graph, ActionEntry actionEntry) : base(automata, graph) { ActionEntry = actionEntry; }
public LazyNode(Automata <TInstruction, TOperand> automata, Graph graph) : base(automata, graph) { }
public PredicateNode(Automata <TInstruction, TOperand> automata, Graph graph, PredicateEntryBase predicateEntry) : base(automata, graph) { PredicateEntry = predicateEntry; }
public EndStateNode(Automata <TInstruction, TOperand> automata, SubGraph subGraph) : base(automata, subGraph) { }
public virtual InstructionStream Advance(int instructionPointer, Automata <TInstruction, TOperand> automata) { throw new NotImplementedException(); }
public EnterStateNode(Automata <TInstruction, TOperand> automata, Graph graph, SubGraph subGraph) : base(automata, graph, subGraph) { }
protected SubGraphNode(Automata <TInstruction, TOperand> automata, Graph graph, SubGraph subGraph) : base(automata, graph) { SubGraph = subGraph; }
public OperandNode(Automata <TInstruction, TOperand> automata, Graph graph, MatchEntry matchEntry) : base(automata, graph) { MatchEntry = matchEntry; }
public ForkNode(Automata <TInstruction, TOperand> automata, IPool <ForkNode> pool) : base(automata, null) { _pool = pool; }
public SubGraph(Automata <TInstruction, TOperand> automata, StateEntry stateEntry, Graph invokingGraph) : this(automata, stateEntry.State, invokingGraph) { StateEntry = stateEntry; }
protected EntryPointSubGraphNode(Automata <TInstruction, TOperand> automata, SubGraph subGraph) : base(automata, null, subGraph) { }
protected StateEntryNode(Automata <TInstruction, TOperand> automata, Graph graph, StateEntry stateEntry) : base(automata, graph) { StateEntry = stateEntry; }
public LeaveStateNode(Automata <TInstruction, TOperand> automata, Graph graph, SubGraph subGraph) : base(automata, graph, subGraph) { //LeavePath = new ExecutionPath(this, new Node[] {this}); }
public InlineLeaveStateNode(Automata <TInstruction, TOperand> automata, Graph graph, StateEntry stateEntry) : base(automata, graph, stateEntry) { }