#include #include "ustr.h" int main(void) { const struct UStr *kwIf = UStrAdd("if"); const struct UStr *kwWhile = UStrAdd("while"); char *line = 0; size_t capacity = 0; ssize_t len; while ((len = getline(&line, &capacity, stdin)) > 0) { line[len - 1] = 0; bool added = false; const struct UStr *ident = UStrAdd_(line, &added); if (ident == kwIf) { printf("keyword 'if'\n"); } else if (ident == kwWhile) { printf("keyword 'while'\n"); } else { printf("identifier '%s'\n", ident->cstr); if (added) { printf("this is new\n"); } } } printf("Pool of UStr:\n"); UStrPrintPool(); }