Esempio n. 1
0
        public IfStatementNode(ExpressionNode cond)
        {
            if (cond == null)
                throw new ParsingException("Parser: An If statmentent must conatain a condition!");

            Condition = cond;
        }
Esempio n. 2
0
        public UnaryOperationNode(ExpressionOperationType opType, ExpressionNode operand)
        {
            if (!validOperators.Contains(opType))
                throw new ArgumentException("Invalid unary operator given!", "opType");

            OperationType = opType;
            Operand = operand;
        }
Esempio n. 3
0
        public VariableAssingmentNode(string name, ExpressionNode expr)
        {
            if (expr == null)
                throw new ParsingException("The assinged expression may not be null!");

            VariableName = name;
            ValueExpression = expr;
        }
        private static readonly ExpressionNode DefaultIntValueExpression = ExpressionNode.CreateConstantExpression(0); //the default value for an int is zero (0).

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new instance of the VariableDeclarationNode class.
        /// </summary>
        /// <param name="type">The type of the variable.</param>
        /// <param name="name">The name of the variable.</param>
        /// <param name="initialValue">A expression used to initialise the variable initially or null to use the default value.</param>
        public VariableDeclarationNode(VariableType type, string name, ExpressionNode initialValue)
        {
            Type = type;
            Name = name;

            initialValue = initialValue ?? DefaultIntValueExpression;
            InitialValueExpression = initialValue;
        }
Esempio n. 5
0
        public BinaryOperationNode(ExpressionOperationType opType, ExpressionNode operandA, ExpressionNode operandB)
        {
            if (!validOperators.Contains(opType))
                throw new ArgumentException("Invalid binary operator given!", "opType");

            OperationType = opType;
            OperandA = operandA;
            OperandB = operandB;
        }
 public void AddArgument(ExpressionNode arg)
 {
     arguments.Add(arg);
 }
Esempio n. 7
0
 public WhileLoopNode(ExpressionNode cond)
 {
     if (cond == null)
         throw new ParsingException("Parser: An while loop must conatain a condition!");
 }
Esempio n. 8
0
 public ReturnStatementNode(ExpressionNode valueExpr)
 {
     ValueExpression = valueExpr;
 }