The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
UnaryExpression.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: UnaryExpression.cs //
6 // Authors: Cristina Gonzalez Muñoz - cristi.gm@gmail.com //
7 // Francisco Ortin - francisco.ortin@gmail.com //
8 // Description: //
9 // Encapsulates a unary expression of our programming language. //
10 // Inheritance: Expression. //
11 // Implements Composite pattern [Composite]. //
12 // Implements Visitor pattern [Concrete Element]. //
13 // -------------------------------------------------------------------------- //
14 // Create date: 05-12-2006 //
15 // Modification date: 25-04-2007 //
17 
18 using System;
19 using System.Collections.Generic;
20 using System.Text;
21 
22 using Tools;
23 using ErrorManagement;
24 
25 namespace AST
26 {
27  #region UnaryOperator
28 
32  public enum UnaryOperator
33  {
38 
43 
48 
53 
57  Not,
58 
62  BitwiseNot,
63 
67  Minus,
68 
72  Plus
73  }
74 
75  #endregion
76 
85  public class UnaryExpression : Expression
86  {
87  #region Fields
88 
92  private Expression operand;
93 
97  private UnaryOperator op;
98 
99  #endregion
100 
101  #region Properties
102 
106  public Expression Operand
107  {
108  get { return operand; }
109  set { this.operand = value; }
110  }
111 
115  public UnaryOperator Operator
116  {
117  get { return op; }
118  }
119 
120  #endregion
121 
122  #region Constructor
123 
133  : base(location)
134  {
135  this.operand = operand;
136  this.op = op;
137  }
138 
139  #endregion
140 
141  #region Accept()
142 
149  public override Object Accept(Visitor v, Object o)
150  {
151  return v.Visit(this, o);
152  }
153 
154  #endregion
155 
156  #region ToString()
157  public override string ToString() {
158  return this.op.ToString();
159  }
160  #endregion
161  }
162 }
Abstract class encapsulate a programming language expression.
Definition: Expression.cs:37
Postfix increment operator: i++
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
Expression Operand
Gets the operand expression of the unary operation
Prefix increment operator: ++i
Bitwise complement operator: ~i
override string ToString()
a + b
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
Encapsulates a unary expression of our programming language.
a - b
UnaryOperator
Unary operators
Prefix decrement operator: –i
Logical negation operator: !i
UnaryExpression(Expression operand, UnaryOperator op, Location location)
Constructor of UnaryExpression.
UnaryOperator Operator
Gets the operator of the unary operation
Postfix decrement operator: i–
override Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.