From a1e0040d82584463b98f168e81bccc6f543c21c8 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Wed, 23 Sep 2015 00:01:39 +0100 Subject: [PATCH] Fix for GitHub issue #79 - literal numbers must have at least one digit. The bug report was for an assertion failure when a number contained only a lowline (e.g. 'b_), but the standard says that a number can't start with a lowline (e.g. 'b_1). The parser already rejected these cases for decimal numbers, but allowed them through for binary/octal/hex numbers. --- lexor.lex | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lexor.lex b/lexor.lex index d14e38694..a153000ad 100644 --- a/lexor.lex +++ b/lexor.lex @@ -4,7 +4,7 @@ %{ /* - * Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2015 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -432,16 +432,26 @@ TU [munpf] return SYSTEM_IDENTIFIER; } -\'[sS]?[dD][ \t]*[0-9][0-9_]* { yylval.number = make_unsized_dec(yytext); - return BASED_NUMBER; } -\'[sS]?[dD][ \t]*[xzXZ?]_* { yylval.number = make_undef_highz_dec(yytext); - return BASED_NUMBER; } -\'[sS]?[bB][ \t]*[0-1xzXZ_\?]+ { yylval.number = make_unsized_binary(yytext); - return BASED_NUMBER; } -\'[sS]?[oO][ \t]*[0-7xzXZ_\?]+ { yylval.number = make_unsized_octal(yytext); - return BASED_NUMBER; } -\'[sS]?[hH][ \t]*[0-9a-fA-FxzXZ_\?]+ { yylval.number = make_unsized_hex(yytext); - return BASED_NUMBER; } +\'[sS]?[dD][ \t]*[0-9][0-9_]* { + yylval.number = make_unsized_dec(yytext); + return BASED_NUMBER; +} +\'[sS]?[dD][ \t]*[xzXZ?]_* { + yylval.number = make_undef_highz_dec(yytext); + return BASED_NUMBER; +} +\'[sS]?[bB][ \t]*[0-1xzXZ?][0-1xzXZ?_]* { + yylval.number = make_unsized_binary(yytext); + return BASED_NUMBER; +} +\'[sS]?[oO][ \t]*[0-7xzXZ?][0-7xzXZ?_]* { + yylval.number = make_unsized_octal(yytext); + return BASED_NUMBER; +} +\'[sS]?[hH][ \t]*[0-9a-fA-FxzXZ?][0-9a-fA-FxzXZ?_]* { + yylval.number = make_unsized_hex(yytext); + return BASED_NUMBER; +} \'[01xzXZ] { if (generation_flag < GN_VER2005_SV) { cerr << yylloc.text << ":" << yylloc.first_line << ": warning: "