X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/bd7cc50d498bc0dcf403af437accdc82dea5f587..a9ae295484868287ff1b8f2d613fa4c010c06891:/src/scan.l diff --git a/src/scan.l b/src/scan.l index 1688873..5610dc3 100644 --- a/src/scan.l +++ b/src/scan.l @@ -29,6 +29,7 @@ #include #include "cdecl-internal.h" #include "cdecl.h" +#include "errmsg.h" #if HAVE_STRTOUMAX /* Best case, implementation provides strtoumax. */ @@ -44,15 +45,10 @@ #define STRTOUMAX strtoul #endif -#define lex_error(...) do { \ - cdecl__err(CDECL_ENOPARSE, __VA_ARGS__); \ - return T_LEX_ERROR; \ -} while(0) - #define dup_token() do { \ yylval->strval = malloc(yyleng+1); \ if (!yylval->strval) { \ - cdecl__err(CDECL_ENOMEM); \ + cdecl__errmsg(CDECL__ENOMEM); \ return T_LEX_ERROR; \ } \ strcpy(yylval->strval, yytext); \ @@ -117,10 +113,14 @@ INTEGER 0x[[:xdigit:]]+|0[0-7]+|[[:digit:]]+ errno = 0; yylval->uintval = STRTOUMAX(yytext, &end, 0); - if (errno == ERANGE) - lex_error(_("integer constant out of range")); - if (*end) - lex_error(_("invalid integer constant")); + if (errno == ERANGE) { + cdecl__errmsg(CDECL__ERANGE); + return T_LEX_ERROR; + } + if (*end) { + cdecl__errmsg(CDECL__EBADINT); + return T_LEX_ERROR; + } return T_UINT; } @@ -165,5 +165,6 @@ INTEGER 0x[[:xdigit:]]+|0[0-7]+|[[:digit:]]+ } } - lex_error(_("syntax error, unexpected '%s'"), buf); + cdecl__err(CDECL_ENOPARSE, _("syntax error, unexpected '%s'"), buf); + return T_LEX_ERROR; }