The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
TernaryExpression.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: TernaryExpression.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Encapsulates a ternary expression of our programming language. //
9 // Inheritance: Expression. //
10 // Implements Composite pattern [Composite]. //
11 // Implements Visitor pattern [Concrete Element]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 05-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 {
26  #region TernaryOperator
27 
31  public enum TernaryOperator
32  {
36  Question
37  }
38 
39  #endregion
40 
50  {
51  #region Fields
52 
56  private Expression operand1;
57 
61  private Expression operand2;
62 
66  private Expression operand3;
67 
71  private TernaryOperator op;
72 
73  #endregion
74 
75  #region Properties
76 
81  {
82  get { return operand1; }
83  set { this.operand1 = value; }
84  }
85 
90  {
91  get { return operand2; }
92  set { this.operand2 = value; }
93  }
94 
99  {
100  get { return operand3; }
101  set { this.operand3 = value; }
102  }
103 
108  {
109  get { return op; }
110  }
111 
112  #endregion
113 
114  #region Constructor
115 
127  : base(location)
128  {
129  this.operand1 = operand1;
130  this.operand2 = operand2;
131  this.operand3 = operand3;
132  this.op = op;
133  }
134 
135  #endregion
136 
137  #region Accept()
138 
145  public override Object Accept(Visitor v, Object o)
146  {
147  return v.Visit(this, o);
148  }
149 
150  #endregion
151  }
152 }
Abstract class encapsulate a programming language expression.
Definition: Expression.cs:37
Expression FirstOperand
Gets the first operand of the ternary expression
override Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.
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
TernaryExpression(Expression operand1, Expression operand2, Expression operand3, TernaryOperator op, Location location)
Constructor of TernaryExpression
Encapsulates a ternary expression of our programming language.
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
op1 ? op2 : op3
Expression ThirdOperand
Gets the third operand of the ternary expression
Expression SecondOperand
Gets the second operand of the ternary expression
TernaryOperator Operator
Gets the operator of the ternary expression
TernaryOperator
Ternary operators