Mescal
|
Implementation of letters and words. More...
#include "alloc.h"
#include "tools.h"
#include "type_basic.h"
#include <stdbool.h>
#include <stdlib.h>
Go to the source code of this file.
Classes | |
struct | letter |
The type used to represent a letter. More... | |
struct | word |
The type used to represent a word. More... | |
Functions | |
uint | length_letter_utf8 (letter) |
Computes the length of a letter when displayed in UTF8, including the subscript. | |
uint | fprint_letter_utf8 (letter, FILE *) |
Displays a letter on a given stream: UTF8 version for the subscripts. | |
int | sprint_letter_utf8 (letter, char *) |
Prints a letter in a given char array: UTF8 version for the subscripts. | |
void | fprint_letter_gviz (letter, FILE *, bool) |
Displays a letter on a given stream: graphviz version for the subscript. | |
void | fprint_letter_latex (letter, FILE *, bool) |
Displays a letter on a given stream: latex version for the subscripts. | |
int | compare_letters (const void *, const void *) |
Comparison of two letters for sorting algorithms. | |
letter * | duplicate_alphabet (const letter *, uint) |
Creates a copy of an array of letters. | |
uint | letter_index (letter l, const letter *alphabet, uint size_alphabet) |
Retrieves the index of a letter in an alphabet (sorted array of letters. | |
word * | create_empty_word (void) |
Creation of an empty word. | |
void | delete_word (word *) |
Release of a word. | |
uint | size_word (const word *) |
Computes the length of a word. | |
bool | isempty_word (const word *) |
Tests whether a word is empty. | |
void | lefcon_word (letter, word *) |
Concatenates a letter to the left of a word. | |
void | rigcon_word (letter, word *) |
Concatenates a letter to the right of a word. | |
letter | lefread_word (const word *, uint) |
Reads a letter inside a word without removing it: left-right version. | |
letter | rigread_word (const word *, uint) |
Reads a letter inside a word without removing it: right-left version. | |
letter | lefpull_word (word *) |
Removes the leftmost letter of a word. | |
letter | rigpull_word (word *) |
Removes the rightmost letter of a word. | |
void | concatenate_word (word *, const word *) |
Concatenates two words into the left one. | |
void | display_word (const word *, FILE *) |
Dislpays a word on a given stream (UTF8 is used for the subscripts of letters). | |
letter * | get_alphabet_word (const word *, uint *) |
Computes the set of letters occuring inside a word. | |
Implementation of letters and words.
int compare_letters | ( | const void * | p1, |
const void * | p2 ) |
Comparison of two letters for sorting algorithms.
p1 | The first letter. |
p2 | The second letter. |
Concatenates two words into the left one.
l | The left word (modified). |
r | The right word (not modified). |
word * create_empty_word | ( | void | ) |
Creation of an empty word.
void delete_word | ( | word * | p | ) |
Release of a word.
p | The word. |
void display_word | ( | const word * | w, |
FILE * | out ) |
Dislpays a word on a given stream (UTF8 is used for the subscripts of letters).
w | The word. |
out | The stream. |
Creates a copy of an array of letters.
alph | The array of letters. |
size | The size of the array of letters. |
void fprint_letter_gviz | ( | letter | l, |
FILE * | out, | ||
bool | inv ) |
Displays a letter on a given stream: graphviz version for the subscript.
l | The letter. |
out | The stream. |
inv | True if an inverse power has to be displayed, false otherwise. |
void fprint_letter_latex | ( | letter | l, |
FILE * | out, | ||
bool | inv ) |
Displays a letter on a given stream: latex version for the subscripts.
l | The letter. |
out | The stream. |
inv | True if an inverse power has to be displayed, false otherwise. |
uint fprint_letter_utf8 | ( | letter | l, |
FILE * | out ) |
Displays a letter on a given stream: UTF8 version for the subscripts.
l | The letter. |
out | The stream. |
Computes the set of letters occuring inside a word.
w | The word. |
l | A pointer used to return the length of the computed array. |
bool isempty_word | ( | const word * | p | ) |
Tests whether a word is empty.
p | The word. |
Concatenates a letter to the left of a word.
val | The letter. |
p | The word. |
Removes the leftmost letter of a word.
p | The word. |
Reads a letter inside a word without removing it: left-right version.
p | The word. |
i | The index. |
uint length_letter_utf8 | ( | letter | l | ) |
Computes the length of a letter when displayed in UTF8, including the subscript.
l | The letter. |
Retrieves the index of a letter in an alphabet (sorted array of letters.
l | The letter. |
alphabet | The alphabet (sorted in increasing order). |
size_alphabet | The size of the alphabet (number of letters). |
Concatenates a letter to the right of a word.
val | The letter. |
p | The word. |
Removes the rightmost letter of a word.
p | The word. |
Reads a letter inside a word without removing it: right-left version.
p | The word. |
i | The index. |
uint size_word | ( | const word * | p | ) |
Computes the length of a word.
p | The word. |
int sprint_letter_utf8 | ( | letter | l, |
char * | out ) |
Prints a letter in a given char array: UTF8 version for the subscripts.
l | The letter. |
out | The string (must be large enough). |