Beispiel #1
0
        public override AstNode VisitAccess(StannumParser.AccessContext context)
        {
            if (!(Visit(context.Subject) is Expr subject))
            {
                throw new Exception("Unrecognized expression!");
            }

            if (!(Visit(context.Field) is Identifier field))
            {
                throw new Exception("Unrecognized identifier!");
            }

            return(new BinaryExpr(subject, context.Op.Text, field));
        }
Beispiel #2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>Access</c>
 /// labeled alternative in <see cref="StannumParser.accessOrCall"/>.
 /// <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 VisitAccess([NotNull] StannumParser.AccessContext context)
 {
     return(VisitChildren(context));
 }