-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFLViz.h
98 lines (77 loc) · 1.82 KB
/
FLViz.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef XX
#define XX
#define BUF_MAX_LEN 512
#define ASSERT assert
#define ERRNUM 2000
#define TOK_MAX_LEN 128
extern const char *errmsg[];
/*
* Tags for the input format. Unfortunately in Polish :-/
*/
#define FA_FMT_DFA "<tablica wejsciowa ASD>"
#define FA_FMT_NFA "<tablica wejsciowa ASN>"
#define FA_FMT_FINAL "<tablica stanow koncowych>"
#define FA_INSERT_NOTHING -1
#define FA_INSERT_EXT 1
/*
* FA state
*/
struct FA_State {
char *name;
#define FA_STATE_FIRST (1 << 0)
#define FA_STATE_LAST (1 << 1)
#define FA_STATE_CURR (1 << 2)
int flag;
/* Simulator support */
void *obj;
};
struct FA_word {
char *word;
};
typedef enum {
FA_TYPE_DFA,
FA_TYPE_NFA
} fa_type_t;
struct tok;
struct FA {
unsigned long _fa_magic;
#define FA_MAGIC 0x6ba531f0
#define FA_INIT(h) do { (h)->_fa_magic = FA_MAGIC; } while (0)
#define FA_ASSERT(h) \
do { \
assert((h) != NULL); \
assert((h)->_fa_magic == FA_MAGIC); \
} while (0)
/* Type of the automata. */
fa_type_t type;
/* Number of states */
struct FA_State *states;
int nstates;
/* Temporary variable holding strings representing final states */
struct tok **finitoks;
/* Number of final states */
int nfinistates;
/* Transition table */
struct FA_State ***transt;
/* All tokens and table size */
struct tok ***toks;
int toks_rows;
int toks_cols;
/* Alphabet and it's size */
struct FA_word *alpha;
int nalpha;
/* Simulator support */
struct FA_State *state0;
struct FA_State *trans_from;
struct FA_State *trans_to;
int simstep;
};
void FA_free(struct FA *fa);
int FA_create(struct FA **retfa, FILE *fp);
int FA_trans(struct FA *fa, int word);
void FA_dump_dot(struct FA *fa, const char *);
void FA_dump_dot_one(struct FA *fa, const char *ofname);
void FA_dump(struct FA *fa);
void FA_restart(struct FA *fa);
int FA_final(struct FA *fa);
#endif