diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-06-07 20:04:18 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-06-07 20:04:18 -0700 |
commit | de547e4ec4e375531ac3d797c3e82ff2544f9464 (patch) | |
tree | 75faa523492a0d0e71e448198f824ad05b5c1780 /parser.y | |
parent | 267c1c96144c983f7c6d4826cb0fede4471c3233 (diff) | |
download | txr-de547e4ec4e375531ac3d797c3e82ff2544f9464.tar.gz txr-de547e4ec4e375531ac3d797c3e82ff2544f9464.tar.bz2 txr-de547e4ec4e375531ac3d797c3e82ff2544f9464.zip |
* 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.
Diffstat (limited to 'parser.y')
-rw-r--r-- | parser.y | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -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; +} |