The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
LexicalError.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: LexicalError.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Represents the error occurred while the source code is lexing. //
9 // -------------------------------------------------------------------------- //
10 // Create date: 14-01-2007 //
11 // Modification date: 14-01-2007 //
13 
14 using System;
15 using System.Collections.Generic;
16 using System.Text;
17 
18 namespace ErrorManagement
19 {
23  public struct LexicalError : IError
24  {
25  #region Fields
26 
30  private string description;
31 
32  #endregion
33 
34  #region Properties
35 
39  public string ErrorType
40  {
41  get { return "Lexical Error"; }
42  }
43 
47  public string Description
48  {
49  get { return this.description; }
50  }
51 
52  #endregion
53 
54  #region Constructor
55 
63  public LexicalError(string description, Location loc)
64  {
65  StringBuilder aux = new StringBuilder();
66  aux.AppendFormat("An error occurred while the file {0} is parsing. [{1}:{2}]\r\n{3}", loc.FileName, loc.Line, loc.Column, description);
67  this.description = aux.ToString();
68  }
69 
70  #endregion
71 
72  #region Equals&GetHashCode
73  public override bool Equals(object obj) {
74  if (!(obj is LexicalError))
75  return false;
76  return ((LexicalError)obj).description.Equals(this.description);
77  }
78  public override int GetHashCode() {
79  return this.description.GetHashCode();
80  }
81  #endregion
82 
83  }
84 }
string ErrorType
Gets the error type
Definition: LexicalError.cs:40
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
LexicalError(string description, Location loc)
Constructor of LexicalError.
Definition: LexicalError.cs:63
System.Text.StringBuilder StringBuilder
Definition: CSharpParser.cs:4
Interfaz for the different error types.
Definition: IError.cs:23
override bool Equals(object obj)
Definition: LexicalError.cs:73
string Description
Gets the error description
Definition: LexicalError.cs:48
Represents the error occurred while the source code is lexing.
Definition: LexicalError.cs:23