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

            Condition = cond;
        }
Exemplo 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;
        }
Exemplo 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;
        }
Exemplo n.º 4
0
        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;
        }
Exemplo 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);
 }
Exemplo n.º 7
0
 public WhileLoopNode(ExpressionNode cond)
 {
     if (cond == null)
         throw new ParsingException("Parser: An while loop must conatain a condition!");
 }
Exemplo n.º 8
0
 public ReturnStatementNode(ExpressionNode valueExpr)
 {
     ValueExpression = valueExpr;
 }