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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#ifndef _GFSM_REGEX_COMPILER_H
#define _GFSM_REGEX_COMPILER_H
#include <gfsmScanner.h>
#include <gfsmAutomaton.h>
#include <gfsmAlphabet.h>
#include <gfsmAlgebra.h>
/** Regex automaton type */
typedef enum {
gfsmREATEmpty, ///< empty acceptor
gfsmREATLabel, ///< single label
gfsmREATFull ///< full automaton
} gfsmRegexAutomatonType;
/** Regex automaton value */
typedef union {
gfsmLabelVal lab; ///< single label
gfsmAutomaton *fsm; ///< full automaton
} gfsmRegexAutomatonValue;
/** Regex automaton */
typedef struct {
gfsmRegexAutomatonType typ; ///< regex type
gfsmRegexAutomatonValue val; ///< regex value
} gfsmRegexAutomaton;
/** Data structure for regex compiler */
typedef struct {
gfsmScanner scanner; ///< scanner
gfsmSRType srtype; ///< semiring type
gfsmRegexAutomaton rea; ///< regex automaton under construction
gfsmAlphabet *abet; ///< alphabet
GString *gstr; ///< buffer
gboolean is_label : 1; ///< is this a singleton fsm? (if so, *fsm is a gfsmLabelVal)
} gfsmRegexCompiler;
/** New full-fleded automaton */
gfsmAutomaton *gfsm_regex_automaton_new_fsm(gfsmRegexCompiler *rec);
/** Get full-fledged automaton */
gfsmAutomaton *gfsm_regex_automaton_fsm(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea);
/** Full Epsilon recognizer */
gfsmAutomaton *gfsm_regex_automaton_epsilon_fsm(gfsmRegexCompiler *rec);
/** Full single-character recognizer */
gfsmAutomaton *gfsm_regex_automaton_label_fsm(gfsmRegexCompiler *rec, gfsmLabelVal lab);
/** Single-label recognizer */
gfsmRegexAutomaton gfsm_regex_automaton_label(gfsmRegexCompiler *rec, gfsmLabelVal lab);
/** Single-label concatenation (low-level) */
gfsmAutomaton *gfsm_regex_automaton_append_lab(gfsmRegexCompiler *rec,
gfsmAutomaton *fsm,
gfsmLabelVal lab);
/** General concatenation */
gfsmRegexAutomaton gfsm_regex_automaton_concat(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea1,
gfsmRegexAutomaton rea2);
/** Closure */
gfsmRegexAutomaton gfsm_regex_automaton_closure(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea,
gboolean is_plus);
/** Power (n-ary closure) */
gfsmRegexAutomaton gfsm_regex_automaton_power(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea,
guint32 n);
/** Projection */
gfsmRegexAutomaton gfsm_regex_automaton_project(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea,
gfsmLabelSide which);
/** Optionality */
gfsmRegexAutomaton gfsm_regex_automaton_optional(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea);
/** Complement */
gfsmRegexAutomaton gfsm_regex_automaton_complement(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea);
/** Union */
gfsmRegexAutomaton gfsm_regex_automaton_union(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea1,
gfsmRegexAutomaton rea2);
/** Intersection */
gfsmRegexAutomaton gfsm_regex_automaton_intersect(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea1,
gfsmRegexAutomaton rea2);
/** Product */
gfsmRegexAutomaton gfsm_regex_automaton_product(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea1,
gfsmRegexAutomaton rea2);
/** Composition */
gfsmRegexAutomaton gfsm_regex_automaton_compose(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea1,
gfsmRegexAutomaton rea2);
/** Difference */
gfsmRegexAutomaton gfsm_regex_automaton_difference(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea1,
gfsmRegexAutomaton rea2);
/** Weight */
gfsmRegexAutomaton gfsm_regex_automaton_weight(gfsmRegexCompiler *rec,
gfsmRegexAutomaton rea1,
gfsmWeight w);
#endif /* _GFSM_REGEX_COMPILER_H */
|