Mescal
Loading...
Searching...
No Matches
words.h
Go to the documentation of this file.
1
6
7#ifndef WORDS_H_
8#define WORDS_H_
9
10 /* _ _ _ _ __ __ _ */
11 /* | | ___| |_| |_ ___ _ __ ___ __ _ _ __ __| | \ \ / /__ _ __ __| |___ */
12 /* | | / _ \ __| __/ _ \ '__/ __| / _` | '_ \ / _` | \ \ /\ / / _ \| '__/ _` / __| */
13 /* | |__| __/ |_| || __/ | \__ \ | (_| | | | | (_| | \ V V / (_) | | | (_| \__ \ */
14 /* |_____\___|\__|\__\___|_| |___/ \__,_|_| |_|\__,_| \_/\_/ \___/|_| \__,_|___/ */
15
16#include "alloc.h"
17#include "tools.h"
18#include "type_basic.h"
19#include <stdbool.h>
20#include <stdlib.h>
21
33typedef struct {
34 uchar lab;
35 short num;
36} letter;
37
46);
47
56 FILE*
57);
58
67 char*
68);
69
70
71
72
73
74
84 FILE*,
85 bool
86);
87
88
94 FILE*,
95 bool
96);
97
105int compare_letters(const void*,
106 const void*
107);
108
117 uint
118);
119
130uint letter_index(letter l,
131 const letter* alphabet,
132 uint size_alphabet
133);
134
135
143typedef struct {
146 uint left;
147 uint right;
148 bool empty;
149} word;
150
159
164void delete_word(word*
165);
166
174uint size_word(const word*
175);
176
184bool isempty_word(const word*
185);
186
191void lefcon_word(letter,
192 word*
193);
194
199void rigcon_word(letter,
200 word*
201);
202
213letter lefread_word(const word*,
214 uint
215);
216
227letter rigread_word(const word*,
228 uint
229);
230
239);
240
249);
250
256 const word*
257);
258
263void display_word(const word*,
264 FILE*
265);
266
276 uint*
277);
278
279#endif
Macros and functions to help memory allocation.
The type used to represent a letter.
Definition words.h:33
short num
The subscript (must be either -1 or positive).
Definition words.h:35
uchar lab
The ASCII character.
Definition words.h:34
The type used to represent a word.
Definition words.h:143
letter * array
Array of letters.
Definition words.h:144
uint right
Index following the righmost letter (when nonempty).
Definition words.h:147
uint size_array
Size of the array of letters.
Definition words.h:145
uint left
Index of the leftmost letter (when nonempty).
Definition words.h:146
bool empty
Boolean indicating whether the word is empty.
Definition words.h:148
Basic types.
letter rigpull_word(word *)
Removes the rightmost letter of a word.
Definition words.c:320
letter lefread_word(const word *, uint)
Reads a letter inside a word without removing it: left-right version.
Definition words.c:246
void delete_word(word *)
Release of a word.
Definition words.c:221
int sprint_letter_utf8(letter, char *)
Prints a letter in a given char array: UTF8 version for the subscripts.
Definition words.c:29
uint fprint_letter_utf8(letter, FILE *)
Displays a letter on a given stream: UTF8 version for the subscripts.
Definition words.c:11
word * create_empty_word(void)
Creation of an empty word.
Definition words.c:209
bool isempty_word(const word *)
Tests whether a word is empty.
Definition words.c:230
void lefcon_word(letter, word *)
Concatenates a letter to the left of a word.
Definition words.c:271
letter * get_alphabet_word(const word *, uint *)
Computes the set of letters occuring inside a word.
Definition words.c:374
void concatenate_word(word *, const word *)
Concatenates two words into the left one.
Definition words.c:338
void rigcon_word(letter, word *)
Concatenates a letter to the right of a word.
Definition words.c:286
uint letter_index(letter l, const letter *alphabet, uint size_alphabet)
Retrieves the index of a letter in an alphabet (sorted array of letters.
Definition words.c:136
letter lefpull_word(word *)
Removes the leftmost letter of a word.
Definition words.c:302
letter * duplicate_alphabet(const letter *, uint)
Creates a copy of an array of letters.
Definition words.c:127
letter rigread_word(const word *, uint)
Reads a letter inside a word without removing it: right-left version.
Definition words.c:254
void fprint_letter_latex(letter, FILE *, bool)
Displays a letter on a given stream: latex version for the subscripts.
Definition words.c:85
void display_word(const word *, FILE *)
Dislpays a word on a given stream (UTF8 is used for the subscripts of letters).
Definition words.c:345
uint size_word(const word *)
Computes the length of a word.
Definition words.c:233
void fprint_letter_gviz(letter, FILE *, bool)
Displays a letter on a given stream: graphviz version for the subscript.
Definition words.c:58
int compare_letters(const void *, const void *)
Comparison of two letters for sorting algorithms.
Definition words.c:106
uint length_letter_utf8(letter)
Computes the length of a letter when displayed in UTF8, including the subscript.
Definition words.c:4