Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
LanguageData.cs
Go to the documentation of this file.
1 #region License
2 
3 /* **********************************************************************************
4  * Copyright (c) Roman Ivantsov
5  * This source code is subject to terms and conditions of the MIT License
6  * for Irony. A copy of the license can be found in the License.txt file
7  * at the root of this distribution.
8  * By using this source code in any fashion, you are agreeing to be bound by the terms of the
9  * MIT License.
10  * You must not remove this notice from this software.
11  * **********************************************************************************/
12 #endregion
13 
14 using System;
15 
16 using Irony.Parsing.Construction;
17 
18 namespace Irony.Parsing
19 {
20  /// <summary>
21  /// Describes a language.
22  /// </summary>
23  public class LanguageData
24  {
25  #region Constants and Fields
26 
27  /// <summary>
28  /// Grammar errors.
29  /// </summary>
30  public readonly GrammarErrorList Errors = new GrammarErrorList();
31 
32  /// <summary>
33  /// The linked Grammar
34  /// </summary>
35  public Grammar Grammar { get; private set; }
36 
37  /// <summary>
38  /// Raw data extracted from the grammar.
39  /// </summary>
40  public GrammarData GrammarData { get; private set; }
41 
42  /// <summary>
43  /// Data for the parser.
44  /// </summary>
45  public ParserData ParserData { get; private set; }
46 
47  /// <summary>
48  /// Time in ms to build a scanner.
49  /// </summary>
50  public long ConstructionTime;
51 
52  /// <summary>
53  /// Error level.
54  /// </summary>
55  public GrammarErrorLevel ErrorLevel = GrammarErrorLevel.NoError;
56 
57  #endregion
58 
59  #region Constructors and Destructors
60 
61  /// <summary>
62  /// Initializes the specified grammar.
63  /// </summary>
64  /// <param name="grammar">The grammar.</param>
65  public LanguageData(Grammar grammar)
66  {
67  Grammar = grammar;
68  GrammarData = new GrammarData(this);
69  ParserData = new ParserData(this);
70  ConstructAll();
71  }
72 
73  public virtual Scanner CreateScanner()
74  {
75  return null;
76  }
77 
78  #endregion
79 
80  #region Public Methods
81 
82  /// <summary>
83  /// Determines whether this instance can parse.
84  /// </summary>
85  /// <returns>
86  /// <c>true</c> if this instance can parse; otherwise, <c>false</c>.
87  /// </returns>
88  public bool CanParse()
89  {
90  return ErrorLevel < GrammarErrorLevel.Error;
91  }
92 
93  /// <summary>
94  /// Constructs all.
95  /// </summary>
96  public void ConstructAll()
97  {
98  var builder = new LanguageDataBuilder(this);
99  builder.Build();
100  }
101 
102  #endregion
103  }
104 }
bool CanParse()
Determines whether this instance can parse.
Definition: LanguageData.cs:88
Scanner base class. The Scanner's function is to transform a stream of characters into aggregates/wor...
Definition: Scanner.cs:22
virtual Scanner CreateScanner()
Definition: LanguageData.cs:73
Describes a language.
Definition: LanguageData.cs:23
void ConstructAll()
Constructs all.
Definition: LanguageData.cs:96
long ConstructionTime
Time in ms to build a scanner.
Definition: LanguageData.cs:50
LanguageData(Grammar grammar)
Initializes the specified grammar.
Definition: LanguageData.cs:65