#include #include static void *tree; static char input[256]; static char string[256]; static int intval; static float floatval; static double doubleval; int main(void); int main(void) { tree = tree_match_parse( "(quit " " debug (on off) " " forget (memoryAlloc " " memoryFoobar " " ) " " number (int (%d",(void *)&intval,") " " float (%f",(void *)&floatval,") " " double (%F",(void *)&doubleval,") " " ) " " string (normal (%s",(void *)&string[0],") " " quoted (%S",(void *)&string[0],") " " ) " ")",(void *)0); if (! tree) { fprintf(stderr,"Parse failed: %.30s\n",tree_match_err_at()); exit(1); } input[0] = '\0'; while (strcmp(input,"quit")) { tree_match(tree,">> ",input); printf("%s\n",input); if (!strcmp(input,"debug on")) { *tree_match_flags() |= CTREE_F_DEBUG; } else if (!strcmp(input,"debug off")) { *tree_match_flags() |= CTREE_F_DEBUG; } else if (!strcmp(input,"number int")) { printf("int: %d\n",intval); } else if (!strcmp(input,"number float")) { printf("float: %g\n",floatval); } else if (!strcmp(input,"number double")) { printf("double: %g\n",doubleval); } else if (!strcmp(input,"string normal")) { printf("string: %s\n",&string[0]); } else if (!strcmp(input,"string quoted")) { printf("string: %s\n",&string[0]); } } exit(0); }