/// <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; }
/// <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; }
/// <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; }
/// <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; }
/// <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; }
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) { }
/// <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; }