mirror of
https://github.com/verilator/verilator.git
synced 2025-04-21 12:06:55 +00:00
Internals: Add success parameter to parseDouble. No functional change intended.
Signed-off-by: Wilson Snyder <wsnyder@wsnyder.org>
This commit is contained in:
parent
9ae40d64f0
commit
b2623b9841
@ -140,7 +140,7 @@ public:
|
||||
void verilatorCmtLintSave();
|
||||
void verilatorCmtLintRestore();
|
||||
void verilatorCmtBad(const char* text);
|
||||
double parseDouble(const char* text, size_t length);
|
||||
static double parseDouble(const char* text, size_t length, bool* successp = NULL);
|
||||
void pushBeginKeywords(int state) { m_inBeginKwd++; m_lastVerilogState=state; }
|
||||
bool popBeginKeywords() { if (m_inBeginKwd) { m_inBeginKwd--; return true; } else return false; }
|
||||
int lastVerilogState() const { return m_lastVerilogState; }
|
||||
|
@ -975,9 +975,10 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
|
||||
%%
|
||||
int V3ParseImp::stateVerilogRecent() { return STATE_VERILOG_RECENT; }
|
||||
|
||||
double V3ParseImp::parseDouble(const char* textp, size_t length) {
|
||||
double V3ParseImp::parseDouble(const char* textp, size_t length, bool* successp) {
|
||||
char* strgp = new char[length+1];
|
||||
char* dp=strgp;
|
||||
if (successp) *successp = true;
|
||||
for (const char* sp=textp; sp<(textp+length); ++sp) {
|
||||
if (*sp != '_') *dp++ = *sp;
|
||||
}
|
||||
@ -985,7 +986,10 @@ double V3ParseImp::parseDouble(const char* textp, size_t length) {
|
||||
char* endp = strgp;
|
||||
double d = strtod(strgp, &endp);
|
||||
size_t parsed_len = endp-strgp;
|
||||
if (parsed_len != strlen(strgp)) { yyerrorf("Syntax error parsing real: %s",strgp); }
|
||||
if (parsed_len != strlen(strgp)) {
|
||||
if (successp) *successp = false;
|
||||
else yyerrorf("Syntax error parsing real: %s",strgp);
|
||||
}
|
||||
delete[] strgp;
|
||||
return d;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user