Example #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));
        }
Example #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());
        }
Example #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);
 }
Example #4
0
        public virtual int Depth()
        {
            int n = 0;

            Antlr4.Runtime.RuleContext p = this;
            while (p != null)
            {
                p = p.parent;
                n++;
            }
            return(n);
        }
Example #5
0
 public static Antlr4.Runtime.RuleContext GetChildContext(Antlr4.Runtime.RuleContext
                                                          parent, int invokingState)
 {
     return(new Antlr4.Runtime.RuleContext(parent, invokingState));
 }
Example #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;
 }
Example #7
0
 public override bool Precpred(RuleContext localctx, int precedence)
 {
     return(precedence >= _precedenceStack[_precedenceStack.Count - 1]);
 }
Example #8
0
 public virtual void Action(RuleContext _localctx, int ruleIndex, int actionIndex)
 {
 }
Example #9
0
 public virtual bool Precpred(RuleContext localctx, int precedence)
 {
     return(true);
 }
Example #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);
 }
Example #11
0
 public virtual string GetText(RuleContext ctx)
 {
     return(GetText(ctx.SourceInterval));
 }
Example #12
0
 public RecognitionException(Lexer lexer, ICharStream input)
 {
     this.recognizer = lexer;
     this.input      = input;
     this.ctx        = null;
 }