Updated foobar example
This commit is contained in:
@@ -3,9 +3,15 @@
|
|||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
mpc_result_t r;
|
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);
|
mpca_lang(MPCA_LANG_DEFAULT, "foobar : \"foo\" | \"bar\";", Foobar);
|
||||||
(void)argc;
|
|
||||||
|
|
||||||
if (mpc_parse("<stdin>", argv[1], Foobar, &r)) {
|
if (mpc_parse("<stdin>", argv[1], Foobar, &r)) {
|
||||||
mpc_ast_print(r.output);
|
mpc_ast_print(r.output);
|
||||||
@@ -14,7 +20,9 @@ int main(int argc, char** argv) {
|
|||||||
mpc_err_print(r.error);
|
mpc_err_print(r.error);
|
||||||
mpc_err_delete(r.error);
|
mpc_err_delete(r.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
mpc_cleanup(1, Foobar);
|
mpc_cleanup(1, Foobar);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user