The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
Namespace.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: Namespace.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Encapsulates a namespace definition. //
9 // Inheritance: AstNode. //
10 // Implements Composite pattern [Composite]. //
11 // Implements Visitor pattern [Concrete Element]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 31-12-2006 //
14 // Modification date: 09-01-2007 //
16 
17 using System;
18 using System.Collections.Generic;
19 using System.IO;
20 using System.Text;
21 using ErrorManagement;
22 
23 using Tools;
24 
25 namespace AST
26 {
35  public class Namespace : AstNode
36  {
37  #region Fields
38 
42  private IdentifierExpression identifier;
43 
47  private List<Declaration> namespaceBody;
48 
49  #endregion
50 
51  #region Properties
52 
57  {
58  get { return this.identifier; }
59  }
60 
64  public int NamespaceMembersCount
65  {
66  get { return this.namespaceBody.Count; }
67  }
68 
69  #endregion
70 
71  #region Constructor
72 
81  public Namespace(IdentifierExpression name, List<Declaration> declarations, Location location) : base(location)
82  {
83  this.identifier = name;
84  this.namespaceBody = declarations;
85  }
86 
87  #endregion
88 
89  #region GetDeclarationElement()
90 
97  {
98  return this.namespaceBody[index];
99  }
100 
101  #endregion
102 
103  #region Accept()
104 
111  public override Object Accept(Visitor v, Object o)
112  {
113  return v.Visit(this, o);
114  }
115 
116  #endregion
117  }
118 }
Encapsulates a name expression of our programming language.
Encapsulates a namespace definition.
Definition: Namespace.cs:35
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 for all nodes that compounds the abstract syntax tree.
Definition: AstNode.cs:33
Declaration GetDeclarationElement(int index)
Gets the element stored in the specified index.
Definition: Namespace.cs:96
Encapsulates a declaration of a concrete type.
Definition: Declaration.cs:34
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
Namespace(IdentifierExpression name, List< Declaration > declarations, Location location)
Constructor of Namespace
Definition: Namespace.cs:81
override Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.
Definition: Namespace.cs:111
IdentifierExpression Identifier
Gets the name of the namespace.
Definition: Namespace.cs:57
int NamespaceMembersCount
Gets the number of declaration in the namespace.
Definition: Namespace.cs:65