#include #include #include typedef enum { BOLD, ITALICS, UNDERLINE, END } attr_t; typedef void (*attr_callback_t)(void); void bold_on(void){ fputs("\033[1m", stdout); } void bold_off(void){ fputs("\033[0m", stdout); } attr_callback_t attr_callbacks[END*2] = { (attr_callback_t)bold_on, (attr_callback_t)bold_off, }; typedef int color; struct hl_t { attr_t attrs; color fg_color; color bg_color; //? font; }; struct hl_group { char* name; std::map o; hl_group* link; }; typedef enum { KEYWORD, MATCH, REGION } token_t; struct token{ hl_group* hl; token_t t; char* syntax; }; std::vector token_table; token* newtoken(char* syntax, token_t t, hl_group* g){ token* mt = new (token){ .hl = g, .t = t, .syntax = syntax }; token_table.push_back(mt); return mt; }