예제 #1
0
        // A set command: evaluating an expression where the operator is an assignment-type
        public override int VisitSetExpression(YarnSpinnerParser.SetExpressionContext context)
        {
            // checking the expression is of the correct form
            var expression = context.expression();

            // TODO: is there really no more elegant way of doing this?!
            if (expression is YarnSpinnerParser.ExpMultDivModEqualsContext ||
                expression is YarnSpinnerParser.ExpPlusMinusEqualsContext)
            {
                // run the expression, it handles it from here
                Visit(expression);
            }
            else
            {
                // throw an error
                throw ParseException.Make(context, "Invalid expression inside assignment statement");
            }
            return(0);
        }
 /// <summary>
 /// Visit a parse tree produced by the <c>setExpression</c>
 /// labeled alternative in <see cref="YarnSpinnerParser.set_statement"/>.
 /// <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 VisitSetExpression([NotNull] YarnSpinnerParser.SetExpressionContext context)
 {
     return(VisitChildren(context));
 }
 /// <summary>
 /// Exit a parse tree produced by the <c>setExpression</c>
 /// labeled alternative in <see cref="YarnSpinnerParser.set_statement"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitSetExpression([NotNull] YarnSpinnerParser.SetExpressionContext context)
 {
 }