summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-04-21 04:06:20 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-04-21 04:06:20 -0700
commit2e36e0feae8d1dd75c8410b365d7dc33b30ce66b (patch)
treedf3e255d60c16c6e320742b87379d2eb7ba8b05a /parser.c
parenteffd37e7ed64dd0300b37af1a102febea84c9504 (diff)
downloadtxr-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.c')
-rw-r--r--parser.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/parser.c b/parser.c
index 4ac341b7..fbc2e2ca 100644
--- a/parser.c
+++ b/parser.c
@@ -173,12 +173,12 @@ val parser(val stream, val lineno)
return parser;
}
-static parser_t *get_parser_impl(val self, val parser)
+parser_t *parser_get_impl(val self, val parser)
{
return coerce(parser_t *, cobj_handle(self, parser, parser_s));
}
-static val ensure_parser(val stream)
+val ensure_parser(val stream)
{
loc pcdr = gethash_l(lit("internal error"), stream_parser_hash, stream, nulloc);
val pars = deref(pcdr);
@@ -541,7 +541,7 @@ static val lisp_parse_impl(val self, val interactive, val rlcp_p, val source_in,
stream_get_prop(input_stream, name_k)));
val parser = ensure_parser(input_stream);
val saved_dyn = dyn_env;
- parser_t *pi = get_parser_impl(self, parser);
+ parser_t *pi = parser_get_impl(self, parser);
volatile val parsed = nil;
if (rlcp_p)
@@ -628,7 +628,7 @@ static val read_file_common(val self, val stream, val error_stream, val compiled
val parser = ensure_parser(stream);
if (compiled) {
- parser_t *pi = get_parser_impl(self, parser);
+ parser_t *pi = parser_get_impl(self, parser);
pi->rec_source_loc = 0;
}