The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
ForeachStatement.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: ForeachStatement.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Encapsulates a Foreach statement of our programming languages. //
9 // Inheritance: Statement. //
10 // Implements Composite pattern [Composite]. //
11 // Implements Visitor pattern [Concrete Element]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 12-01-2007 //
14 // Modification date: 03-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 {
34  public class ForeachStatement : Statement
35  {
36  #region Fields
37 
41  private Declaration decl;
42 
46  private Expression expression;
47 
51  private Statement block;
52 
53  #endregion
54 
55  #region Properties
56 
61  {
62  get { return this.decl; }
63  }
64 
68  public Expression ForeachExp
69  {
70  get { return this.expression; }
71  }
72 
76  public Statement ForeachBlock
77  {
78  get { return this.block; }
79  }
80 
81  #endregion
82 
83  #region Constructor
84 
96  :base(location)
97  {
98  this.decl = new IdDeclaration(id, type, location);
99  this.expression = expr;
100  this.block = stats;
101  }
102 
103  #endregion
104 
105  #region Accept()
106 
113  public override Object Accept(Visitor v, Object o)
114  {
115  return v.Visit(this, o);
116  }
117 
118  #endregion
119  }
120 }
Expression ForeachExp
Gets the expression of the foreach statement.
Abstract class encapsulate a programming language expression.
Definition: Expression.cs:37
Statement ForeachBlock
Gets the block of Foreach statement.
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
Abstract class represents a programming language statement.
Definition: Statement.cs:30
ForeachStatement(string type, SingleIdentifierExpression id, Expression expr, Statement stats, Location location)
Constructor of ForeachStatement
Encapsulates a identifier expression of our programming language.
override Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.
Encapsulates a declaration of a concrete type.
Definition: Declaration.cs:34
Encapsulates a declaration.
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
Declaration ForEachDeclaration
Gets the declaration of the foreach statement.
Encapsulates a Foreach statement of our programming languages.