コード例 #1
0
        public virtual Antlr4.Runtime.Atn.ATNConfig AppendContext(PredictionContext context, PredictionContextCache contextCache)
        {
            PredictionContext appendedContext = Context.AppendContext(context, contextCache);

            Antlr4.Runtime.Atn.ATNConfig result = Transform(State, appendedContext, false);
            return(result);
        }
コード例 #2
0
 public virtual bool Equals(Antlr4.Runtime.Atn.ATNConfig other)
 {
     if (this == other)
     {
         return(true);
     }
     else
     {
         if (other == null)
         {
             return(false);
         }
     }
     return(this.State.stateNumber == other.State.stateNumber && this.Alt == other.Alt && this.ReachesIntoOuterContext == other.ReachesIntoOuterContext && this.Context.Equals(other.Context) && this.SemanticContext.Equals(other.SemanticContext) && this.PrecedenceFilterSuppressed == other.PrecedenceFilterSuppressed && this.PassedThroughNonGreedyDecision == other.PassedThroughNonGreedyDecision && EqualityComparer <LexerActionExecutor> .Default.Equals(this.ActionExecutor, other.ActionExecutor));
 }
コード例 #3
0
        public virtual bool Contains(Antlr4.Runtime.Atn.ATNConfig subconfig)
        {
            if (this.State.stateNumber != subconfig.State.stateNumber || this.Alt != subconfig.Alt || !this.SemanticContext.Equals(subconfig.SemanticContext))
            {
                return(false);
            }
            Stack <PredictionContext> leftWorkList  = new Stack <PredictionContext>();
            Stack <PredictionContext> rightWorkList = new Stack <PredictionContext>();

            leftWorkList.Push(Context);
            rightWorkList.Push(subconfig.Context);
            while (leftWorkList.Count > 0)
            {
                PredictionContext left  = leftWorkList.Pop();
                PredictionContext right = rightWorkList.Pop();
                if (left == right)
                {
                    return(true);
                }
                if (left.Size < right.Size)
                {
                    return(false);
                }
                if (right.IsEmpty)
                {
                    return(left.HasEmpty);
                }
                else
                {
                    for (int i = 0; i < right.Size; i++)
                    {
                        int index = left.FindReturnState(right.GetReturnState(i));
                        if (index < 0)
                        {
                            // assumes invokingStates has no duplicate entries
                            return(false);
                        }
                        leftWorkList.Push(left.GetParent(index));
                        rightWorkList.Push(right.GetParent(i));
                    }
                }
            }
            return(false);
        }
コード例 #4
0
 protected internal ATNConfig([NotNull] Antlr4.Runtime.Atn.ATNConfig c, [NotNull] ATNState state, [NotNull] PredictionContext context)
 {
     this.state = state;
     this.altAndOuterContextDepth = c.altAndOuterContextDepth;
     this.context = context;
 }
コード例 #5
0
 private static bool CheckNonGreedyDecision(Antlr4.Runtime.Atn.ATNConfig source, ATNState target)
 {
     return(source.PassedThroughNonGreedyDecision || target is DecisionState && ((DecisionState)target).nonGreedy);
 }