Exemplo n.º 1
0
 private static Value enterOperand(OperandAST operandAst)
 {
     return(operandAst.Type switch
     {
         OperandType.Delta => new DeltaValue(createValue(operandAst)),
         OperandType.Prior => new PriorValue(createValue(operandAst)),
         _ => createValue(operandAst),
     });
Exemplo n.º 2
0
        private ConditionAST parseCompare()
        {
            var startIndex = _index;

            OperandAST left = parseExpression();

            if (left != null)
            {
                if (isConditionCompare(peekToken()))
                {
                    ConditionCompare?compareOperator = parseCompareOperator();
                    if (compareOperator.HasValue)
                    {
                        startIndex = _index;
                        OperandAST right = parseExpression();

                        if (right != null)
                        {
                            return(new ConditionAST
                            {
                                Left = left,
                                Right = right,
                                CompareOperator = compareOperator.Value
                            });
                        }
                        else
                        {
                            throw new ParserException($"Invalid right operand at column {startIndex}");
                        }
                    }
                    else
                    {
                        throw new ParserException($"Invalid or inexistant comparison operator at column {_index}");
                    }
                }
                else
                {
                    throw new ParserException($"Invalid or inexistant comparison operator at column {_index}");
                }
            }
            else
            {
                throw new ParserException($"Invalid left operand at column {startIndex}");
            }
        }