25 tokenizer->
input = input;
85 *inside_open_tag =
false;
89 *inside_open_tag =
true;
99 *inside_open_tag =
false;
110 if (ch ==
'"' || ch ==
'\'') {
119 token.
value[pos] =
'\0';
125 if (*inside_open_tag && (isalpha(ch) || ch ==
'-')) {
132 token.
value[pos] =
'\0';
144 if (ch !=
'<' && ch !=
'>') {
145 if (!*inside_open_tag) {
147 while (ch !=
'<' && ch !=
'>' && !
n_gui_is_eof(tokenizer)) {
153 token.
value[pos] =
'\0';
172 switch (token.
type) {
174 printf(
"N_GUI_TOKEN_TAG_OPEN: %s\n", token.
value);
177 printf(
"N_GUI_TOKEN_TAG_CLOSE: %s\n", token.
value);
180 printf(
"N_GUI_TOKEN_TAG_NAME: %s\n", token.
value);
183 printf(
"N_GUI_TOKEN_ATTR_NAME: %s\n", token.
value);
186 printf(
"N_GUI_TOKEN_ATTR_VALUE: %s\n", token.
value);
189 printf(
"N_GUI_TOKEN_TEXT: %s\n", token.
value);
192 printf(
"N_GUI_TOKEN_EOF\n");
210 N_STR* nstr_css = NULL;
222 bool inside_open_tag =
false;
224 switch (token.
type) {
#define Malloc(__ptr, __struct, __size)
Malloc Handler to get errors and set to 0.
#define __n_assert(__ptr, __ret)
macro to assert things
#define _nstr(__PTR)
N_STR or "NULL" string for logging purposes.
#define N_ENUM_DEFINE(MACRO_DEFINITION, enum_name)
Macro to define an N_ENUM.
char value[1024]
token content
size_t position
position in the input text
const char * input
pointer to the input text
__N_GUI_TOKEN
Network codes declaration.
char n_gui_next_char(N_GUI_TOKENIZER *tokenizer)
Get next character from input.
void n_gui_print_token(N_GUI_TOKEN token)
Function to print a token (for debugging purposes)
int n_gui_is_eof(N_GUI_TOKENIZER *tokenizer)
char n_gui_peek_char(N_GUI_TOKENIZER *tokenizer)
Peek at next character without advancing the position.
N_GUI_DIALOG * n_gui_load_dialog(char *html, char *css)
Load a html + css file into a N_GUI_DIALOG.
#define N_GUI_MAX_TOKEN_SIZE
maximum size of a single token content
void n_gui_init_tokenizer(N_GUI_TOKENIZER *tokenizer, const char *input)
Initialize tokenizer.
N_GUI_TOKEN n_gui_next_token(N_GUI_TOKENIZER *tokenizer, bool *inside_open_tag)
Read next N_GUI_TOKEN from input.
structure of a N_GUI_DIALOG
structure of a N_GUI_TOKENIZER token
structure of a N_GUI_DIALOG tokenizer
#define free_nstr(__ptr)
free a N_STR structure and set the pointer to NULL
N_STR * file_to_nstr(char *filename)
Load a whole file into a N_STR.
A box including a string and his lenght.
Common headers and low-level functions & define.
N_ENUM_N_GUI_TOKEN
N_GUI context codes.
N_STR and string function declaration.