Beispiel #1
0
 /// <summary>
 /// Returns true if the suggested parameters match a configuration.
 /// That configuration is returned.
 /// </summary>
 /// <param name="parameters"></param>
 /// <param name="config"></param>
 /// <returns></returns>
 public virtual bool SuggestParameters(ExpressionItem[] parameters, out OperatorConfiguration config)
 {
     for (int i = 0; i < configs.Length; i++)
     {
         if (parameters.Length == configs[i].NrOfParameters)
         {
             config = configs[i];
             return(true);
         }
     }
     config = null;
     return(false);
 }
        /// <summary>
        /// The operator is supplied by a range of parameters.
        /// The operator returns true if the parameters are accepted.
        /// If the parameters are not accepted,
        /// the suggested configuration is returned.
        /// If the config is null, this means that the parameters are not accepted in any way.
        /// </summary>
        /// <param name="parameters">The parameters suggested.</param>
        /// <param name="config">The alternative config suggested by the operator.</param>
        /// <returns>True if the parameters are accepted as is.</returns>
        public override bool SuggestParameters(ExpressionItem[] parameters, out OperatorConfiguration config)
        {
            bool result = base.SuggestParameters(parameters, out config);

            if (result)
            {
                if (parameters[0] is VariableItem)
                {
                    config = configs[0];
                    return(true);
                }
            }
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// The operator is supplied by a range of parameters.
        /// The operator returns true if the parameters are accepted.
        /// If the parameters are not accepted,
        /// the suggested configuration is returned.
        /// If the config is null, this means that the parameters are not accepted in any way.
        /// </summary>
        /// <param name="parameters">The parameters suggested.</param>
        /// <param name="config">The alternative config suggested by the operator.</param>
        /// <returns>True if the parameters are accepted as is.</returns>
        public override bool SuggestParameters(ExpressionItem[] parameters, out OperatorConfiguration config)
        {
            bool result = base.SuggestParameters(parameters, out config);

            if (result)
            {
                if (parameters.Length == 2 && parameters[0] is OperatorItem)
                {
                    config = configs[1];
                    return(false);
                }
                else if (parameters.Length == 1 && parameters[0] is OperatorItem)
                {
                    config = null;
                    return(false);
                }
            }
            return(result);
        }
Beispiel #4
0
 /// <summary>
 /// Creates a division operator.
 /// Binary operator, left associative with precedence 3.
 /// </summary>
 internal DivideOperatorItem()
 {
     configs = new OperatorConfiguration[]
     { new OperatorConfiguration(Associativity.left, 2, 3) };
 }
Beispiel #5
0
 /// <summary>
 /// Returns true if both configurations have the same number of parameters and associativity.
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public bool Equals(OperatorConfiguration config)
 {
     return(this.associativity == config.associativity && this.nrOfParameters == config.nrOfParameters);
 }
 internal AssignmentOperatorItem()
 {
     configs = new OperatorConfiguration[]
     { new OperatorConfiguration(Associativity.right, 2, 14) };
 }
Beispiel #7
0
 internal MinusOperatorItem()
 {
     configs = new OperatorConfiguration[]
     { new OperatorConfiguration(Associativity.left, 2, 4), new OperatorConfiguration(Associativity.left, 1, 2) };
 }