diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-05-29 22:35:45 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-05-29 22:35:45 -0700 |
commit | d87f9b4b380df188a17b6c1b04c4d24d7d79f98e (patch) | |
tree | 1f736a87e0ca25648a03c70d91565343d91d2f17 /parser.l | |
parent | ec3c1573e7cc8ce1d0f884fae30c4171d669c95f (diff) | |
download | txr-d87f9b4b380df188a17b6c1b04c4d24d7d79f98e.tar.gz txr-d87f9b4b380df188a17b6c1b04c4d24d7d79f98e.tar.bz2 txr-d87f9b4b380df188a17b6c1b04c4d24d7d79f98e.zip |
parser: handle "fatal" conditions in flex scanner
* parser.l (YY_FATAL_ERROR): New macro.
(lex_irrecovarable_error): New function.
(parser_l_init): Take address of yy_fatal_error and cast to
void, to suppress warning that the function is unused.
* lex.yy.c.shipped: Updated.
Diffstat (limited to 'parser.l')
-rw-r--r-- | parser.l | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -58,6 +58,8 @@ #define YY_DECL \ static int yylex_impl(YYSTYPE *yylval_param, yyscan_t yyscanner) +#define YY_FATAL_ERROR(msg) lex_irrecoverable_error(msg) + int opt_loglevel = 1; /* 0 - quiet; 1 - normal; 2 - verbose */ val form_to_ln_hash; @@ -131,6 +133,12 @@ static void yyerrprepf(scanner_t *scanner, val fmt, ...) } } +static void lex_irrecoverable_error(const char *msg8) +{ + val msg = string_utf8(msg8); + uw_throwf(error_s, lit("error in parser: ~a"), msg, nao); +} + static void out_of_range_float(scanner_t *scanner, const char *tok) { yyerrorf(scanner, lit("out-of-range floating-point literal: ~a"), @@ -1521,4 +1529,5 @@ void parser_l_init(void) { prot1(&form_to_ln_hash); form_to_ln_hash = make_eq_hash(hash_weak_keys); + (void) &yy_fatal_error; /* suppress unused function warning */ } |