Mercury library  1.0
Translation of CFG grammars into an object model (Bachelor's thesis).
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
AnalyserResult.cs
Go to the documentation of this file.
1 using Mercury.Interpreting;
2 using Mercury.Syntax;
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Text;
7 using System.Threading.Tasks;
8 
9 namespace Mercury
10 {
11 
12 //==<< AnalyserStatus >>=====================================================
13 
15  public enum AnalyserStatus
16  {
18  Success,
24  ParserFail,
28  Undefined,
29  }
30 
31 //==<< FailReason >>=========================================================
32 
34  public enum FailReason
35  {
37  None,
39  Exception,
41  NoResult
42  }
43 
44 //=============================================================================
45 // AnalyserResult
46 //=============================================================================
47 
67  public class AnalyserResult<T, TResult>
68  where T : class
69  where TResult : class
70  {
71  //--[ Internal methods ]---------------------------------------------
72 
73  internal void SetStatus(TimeSpan tt, AnalyserStatus stat,
74  FailReason fr = Mercury.FailReason.None, Exception ex = null)
75  {
76  Status = stat;
77  FailReason = fr;
78  Exception = ex;
79  if (ex != null) FailReason = Mercury.FailReason.Exception;
80  TotalTime = tt;
81  }
82 
83  //--[ Constructors ]-------------------------------------------------
84 
85  internal AnalyserResult()
86  {
87  Status = AnalyserStatus.Undefined;
88  FailReason = Mercury.FailReason.NoResult;
89  ParserResult = null;
90  InterpreterResults = null;
91  Exception = null;
92  ParserTime = TimeSpan.Zero;
93  InterpreterTime = TimeSpan.Zero;
94  TotalTime = TimeSpan.Zero;
95  }
96 
97  //--[ Properties ]---------------------------------------------------
98 
100  public AnalyserStatus Status { get; internal set; }
101 
106  public FailReason FailReason { get; internal set; }
107 
109  public ParserResult ParserResult { get; internal set; }
110 
112  public IReadOnlyList<InterpreterResult<T>> InterpreterResults { get; internal set; }
113 
115  public IReadOnlyList<TResult> Interpretations { get; internal set; }
116 
118  public Exception Exception { get; internal set; }
119 
121  public TimeSpan ParserTime { get; internal set; }
122 
124  public TimeSpan InterpreterTime { get; internal set; }
125 
130  public TimeSpan TotalTime { get; internal set; }
131  }
132 
133 }
Failed to tokenize input
There was no result in the stage where analysis failed
Interpreter failed
Undefined error
Failed to scan input
Represents the result returned by the parser.
Definition: ParserResult.cs:14
An exception has been thrown
FailReason
Specifies the reason of analysis failure
AnalyserStatus
The status of analysis. If failed, see FailReason
Parser failed
The analysis was successful and there is at least one result
No failure