public override ParserRuleContext VisitTerm([NotNull] StructuredTextParser.TermContext context)
            {
                //TODO: MOD対応
                var result = new VisualBasicParser.ModExprContext(_contextStack.Peek(), 0);
                var term   = new VisualBasicParser.TermContext(result, 0);

                result.AddChild(term);
                _contextStack.Push(term);
                term.AddChild(Visit(context.lhs));
                for (int i = 1; i < context.ChildCount; i += 2)
                {
                    var operand = context.GetChild <ITerminalNode>(i).Symbol;
                    int type;
                    switch (operand.Type)
                    {
                    case StructuredTextParser.ASTERISK: type = VisualBasicParser.ASTERISK; break;

                    case StructuredTextParser.SLASH: type = VisualBasicParser.SLASH; break;

                    case StructuredTextParser.MOD: throw new NotImplementedException();

                    default: throw new InvalidOperationException();
                    }
                    term.AddChild(new CommonToken(type, operand.Text));

                    term.AddChild(Visit(context.GetChild(i + 1)));
                }
                _contextStack.Pop();
                return(result);
            }
Ejemplo n.º 2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="VisualBasicParser.modExpr"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitModExpr([NotNull] VisualBasicParser.ModExprContext context)
 {
     return(VisitChildren(context));
 }