Esempio n. 1
0
        public virtual IntervalSet NextTokens(ATNState s, RuleContext ctx)
        {
            LL1Analyzer anal = new LL1Analyzer(this);

            IntervalSet next = anal.Look(s, ctx);

            return(next);
        }
Esempio n. 2
0
        public virtual IntervalSet NextTokens(ATNState s, PredictionContext ctx)
        {
            Args.NotNull("ctx", ctx);

            LL1Analyzer anal = new LL1Analyzer(this);
            IntervalSet next = anal.Look(s, ctx);

            return(next);
        }
Esempio n. 3
0
        protected virtual void ProcessLexer()
        {
            // make sure all non-fragment lexer rules must match at least one symbol
            foreach (Rule rule in g.rules.Values)
            {
                if (rule.IsFragment())
                {
                    continue;
                }

                LL1Analyzer analyzer = new LL1Analyzer(g.atn);
                IntervalSet look = analyzer.Look(g.atn.ruleToStartState[rule.index], PredictionContext.EmptyLocal);
                if (look.Contains(TokenConstants.Epsilon))
                {
                    g.tool.errMgr.GrammarError(ErrorType.EPSILON_TOKEN, g.fileName, ((GrammarAST)rule.ast.GetChild(0)).Token, rule.name);
                }
            }
        }
Esempio n. 4
0
        protected virtual void ProcessParser()
        {
            g.decisionLOOK = new List<IntervalSet[]>(g.atn.NumberOfDecisions + 1);
            foreach (DecisionState s in g.atn.decisionToState)
            {
                g.tool.Log("LL1", "\nDECISION " + s.decision + " in rule " + g.GetRule(s.ruleIndex).name);
                IntervalSet[] look;
                if (s.nonGreedy)
                { // nongreedy decisions can't be LL(1)
                    look = new IntervalSet[s.NumberOfTransitions + 1];
                }
                else
                {
                    LL1Analyzer anal = new LL1Analyzer(g.atn);
                    look = anal.GetDecisionLookahead(s);
                    g.tool.Log("LL1", "look=[" + string.Join(", ", look.AsEnumerable()) + "]");
                }

                Debug.Assert(s.decision + 1 >= g.decisionLOOK.Count);
                Utils.SetSize(g.decisionLOOK, s.decision + 1);
                g.decisionLOOK[s.decision] = look;
                g.tool.Log("LL1", "LL(1)? " + Disjoint(look));
            }
        }
Esempio n. 5
0
 public virtual IntervalSet NextTokens(ATNState s, PredictionContext ctx)
 {
     Args.NotNull("ctx", ctx);
     LL1Analyzer anal = new LL1Analyzer(this);
     IntervalSet next = anal.Look(s, ctx);
     return next;
 }