foobar.c (560B)
1 #include "../mpc.h" 2 3 int main(int argc, char** argv) { 4 5 mpc_result_t r; 6 mpc_parser_t* Foobar; 7 8 if (argc != 2) { 9 printf("Usage: ./foobar <foo/bar>\n"); 10 exit(0); 11 } 12 13 Foobar = mpc_new("foobar"); 14 mpca_lang(MPCA_LANG_DEFAULT, "foobar : \"foo\" | \"bar\";", Foobar); 15 16 if (mpc_parse("<stdin>", argv[1], Foobar, &r)) { 17 mpc_ast_print(r.output); 18 mpc_ast_delete(r.output); 19 } else { 20 mpc_err_print(r.error); 21 mpc_err_delete(r.error); 22 } 23 24 mpc_cleanup(1, Foobar); 25 26 return 0; 27 } 28