Пример #1
0
        public override object VisitSignedFactor([NotNull] SLangGrammarParser.SignedFactorContext context)
        {
            var exprRes = (Visit(context.factor()) as ExpressionResult);

            if (exprRes != null)
            {
                var type      = exprRes.Type;
                var signToken = context.AddOp() ?? context.SubOp();

                if (signToken != null)
                {
                    if (type is SlangSimpleType t && (t.Equals(SlangSimpleType.Real) || t.Equals(SlangSimpleType.Int)))
                    {
                        return(new ExpressionResult(type, ExpressionValueType.Value));
                    }
                    ThrowInvalidTypesForUnaryOperationException(signToken, file, type);
                }
                else
                {
                    return(new ExpressionResult(type, exprRes.ExpressionType));
                }
            }

            return(null);
        }
Пример #2
0
        public override object VisitSignedFactor([NotNull] SLangGrammarParser.SignedFactorContext context)
        {
            var op = context.AddOp() ?? context.SubOp();

            if (op != null)
            {
                cppText.Write(op.GetText());
            }
            Visit(context.factor());
            return(null);
        }