The abstract base class for any operator (unary, binary, ...).
Inheritance: Block, IRegisterElement
コード例 #1
0
 /// <summary>
 /// Creates a new expression container.
 /// </summary>
 /// <param name="container">The container which contains expressions and an operator.</param>
 public ContainerExpression(ContainerExpression container)
 {
     _expressions = container._expressions;
     _operator    = container._operator;
 }
コード例 #2
0
 /// <summary>
 /// Creates a new expression container.
 /// </summary>
 /// <param name="leftExpression">The left expression to evaluate.</param>
 /// <param name="rightExpression">The right expression to evaluate.</param>
 /// <param name="operator">The operator that connects the expressions.</param>
 public ContainerExpression(Expression leftExpression, Expression rightExpression, Operator @operator)
 {
     _expressions = new Expression[] { leftExpression, rightExpression };
     _operator    = @operator;
 }
コード例 #3
0
 /// <summary>
 /// Creates a new expression container.
 /// </summary>
 /// <param name="expressions">The expressions to evaluate.</param>
 /// <param name="operator">The operator that connects the expressions.</param>
 public ContainerExpression(Expression[] expressions, Operator @operator)
 {
     _expressions = expressions;
     _operator    = @operator;
 }
コード例 #4
0
 /// <summary>
 /// Creates a new expression container.
 /// </summary>
 /// <param name="expression">The (1) expression to contain.</param>
 public ContainerExpression(Expression expression)
 {
     _expressions = new Expression[] { expression };
     _operator    = null;
 }
コード例 #5
0
 /// <summary>
 /// Creates a new expression container.
 /// </summary>
 /// <param name="expression">The (1) expression to contain.</param>
 /// <param name="operator">The assigned operator for the expression.</param>
 public ContainerExpression(Expression expression, Operator @operator)
 {
     _expressions = new Expression[] { expression };
     _operator    = @operator;
 }
コード例 #6
0
 /// <summary>
 /// Creates a new expression container.
 /// </summary>
 /// <param name="expressions">The expressions to evaluate.</param>
 /// <param name="operator">The operator that connects the expressions.</param>
 public ContainerExpression(Expression[] expressions, Operator @operator)
 {
     _expressions = expressions;
     _operator = @operator;
 }
コード例 #7
0
 /// <summary>
 /// Creates a new expression container.
 /// </summary>
 /// <param name="container">The container which contains expressions and an operator.</param>
 public ContainerExpression(ContainerExpression container)
 {
     _expressions = container._expressions;
     _operator = container._operator;
 }
コード例 #8
0
 /// <summary>
 /// Creates a new expression container.
 /// </summary>
 /// <param name="leftExpression">The left expression to evaluate.</param>
 /// <param name="rightExpression">The right expression to evaluate.</param>
 /// <param name="operator">The operator that connects the expressions.</param>
 public ContainerExpression(Expression leftExpression, Expression rightExpression, Operator @operator)
 {
     _expressions = new Expression[] { leftExpression, rightExpression };
     _operator = @operator;
 }
コード例 #9
0
 /// <summary>
 /// Creates a new expression container.
 /// </summary>
 /// <param name="expression">The (1) expression to contain.</param>
 /// <param name="operator">The assigned operator for the expression.</param>
 public ContainerExpression(Expression expression, Operator @operator)
 {
     _expressions = new Expression[] { expression };
     _operator = @operator;
 }
コード例 #10
0
 /// <summary>
 /// Creates a new expression container.
 /// </summary>
 /// <param name="expression">The (1) expression to contain.</param>
 public ContainerExpression(Expression expression)
 {
     _expressions = new Expression[] { expression };
     _operator = null;
 }
コード例 #11
0
 public YAMPExpressionMissingError(ParseEngine pe, Operator op, int found)
     : base(pe.CurrentLine, pe.CurrentColumn, "The {0} operator requires {1} expression(s), but only {2} expression(s) have been found.", op.Op, op.Expressions, found)
 {
 }
コード例 #12
0
ファイル: ParseEngine.cs プロジェクト: FlorianRappl/YAMP
        /// <summary>
        /// Parses a block with a default operator if no operator has been found.
        /// </summary>
        /// <param name="statement">The statement that should get the block.</param>
        /// <param name="defaultOperator">The default operator if no operator has been found.</param>
        /// <returns>The statement again (allows chaining).</returns>
        internal Statement ParseBlock(Statement statement, Operator defaultOperator = null)
        {
            _currentStatement = statement;

            if (statement.IsOperator)
            {
                var op = Elements.FindOperator(this) ?? defaultOperator;

                if (op == null)
                {
                    AddError(new YAMPOperatorMissingError(_currentLine, _currentColumn));
                }

                statement.Push(this, op);
            }
            else
            {
                var op = Elements.FindLeftUnaryOperator(this);

                if (op == null)
                {
                    var exp = Elements.FindExpression(this);

                    if (exp == null)
                    {
                        AddError(new YAMPExpressionExpectedError(_currentLine, _currentColumn));
                    }

                    statement.Push(this, exp);
                }
                else
                {
                    statement.Push(this, op);
                }
            }

            return statement;
        }