libsapling  0.8.0
Data Structures | Functions
lexer.h File Reference

Lexer implementation hello. More...

#include "libsapling/dm/graph.h"

Go to the source code of this file.

Data Structures

struct  lexer_state
 Lexer state object. More...
 

Functions

void * lexer__data (const node_t node)
 
void lexer__access (enum qt qt, node_t *ref, void *info, predicate_t predicate, apply_t apply)
 
void lexer__print (FILE *stream, node_t *ref, fpfdata_t fpfdata)
 
void lexer__dump_dot (FILE *stream, node_t *ref, fpfdata_t fpfdata)
 
int lexer__length (const node_t *ref)
 
void lexer__literal (node_t *dst, const char *expr)
 Build an automaton that accepts a string literal. More...
 
void lexer__class (node_t *dst, const char *expr)
 Build an automaton that accepts a class of characters. More...
 
void lexer__anything (node_t *dst)
 Build an automaton that accepts one of any character. More...
 
void lexer__copy (node_t *dst, node_t *src)
 Build a copy of a given automaton. More...
 
void lexer__union (node_t *dst, node_t *src)
 
void lexer__concatenation (node_t *dst, node_t *src)
 
void lexer__kleene_star (node_t *dst)
 
void lexer__kleene_plus (node_t *dst)
 
void lexer__minimize (node_t *dst)
 
void lexer__set_accepting_states_data (node_t *ref, void *data)
 Sets the data pointer value of all accepting state of the automaton. More...
 
void lexer__init (struct lexer_state *ref, const char *buf)
 Initializes a lexer state object. More...
 
void ** lexer__next_terminal (node_t *ref, struct lexer_state *sta)
 Processes the set character buffer up until it finds the next acceptable lexeme and returns a pointer to the pointer to its data.
 
node_t lexer__enumerate_states (node_t *ref)
 Returns an AVL map of (node_t, int) More...
 
const char * lexer__to_string (node_t *ref, node_t *map)
 Prints a lexer automaton in a somewhat-more human readable form. More...
 

Detailed Description

Lexer implementation hello.

Function Documentation

◆ lexer__anything()

void lexer__anything ( node_t *  dst)

Build an automaton that accepts one of any character.

Parameters
dstWhere to store the reference to the initial state

◆ lexer__class()

void lexer__class ( node_t *  dst,
const char *  expr 
)

Build an automaton that accepts a class of characters.

Parameters
dstWhere to store the reference to the initial state
exprString literal with the class description, the description consists of opening and closing brackets [] with all the accepted characters within. Furthermore, the description accepts character ranges (e.g. a-z ) and if the dash or minus sign is adjacent to either of the brackets it is considered a character of the class.

◆ lexer__concatenation()

void lexer__concatenation ( node_t *  dst,
node_t *  src 
)
Precondition
*dst != NULL && *src != NULL

Concatenation of empty graphs is not implemented.

Parameters
dstLeft hand automaton in which the concatenation of both automata will be written
srcRight hand automaton which will not be overwritten

◆ lexer__copy()

void lexer__copy ( node_t *  dst,
node_t *  src 
)

Build a copy of a given automaton.

Parameters
dstWhere to store the reference to the initial state
srcReference to the initial state of the source automaton

◆ lexer__enumerate_states()

node_t lexer__enumerate_states ( node_t *  ref)

Returns an AVL map of (node_t, int)

Warning
Remnant of debug diagnostics

This was used in lexer__to_string to print automaton state ids as small numbers instead of their hexadecimal addresses

◆ lexer__init()

void lexer__init ( struct lexer_state ref,
const char *  buf 
)

Initializes a lexer state object.

Parameters
refReference to the lexer state object
bufCharacter buffer that will be processed

◆ lexer__kleene_plus()

void lexer__kleene_plus ( node_t *  dst)
Precondition
*dst != NULL

Kleene plus of empty graphs is not implemented.

Parameters
dstReference to the automaton to be converted to a kleene plus of itself

◆ lexer__kleene_star()

void lexer__kleene_star ( node_t *  dst)
Precondition
*dst != NULL

Kleene star of empty graphs is not implemented.

Parameters
dstReference to the automaton to be converted to a kleene star of itself

◆ lexer__literal()

void lexer__literal ( node_t *  dst,
const char *  expr 
)

Build an automaton that accepts a string literal.

Parameters
dstWhere to store the reference to the initial state
exprString literal surrounded by escaped double quotes (e.g. "\"literal\"" )

◆ lexer__minimize()

void lexer__minimize ( node_t *  dst)
Precondition
*dst != NULL

Minimization of empty graphs is not implemented.

Parameters
dstReference to the automaton to be minimized

◆ lexer__set_accepting_states_data()

void lexer__set_accepting_states_data ( node_t *  ref,
void *  data 
)

Sets the data pointer value of all accepting state of the automaton.

Parameters
dstReference to the initial state of the automaton
dataPointer to the user data that all accepting states will be set to hold

◆ lexer__to_string()

const char* lexer__to_string ( node_t *  ref,
node_t *  map 
)

Prints a lexer automaton in a somewhat-more human readable form.

Warning
Remnant of debug diagnostics

◆ lexer__union()

void lexer__union ( node_t *  dst,
node_t *  src 
)
Precondition
*dst != NULL && *src != NULL
Attention
Union of empty graphs is not implemented.
Parameters
dstFirst source automaton in which the union of both automata will be written
srcSecond source automaton which will not be overwritten