Example #1
0
 protected virtual Handle Action(GrammarAST node, ILexerAction lexerAction)
 {
     ATNState left = NewState(node);
     ATNState right = NewState(node);
     bool isCtxDependent = false;
     int lexerActionIndex = GetLexerActionIndex(lexerAction);
     ActionTransition a =
         new ActionTransition(right, currentRule.index, lexerActionIndex, isCtxDependent);
     left.AddTransition(a);
     node.atnState = left;
     Handle h = new Handle(left, right);
     return h;
 }
Example #2
0
 public override Handle LexerAltCommands(Handle alt, Handle cmds)
 {
     Handle h = new Handle(alt.left, cmds.right);
     Epsilon(alt.right, cmds.left);
     return h;
 }
Example #3
0
 public override Handle Rule(GrammarAST ruleAST, string name, Handle blk)
 {
     ruleCommands.Clear();
     return base.Rule(ruleAST, name, blk);
 }
Example #4
0
 public virtual Handle LexerAltCommands([NotNull] Handle alt, [NotNull] Handle cmds)
 {
     throw new InvalidOperationException("This element is not allowed in parsers.");
 }
Example #5
0
 public virtual Handle ListLabel([NotNull] Handle t)
 {
     return(t);
 }
Example #6
0
        public virtual Handle RuleRef([NotNull] GrammarAST node)
        {
            Handle h = _RuleRef(node);

            return(h);
        }
Example #7
0
        public virtual Handle Rule([NotNull] GrammarAST ruleAST, [NotNull] string name, [NotNull] Handle blk)
        {
            Rule r = g.GetRule(name);

            RuleStartState start = atn.ruleToStartState[r.index];

            Epsilon(start, blk.left);
            RuleStopState stop = atn.ruleToStopState[r.index];

            Epsilon(blk.right, stop);
            Handle h = new Handle(start, stop);

            //ATNPrinter ser = new ATNPrinter(g, h.left);
            //System.Console.WriteLine(ruleAST.ToStringTree() + ":\n" + ser.AsString());
            ruleAST.atnState = start;
            return(h);
        }