* This file contains the public and the private API of the flex/bison based
* mood parser.
*
- * The public API (at the bottom of the file) allows to parse the same mood
+ * The public API (at the bottom of the file) allows parsing the same mood
* definition many times in an efficient manner.
*
* The first function to call is \ref mp_init(), which analyzes the given mood
*
* This function turns a generalized C99 string literal like "xyz\n" into a C
* string (containing the three characters 'x', 'y' and 'z', followed by a
- * newline character and the terminating zero byte). The function allows to
- * specify different quote characters so that, for example, regular expression
+ * newline character and the terminating zero byte). The function receives
+ * quote characters as an argument so that, for example, regular expression
* patterns enclosed in '/' can be parsed as well. To parse a proper string
* literal, one has to pass two double quotes as the second argument.
*
struct mp_context *ctx;
struct yy_buffer_state *buffer_state;
+ *result = NULL;
if (!definition || nbytes == 0) { /* dummy mood */
if (errmsg)
*errmsg = NULL;
- *result = NULL;
return 0;
}
ctx = para_calloc(sizeof(*ctx));
mp_yy_delete_buffer(buffer_state, scanner);
mp_yylex_destroy(scanner);
if (ctx->errmsg) { /* parse error */
+ mp_free_ast(ctx->ast);
if (errmsg)
*errmsg = ctx->errmsg;
else
{
if (!ctx) /* dummy mood */
return true;
+ if (!ctx->ast) /* empty mood */
+ return true;
assert(aft_row);
ctx->aft_row = aft_row;
ctx->have_afsi = false;