コード例 #1
0
 public void Dispose()
 {
     SubParseResult = SubParseResult.DisposeExchange();
     CallSubParserContext.ReleaseReference();
     CallSubParserContext = null;
     _poolCollection.ForkBranchPool.Release(this);
 }
コード例 #2
0
ファイル: Automata.SubGraph.cs プロジェクト: Egaros/lib
            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);
            }
コード例 #3
0
                    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);
                    }
コード例 #4
0
ファイル: ParserAutomata.cs プロジェクト: Egaros/lib
            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);
                    }
                }
コード例 #6
0
ファイル: Automata.SubGraph.cs プロジェクト: Egaros/lib
 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;
 }
コード例 #7
0
ファイル: Automata.SubGraph.cs プロジェクト: Egaros/lib
            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();
            }
コード例 #8
0
ファイル: Automata.AutomataStack.cs プロジェクト: Egaros/lib
            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);
            }
コード例 #9
0
            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;
                }
            }
コード例 #10
0
ファイル: Automata.cs プロジェクト: Egaros/lib
            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);
                }
            }
コード例 #11
0
            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));
                };
            }
コード例 #12
0
            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);
                }
            }
コード例 #13
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public EndProductionNode(Automata <TInstruction, TOperand> automata, Graph graph, Production production) : base(automata, graph, production)
 {
 }
コード例 #14
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 protected ProductionNode(Automata <TInstruction, TOperand> automata, Graph graph, Production production) : base(automata, graph)
 {
     Production = production;
 }
コード例 #15
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public ReturnStateNode(Automata <TInstruction, TOperand> automata, Graph graph) : base(automata, graph)
 {
 }
コード例 #16
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public PredicateNode(Automata <TInstruction, TOperand> automata, IPool <PredicateNode> pool) : base(automata, null)
 {
     _pool = pool;
 }
コード例 #17
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public ActionNode(Automata <TInstruction, TOperand> automata, Graph graph, ActionEntry actionEntry) : base(automata, graph)
 {
     ActionEntry = actionEntry;
 }
コード例 #18
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public LazyNode(Automata <TInstruction, TOperand> automata, Graph graph) : base(automata, graph)
 {
 }
コード例 #19
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public PredicateNode(Automata <TInstruction, TOperand> automata, Graph graph, PredicateEntryBase predicateEntry) : base(automata, graph)
 {
     PredicateEntry = predicateEntry;
 }
コード例 #20
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public EndStateNode(Automata <TInstruction, TOperand> automata, SubGraph subGraph) : base(automata, subGraph)
 {
 }
コード例 #21
0
 public virtual InstructionStream Advance(int instructionPointer, Automata <TInstruction, TOperand> automata)
 {
     throw new NotImplementedException();
 }
コード例 #22
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public EnterStateNode(Automata <TInstruction, TOperand> automata, Graph graph, SubGraph subGraph) : base(automata, graph, subGraph)
 {
 }
コード例 #23
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 protected SubGraphNode(Automata <TInstruction, TOperand> automata, Graph graph, SubGraph subGraph) : base(automata, graph)
 {
     SubGraph = subGraph;
 }
コード例 #24
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public OperandNode(Automata <TInstruction, TOperand> automata, Graph graph, MatchEntry matchEntry) : base(automata, graph)
 {
     MatchEntry = matchEntry;
 }
コード例 #25
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public ForkNode(Automata <TInstruction, TOperand> automata, IPool <ForkNode> pool) : base(automata, null)
 {
     _pool = pool;
 }
コード例 #26
0
ファイル: Automata.SubGraph.cs プロジェクト: Egaros/lib
 public SubGraph(Automata <TInstruction, TOperand> automata, StateEntry stateEntry, Graph invokingGraph) : this(automata, stateEntry.State, invokingGraph)
 {
     StateEntry = stateEntry;
 }
コード例 #27
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 protected EntryPointSubGraphNode(Automata <TInstruction, TOperand> automata, SubGraph subGraph) : base(automata, null, subGraph)
 {
 }
コード例 #28
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 protected StateEntryNode(Automata <TInstruction, TOperand> automata, Graph graph, StateEntry stateEntry) : base(automata, graph)
 {
     StateEntry = stateEntry;
 }
コード例 #29
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public LeaveStateNode(Automata <TInstruction, TOperand> automata, Graph graph, SubGraph subGraph) : base(automata, graph, subGraph)
 {
     //LeavePath = new ExecutionPath(this, new Node[] {this});
 }
コード例 #30
0
ファイル: Automata.Node.Kind.cs プロジェクト: Egaros/lib
 public InlineLeaveStateNode(Automata <TInstruction, TOperand> automata, Graph graph, StateEntry stateEntry) : base(automata, graph, stateEntry)
 {
 }