Mescal
|
Implementation of regular expressions. More...
#include "alloc.h"
#include "error.h"
#include "nfa.h"
#include "tools.h"
#include "type_basic.h"
#include "type_dequeue.h"
#include <assert.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
Go to the source code of this file.
Classes | |
struct | syletter |
Type used to represent a symbolic letter. More... | |
struct | syvariable |
Type used to represent a symbolic variable. More... | |
struct | regexp |
Type used to represent a single node in a regular expression. More... | |
Enumerations | |
enum | regelem { EMPTY , EPSILON , CHAR , SYCHAR , SYVAR , WORD , UNION , INTER , COMPLEMENT , CONCAT , STAR , PLUS , NONE } |
The operator available in an extended regular expression. More... | |
Functions | |
short | symbolic_index (char *) |
Computes the index of a symbolic variable name in the array symbolic_names. | |
uint | display_syletter_utf8 (syletter, FILE *) |
Displays a symbolic letter on a given stream: UTF8 version for the indices. | |
uint | display_syvar_utf8 (syvariable v, FILE *out) |
Displays a symbolic variable on a given stream: UTF8 version for the indices. | |
bool | reg_has_symbolic (regexp *) |
Tests if a regular expression contains a symbolic node. | |
bool | reg_issimple (regexp *) |
Tests if a regular expression is simple. | |
void | reg_free (regexp *) |
Release of a regular expression. | |
regexp * | reg_copy (regexp *) |
Copy of a regular expression. | |
regexp * | reg_empty (void) |
Computes a regular expression recognizing the empty language. | |
regexp * | reg_epsilon (void) |
Computes a regular expression recognizing the language {ε}. | |
regexp * | reg_letter (uchar) |
Computes a regular expression recognizing the language {a} for an input letter a. | |
regexp * | reg_letter_ext (letter) |
Computes a regular expression recognizing the language {a} for an input letter a. Extended version. | |
regexp * | reg_letter_numbered (uchar c, uchar index) |
Computes a regular expression recognizing the language {a_n} for an input letter a, subscripted by n. | |
regexp * | reg_letter_symbolic (uchar c, uchar number) |
Computes a regular expression corresponding to the symbolic letter a_{i+k}. | |
regexp * | reg_var_symbolic (char *s, uchar number) |
regexp * | reg_union (regexp *, regexp *) |
Combines two regular expressions with the union operator. | |
regexp * | reg_inter (regexp *, regexp *) |
Combines two regular expressions with the intersection operator. | |
regexp * | reg_concat (regexp *, regexp *) |
Combines two regular expressions with the concatenation operator. | |
regexp * | reg_star (regexp *) |
Applies the Kleene star operator to a regular expression. | |
regexp * | reg_plus (regexp *) |
Applies the Kleene plus operator to a regular expression. | |
regexp * | reg_complement (regexp *) |
Applies the complement operator to a regular expression. | |
void | reg_print (regexp *) |
Displays a regular expression on the standard output stream. | |
bool | reg_symbolic_loops (regexp *, ushort, uchar, bool *) |
Computes information on the symbolic variables of a regular expression. | |
Implementation of regular expressions.
enum regelem |
The operator available in an extended regular expression.
uint display_syletter_utf8 | ( | syletter | l, |
FILE * | out ) |
Displays a symbolic letter on a given stream: UTF8 version for the indices.
l | The symbolic letter. |
out | The stream. |
uint display_syvar_utf8 | ( | syvariable | v, |
FILE * | out ) |
Displays a symbolic variable on a given stream: UTF8 version for the indices.
Applies the complement operator to a regular expression.
left | The expression. |
Combines two regular expressions with the concatenation operator.
left | The left expression. |
right | The right expression. |
Copy of a regular expression.
r | The regular expression. |
regexp * reg_empty | ( | void | ) |
Computes a regular expression recognizing the empty language.
regexp * reg_epsilon | ( | void | ) |
Computes a regular expression recognizing the language {ε}.
void reg_free | ( | regexp * | r | ) |
Release of a regular expression.
r | The regular expression. |
bool reg_has_symbolic | ( | regexp * | exp | ) |
Tests if a regular expression contains a symbolic node.
exp | The regular expression. |
Combines two regular expressions with the intersection operator.
left | The left expression. |
right | The right expression. |
bool reg_issimple | ( | regexp * | exp | ) |
Tests if a regular expression is simple.
exp | The regular expression. |
regexp * reg_letter | ( | uchar | c | ) |
Computes a regular expression recognizing the language {a} for an input letter a.
c | The letter. |
Computes a regular expression recognizing the language {a} for an input letter a. Extended version.
l | The letter. |
regexp * reg_letter_numbered | ( | uchar | c, |
uchar | index ) |
Computes a regular expression recognizing the language {a_n} for an input letter a, subscripted by n.
c | The letter. |
index | The number. |
regexp * reg_letter_symbolic | ( | uchar | c, |
uchar | number ) |
Computes a regular expression corresponding to the symbolic letter a_{i+k}.
c | The letter. |
number | The number k. |
Applies the Kleene plus operator to a regular expression.
left | The expression. |
void reg_print | ( | regexp * | r | ) |
Displays a regular expression on the standard output stream.
r | The expression. |
Applies the Kleene star operator to a regular expression.
left | The expression. |
bool reg_symbolic_loops | ( | regexp * | exp, |
ushort | max, | ||
uchar | num, | ||
bool * | cycle ) |
Computes information on the symbolic variables of a regular expression.
A list of symbolic variable names is given as input. The function checks whether all names in the expressions are in this set. Furthermore, for each name, it checks if there exists an occurence of this name with the index 0.
exp | The regular expression. |
max | The maximum decrement. |
num | The number of names in the input set. |
cycle | Used to return the names which occur with the index 0. |
Combines two regular expressions with the union operator.
left | The left expression. |
right | The right expression. |
short symbolic_index | ( | char * | varname | ) |
Computes the index of a symbolic variable name in the array symbolic_names.
varname | The symbolic variable name. |