The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
AstNode.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: AstNode.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Abstract class for all nodes that compounds the abstract syntax tree. //
9 // Implements Composite pattern [Component]. //
10 // Implements Visitor pattern [Element]. //
11 // -------------------------------------------------------------------------- //
12 // Create date: 04-12-2006 //
13 // Modification date: 04-12-2006 //
15 
16 using System;
17 using System.Collections.Generic;
18 using System.Text;
19 using ErrorManagement;
20 
21 using Tools;
22 using AST.Operations;
23 
24 
25 namespace AST {
33  public abstract class AstNode : antlr.CommonAST {
34  #region Fields
35  // the ocurrence of an intem in the text program
39  protected Location location;
40 
41  #endregion
42 
43  #region Properties
44 
45  public Location Location {
46  get { return this.location; }
47  }
48 
49  #endregion
50 
51  #region Constructor
52 
59  protected AstNode(Location location) {
60  this.location = location;
61  }
62 
63 
64  #endregion
65 
66  #region Accept()
67 
74  public abstract Object Accept(Visitor v, Object o);
75 
76  #endregion
77 
78  #region EqualsAndGetHashCode
79  public override bool Equals(object obj) {
85  AstNode node = obj as AstNode;
86  if (obj == null)
87  return false;
88  return this.Location.Equals(node.Location);
89  }
90  public override int GetHashCode() {
91  return Location.GetHashCode();
92  }
93 
94  #endregion
95 
96  #region Dispatcher AstOperation
97  public virtual object AcceptOperation(AstOperation op, object arg) {
105  return op.Exec(this, arg);
106  }
107 
108  #endregion
109 
110  }
111 }
virtual object AcceptOperation(AstOperation op, object arg)
Dispatches expressions to the operation passed as argument. It provokes the execution of op...
Definition: AstNode.cs:104
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
override int GetHashCode()
Definition: AstNode.cs:90
This class represent the entry wnen sending a message to an operation object. derived from AstNode ...
AstNode(Location location)
Protected constructor of NodeAst
Definition: AstNode.cs:59
override bool Equals(object obj)
AntLR compares Nodes with the class name. This is not correct for our purposes.
Definition: AstNode.cs:84
Abstract class for all nodes that compounds the abstract syntax tree.
Definition: AstNode.cs:33
abstract Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39