Exemple #1
0
 public SignCondition(ConditionOperand operand, SyntaxProperty <SignComparison> signComparison, SyntaxProperty <bool> invertResult) :
     base(ExpressionNodeType.SignCondition)
 {
     Operand        = operand;
     SignComparison = signComparison;
     InvertResult   = invertResult;
 }
Exemple #2
0
 public RelationCondition(ConditionOperand leftOperand, SyntaxProperty <RelationalOperator> relationalOperator, ConditionOperand rightOperand) :
     base(ExpressionNodeType.RelationCondition)
 {
     LeftOperand  = leftOperand;
     Operator     = relationalOperator;
     RightOperand = rightOperand;
 }
Exemple #3
0
 public SignCondition(ConditionOperand operand, SyntaxProperty<SignComparison> signComparison, SyntaxProperty<bool> invertResult)
     : base(ExpressionNodeType.SignCondition)
 {
     Operand = operand;
     SignComparison = signComparison;
     InvertResult = invertResult;
 }
Exemple #4
0
 public RelationCondition(ConditionOperand leftOperand, SyntaxProperty<RelationalOperator> relationalOperator, ConditionOperand rightOperand)
     : base(ExpressionNodeType.RelationCondition)
 {
     LeftOperand = leftOperand;
     Operator = relationalOperator;
     RightOperand = rightOperand;
 }
 private ConditionOperand CreateConditionOperand(CodeElementsParser.ConditionOperandContext context)
 {
     ConditionOperand conditionOperand = null;
     if (context.arithmeticExpression() != null)
     {
         conditionOperand = new ConditionOperand(
             CreateArithmeticExpression(context.arithmeticExpression()));
     }
     else if (context.variableOrIndex() != null)
     {
         conditionOperand = new ConditionOperand(
             CreateVariableOrIndex(context.variableOrIndex()));
     }
     else if (context.nullPointerValue() != null)
     {
         conditionOperand = new ConditionOperand(
             CobolWordsBuilder.CreateNullPointerValue(context.nullPointerValue()));
     }
     else if (context.selfObjectIdentifier() != null)
     {
         conditionOperand = new ConditionOperand(
             ParseTreeUtils.GetFirstToken(context.selfObjectIdentifier()));
     }
     return conditionOperand;
 }
        private ConditionalExpression CreateAbbreviatedExpression(ConditionOperand subjectOperand, SyntaxProperty<RelationalOperator> distributedRelationalOperator, CodeElementsParser.AbbreviatedExpressionContext context)
        {
            if (context.conditionOperand() != null)
            {
                ConditionOperand objectOperand = CreateConditionOperand(context.conditionOperand());
                SyntaxProperty<RelationalOperator> relationalOperator = distributedRelationalOperator;
                if (context.relationalOperator() != null)
                {
                    relationalOperator = CreateRelationalOperator(context.relationalOperator());
                }
                return new RelationCondition(subjectOperand, relationalOperator, objectOperand);
            }
            else
            {
                SyntaxProperty<LogicalOperator> logicalOperator = null;
                if (context.NOT() != null)
                {
                    logicalOperator = new SyntaxProperty<LogicalOperator>(
                       LogicalOperator.NOT,
                       ParseTreeUtils.GetFirstToken(context.NOT()));
                }
                else if (context.AND() != null)
                {
                    logicalOperator = new SyntaxProperty<LogicalOperator>(
                       LogicalOperator.AND,
                       ParseTreeUtils.GetFirstToken(context.AND()));
                }
                else if (context.OR() != null)
                {
                    logicalOperator = new SyntaxProperty<LogicalOperator>(
                       LogicalOperator.OR,
                       ParseTreeUtils.GetFirstToken(context.OR()));
                }

                if (logicalOperator == null)
                {
                    return CreateAbbreviatedExpression(subjectOperand, distributedRelationalOperator, context.abbreviatedExpression()[0]);
                }
                else
                {
                    if (context.abbreviatedExpression().Length == 1)
                    {
                        ConditionalExpression rightOperand = CreateAbbreviatedExpression(subjectOperand, distributedRelationalOperator, context.abbreviatedExpression()[0]);
                        return new LogicalOperation(null, logicalOperator, rightOperand);
                    }
                    else
                    {
                        ConditionalExpression leftOperand = CreateAbbreviatedExpression(subjectOperand, distributedRelationalOperator, context.abbreviatedExpression()[0]);
                        ConditionalExpression rightOperand = CreateAbbreviatedExpression(subjectOperand, distributedRelationalOperator, context.abbreviatedExpression()[1]);
                        return new LogicalOperation(leftOperand, logicalOperator, rightOperand);
                    }
                }
            }
        }