Fixed two minor bugs in constant parsing
authorClifford Wolf <clifford@clifford.at>
Mon, 24 Nov 2014 13:39:24 +0000 (14:39 +0100)
committerClifford Wolf <clifford@clifford.at>
Mon, 24 Nov 2014 13:39:24 +0000 (14:39 +0100)
frontends/verilog/const2ast.cc
frontends/verilog/verilog_lexer.l

index ca995915fa27848806d5dc4fcb05d8348a4fa95f..735bc5f9924b8251b9bc6914206554f18e1b7233 100644 (file)
@@ -182,7 +182,7 @@ AstNode *VERILOG_FRONTEND::const2ast(std::string code, char case_type, bool warn
        if (str == endptr)
                len_in_bits = -1;
 
-       // The "<bits>'s?[bodh]<digits>" syntax
+       // The "<bits>'s?[bodhBODH]<digits>" syntax
        if (*endptr == '\'')
        {
                std::vector<RTLIL::State> data;
@@ -194,15 +194,19 @@ AstNode *VERILOG_FRONTEND::const2ast(std::string code, char case_type, bool warn
                switch (*(endptr+1))
                {
                case 'b':
+               case 'B':
                        my_strtobin(data, endptr+2, len_in_bits, 2, case_type);
                        break;
                case 'o':
+               case 'O':
                        my_strtobin(data, endptr+2, len_in_bits, 8, case_type);
                        break;
                case 'd':
+               case 'D':
                        my_strtobin(data, endptr+2, len_in_bits, 10, case_type);
                        break;
                case 'h':
+               case 'H':
                        my_strtobin(data, endptr+2, len_in_bits, 16, case_type);
                        break;
                default:
index 5e739842b1302fff9602186bafd4e32cbd8e7367..c3dfa8b926b86049ebf59e481da60c228c7fdec3 100644 (file)
@@ -177,12 +177,12 @@ YOSYS_NAMESPACE_END
 "genvar"  { return TOK_GENVAR; }
 "real"    { return TOK_REAL; }
 
-[0-9]+ {
+[0-9][0-9_]* {
        frontend_verilog_yylval.string = new std::string(yytext);
        return TOK_CONST;
 }
 
-[0-9]*[ \t]*\'s?[bodh][ \t\r\n]*[0-9a-fA-FzxZX?_]+ {
+[0-9]*[ \t]*\'s?[bodhBODH][ \t\r\n]*[0-9a-fA-FzxZX?_]+ {
        frontend_verilog_yylval.string = new std::string(yytext);
        return TOK_CONST;
 }