The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
CompoundExpression.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: CompoundExpression.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Encapsulates a set of expressions. //
9 // Inheritance: Expression. //
10 // Implements Composite pattern [Composite]. //
11 // Implements Visitor pattern [Concrete Element]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 11-12-2006 //
14 // Modification date: 25-04-2007 //
16 
17 using System;
18 using System.Collections.Generic;
19 using System.Text;
20 
21 using Tools;
22 using ErrorManagement;
23 
24 namespace AST
25 {
35  {
36  #region Fields
37 
41  private List<Expression> expressions;
42 
43  #endregion
44 
45  #region Properties
46 
50  public int ExpressionCount
51  {
52  get { return this.expressions.Count; }
53  }
54 
55  #endregion
56 
57  #region Constructor
58 
65  public CompoundExpression(Location location): base(location) {
66  this.expressions = new List<Expression>();
67  }
68 
69  #endregion
70 
71  #region AddExpression()
72 
77  public void AddExpression(Expression exp)
78  {
79  this.expressions.Add(exp);
80  }
81 
82  #endregion
83 
84  #region GetExpressionElement()
85 
91  public Expression GetExpressionElement(int index)
92  {
93  return this.expressions[index];
94  }
95 
96  #endregion
97 
98  #region SetExpressionElement()
99 
105  {
106  this.expressions[index] = exp;
107  }
108 
109  #endregion
110 
111  #region Accept()
112 
119  public override Object Accept(Visitor v, Object o)
120  {
121  return v.Visit(this, o);
122  }
123 
124  #endregion
125  }
126 }
Abstract class encapsulate a programming language expression.
Definition: Expression.cs:37
Abstract class to define different visits over the abstract syntax tree.
Definition: Visitor.cs:29
This class encapsulates a location in a specific file. Implements an Inmutable pattern. So it can be used in any context, that is his internal fields never change.
Definition: Location.cs:24
override Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.
void SetExpressionElement(int index, SingleIdentifierExpression exp)
Updates the value of the element stored in the specified index.
void AddExpression(Expression exp)
Add a new expression.
Encapsulates a identifier expression of our programming language.
int ExpressionCount
Gets the number of expressions.
Encapsulates a set of expressions.
Expression GetExpressionElement(int index)
Gets the element stored in the specified index.
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
CompoundExpression(Location location)
Constructor of CompoundExpression