32#pragma GCC diagnostic push
33#pragma GCC diagnostic ignored "-Wunused-variable"
34#pragma GCC diagnostic ignored "-Wsign-compare"
37#include <libeval/grammar.c>
38#include <libeval/grammar.h>
41#pragma GCC diagnostic pop
54 m_parser = numEval::ParseAlloc( malloc );
62 numEval::ParseFree(
m_parser, free );
97 struct lconv* lc = localeconv();
119 if( std::isnan( val ) )
151 if( aString.IsEmpty() )
168 }
while( tok.
token );
210 auto isOldSchoolDecimalSeparator =
211 [](
char ch,
double* siScaler ) ->
bool
215 case 'a': *siScaler = 1.0e-18;
return true;
216 case 'f': *siScaler = 1.0e-15;
return true;
217 case 'p': *siScaler = 1.0e-12;
return true;
218 case 'n': *siScaler = 1.0e-9;
return true;
219 case 'u': *siScaler = 1.0e-6;
return true;
220 case 'm': *siScaler = 1.0e-3;
return true;
222 case 'K': *siScaler = 1.0e3;
return true;
223 case 'M': *siScaler = 1.0e6;
return true;
224 case 'G': *siScaler = 1.0e9;
return true;
225 case 'T': *siScaler = 1.0e12;
return true;
226 case 'P': *siScaler = 1.0e15;
return true;
227 case 'E': *siScaler = 1.0e18;
return true;
228 default:
return false;
232 auto isDecimalSeparator =
233 [&](
char ch ) ->
bool
248 [&](
double* aScaler )
250 bool haveSeparator =
false;
251 double siScaler = 1.0;
258 if( isDecimalSeparator( ch ) )
263 haveSeparator =
true;
265 if( isOldSchoolDecimalSeparator( ch, &siScaler ) )
277 }
while( isdigit(
static_cast<unsigned char>( ch ) ) || isDecimalSeparator( ch ) );
285 [&](
double* siScaler ) ->
Unit
300 if( sizeLeft >= 2 && ch ==
'\xC2' && cptr[1] ==
'\xB0' )
309 if( sizeLeft >= 2 && ch ==
'u' && cptr[ 1 ] ==
'm' && !isalnum( cptr[ 2 ] ) )
315 if( sizeLeft >= 2 && ch ==
'm' && cptr[ 1 ] ==
'm' && !isalnum( cptr[ 2 ] ) )
321 if( sizeLeft >= 2 && ch ==
'c' && cptr[ 1 ] ==
'm' && !isalnum( cptr[ 2 ] ) )
327 if( sizeLeft >= 2 && ch ==
'i' && cptr[ 1 ] ==
'n' && !isalnum( cptr[ 2 ] ) )
333 if( sizeLeft >= 3 && ch ==
'm' && cptr[ 1 ] ==
'i' && cptr[ 2 ] ==
'l'
334 && !isalnum( cptr[ 3 ] ) )
340 if( sizeLeft >= 4 && ch ==
't' && cptr[ 1 ] ==
'h' && cptr[ 2 ] ==
'o'
341 && cptr[ 3 ] ==
'u' && !isalnum( cptr[ 4 ] ) )
348 && isOldSchoolDecimalSeparator( ch, siScaler ) )
370 double siScaler = 1.0;
377 else if( isdigit(
static_cast<unsigned char>( ch ) ) || isDecimalSeparator( ch ) )
381 extractNumber( &siScaler );
382 retval.
token = VALUE;
385 else if( ( convertFrom = checkUnit( &siScaler ) ) !=
Unit::Invalid )
397 switch( convertFrom )
410 switch( convertFrom )
423 switch( convertFrom )
443 else if( isalpha( ch ) )
449 while( isalnum( *cptr ) )
455 if( bytesToCopy >=
sizeof( retval.
value.
text ) )
456 bytesToCopy =
sizeof( retval.
value.
text ) - 1;
467 case '+': retval.
token = PLUS;
break;
468 case '-': retval.
token = MINUS;
break;
469 case '*': retval.
token = MULT;
break;
470 case '/': retval.
token = DIVIDE;
break;
471 case '(': retval.
token = PARENL;
break;
472 case ')': retval.
token = PARENR;
break;
473 case '=': retval.
token = ASSIGN;
break;
474 case ';': retval.
token = SEMCOL;
break;
void parseSetResult(double)
wxString OriginalText() const
struct NUMERIC_EVALUATOR::TokenStat m_token
void newString(const wxString &aString)
char m_localeDecimalSeparator
void parseError(const char *s)
double GetVar(const wxString &aString)
NUMERIC_EVALUATOR(EDA_UNITS aUnits)
void SetDefaultUnits(EDA_UNITS aUnits)
void SetVar(const wxString &aString, double aValue)
bool Process(const wxString &aString)
std::map< wxString, double > m_varMap
std::vector< FAB_LAYER_COLOR > dummy
std::string UIDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...