Exemplo n.º 1
0
        public override Node VisitAssignmentExpression(DustParser.AssignmentExpressionContext context)
        {
            Expression left  = (Expression)Visit(context.expression(0));
            Expression right = (Expression)Visit(context.expression(1));

            if (!(left is IdentifierExpression))
            {
                visitorContext.ErrorHandler.ThrowError(new SyntaxError("Assignment target must be a mutable property.", context.GetRange()));

                return(null);
            }

            if (!((IdentifierExpression)left).IsMutable)
            {
                visitorContext.ErrorHandler.ThrowError(new SyntaxError($"Property '{((IdentifierExpression) left).Name}' is not mutable.", context.GetRange()));

                return(null);
            }

            return(new AssignmentExpression(left, right, context.GetRange()));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>AssignmentExpression</c>
 /// labeled alternative in <see cref="DustParser.expression"/>.
 /// <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 VisitAssignmentExpression([NotNull] DustParser.AssignmentExpressionContext context)
 {
     return(VisitChildren(context));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Exit a parse tree produced by the <c>AssignmentExpression</c>
 /// labeled alternative in <see cref="DustParser.expression"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitAssignmentExpression([NotNull] DustParser.AssignmentExpressionContext context)
 {
 }