diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-04-21 04:06:20 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-04-21 04:06:20 -0700 |
commit | 2e36e0feae8d1dd75c8410b365d7dc33b30ce66b (patch) | |
tree | df3e255d60c16c6e320742b87379d2eb7ba8b05a /parser.y | |
parent | effd37e7ed64dd0300b37af1a102febea84c9504 (diff) | |
download | txr-2e36e0feae8d1dd75c8410b365d7dc33b30ce66b.tar.gz txr-2e36e0feae8d1dd75c8410b365d7dc33b30ce66b.tar.bz2 txr-2e36e0feae8d1dd75c8410b365d7dc33b30ce66b.zip |
parser: always use stream-associated parser for parse_once.
This refactoring is needed for fixing the off-by-one
line number bug when the hash bang line is processed.
* eval.c (load): Don't define parser locally; ensure there is
one in the stream and use it.
* match.c (v_load): Likewise.
* parser.c (get_parser_impl): Renamed to parser_get_impl and
changed from internal to external linkage.
(ensure_parser): Changed to external linkage.
(lisp_parser_impl, read_file_common): Follow rename of
get_parser_impl.
* parser.h (parse_once): Declaration updated.
(parser_get_impl, ensure_parser): Declared.
* parser.y (parse_once): Take self parameter; drop parser
parameter. Ensure a parser to the stream, rather than
declaring one locally. Don't clean up the parser when
done, just let the stream clean it up.
* txr.c (parse_once_noerr): Parser argument is dropped and
not passed to parse_once. Program name is passed as self
argument to parse_once.
(txr_main): When parsing the TXR pattern query, don't define a
parser locally; ensure there is one in the stream and use it,
like in load and v_load.
Diffstat (limited to 'parser.y')
-rw-r--r-- | parser.y | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -1847,16 +1847,14 @@ void yybadtoken(parser_t *parser, int tok, val context) yyerrorf(scnr, lit("unexpected character ~a"), chr(tok), nao); } -int parse_once(val stream, val name, parser_t *parser) +int parse_once(val self, val stream, val name) { int res = 0; #if CONFIG_DEBUG_SUPPORT unsigned dbg_state = debug_clear(opt_dbg_expansion ? 0 : DBG_ENABLE); #endif - parser_common_init(parser); - - parser->stream = stream; - parser->name = name; + val parser_obj = ensure_parser(stream); + parser_t *parser = parser_get_impl(self, parser_obj); parser->rec_source_loc = 1; uw_catch_begin(cons(error_s, nil), esym, eobj); @@ -1872,7 +1870,6 @@ int parse_once(val stream, val name, parser_t *parser) } uw_unwind { - parser_cleanup(parser); #if CONFIG_DEBUG_SUPPORT debug_set(dbg_state); #endif |