From de547e4ec4e375531ac3d797c3e82ff2544f9464 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 7 Jun 2015 20:04:18 -0700 Subject: * match.c (v_load): Call parse_once rater than parse. * parser.c (regex_parse): Likewise. * txr.c (txr_main): Likewise. * parser.h (parse): Declaration updated. (parse_once): Declared. * parser.y (parse_once): New function, same as old parse implementation. (parse): Becomes one argument function which works with a previously initialized parser and continues the parse. --- parser.y | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'parser.y') diff --git a/parser.y b/parser.y index d95b3ed5..ceb1801b 100644 --- a/parser.y +++ b/parser.y @@ -1428,7 +1428,7 @@ void yybadtoken(parser_t *parser, int tok, val context) yyerrorf(scnr, lit("unexpected ~s"), chr(tok), nao); } -int parse(val stream, val name, parser_t *parser) +int parse_once(val stream, val name, parser_t *parser) { int res; yyscan_t scanner; @@ -1450,3 +1450,23 @@ int parse(val stream, val name, parser_t *parser) return res; } + +int parse(parser_t *parser) +{ + int res; + yyscan_t scanner; + + parser->errors = 0; + parser->prepared_msg = nil; + parser->syntax_tree = nil; + yylex_init(&scanner); + parser->scanner = convert(scanner_t *, scanner); + + yyset_extra(parser, parser->scanner); + + res = yyparse(parser->scanner, parser); + + yylex_destroy(parser->scanner); + + return res; +} -- cgit v1.2.3