The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
SwitchLabel.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: SwitchLabel.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Encapsulates a switch label (Case + condition or Default section). //
9 // Inheritance: Statement. //
10 // Implements Composite pattern [Composite]. //
11 // Implements Visitor pattern [Concrete Element]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 19-04-2007 //
14 // Modification date: 19-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 {
26  #region CaseType
27 
31  public enum SectionType
32  {
33  Case,
34  Default,
35  }
36 
37  #endregion
38 
47  public class SwitchLabel : Statement
48  {
49  #region Fields
50 
54  private SectionType sectionType;
55 
59  private Expression condition;
60 
61  #endregion
62 
63  #region Properties
64 
68  public Expression Condition
69  {
70  get { return this.condition; }
71  }
72 
77  {
78  get { return this.sectionType; }
79  }
80 
81  #endregion
82 
83  #region Constructor
84 
93  : base(location)
94  {
95  this.sectionType = SectionType.Case;
96  this.condition = cond;
97  }
98 
106  : base(location)
107  {
108  this.sectionType = SectionType.Default;
109  }
110 
111  #endregion
112 
113  #region Accept()
114 
121  public override Object Accept(Visitor v, Object o)
122  {
123  return v.Visit(this, o);
124  }
125 
126  #endregion
127  }
128 }
Abstract class encapsulate a programming language expression.
Definition: Expression.cs:37
SectionType SwitchSectionType
Gets the type of the Case statement (case or default)
Definition: SwitchLabel.cs:77
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
Encapsulates a switch label (Case + condition or Default section).
Definition: SwitchLabel.cs:47
override Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.
Definition: SwitchLabel.cs:121
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
SwitchLabel(Location location)
Constructor of SwitchLabel
Definition: SwitchLabel.cs:105
SectionType
Indicates if it is a case statement or a default case.
Definition: SwitchLabel.cs:31
Expression Condition
Gets the condition expression of Case statement.
Definition: SwitchLabel.cs:69
SwitchLabel(Expression cond, Location location)
Constructor of SwitchLabel
Definition: SwitchLabel.cs:92