/* retoor */ #ifndef LOREG_LEXER_H #define LOREG_LEXER_H #include #include typedef enum { TOKEN_CHAR, TOKEN_DOT, TOKEN_STAR, TOKEN_PLUS, TOKEN_QUESTION, TOKEN_PIPE, TOKEN_LPAREN, TOKEN_RPAREN, TOKEN_LBRACKET, TOKEN_RBRACKET, TOKEN_CARET, TOKEN_DOLLAR, TOKEN_LBRACE, TOKEN_RBRACE, TOKEN_BACKSLASH, TOKEN_DASH, TOKEN_CLASS_DIGIT, TOKEN_CLASS_WORD, TOKEN_CLASS_SPACE, TOKEN_CLASS_NDIGIT, TOKEN_CLASS_NWORD, TOKEN_CLASS_NSPACE, TOKEN_EOF } token_type_t; typedef struct { token_type_t type; char value; size_t position; } token_t; typedef struct { const char *pattern; size_t length; size_t position; bool in_bracket; } lexer_t; void lexer_init(lexer_t *lexer, const char *pattern); token_t lexer_next(lexer_t *lexer); token_t lexer_peek(lexer_t *lexer); bool lexer_eof(lexer_t *lexer); #endif