Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
LRState.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 //
4 // ----------------------------------------------------------------------
5 // Gold Parser engine.
6 // See more details on http://www.devincook.com/goldparser/
7 //
8 // Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
9 //
10 // This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
11 //
12 // The translation is based on the other engine translations:
13 // Delphi engine by Alexandre Rai (riccio@gmx.at)
14 // C# engine by Marcus Klimstra (klimstra@home.nl)
15 // ----------------------------------------------------------------------
16 #region Using directives
17 
18 using System;
19 
20 #endregion
21 
22 namespace GoldParser
23 {
24  /// <summary>
25  /// State of LR parser.
26  /// </summary>
27  internal class LRState
28  {
29  private int m_index;
30  private LRStateAction[] m_actions;
31  internal LRStateAction[] m_transitionVector;
32 
33  /// <summary>
34  /// Creates a new instance of the <c>LRState</c> class
35  /// </summary>
36  /// <param name="index">Index of the LR state in the LR state table.</param>
37  /// <param name="actions">List of all available LR actions in this state.</param>
38  /// <param name="transitionVector">Transition vector which has symbol index as an index.</param>
39  public LRState(int index, LRStateAction[] actions, LRStateAction[] transitionVector)
40  {
41  m_index = index;
42  m_actions = actions;
43  m_transitionVector = transitionVector;
44  }
45 
46  /// <summary>
47  /// Gets index of the LR state in LR state table.
48  /// </summary>
49  public int Index
50  {
51  get { return m_index; }
52  }
53 
54  /// <summary>
55  /// Gets LR state action count.
56  /// </summary>
57  public int ActionCount
58  {
59  get { return m_actions.Length; }
60  }
61 
62  /// <summary>
63  /// Returns state action by its index.
64  /// </summary>
65  /// <param name="index">State action index.</param>
66  /// <returns>LR state action for the given index.</returns>
67  public LRStateAction GetAction(int index)
68  {
69  return m_actions[index];
70  }
71 
72  /// <summary>
73  /// Returns LR state action by symbol index.
74  /// </summary>
75  /// <param name="symbolIndex">Symbol Index to search for.</param>
76  /// <returns>LR state action object.</returns>
77  public LRStateAction GetActionBySymbolIndex(int symbolIndex)
78  {
79  return m_transitionVector[symbolIndex];
80  }
81  }
82 }