libsapling  0.8.0
lexer.h
Go to the documentation of this file.
1 #ifndef _LIBSAPLING_LEXER_H_
2 #define _LIBSAPLING_LEXER_H_
3 
9 #include "libsapling/dm/graph.h"
10 
11 void *lexer__data(const node_t node);
12 void lexer__access(enum qt qt, node_t *ref, void *info, predicate_t predicate,
13  apply_t apply);
14 void lexer__print(FILE *stream, node_t *ref, fpfdata_t fpfdata);
15 void lexer__dump_dot(FILE *stream, node_t *ref, fpfdata_t fpfdata);
16 int lexer__length(const node_t *ref);
17 
25 void lexer__literal(node_t *dst, const char *expr);
26 
37 void lexer__class(node_t *dst, const char *expr);
38 
44 void lexer__anything(node_t *dst);
45 
52 void lexer__copy(node_t *dst, node_t *src);
53 
63 void lexer__union(node_t *dst, node_t *src);
64 
74 void lexer__concatenation(node_t *dst, node_t *src);
75 
84 void lexer__kleene_star(node_t *dst);
85 
94 void lexer__kleene_plus(node_t *dst);
95 
103 void lexer__minimize(node_t *dst);
104 
112 void lexer__set_accepting_states_data(node_t *ref, void *data);
113 
144 struct lexer_state {
145  const char *buf;
146  int cursor;
147  int overread;
148  void **ref_to_data;
149  char lexeme[4096];
150  int lexeme_cursor;
151  int end;
152 };
153 
160 void lexer__init(struct lexer_state *ref, const char *buf);
161 
166 void **lexer__next_terminal(node_t *ref, struct lexer_state *sta);
167 
176 node_t lexer__enumerate_states(node_t *ref);
177 
183 const char *lexer__to_string(node_t *ref, node_t *map);
184 
185 #endif
Graph implementation.
void(* apply_t)(node_t *ref, const struct info_stack *info)
Performs a user-defined operation on the node.
Definition: graph.h:117
void(* fpfdata_t)(FILE *stream, const void *data)
File print format data function prototype.
Definition: graph.h:152
int(* predicate_t)(const node_t *ref, const struct info_stack *info)
Decides whether to run the apply function on an item. Behavior is modified by quantifiers.
Definition: graph.h:112
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...
void lexer__class(node_t *dst, const char *expr)
Build an automaton that accepts a class of characters.
const char * lexer__to_string(node_t *ref, node_t *map)
Prints a lexer automaton in a somewhat-more human readable form.
void lexer__kleene_plus(node_t *dst)
node_t lexer__enumerate_states(node_t *ref)
Returns an AVL map of (node_t, int)
void lexer__copy(node_t *dst, node_t *src)
Build a copy of a given automaton.
void lexer__set_accepting_states_data(node_t *ref, void *data)
Sets the data pointer value of all accepting state of the automaton.
void lexer__minimize(node_t *dst)
void lexer__literal(node_t *dst, const char *expr)
Build an automaton that accepts a string literal.
void lexer__kleene_star(node_t *dst)
void lexer__concatenation(node_t *dst, node_t *src)
void lexer__init(struct lexer_state *ref, const char *buf)
Initializes a lexer state object.
void lexer__union(node_t *dst, node_t *src)
void lexer__anything(node_t *dst)
Build an automaton that accepts one of any character.
qt
Quantifier definitions.
Definition: logic.h:10
Lexer state object.
Definition: lexer.h:144
void ** ref_to_data
Definition: lexer.h:148
int end
Definition: lexer.h:151
const char * buf
Definition: lexer.h:145
char lexeme[4096]
Definition: lexer.h:149
int cursor
Definition: lexer.h:146
int overread
Definition: lexer.h:147