Mescal
Loading...
Searching...
No Matches
shell_languages.h
1#ifndef LANGUAGES_H_
2#define LANGUAGES_H_
3
4#include "monoid.h"
5#include "monoid_kernels.h"
6#include "monoid_orbits.h"
7#include "nfa.h"
8#include "nfa_determi.h"
9#include "printing.h"
10#include "monoid_display.h"
11#include "regexp.h"
12#include "regexp_tonfa.h"
13#include <stdlib.h>
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
43typedef struct {
44 char* name;
45 uint count;
46 uchar digits;
48
49
54typedef enum {
55 KER_MOD,
56 KER_AMT,
57 KER_GR,
58 KER_SIZE,
59} kernel_type;
60
61
62
67typedef enum {
68 ORB_DD,
69 ORB_MODP,
70 ORB_AMTP,
71 ORB_GRP,
72 ORB_PT,
73 ORB_BPMOD,
74 ORB_BPAMT,
75 ORB_BPGR,
76 ORB_BPDD,
77 ORB_BPMODP,
78 ORB_BPAMTP,
79 ORB_BPGRP,
80 ORB_SIZE,
81} orbits_type;
82
83
84
85
90typedef struct {
92 subsemi* kers[KER_SIZE];
93 orbits* orbs[ORB_SIZE];
95
96#define RECMAX 8
97
102typedef struct {
103 bool full;
104 uchar num;
105 ushort init;
106 char* names[RECMAX];
107 uchar evalseq[RECMAX];
108 regexp** regexps[RECMAX];
109 regexp* def[RECMAX];
111
116typedef enum {
117 OD_MINI,
118 OD_SYNT,
119 OD_SIZE,
120} ob_depend;
121
126typedef enum {
127 EMPTYOBJ,
128 REGEXP,
129 NAUTOMATON,
130 DAUTOMATON,
131 MORPHISM,
132 RECDEF,
133 DUMMY,
134} ob_type;
135
136
137extern char* object_types_names[DUMMY];
138
139#define NAME_MAXSIZE 128
140
145typedef struct {
146 //char name[NAME_MAXSIZE]; //!< Variable name (NULL if the object is a dependency).
147 ob_prefixname* prefix; //<! Prefix of the variable name (Index in the prefixnames array). Equal to -1 if the object is a dependency (noname). Full name is prefix + number.
148 uint number;
149
150 ob_type type;
151 union {
157 };
158 int depend[OD_SIZE];
159 int parent;
160} object;
161
166extern object* objects;
167
172extern int nb_objects;
173
178void init_objects_array(void);
179
184void grow_objects_array(void);
185
186/************************/
187/* Creation/Deletion */
188/************************/
189
197ob_prefixname* create_prefixname_full(const char* name
198);
199
200
208ob_prefixname* create_prefixname(const char* name,
209 uint count
210);
211
216void remove_instance_prefixname(ob_prefixname* prefixname
217);
218
219
227int object_init(const char* name
228);
229
230
235void object_swap(int,
236 int
237);
238
243void object_free_aux(object*
244);
245
250void object_free(int
251);
252
257void object_free_all(void);
258
266void object_delete_prefix(const char*
267);
268
269/************************/
270/* Get/insert an object */
271/************************/
272
283const char* object_get_full_name(int i
284);
285
293int object_get_from_name(const char*
294);
295
303int object_delete_from_name(const char*
304);
305
317int object_add_regexp(const char*,
318 regexp*
319);
320
332int object_add_automaton_nfa(const char*,
333 nfa*
334);
335
347int object_add_automaton_dfa(const char* name,
348 dfa* A
349);
350
351void object_add_automaton_dfa_family(const char* pname, dfa** array, uint count);
352
364int object_add_morphism(char*,
365 morphism*
366);
367
378int shell_copy_generic(int i,
379 char* newname
380);
381
382
383
384
385/***********************************************/
386/* Computing information on an existing object */
387/***********************************************/
388
396int shell_compute_minimal(int
397);
398
410int shell_compute_syntac(int,
411 bool
412);
413
421void shell_compute_mult(int
422);
423
432void shell_compute_order(int
433);
434
445subsemi* shell_compute_ker(int,
446 kernel_type,
447 sub_level
448);
449
450
461orbits* shell_compute_orbits(int,
462 orbits_type,
463 sub_level
464);
465
466
467/*************/
468/* Recursion */
469/*************/
470
480uchar shell_rec_getnum(ob_recursion*,
481 char*
482);
483
491bool shell_check_recursion(int
492);
493
501int shell_rec_defadd(int,
502 uchar,
503 regexp*
504);
505
513int shell_rec_iniadd(int,
514 uchar,
515 ushort,
516 regexp*
517);
518
526regexp** shell_rec_compute(ob_recursion*,
527 ushort
528);
529
537regexp* shell_rec_getexp(int,
538 char*,
539 ushort
540);
541
546void shell_rec_display(ob_recursion*,
547 FILE*
548);
549
550
551/***********/
552/* Display */
553/***********/
554
555
560void shell_view_object(object* ob,
561 bool title
562);
563
564
565
566#endif // LANGUAGES_H_
Implementation of morphisms into finite monoids.
Computation of kernels.
Computation of orbits.
Implementation of NFAs.
Determinization and complementation of NFAs.
Implementation of regular expressions.
Construction of a NFA from a regular expression. Thompson's et Glushkov's algorithms.
Type used to represent a complete DFA.
Definition nfa.h:61
The type used to represent a morphism into a finite monoid.
Definition monoid.h:91
Type used to represent a NFA.
Definition nfa.h:43
Structure used to store a morphism and its Green relations.
Definition shell_languages.h:90
morphism * obj
The morphism.
Definition shell_languages.h:91
subsemi * kers[KER_SIZE]
The kernels.
Definition shell_languages.h:92
orbits * orbs[ORB_SIZE]
The orbits.
Definition shell_languages.h:93
Structure used to store a variable name prefix.
Definition shell_languages.h:43
char * name
The variable name prefix.
Definition shell_languages.h:44
uchar digits
The number of digits used for the suffix.
Definition shell_languages.h:46
uint count
The number of objects with this prefix.
Definition shell_languages.h:45
Type used to represent a recursive definition of regular expressions.
Definition shell_languages.h:102
regexp ** regexps[RECMAX]
Array mapping each sequence to an array containing the indices of the computed elements in the object...
Definition shell_languages.h:108
char * names[RECMAX]
Array mapping each relation to its variable name.
Definition shell_languages.h:106
regexp * def[RECMAX]
Array mapping each sequence to its inductive definition.
Definition shell_languages.h:109
uchar evalseq[RECMAX]
Sequence of evaluation.
Definition shell_languages.h:107
bool full
Boolean indicating if the recursive definition is fully specified.
Definition shell_languages.h:103
uchar num
Number of relations in the recursion.
Definition shell_languages.h:104
ushort init
The number of indices that are required to start the recursion.
Definition shell_languages.h:105
Type used to represent an object.
Definition shell_languages.h:145
nfa * obj_nfa
Case of a nondeterministic finite automaton.
Definition shell_languages.h:153
int parent
Index of the parent object for dependencies (-1 if no parent).
Definition shell_languages.h:159
ob_type type
Type of the object.
Definition shell_languages.h:150
uint number
Number of object for this variable name (added as a suffix to the name). UINT_MAX if not used.
Definition shell_languages.h:148
int depend[OD_SIZE]
Array of dependencies (-1 if no dependency).
Definition shell_languages.h:158
ob_recursion * rec
Case of a recursive definition of regular expressions.
Definition shell_languages.h:156
regexp * exp
Case of a regular expression.
Definition shell_languages.h:152
dfa * obj_dfa
Case of a deterministic finite automaton.
Definition shell_languages.h:154
ob_morphism * mor
Case of a morphism.
Definition shell_languages.h:155
Type used to represent C-orbits of a morphism.
Definition monoid_orbits.h:31
Type used to represent a single node in a regular expression.
Definition regexp.h:123
Type used to represent a subsemigroup and its Green relations.
Definition monoid_sub.h:35