示例#1
0
        // recog null unless ParserRuleContext, in which case we use subclass toString(...)
        public virtual string ToString(IRecognizer recog, Antlr4.Runtime.RuleContext stop)
        {
            string[]       ruleNames     = recog != null ? recog.RuleNames : null;
            IList <string> ruleNamesList = ruleNames != null?Arrays.AsList(ruleNames) : null;

            return(ToString(ruleNamesList, stop));
        }
示例#2
0
        public virtual string ToString(IList <string> ruleNames, Antlr4.Runtime.RuleContext
                                       stop)
        {
            StringBuilder buf = new StringBuilder();

            Antlr4.Runtime.RuleContext p = this;
            buf.Append("[");
            while (p != null && p != stop)
            {
                if (ruleNames == null)
                {
                    if (!p.IsEmpty())
                    {
                        buf.Append(p.invokingState);
                    }
                }
                else
                {
                    int    ruleIndex = p.GetRuleIndex();
                    string ruleName  = ruleIndex >= 0 && ruleIndex < ruleNames.Count ? ruleNames[ruleIndex
                                       ] : ruleIndex.ToString();
                    buf.Append(ruleName);
                }
                if (p.parent != null && (ruleNames != null || !p.parent.IsEmpty()))
                {
                    buf.Append(" ");
                }
                p = p.parent;
            }
            buf.Append("]");
            return(buf.ToString());
        }
示例#3
0
 public override bool Sempred(Antlr4.Runtime.RuleContext _localctx, int ruleIndex, int actionIndex)
 {
     switch (ruleIndex)
     {
     case 1: return(expression_sempred((ExpressionContext)_localctx, actionIndex));
     }
     return(true);
 }
示例#4
0
        public virtual int Depth()
        {
            int n = 0;

            Antlr4.Runtime.RuleContext p = this;
            while (p != null)
            {
                p = p.parent;
                n++;
            }
            return(n);
        }
示例#5
0
 public static Antlr4.Runtime.RuleContext GetChildContext(Antlr4.Runtime.RuleContext
                                                          parent, int invokingState)
 {
     return(new Antlr4.Runtime.RuleContext(parent, invokingState));
 }
示例#6
0
 public RuleContext(Antlr4.Runtime.RuleContext parent, int invokingState)
 {
     this.parent = parent;
     //if ( parent!=null ) System.out.println("invoke "+stateNumber+" from "+parent);
     this.invokingState = invokingState;
 }
示例#7
0
 public override bool Precpred(RuleContext localctx, int precedence)
 {
     return(precedence >= _precedenceStack[_precedenceStack.Count - 1]);
 }
示例#8
0
 public virtual void Action(RuleContext _localctx, int ruleIndex, int actionIndex)
 {
 }
示例#9
0
 public virtual bool Precpred(RuleContext localctx, int precedence)
 {
     return(true);
 }
示例#10
0
 // subclass needs to override these if there are sempreds or actions
 // that the ATN interp needs to execute
 public virtual bool Sempred(RuleContext _localctx, int ruleIndex, int actionIndex)
 {
     return(true);
 }
示例#11
0
 public virtual string GetText(RuleContext ctx)
 {
     return(GetText(ctx.SourceInterval));
 }
示例#12
0
 public RecognitionException(Lexer lexer, ICharStream input)
 {
     this.recognizer = lexer;
     this.input      = input;
     this.ctx        = null;
 }