Mescal
Loading...
Searching...
No Matches
regexp.h
Go to the documentation of this file.
1
6#ifndef REGEXP_H_
7#define REGEXP_H_
8
9 /* ____ _ _ */
10 /* | _ \ ___ __ _ _ _| | __ _ _ __ _____ ___ __ _ __ ___ ___ ___(_) ___ _ __ ___ */
11 /* | |_) / _ \/ _` | | | | |/ _` | '__| / _ \ \/ / '_ \| '__/ _ \/ __/ __| |/ _ \| '_ \/ __| */
12 /* | _ < __/ (_| | |_| | | (_| | | | __/> <| |_) | | | __/\__ \__ \ | (_) | | | \__ \ */
13 /* |_| \_\___|\__, |\__,_|_|\__,_|_| \___/_/\_\ .__/|_| \___||___/___/_|\___/|_| |_|___/ */
14 /* |___/ |_| */
15
16#include "alloc.h"
17#include "error.h"
18#include "nfa.h"
19#include "tools.h"
20#include "type_basic.h"
21#include "type_dequeue.h"
22#include <assert.h>
23#include <ctype.h>
24#include <stdbool.h>
25#include <stdio.h>
26#include <string.h>
27
28
29
35extern short symbolic_count;
36
42extern char** symbolic_names;
43
44
45
53short symbolic_index(char*
54);
55
56
57
62typedef struct syletter {
63 uchar lab;
64 uchar dec;
66
71typedef struct syvariable {
72 uchar ind;
73 uchar dec;
75
84 , FILE*
85);
86
97uint display_syvar_utf8(syvariable v, FILE* out);
98
118
134
142);
143
154bool reg_issimple(regexp*
155);
156
161void reg_free(regexp*
162);
163
172);
173
181regexp* reg_empty(void);
182
190regexp* reg_epsilon(void);
191
199regexp* reg_letter(uchar
200);
201
210);
211
219
221 uchar index
222);
223
232 uchar number
233);
234
235regexp* reg_var_symbolic(char* s, uchar number);
236
248 regexp*
249);
250
262 regexp*
263);
264
276 regexp*
277);
278
290);
291
303);
304
316);
317
322void reg_print(regexp*
323);
324
325
339 , ushort
340 , uchar
341 , bool*
342);
343
344
345
346
347#endif
Macros and functions to help memory allocation.
Macros for displaying error messages.
Implementation of NFAs.
regexp * reg_letter_symbolic(uchar c, uchar number)
Computes a regular expression corresponding to the symbolic letter a_{i+k}.
Definition regexp.c:226
regexp * reg_inter(regexp *, regexp *)
Combines two regular expressions with the intersection operator.
Definition regexp.c:288
regexp * reg_star(regexp *)
Applies the Kleene star operator to a regular expression.
Definition regexp.c:368
regexp * reg_letter(uchar)
Computes a regular expression recognizing the language {a} for an input letter a.
Definition regexp.c:204
regexp * reg_epsilon(void)
Computes a regular expression recognizing the language {ε}.
Definition regexp.c:199
regexp * reg_empty(void)
Computes a regular expression recognizing the empty language.
Definition regexp.c:194
regexp * reg_copy(regexp *)
Copy of a regular expression.
Definition regexp.c:120
regexp * reg_union(regexp *, regexp *)
Combines two regular expressions with the union operator.
Definition regexp.c:266
regexp * reg_complement(regexp *)
Applies the complement operator to a regular expression.
Definition regexp.c:397
regexp * reg_plus(regexp *)
Applies the Kleene plus operator to a regular expression.
Definition regexp.c:383
regexp * reg_letter_ext(letter)
Computes a regular expression recognizing the language {a} for an input letter a. Extended version.
Definition regexp.c:213
void reg_print(regexp *)
Displays a regular expression on the standard output stream.
Definition regexp.c:519
short symbolic_index(char *)
Computes the index of a symbolic variable name in the array symbolic_names.
Definition regexp.c:6
regelem
The operator available in an extended regular expression.
Definition regexp.h:103
@ COMPLEMENT
Complement of an expression.
Definition regexp.h:112
@ EPSILON
Empty word.
Definition regexp.h:105
@ SYCHAR
Symbolic letter.
Definition regexp.h:107
@ EMPTY
Empty language.
Definition regexp.h:104
@ CHAR
Single letter.
Definition regexp.h:106
@ WORD
Single word.
Definition regexp.h:109
@ UNION
Union of two expressions.
Definition regexp.h:110
@ INTER
Intersection of two expressions.
Definition regexp.h:111
@ PLUS
Kleene plus of an expression.
Definition regexp.h:115
@ CONCAT
Concatenation of two expressions.
Definition regexp.h:113
@ STAR
Kleene star of an expression.
Definition regexp.h:114
@ NONE
Used for simplifying the display.
Definition regexp.h:116
@ SYVAR
Symbolic variable.
Definition regexp.h:108
uint display_syvar_utf8(syvariable v, FILE *out)
Displays a symbolic variable on a given stream: UTF8 version for the indices.
Definition regexp.c:36
void reg_free(regexp *)
Release of a regular expression.
Definition regexp.c:105
regexp * reg_concat(regexp *, regexp *)
Combines two regular expressions with the concatenation operator.
Definition regexp.c:300
bool reg_has_symbolic(regexp *)
Tests if a regular expression contains a symbolic node.
Definition regexp.c:51
bool reg_symbolic_loops(regexp *, ushort, uchar, bool *)
Computes information on the symbolic variables of a regular expression.
Definition regexp.c:526
regexp * reg_letter_numbered(uchar c, uchar index)
Computes a regular expression recognizing the language {a_n} for an input letter a,...
Definition regexp.c:219
bool reg_issimple(regexp *)
Tests if a regular expression is simple.
Definition regexp.c:80
uint display_syletter_utf8(syletter, FILE *)
Displays a symbolic letter on a given stream: UTF8 version for the indices.
Definition regexp.c:15
The type used to represent a letter.
Definition words.h:33
Type used to represent a single node in a regular expression.
Definition regexp.h:123
syletter sylet
Symbolic letter.
Definition regexp.h:130
struct regexp * left
The left sub-expression (NULL if no left sub-expression).
Definition regexp.h:125
letter letter
Letter (if this is a letter node).
Definition regexp.h:128
syvariable syvar
Symbolic variable.
Definition regexp.h:131
regelem op
The operator.
Definition regexp.h:124
struct regexp * right
The right sub-expression (NULL if no right sub-expression).
Definition regexp.h:126
word * word
Word (if this is a word node).
Definition regexp.h:129
Type used to represent a symbolic letter.
Definition regexp.h:62
uchar lab
The letter itself.
Definition regexp.h:63
uchar dec
The decrementation index.
Definition regexp.h:64
Type used to represent a symbolic variable.
Definition regexp.h:71
uchar ind
The index of the symbolic variable.
Definition regexp.h:72
uchar dec
The decrementation index.
Definition regexp.h:73
Basic types.
Implementation of dequeues of unsigned integers.