~ubuntu-branches/ubuntu/wily/aspectc++/wily

« back to all changes in this revision

Viewing changes to Puma/tools/orange/automaton.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2005-12-23 10:49:40 UTC
  • Revision ID: james.westby@ubuntu.com-20051223104940-ig4klhoi991zs7km
Tags: upstream-0.99+1.0pre2
ImportĀ upstreamĀ versionĀ 0.99+1.0pre2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ifndef __AUTOMATON__
 
2
# define __AUTOMATON__
 
3
 
 
4
# include "classes.h"
 
5
 
 
6
class ListData
 
7
 {
 
8
   public:
 
9
      virtual ~ListData () {};
 
10
      virtual void Print (void) = 0;
 
11
 };
 
12
      
 
13
class ListEntry
 
14
 {    ListEntry* Next;
 
15
      ListEntry* Prev;
 
16
      ListData*  Data;
 
17
   public:
 
18
      ListEntry (ListData* New);
 
19
      void Insert (ListEntry *Behind, ListEntry* Before);
 
20
      void Remove (void);
 
21
      ListEntry* NextEntry (void);
 
22
      ListEntry* PrevEntry (void);
 
23
      ListData* GetData (void);
 
24
 };
 
25
 
 
26
class List : public ListData
 
27
 { protected:
 
28
      ListEntry* First;
 
29
      ListEntry* Last;
 
30
      long       Entries;
 
31
   public:
 
32
      List (void);
 
33
      virtual ~List (void);
 
34
      int Empty (void);
 
35
      long Length (void);
 
36
      void Append (ListData* New);
 
37
      void Remove (ListData* ToRemove);
 
38
      void StartScanning (ListEntry*& Context);
 
39
      ListData* GetNext (ListEntry*& Context);
 
40
      void ShiftEntries (List& List);
 
41
      void CopyEntries (List& ToCopy);
 
42
      int IsIn (ListData* ToFind);
 
43
      int IsEqual (List& List);
 
44
      virtual void Print (void);
 
45
 };
 
46
 
 
47
class Stack : public List
 
48
 {
 
49
   public:
 
50
      void PushList (List& List);
 
51
      void Push (ListData* New);
 
52
      ListData* Pop (void);
 
53
 };
 
54
 
 
55
typedef enum { EPSILON_TRANS, CHAR_CLASS_TRANS, CLASS_NAME_TRANS,
 
56
               CHAR_TRANS
 
57
             } TransitionType;
 
58
 
 
59
class State;
 
60
 
 
61
class Transition : public ListData
 
62
 { 
 
63
   public:
 
64
      State*         TransitionState;
 
65
      TransitionType Type;
 
66
      ClassId        Id;
 
67
      union
 
68
       { char*   Name;
 
69
         char    Char;
 
70
       } Temp;
 
71
      Transition (TransitionType Type, State* State);
 
72
      Transition (TransitionType Type, char Char, State* State);
 
73
      Transition (TransitionType Type, char* Name, State* State);
 
74
      Transition (TransitionType Type, ClassId Id, State* State);
 
75
      void Print (void);
 
76
 };
 
77
 
 
78
 
 
79
typedef enum { NORMAL_STATE, END_STATE , LOOK_AHEAD_END_STATE } StateType;
 
80
 
 
81
class State : public ListData
 
82
 { 
 
83
   int       Expression;
 
84
   public:
 
85
   StateType Type;
 
86
   int       LookAhead;
 
87
   List      EpsilonTransitions;
 
88
   List      NonEpsilonTransitions;
 
89
   int       Group;
 
90
   int       Number;
 
91
   State*    Representative;
 
92
   State (void);
 
93
   ~State (void);
 
94
   int Expr ();
 
95
   void Expr (int);
 
96
   void AddTransition (TransitionType Type, State* State);
 
97
   void AddTransition (TransitionType Type, char Char, State* State);
 
98
   void AddTransition (TransitionType Type, char* Name, State* State);
 
99
   void AddTransition (TransitionType Type, ClassId Id, State* State);
 
100
   void ShiftTransitionList (State* State);
 
101
   void Print (void);
 
102
 };
 
103
 
 
104
class Automaton
 
105
 {
 
106
   List States;
 
107
 public:
 
108
   State* Start;
 
109
   State* End;
 
110
   Automaton (void);
 
111
   ~Automaton (void);
 
112
   void ShiftStates (Automaton& Automaton);
 
113
   State* AddState (void);
 
114
   void RemoveState (State* State);
 
115
   void ShiftState (Automaton& From, State* State);
 
116
   void Automaton::ScanStates (ListEntry*& Context);
 
117
   State* Automaton::NextState (ListEntry*& Context);
 
118
   void Print (void);
 
119
 };
 
120
 
 
121
class DFAStateDescriptor : public ListData
 
122
 { public:
 
123
      List NFAStates;
 
124
      State* DFAState;
 
125
      void Print (void);
 
126
 };
 
127
 
 
128
 
 
129
# endif
 
130
 
 
131
 
 
132