diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 8b384e0c0..57890f8a3 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -1624,7 +1624,7 @@ public: void ignoreOverlap(bool flag) { m_ignoreOverlap = flag; } }; -class AstSFormatF : public AstNode { +struct AstSFormatF : public AstNode { // Convert format to string, generally under a AstDisplay or AstSFormat // Also used as "real" function for /*verilator sformat*/ functions string m_text; diff --git a/src/V3Number.cpp b/src/V3Number.cpp index ab2d97a8f..5d8690db4 100644 --- a/src/V3Number.cpp +++ b/src/V3Number.cpp @@ -306,12 +306,12 @@ V3Number& V3Number::setSingleBits(char value) { } V3Number& V3Number::setAllBits0() { - for (int i=0; iparseDouble(yytext, yyleng); return yaFLOATNUM; } [0-9][_0-9]*(\.[_0-9]+)?([eE][-+]?[_0-9]+) { - FL; yylval.cdouble = 0; /* Only for delays, not used yet */ + FL; yylval.cdouble = PARSEP->parseDouble(yytext, yyleng); return yaFLOATNUM; } [0-9][_0-9]*(\.[_0-9]+)?(fs|ps|ns|us|ms|s|step) { @@ -949,6 +949,20 @@ word [a-zA-Z0-9_]+ %% int V3ParseImp::stateVerilogRecent() { return STATE_VERILOG_RECENT; } +double V3ParseImp::parseDouble(const char* textp, size_t length) { + char* strgp = new char[strlen(textp)+1]; + char* dp=strgp; + for (const char* sp=textp; sp<(textp+length);) { + if (*sp != '_') *dp++ = *sp++; + else sp++; + } + char* endp = strgp; + double d = strtod(strgp, &endp); + if ((endp-strgp) != length) { yyerrorf("Syntax error parsing real: %s",strgp); } + delete strgp; + return d; +} + int V3ParseImp::lexToken() { // called from lexToBison, has a "this" // Fetch next token from prefetch or real lexer