예제 #1
0
        public virtual string ToString([Nullable] IList <string> ruleNames, [Nullable] 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.RuleIndex;
                    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());
        }
예제 #2
0
        // recog null unless ParserRuleContext, in which case we use subclass toString(...)
        public virtual string ToString(IRecognizer recog, [Nullable] Antlr4.Runtime.RuleContext stop)
        {
            string[]       ruleNames     = recog != null ? recog.RuleNames : null;
            IList <string> ruleNamesList = ruleNames != null?Arrays.AsList(ruleNames) : null;

            return(ToString(ruleNamesList, stop));
        }
예제 #3
0
        public virtual int Depth()
        {
            int n = 0;

            Antlr4.Runtime.RuleContext p = this;
            while (p != null)
            {
                p = p.parent;
                n++;
            }
            return(n);
        }
예제 #4
0
        internal bool GetPropertyInContext(string name, Antlr4.Runtime.RuleContext scope, out Member property)
        {
            property = GetProperty(name);

            if (!property.isPrivate)
            {
                return(true);
            }

            var parent    = (Engine.Parser.GetDefinitionBlock(scope)).LexicalEnvironment;
            var canAccess = false;

            while (parent != null)
            {
                if (parent.Context == property.definitionBlock)
                {
                    canAccess = true;
                }

                parent = parent.Parent;
            }

            return(canAccess);
        }
예제 #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
 internal static void AddError(Node node, string message, Antlr4.Runtime.RuleContext context, MessageCode code = MessageCode.SyntaxErrorInParser)
 {
     AddError(node, message, ParseTreeUtils.GetFirstToken(context), RuleStackBuilder.GetRuleStack(context), code);
 }