diff --git a/README.md b/README.md index ed320e4..95733a1 100644 --- a/README.md +++ b/README.md @@ -641,7 +641,6 @@ Fold Functions mpc_val_t *mpcf_snd_free(int n, mpc_val_t** xs);Returns second element of xs and calls free on others mpc_val_t *mpcf_trd_free(int n, mpc_val_t** xs);Returns third element of xs and calls free on others mpc_val_t *mpcf_strfold(int n, mpc_val_t** xs);Concatenates all xs together as strings and returns result - mpc_val_t *mpcf_maths(int n, mpc_val_t** xs);Examines second argument as string to see which operator it is, then operators on first and third argument as if they are int*. diff --git a/examples/doge.c b/examples/doge.c index f7331fe..597eebc 100644 --- a/examples/doge.c +++ b/examples/doge.c @@ -12,7 +12,7 @@ int main(int argc, char **argv) { " noun : \"lisp\" | \"language\" | \"c\" | \"book\" | \"build\"; " " phrase : ; " " doge : /^/ * /$/; ", - Adjective, Noun, Phrase, Doge); + Adjective, Noun, Phrase, Doge, NULL); if (argc > 1) { diff --git a/examples/lispy.c b/examples/lispy.c index f3977f3..982bf0b 100644 --- a/examples/lispy.c +++ b/examples/lispy.c @@ -21,7 +21,7 @@ int main(int argc, char **argv) { " expr : | | " " | | | ; " " lispy : /^/ * /$/ ; ", - Number, Symbol, String, Comment, Sexpr, Qexpr, Expr, Lispy); + Number, Symbol, String, Comment, Sexpr, Qexpr, Expr, Lispy, NULL); if (argc > 1) { diff --git a/examples/maths.c b/examples/maths.c index 1366d0a..1bccc36 100644 --- a/examples/maths.c +++ b/examples/maths.c @@ -12,7 +12,12 @@ int main(int argc, char **argv) { " product : (('*' | '/') )*; " " value : /[0-9]+/ | '(' ')'; " " maths : /^/ /$/; ", - Expr, Prod, Value, Maths); + Expr, Prod, Value, Maths, NULL); + + mpc_print(Expr); + mpc_print(Prod); + mpc_print(Value); + mpc_print(Maths); if (argc > 1) { diff --git a/examples/smallc.c b/examples/smallc.c index d061c2b..ffc6683 100644 --- a/examples/smallc.c +++ b/examples/smallc.c @@ -60,7 +60,7 @@ int main(int argc, char **argv) { " includes : (\"#include\" )* ; \n" " smallc : /^/ *
/$/ ; \n", Ident, Number, Character, String, Factor, Term, Lexp, Stmt, Exp, - Typeident, Decls, Args, Body, Procedure, Main, Includes, Smallc); + Typeident, Decls, Args, Body, Procedure, Main, Includes, Smallc, NULL); if (err != NULL) { mpc_err_print(err); diff --git a/mpc.c b/mpc.c index b2b341d..4f9dba9 100644 --- a/mpc.c +++ b/mpc.c @@ -157,9 +157,8 @@ char *mpc_err_string(mpc_err_t *x) { if (x->failure) { mpc_err_string_cat(buffer, &pos, &max, - "error: %s\n", - x->filename, x->state.row+1, - x->state.col+1, x->failure); + "%s: error: %s\n", + x->filename, x->failure); return buffer; } @@ -2867,6 +2866,7 @@ static mpc_parser_t *mpca_grammar_find_parser(char *x, mpca_grammar_st_t *st) { /* Search Existing Parsers */ for (i = 0; i < st->parsers_num; i++) { mpc_parser_t *p = st->parsers[i]; + if (p == NULL) { return mpc_failf("Unknown Parser '%s'!", x); } if (p->name && strcmp(p->name, x) == 0) { return p; } } @@ -2879,10 +2879,7 @@ static mpc_parser_t *mpca_grammar_find_parser(char *x, mpca_grammar_st_t *st) { st->parsers = realloc(st->parsers, sizeof(mpc_parser_t*) * st->parsers_num); st->parsers[st->parsers_num-1] = p; - if (p == NULL) { - return mpc_failf("Unknown Parser '%s'!", x); - } - + if (p == NULL) { return mpc_failf("Unknown Parser '%s'!", x); } if (p->name && strcmp(p->name, x) == 0) { return p; } }