Updated foobar example

This commit is contained in:
Daniel Holden
2015-02-07 19:41:33 +00:00
parent 9481c6573c
commit c4c963f3b3

View File

@@ -3,9 +3,15 @@
int main(int argc, char** argv) {
mpc_result_t r;
mpc_parser_t* Foobar = mpc_new("foobar");
mpc_parser_t* Foobar;
if (argc != 2) {
printf("Usage: ./foobar <foo/bar>\n");
exit(0);
}
Foobar = mpc_new("foobar");
mpca_lang(MPCA_LANG_DEFAULT, "foobar : \"foo\" | \"bar\";", Foobar);
(void)argc;
if (mpc_parse("<stdin>", argv[1], Foobar, &r)) {
mpc_ast_print(r.output);
@@ -14,7 +20,9 @@ int main(int argc, char** argv) {
mpc_err_print(r.error);
mpc_err_delete(r.error);
}
mpc_cleanup(1, Foobar);
return 0;
}