Base: Added Quantities for Optic/Chemical mechanics (#27944)
* Base: Added Quantities for Optic/Chemical mechanics * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -211,6 +211,9 @@ EXPO [eE][-+]?[0-9]+
|
||||
"h" COUNTCHARS; yylval.quantity.scaler = Quantity::Hour; yylval.quantity.unitStr = yytext; return UNIT; // hour
|
||||
|
||||
"A" COUNTCHARS; yylval.quantity.scaler = Quantity::Ampere; yylval.quantity.unitStr = yytext; return UNIT; // Ampere (internal standard electric current)
|
||||
"nA" COUNTCHARS; yylval.quantity.scaler = Quantity::NanoAmpere; yylval.quantity.unitStr = yytext; return UNIT; // nano Ampere
|
||||
"uA" COUNTCHARS; yylval.quantity.scaler = Quantity::MicroAmpere; yylval.quantity.unitStr = yytext; return UNIT; // micro Ampere
|
||||
"\xC2\xB5""A" COUNTCHARS; yylval.quantity.scaler = Quantity::MicroAmpere; yylval.quantity.unitStr = yytext; return UNIT; // micro Ampere
|
||||
"mA" COUNTCHARS; yylval.quantity.scaler = Quantity::MilliAmpere; yylval.quantity.unitStr = yytext; return UNIT; // milli Ampere
|
||||
"kA" COUNTCHARS; yylval.quantity.scaler = Quantity::KiloAmpere; yylval.quantity.unitStr = yytext; return UNIT; // kilo Ampere
|
||||
"MA" COUNTCHARS; yylval.quantity.scaler = Quantity::MegaAmpere; yylval.quantity.unitStr = yytext; return UNIT; // mega Ampere
|
||||
@@ -221,6 +224,9 @@ EXPO [eE][-+]?[0-9]+
|
||||
"uK" COUNTCHARS; yylval.quantity.scaler = Quantity::MicroKelvin; yylval.quantity.unitStr = yytext; return UNIT; // micro Kelvin
|
||||
|
||||
"mol" COUNTCHARS; yylval.quantity.scaler = Quantity::Mole; yylval.quantity.unitStr = yytext; return UNIT; // Mole (internal standard amount of substance)
|
||||
"nmol" COUNTCHARS; yylval.quantity.scaler = Quantity::NanoMole; yylval.quantity.unitStr = yytext; return UNIT; // nano Mole
|
||||
"\xC2\xB5mol" COUNTCHARS; yylval.quantity.scaler = Quantity::MicroMole; yylval.quantity.unitStr = yytext; return UNIT; // micro Mole
|
||||
"umol" COUNTCHARS; yylval.quantity.scaler = Quantity::MicroMole; yylval.quantity.unitStr = yytext; return UNIT; // micro Mole
|
||||
"mmol" COUNTCHARS; yylval.quantity.scaler = Quantity::MilliMole; yylval.quantity.unitStr = yytext; return UNIT; // milli Mole
|
||||
|
||||
"cd" COUNTCHARS; yylval.quantity.scaler = Quantity::Candela; yylval.quantity.unitStr = yytext; return UNIT; // Candela (internal standard luminous intensity)
|
||||
@@ -269,6 +275,9 @@ EXPO [eE][-+]?[0-9]+
|
||||
"Mpsi" COUNTCHARS; yylval.quantity.scaler = Quantity::MPSI; yylval.quantity.unitStr = yytext; return UNIT; // 1000 ksi
|
||||
|
||||
"W" COUNTCHARS; yylval.quantity.scaler = Quantity::Watt; yylval.quantity.unitStr = yytext; return UNIT; // Watt (kg*m^2/s^3)
|
||||
"nW" COUNTCHARS; yylval.quantity.scaler = Quantity::NanoWatt; yylval.quantity.unitStr = yytext; return UNIT; // nano Watt
|
||||
"uW" COUNTCHARS; yylval.quantity.scaler = Quantity::MicroWatt; yylval.quantity.unitStr = yytext; return UNIT; // micro Watt
|
||||
"\xC2\xB5W" COUNTCHARS; yylval.quantity.scaler = Quantity::MicroWatt; yylval.quantity.unitStr = yytext; return UNIT; // micro Watt
|
||||
"mW" COUNTCHARS; yylval.quantity.scaler = Quantity::MilliWatt; yylval.quantity.unitStr = yytext; return UNIT; // milli Watt
|
||||
"kW" COUNTCHARS; yylval.quantity.scaler = Quantity::KiloWatt; yylval.quantity.unitStr = yytext; return UNIT; // kilo Watt
|
||||
"VA" COUNTCHARS; yylval.quantity.scaler = Quantity::VoltAmpere; yylval.quantity.unitStr = yytext; return UNIT; // VoltAmpere (kg*m^2/s^3)
|
||||
|
||||
+6215
-6349
File diff suppressed because it is too large
Load Diff
+10
-178
@@ -70,7 +70,6 @@
|
||||
|
||||
|
||||
/* First part of user prologue. */
|
||||
#line 26 "Expression.y"
|
||||
|
||||
#define YYSTYPE App::ExpressionParser::semantic_type
|
||||
|
||||
@@ -79,7 +78,6 @@ std::stack<FunctionExpression::Function> functions; /**< Function
|
||||
#define yyparse ExpressionParser_yyparse
|
||||
#define yyerror ExpressionParser_yyerror
|
||||
|
||||
#line 80 "Expression.tab.c"
|
||||
|
||||
# ifndef YY_CAST
|
||||
# ifdef __cplusplus
|
||||
@@ -555,14 +553,14 @@ static const yytype_int8 yytranslate[] =
|
||||
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
||||
static const yytype_uint8 yyrline[] =
|
||||
{
|
||||
0, 81, 81, 82, 85, 86, 89, 90, 91, 92,
|
||||
93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
|
||||
103, 104, 105, 106, 107, 108, 109, 110, 111, 114,
|
||||
115, 116, 117, 119, 120, 121, 122, 123, 124, 127,
|
||||
131, 132, 134, 135, 136, 137, 138, 139, 140, 143,
|
||||
144, 148, 149, 153, 154, 158, 163, 168, 174, 181,
|
||||
188, 195, 199, 200, 201, 202, 203, 204, 205, 206,
|
||||
210, 211, 212, 216, 217, 221, 222
|
||||
0, 83, 83, 84, 87, 88, 91, 92, 93, 94,
|
||||
95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
|
||||
105, 106, 107, 108, 109, 110, 111, 112, 113, 116,
|
||||
117, 118, 119, 121, 122, 123, 124, 125, 126, 129,
|
||||
133, 134, 136, 137, 138, 139, 140, 141, 142, 145,
|
||||
146, 150, 151, 155, 156, 160, 165, 170, 176, 183,
|
||||
190, 197, 201, 202, 203, 204, 205, 206, 207, 208,
|
||||
212, 213, 214, 218, 219, 223, 224
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1007,45 +1005,31 @@ yydestruct (const char *yymsg,
|
||||
switch (yykind)
|
||||
{
|
||||
case YYSYMBOL_exp: /* exp */
|
||||
#line 73 "Expression.y"
|
||||
{ delete ((*yyvaluep).expr); }
|
||||
#line 1010 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case YYSYMBOL_num: /* num */
|
||||
#line 73 "Expression.y"
|
||||
{ delete ((*yyvaluep).expr); }
|
||||
#line 1016 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case YYSYMBOL_args: /* args */
|
||||
#line 75 "Expression.y"
|
||||
{ std::vector<Expression*>::const_iterator i = ((*yyvaluep).arguments).begin(); while (i != ((*yyvaluep).arguments).end()) { delete *i; ++i; } }
|
||||
#line 1022 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case YYSYMBOL_range: /* range */
|
||||
#line 73 "Expression.y"
|
||||
{ delete ((*yyvaluep).expr); }
|
||||
#line 1028 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case YYSYMBOL_unit_exp: /* unit_exp */
|
||||
#line 73 "Expression.y"
|
||||
{ delete ((*yyvaluep).expr); }
|
||||
#line 1034 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case YYSYMBOL_indexer: /* indexer */
|
||||
#line 74 "Expression.y"
|
||||
{ delete ((*yyvaluep).component); }
|
||||
#line 1040 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case YYSYMBOL_indexable: /* indexable */
|
||||
#line 73 "Expression.y"
|
||||
{ delete ((*yyvaluep).expr); }
|
||||
#line 1046 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1313,356 +1297,243 @@ yyreduce:
|
||||
switch (yyn)
|
||||
{
|
||||
case 2: /* input: exp */
|
||||
#line 81 "Expression.y"
|
||||
{ ScanResult = std::unique_ptr<Expression>(yyvsp[0].expr); valueExpression = true; }
|
||||
#line 1316 "Expression.tab.c"
|
||||
{ ScanResult = std::unique_ptr<Expression>((yyvsp[0].expr)); valueExpression = true; }
|
||||
break;
|
||||
|
||||
case 3: /* input: unit_exp */
|
||||
#line 82 "Expression.y"
|
||||
{ ScanResult = std::unique_ptr<Expression>(yyvsp[0].expr); unitExpression = true; }
|
||||
#line 1322 "Expression.tab.c"
|
||||
{ ScanResult = std::unique_ptr<Expression>((yyvsp[0].expr)); unitExpression = true; }
|
||||
break;
|
||||
|
||||
case 4: /* unit_num: num unit_exp */
|
||||
#line 85 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-1].expr), OperatorExpression::UNIT, (yyvsp[0].expr)); }
|
||||
#line 1328 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 5: /* unit_num: num us_building_unit num us_building_unit */
|
||||
#line 86 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, new OperatorExpression(DocumentObject, (yyvsp[-3].expr), OperatorExpression::UNIT, (yyvsp[-2].expr)), OperatorExpression::ADD, new OperatorExpression(DocumentObject, (yyvsp[-1].expr), OperatorExpression::UNIT, (yyvsp[0].expr)));}
|
||||
#line 1334 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 6: /* exp: num */
|
||||
#line 89 "Expression.y"
|
||||
{ (yyval.expr) = (yyvsp[0].expr); }
|
||||
#line 1340 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 7: /* exp: unit_num */
|
||||
#line 90 "Expression.y"
|
||||
{ (yyval.expr) = (yyvsp[0].expr); }
|
||||
#line 1346 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 8: /* exp: STRING */
|
||||
#line 91 "Expression.y"
|
||||
{ (yyval.expr) = new StringExpression(DocumentObject, (yyvsp[0].string)); }
|
||||
#line 1352 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 9: /* exp: identifier */
|
||||
#line 92 "Expression.y"
|
||||
{ (yyval.expr) = new VariableExpression(DocumentObject, (yyvsp[0].path)); }
|
||||
#line 1358 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 10: /* exp: MINUSSIGN exp */
|
||||
#line 93 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[0].expr), OperatorExpression::NEG, new NumberExpression(DocumentObject, Quantity(-1))); }
|
||||
#line 1364 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 11: /* exp: '+' exp */
|
||||
#line 94 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[0].expr), OperatorExpression::POS, new NumberExpression(DocumentObject, Quantity(1))); }
|
||||
#line 1370 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 12: /* exp: exp '+' exp */
|
||||
#line 95 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::ADD, (yyvsp[0].expr)); }
|
||||
#line 1376 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 13: /* exp: exp MINUSSIGN exp */
|
||||
#line 96 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::SUB, (yyvsp[0].expr)); }
|
||||
#line 1382 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 14: /* exp: exp '*' exp */
|
||||
#line 97 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::MUL, (yyvsp[0].expr)); }
|
||||
#line 1388 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 15: /* exp: exp '/' exp */
|
||||
#line 98 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::DIV, (yyvsp[0].expr)); }
|
||||
#line 1394 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 16: /* exp: exp '%' exp */
|
||||
#line 99 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::MOD, (yyvsp[0].expr)); }
|
||||
#line 1400 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 17: /* exp: exp '/' unit_exp */
|
||||
#line 100 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::DIV, (yyvsp[0].expr)); }
|
||||
#line 1406 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 18: /* exp: exp '^' exp */
|
||||
#line 101 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::POW, (yyvsp[0].expr)); }
|
||||
#line 1412 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 19: /* exp: exp EQ exp */
|
||||
#line 102 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::EQ, (yyvsp[0].expr)); }
|
||||
#line 1418 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 20: /* exp: exp NEQ exp */
|
||||
#line 103 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::NEQ, (yyvsp[0].expr)); }
|
||||
#line 1424 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 21: /* exp: exp LT exp */
|
||||
#line 104 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::LT, (yyvsp[0].expr)); }
|
||||
#line 1430 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 22: /* exp: exp GT exp */
|
||||
#line 105 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::GT, (yyvsp[0].expr)); }
|
||||
#line 1436 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 23: /* exp: exp GTE exp */
|
||||
#line 106 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::GTE, (yyvsp[0].expr)); }
|
||||
#line 1442 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 24: /* exp: exp LTE exp */
|
||||
#line 107 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::LTE, (yyvsp[0].expr)); }
|
||||
#line 1448 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 25: /* exp: indexable */
|
||||
#line 108 "Expression.y"
|
||||
{ (yyval.expr) = (yyvsp[0].expr); }
|
||||
#line 1454 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 26: /* exp: FUNC args ')' */
|
||||
#line 109 "Expression.y"
|
||||
{ (yyval.expr) = new FunctionExpression(DocumentObject, (yyvsp[-2].func).first, std::move((yyvsp[-2].func).second), (yyvsp[-1].arguments));}
|
||||
#line 1460 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 27: /* exp: exp '?' exp ':' exp */
|
||||
#line 110 "Expression.y"
|
||||
{ (yyval.expr) = new ConditionalExpression(DocumentObject, (yyvsp[-4].expr), (yyvsp[-2].expr), (yyvsp[0].expr)); }
|
||||
#line 1466 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 28: /* exp: '(' exp ')' */
|
||||
#line 111 "Expression.y"
|
||||
{ (yyval.expr) = (yyvsp[-1].expr); }
|
||||
#line 1472 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 29: /* num: ONE */
|
||||
#line 114 "Expression.y"
|
||||
{ (yyval.expr) = new NumberExpression(DocumentObject, Quantity((yyvsp[0].fvalue))); }
|
||||
#line 1478 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 30: /* num: NUM */
|
||||
#line 115 "Expression.y"
|
||||
{ (yyval.expr) = new NumberExpression(DocumentObject, Quantity((yyvsp[0].fvalue))); }
|
||||
#line 1484 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 31: /* num: INTEGER */
|
||||
#line 116 "Expression.y"
|
||||
{ (yyval.expr) = new NumberExpression(DocumentObject, Quantity((double)(yyvsp[0].ivalue))); }
|
||||
#line 1490 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 32: /* num: CONSTANT */
|
||||
#line 117 "Expression.y"
|
||||
{ (yyval.expr) = new ConstantExpression(DocumentObject, (yyvsp[0].constant).name, Quantity((yyvsp[0].constant).fvalue)); }
|
||||
#line 1496 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 33: /* args: exp */
|
||||
#line 119 "Expression.y"
|
||||
{ (yyval.arguments).push_back((yyvsp[0].expr)); }
|
||||
#line 1502 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 34: /* args: range */
|
||||
#line 120 "Expression.y"
|
||||
{ (yyval.arguments).push_back((yyvsp[0].expr)); }
|
||||
#line 1508 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 35: /* args: args ',' exp */
|
||||
#line 121 "Expression.y"
|
||||
{ (yyvsp[-2].arguments).push_back((yyvsp[0].expr)); (yyval.arguments) = (yyvsp[-2].arguments); }
|
||||
#line 1514 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 36: /* args: args ';' exp */
|
||||
#line 122 "Expression.y"
|
||||
{ (yyvsp[-2].arguments).push_back((yyvsp[0].expr)); (yyval.arguments) = (yyvsp[-2].arguments); }
|
||||
#line 1520 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 37: /* args: args ',' range */
|
||||
#line 123 "Expression.y"
|
||||
{ (yyvsp[-2].arguments).push_back((yyvsp[0].expr)); (yyval.arguments) = (yyvsp[-2].arguments); }
|
||||
#line 1526 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 38: /* args: args ';' range */
|
||||
#line 124 "Expression.y"
|
||||
{ (yyvsp[-2].arguments).push_back((yyvsp[0].expr)); (yyval.arguments) = (yyvsp[-2].arguments); }
|
||||
#line 1532 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 39: /* range: id_or_cell ':' id_or_cell */
|
||||
#line 127 "Expression.y"
|
||||
{ (yyval.expr) = new RangeExpression(DocumentObject, (yyvsp[-2].string), (yyvsp[0].string)); }
|
||||
#line 1538 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 40: /* us_building_unit: USUNIT */
|
||||
#line 131 "Expression.y"
|
||||
{ (yyval.expr) = new UnitExpression(DocumentObject, (yyvsp[0].quantity).scaler, (yyvsp[0].quantity).unitStr ); }
|
||||
#line 1544 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 41: /* other_unit: UNIT */
|
||||
#line 132 "Expression.y"
|
||||
{ (yyval.expr) = new UnitExpression(DocumentObject, (yyvsp[0].quantity).scaler, (yyvsp[0].quantity).unitStr ); }
|
||||
#line 1550 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 42: /* unit_exp: other_unit */
|
||||
#line 134 "Expression.y"
|
||||
{ (yyval.expr) = (yyvsp[0].expr); }
|
||||
#line 1556 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 43: /* unit_exp: us_building_unit */
|
||||
#line 135 "Expression.y"
|
||||
{ (yyval.expr) = (yyvsp[0].expr); }
|
||||
#line 1562 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 44: /* unit_exp: unit_exp '/' unit_exp */
|
||||
#line 136 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::DIV, (yyvsp[0].expr)); }
|
||||
#line 1568 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 45: /* unit_exp: unit_exp '*' unit_exp */
|
||||
#line 137 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::MUL, (yyvsp[0].expr)); }
|
||||
#line 1574 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 46: /* unit_exp: unit_exp '^' integer */
|
||||
#line 138 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::POW, new NumberExpression(DocumentObject, Quantity((double)(yyvsp[0].ivalue)))); }
|
||||
#line 1580 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 47: /* unit_exp: unit_exp '^' MINUSSIGN integer */
|
||||
#line 139 "Expression.y"
|
||||
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-3].expr), OperatorExpression::POW, new OperatorExpression(DocumentObject, new NumberExpression(DocumentObject, Quantity((double)(yyvsp[0].ivalue))), OperatorExpression::NEG, new NumberExpression(DocumentObject, Quantity(-1)))); }
|
||||
#line 1586 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 48: /* unit_exp: '(' unit_exp ')' */
|
||||
#line 140 "Expression.y"
|
||||
{ (yyval.expr) = (yyvsp[-1].expr); }
|
||||
#line 1592 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 49: /* integer: INTEGER */
|
||||
#line 143 "Expression.y"
|
||||
{ (yyval.ivalue) = (yyvsp[0].ivalue); }
|
||||
#line 1598 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 50: /* integer: ONE */
|
||||
#line 144 "Expression.y"
|
||||
{ (yyval.ivalue) = (yyvsp[0].fvalue); }
|
||||
#line 1604 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 51: /* id_or_cell: IDENTIFIER */
|
||||
#line 148 "Expression.y"
|
||||
{ (yyval.string) = std::move((yyvsp[0].string)); }
|
||||
#line 1610 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 52: /* id_or_cell: CELLADDRESS */
|
||||
#line 149 "Expression.y"
|
||||
{ (yyval.string) = std::move((yyvsp[0].string)); }
|
||||
#line 1616 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 53: /* identifier: id_or_cell */
|
||||
#line 153 "Expression.y"
|
||||
{ (yyval.path) = ObjectIdentifier(DocumentObject); (yyval.path) << ObjectIdentifier::SimpleComponent((yyvsp[0].string)); }
|
||||
#line 1622 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 54: /* identifier: iden */
|
||||
#line 154 "Expression.y"
|
||||
{ (yyval.path) = std::move((yyvsp[0].path)); }
|
||||
#line 1628 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 55: /* iden: '.' STRING '.' id_or_cell */
|
||||
#line 158 "Expression.y"
|
||||
{ /* Path to property of a sub-object of the current object*/
|
||||
(yyval.path) = ObjectIdentifier(DocumentObject,true);
|
||||
(yyval.path).setDocumentObjectName(DocumentObject,false,ObjectIdentifier::String(std::move((yyvsp[-2].string)),true),true);
|
||||
(yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
|
||||
}
|
||||
#line 1638 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 56: /* iden: '.' id_or_cell */
|
||||
#line 163 "Expression.y"
|
||||
{ /* Path to property of the current document object */
|
||||
(yyval.path) = ObjectIdentifier(DocumentObject,true);
|
||||
(yyval.path).setDocumentObjectName(DocumentObject);
|
||||
(yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
|
||||
}
|
||||
#line 1648 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 57: /* iden: object '.' STRING '.' id_or_cell */
|
||||
#line 168 "Expression.y"
|
||||
{ /* Path to property of a sub-object */
|
||||
(yyval.path) = ObjectIdentifier(DocumentObject);
|
||||
(yyval.path).setDocumentObjectName(std::move((yyvsp[-4].string_or_identifier)), true, ObjectIdentifier::String(std::move((yyvsp[-2].string)),true),true);
|
||||
(yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
|
||||
(yyval.path).resolveAmbiguity();
|
||||
}
|
||||
#line 1659 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 58: /* iden: object '.' id_or_cell */
|
||||
#line 174 "Expression.y"
|
||||
{ /* Path to property of a given document object */
|
||||
(yyval.path) = ObjectIdentifier(DocumentObject);
|
||||
(yyvsp[-2].string_or_identifier).checkImport(DocumentObject);
|
||||
@@ -1670,11 +1541,9 @@ yyreduce:
|
||||
(yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
|
||||
(yyval.path).resolveAmbiguity();
|
||||
}
|
||||
#line 1671 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 59: /* iden: document '#' object '.' id_or_cell */
|
||||
#line 181 "Expression.y"
|
||||
{ /* Path to property from an external document, within a named document object */
|
||||
(yyval.path) = ObjectIdentifier(DocumentObject);
|
||||
(yyval.path).setDocumentName(std::move((yyvsp[-4].string_or_identifier)), true);
|
||||
@@ -1682,118 +1551,82 @@ yyreduce:
|
||||
(yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
|
||||
(yyval.path).resolveAmbiguity();
|
||||
}
|
||||
#line 1683 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 60: /* iden: document '#' object '.' STRING '.' id_or_cell */
|
||||
#line 189 "Expression.y"
|
||||
{ (yyval.path) = ObjectIdentifier(DocumentObject);
|
||||
(yyval.path).setDocumentName(std::move((yyvsp[-6].string_or_identifier)), true);
|
||||
(yyval.path).setDocumentObjectName(std::move((yyvsp[-4].string_or_identifier)), true, ObjectIdentifier::String(std::move((yyvsp[-2].string)),true));
|
||||
(yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
|
||||
(yyval.path).resolveAmbiguity();
|
||||
}
|
||||
#line 1694 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 61: /* iden: iden '.' IDENTIFIER */
|
||||
#line 195 "Expression.y"
|
||||
{ (yyval.path)= std::move((yyvsp[-2].path)); (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string))); }
|
||||
#line 1700 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 62: /* indexer: '[' exp ']' */
|
||||
#line 199 "Expression.y"
|
||||
{ (yyval.component) = Expression::createComponent((yyvsp[-1].expr)); }
|
||||
#line 1706 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 63: /* indexer: '[' exp ':' ']' */
|
||||
#line 200 "Expression.y"
|
||||
{ (yyval.component) = Expression::createComponent((yyvsp[-2].expr),0,0,true); }
|
||||
#line 1712 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 64: /* indexer: '[' ':' exp ']' */
|
||||
#line 201 "Expression.y"
|
||||
{ (yyval.component) = Expression::createComponent(0,(yyvsp[-1].expr)); }
|
||||
#line 1718 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 65: /* indexer: '[' ':' ':' exp ']' */
|
||||
#line 202 "Expression.y"
|
||||
{ (yyval.component) = Expression::createComponent(0,0,(yyvsp[-1].expr)); }
|
||||
#line 1724 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 66: /* indexer: '[' exp ':' exp ']' */
|
||||
#line 203 "Expression.y"
|
||||
{ (yyval.component) = Expression::createComponent((yyvsp[-3].expr),(yyvsp[-1].expr));}
|
||||
#line 1730 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 67: /* indexer: '[' exp ':' ':' exp ']' */
|
||||
#line 204 "Expression.y"
|
||||
{ (yyval.component) = Expression::createComponent((yyvsp[-4].expr),0,(yyvsp[-1].expr)); }
|
||||
#line 1736 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 68: /* indexer: '[' ':' exp ':' exp ']' */
|
||||
#line 205 "Expression.y"
|
||||
{ (yyval.component) = Expression::createComponent(0,(yyvsp[-3].expr),(yyvsp[-1].expr)); }
|
||||
#line 1742 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 69: /* indexer: '[' exp ':' exp ':' exp ']' */
|
||||
#line 206 "Expression.y"
|
||||
{ (yyval.component) = Expression::createComponent((yyvsp[-5].expr),(yyvsp[-3].expr),(yyvsp[-1].expr));}
|
||||
#line 1748 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 70: /* indexable: identifier indexer */
|
||||
#line 210 "Expression.y"
|
||||
{ (yyval.expr) = new VariableExpression(DocumentObject,(yyvsp[-1].path)); (yyval.expr)->addComponent((yyvsp[0].component)); }
|
||||
#line 1754 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 71: /* indexable: indexable indexer */
|
||||
#line 211 "Expression.y"
|
||||
{ (yyvsp[-1].expr)->addComponent(std::move((yyvsp[0].component))); (yyval.expr) = (yyvsp[-1].expr); }
|
||||
#line 1760 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 72: /* indexable: indexable '.' IDENTIFIER */
|
||||
#line 212 "Expression.y"
|
||||
{ (yyvsp[-2].expr)->addComponent(Expression::createComponent((yyvsp[0].string))); (yyval.expr) = (yyvsp[-2].expr); }
|
||||
#line 1766 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 73: /* document: STRING */
|
||||
#line 216 "Expression.y"
|
||||
{ (yyval.string_or_identifier) = ObjectIdentifier::String(std::move((yyvsp[0].string)), true); }
|
||||
#line 1772 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 74: /* document: IDENTIFIER */
|
||||
#line 217 "Expression.y"
|
||||
{ (yyval.string_or_identifier) = ObjectIdentifier::String(std::move((yyvsp[0].string)), false, true);}
|
||||
#line 1778 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 75: /* object: STRING */
|
||||
#line 221 "Expression.y"
|
||||
{ (yyval.string_or_identifier) = ObjectIdentifier::String(std::move((yyvsp[0].string)), true); }
|
||||
#line 1784 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
case 76: /* object: id_or_cell */
|
||||
#line 222 "Expression.y"
|
||||
{ (yyval.string_or_identifier) = ObjectIdentifier::String(std::move((yyvsp[0].string)), false);}
|
||||
#line 1790 "Expression.tab.c"
|
||||
break;
|
||||
|
||||
|
||||
#line 1794 "Expression.tab.c"
|
||||
|
||||
default: break;
|
||||
}
|
||||
@@ -1986,5 +1819,4 @@ yyreturnlab:
|
||||
return yyresult;
|
||||
}
|
||||
|
||||
#line 225 "Expression.y"
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
// clang-format off
|
||||
/* A Bison parser, made by GNU Bison 3.8.2. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
@@ -37,7 +38,8 @@
|
||||
especially those whose name start with YY_ or yy_. They are
|
||||
private implementation details that can be changed or removed. */
|
||||
|
||||
#pragma once
|
||||
#ifndef YY_YY_EXPRESSION_TAB_H_INCLUDED
|
||||
# define YY_YY_EXPRESSION_TAB_H_INCLUDED
|
||||
/* Debug traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 0
|
||||
@@ -90,3 +92,6 @@ extern YYSTYPE yylval;
|
||||
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
|
||||
#endif /* !YY_YY_EXPRESSION_TAB_H_INCLUDED */
|
||||
|
||||
@@ -456,6 +456,8 @@ App.Units.Minute = App.Units.Quantity('min')
|
||||
App.Units.Hour = App.Units.Quantity('h')
|
||||
|
||||
App.Units.Ampere = App.Units.Quantity('A')
|
||||
App.Units.NanoAmpere = App.Units.Quantity('nA')
|
||||
App.Units.MicroAmpere = App.Units.Quantity('uA')
|
||||
App.Units.MilliAmpere = App.Units.Quantity('mA')
|
||||
App.Units.KiloAmpere = App.Units.Quantity('kA')
|
||||
App.Units.MegaAmpere = App.Units.Quantity('MA')
|
||||
@@ -464,8 +466,10 @@ App.Units.Kelvin = App.Units.Quantity('K')
|
||||
App.Units.MilliKelvin = App.Units.Quantity('mK')
|
||||
App.Units.MicroKelvin = App.Units.Quantity('uK')
|
||||
|
||||
App.Units.MilliMole = App.Units.Quantity('mmol')
|
||||
App.Units.Mole = App.Units.Quantity('mol')
|
||||
App.Units.NanoMole = App.Units.Quantity('nmol')
|
||||
App.Units.MicroMole = App.Units.Quantity('umol')
|
||||
App.Units.MilliMole = App.Units.Quantity('mmol')
|
||||
|
||||
App.Units.Candela = App.Units.Quantity('cd')
|
||||
|
||||
@@ -511,6 +515,8 @@ App.Units.KSI = App.Units.Quantity('ksi')
|
||||
App.Units.MPSI = App.Units.Quantity('Mpsi')
|
||||
|
||||
App.Units.Watt = App.Units.Quantity('W')
|
||||
App.Units.NanoWatt = App.Units.Quantity('nW')
|
||||
App.Units.MicroWatt = App.Units.Quantity('uW')
|
||||
App.Units.MilliWatt = App.Units.Quantity('mW')
|
||||
App.Units.KiloWatt = App.Units.Quantity('kW')
|
||||
App.Units.VoltAmpere = App.Units.Quantity('VA')
|
||||
|
||||
@@ -359,6 +359,8 @@ const Quantity Quantity::Minute ( 60.0 , Unit::
|
||||
const Quantity Quantity::Hour ( 3600.0 , Unit::TimeSpan );
|
||||
|
||||
const Quantity Quantity::Ampere ( 1.0 , Unit::ElectricCurrent );
|
||||
const Quantity Quantity::NanoAmpere ( 1.0e-9 , Unit::ElectricCurrent );
|
||||
const Quantity Quantity::MicroAmpere ( 1.0e-6 , Unit::ElectricCurrent );
|
||||
const Quantity Quantity::MilliAmpere ( 0.001 , Unit::ElectricCurrent );
|
||||
const Quantity Quantity::KiloAmpere ( 1000.0 , Unit::ElectricCurrent );
|
||||
const Quantity Quantity::MegaAmpere ( 1.0e6 , Unit::ElectricCurrent );
|
||||
@@ -367,6 +369,8 @@ const Quantity Quantity::Kelvin ( 1.0 , Unit::
|
||||
const Quantity Quantity::MilliKelvin ( 0.001 , Unit::Temperature );
|
||||
const Quantity Quantity::MicroKelvin ( 0.000001 , Unit::Temperature );
|
||||
|
||||
const Quantity Quantity::NanoMole ( 1e-9 , Unit::AmountOfSubstance );
|
||||
const Quantity Quantity::MicroMole ( 1e-6 , Unit::AmountOfSubstance );
|
||||
const Quantity Quantity::MilliMole ( 0.001 , Unit::AmountOfSubstance );
|
||||
const Quantity Quantity::Mole ( 1.0 , Unit::AmountOfSubstance );
|
||||
|
||||
@@ -417,6 +421,8 @@ const Quantity Quantity::KSI ( psi * 1000 , Unit::
|
||||
const Quantity Quantity::MPSI ( psi * 1000000 , Unit::Pressure );
|
||||
|
||||
const Quantity Quantity::Watt ( 1e+6 , Unit::Power ); // Watt (kg*m^2/s^3)
|
||||
const Quantity Quantity::NanoWatt ( 1e-3 , Unit::Power );
|
||||
const Quantity Quantity::MicroWatt ( 1.0 , Unit::Power );
|
||||
const Quantity Quantity::MilliWatt ( 1e+3 , Unit::Power );
|
||||
const Quantity Quantity::KiloWatt ( 1e+9 , Unit::Power );
|
||||
const Quantity Quantity::VoltAmpere ( 1e+6 , Unit::Power ); // VoltAmpere (kg*m^2/s^3)
|
||||
|
||||
@@ -224,6 +224,8 @@ public:
|
||||
static const Quantity Hour;
|
||||
|
||||
static const Quantity Ampere;
|
||||
static const Quantity NanoAmpere;
|
||||
static const Quantity MicroAmpere;
|
||||
static const Quantity MilliAmpere;
|
||||
static const Quantity KiloAmpere;
|
||||
static const Quantity MegaAmpere;
|
||||
@@ -232,6 +234,8 @@ public:
|
||||
static const Quantity MilliKelvin;
|
||||
static const Quantity MicroKelvin;
|
||||
|
||||
static const Quantity NanoMole;
|
||||
static const Quantity MicroMole;
|
||||
static const Quantity MilliMole;
|
||||
static const Quantity Mole;
|
||||
|
||||
@@ -282,6 +286,8 @@ public:
|
||||
static const Quantity MPSI;
|
||||
|
||||
static const Quantity Watt;
|
||||
static const Quantity NanoWatt;
|
||||
static const Quantity MicroWatt;
|
||||
static const Quantity MilliWatt;
|
||||
static const Quantity KiloWatt;
|
||||
static const Quantity VoltAmpere;
|
||||
|
||||
@@ -93,6 +93,9 @@ CGRP '\,'[0-9][0-9][0-9]
|
||||
"h" yylval = Quantity::Hour; return UNIT; // hour
|
||||
|
||||
"A" yylval = Quantity::Ampere; return UNIT; // Ampere (internal standard electric current)
|
||||
"nA" yylval = Quantity::NanoAmpere; return UNIT; // nano Ampere
|
||||
"uA" yylval = Quantity::MicroAmpere; return UNIT; // micro Ampere
|
||||
"\xC2\xB5""A" yylval = Quantity::MicroAmpere; return UNIT; // micro Ampere
|
||||
"mA" yylval = Quantity::MilliAmpere; return UNIT; // milli Ampere
|
||||
"kA" yylval = Quantity::KiloAmpere; return UNIT; // kilo Ampere
|
||||
"MA" yylval = Quantity::MegaAmpere; return UNIT; // mega Ampere
|
||||
@@ -103,6 +106,9 @@ CGRP '\,'[0-9][0-9][0-9]
|
||||
"uK" yylval = Quantity::MicroKelvin; return UNIT; // micro Kelvin
|
||||
|
||||
"mol" yylval = Quantity::Mole; return UNIT; // Mole (internal standard amount of substance)
|
||||
"nmol" yylval = Quantity::NanoMole; return UNIT; // Nano Mole
|
||||
"umol" yylval = Quantity::MicroMole; return UNIT; // Micro Mole
|
||||
"\xC2\xB5mol" yylval = Quantity::MicroMole; return UNIT; // Micro Mole
|
||||
"mmol" yylval = Quantity::MilliMole; return UNIT; // Milli Mole
|
||||
|
||||
"cd" yylval = Quantity::Candela; return UNIT; // Candela (internal standard luminous intensity)
|
||||
@@ -151,6 +157,9 @@ CGRP '\,'[0-9][0-9][0-9]
|
||||
"Mpsi" yylval = Quantity::MPSI; return UNIT; // 1000 ksi
|
||||
|
||||
"W" yylval = Quantity::Watt; return UNIT; // Watt (kg*m^2/s^3)
|
||||
"nW" yylval = Quantity::NanoWatt; return UNIT; // milli Watt
|
||||
"uW" yylval = Quantity::MicroWatt; return UNIT; // micro Watt
|
||||
"\xC2\xB5W" yylval = Quantity::MicroWatt; return UNIT; // micro Watt
|
||||
"mW" yylval = Quantity::MilliWatt; return UNIT; // milli Watt
|
||||
"kW" yylval = Quantity::KiloWatt; return UNIT; // kilo Watt
|
||||
"VA" yylval = Quantity::VoltAmpere; return UNIT; // VoltAmpere (kg*m^2/s^3)
|
||||
|
||||
+330
-457
File diff suppressed because it is too large
Load Diff
@@ -70,13 +70,11 @@
|
||||
|
||||
|
||||
/* First part of user prologue. */
|
||||
#line 26 "Quantity.y"
|
||||
|
||||
#define YYSTYPE Quantity
|
||||
#define yyparse Quantity_yyparse
|
||||
#define yyerror Quantity_yyerror
|
||||
|
||||
#line 77 "Quantity.tab.c"
|
||||
|
||||
# ifndef YY_CAST
|
||||
# ifdef __cplusplus
|
||||
@@ -1225,223 +1223,150 @@ yyreduce:
|
||||
switch (yyn)
|
||||
{
|
||||
case 2: /* input: %empty */
|
||||
#line 45 "Quantity.y"
|
||||
{ QuantResult = Quantity(std::numeric_limits<double>::min()); /* empty input */ }
|
||||
#line 1228 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 3: /* input: num */
|
||||
#line 46 "Quantity.y"
|
||||
{ QuantResult = yyvsp[0]; }
|
||||
#line 1234 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 4: /* input: unit */
|
||||
#line 47 "Quantity.y"
|
||||
{ QuantResult = yyvsp[0]; }
|
||||
#line 1240 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 5: /* input: quantity */
|
||||
#line 48 "Quantity.y"
|
||||
{ QuantResult = yyvsp[0]; }
|
||||
#line 1246 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 6: /* input: quantity quantity */
|
||||
#line 49 "Quantity.y"
|
||||
{ QuantResult = yyvsp[-1] + yyvsp[0]; }
|
||||
#line 1252 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 7: /* input: quantity quantity quantity */
|
||||
#line 50 "Quantity.y"
|
||||
{ QuantResult = yyvsp[-2] + yyvsp[-1] + yyvsp[0]; }
|
||||
#line 1258 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 8: /* num: NUM */
|
||||
#line 52 "Quantity.y"
|
||||
{ yyval = yyvsp[0]; }
|
||||
#line 1264 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 9: /* num: ONE */
|
||||
#line 53 "Quantity.y"
|
||||
{ yyval = yyvsp[0]; }
|
||||
#line 1270 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 10: /* num: num '+' num */
|
||||
#line 54 "Quantity.y"
|
||||
{ yyval = Quantity(yyvsp[-2].getValue() + yyvsp[0].getValue()); }
|
||||
#line 1276 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 11: /* num: num MINUSSIGN num */
|
||||
#line 55 "Quantity.y"
|
||||
{ yyval = Quantity(yyvsp[-2].getValue() - yyvsp[0].getValue()); }
|
||||
#line 1282 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 12: /* num: num '*' num */
|
||||
#line 56 "Quantity.y"
|
||||
{ yyval = Quantity(yyvsp[-2].getValue() * yyvsp[0].getValue()); }
|
||||
#line 1288 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 13: /* num: num '/' num */
|
||||
#line 57 "Quantity.y"
|
||||
{ yyval = Quantity(yyvsp[-2].getValue() / yyvsp[0].getValue()); }
|
||||
#line 1294 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 14: /* num: MINUSSIGN num */
|
||||
#line 58 "Quantity.y"
|
||||
{ yyval = Quantity(-yyvsp[0].getValue()); }
|
||||
#line 1300 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 15: /* num: num '^' num */
|
||||
#line 59 "Quantity.y"
|
||||
{ yyval = Quantity(pow(yyvsp[-2].getValue(), yyvsp[0].getValue())); }
|
||||
#line 1306 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 16: /* num: '(' num ')' */
|
||||
#line 60 "Quantity.y"
|
||||
{ yyval = yyvsp[-1]; }
|
||||
#line 1312 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 17: /* num: ACOS '(' num ')' */
|
||||
#line 61 "Quantity.y"
|
||||
{ yyval = Quantity(acos(yyvsp[-1].getValue())); }
|
||||
#line 1318 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 18: /* num: ASIN '(' num ')' */
|
||||
#line 62 "Quantity.y"
|
||||
{ yyval = Quantity(asin(yyvsp[-1].getValue())); }
|
||||
#line 1324 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 19: /* num: ATAN '(' num ')' */
|
||||
#line 63 "Quantity.y"
|
||||
{ yyval = Quantity(atan(yyvsp[-1].getValue())); }
|
||||
#line 1330 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 20: /* num: ABS '(' num ')' */
|
||||
#line 64 "Quantity.y"
|
||||
{ yyval = Quantity(fabs(yyvsp[-1].getValue())); }
|
||||
#line 1336 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 21: /* num: EXP '(' num ')' */
|
||||
#line 65 "Quantity.y"
|
||||
{ yyval = Quantity(exp(yyvsp[-1].getValue())); }
|
||||
#line 1342 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 22: /* num: LOG '(' num ')' */
|
||||
#line 66 "Quantity.y"
|
||||
{ yyval = Quantity(log(yyvsp[-1].getValue())); }
|
||||
#line 1348 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 23: /* num: LOG10 '(' num ')' */
|
||||
#line 67 "Quantity.y"
|
||||
{ yyval = Quantity(log10(yyvsp[-1].getValue())); }
|
||||
#line 1354 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 24: /* num: SIN '(' num ')' */
|
||||
#line 68 "Quantity.y"
|
||||
{ yyval = Quantity(sin(yyvsp[-1].getValue())); }
|
||||
#line 1360 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 25: /* num: SINH '(' num ')' */
|
||||
#line 69 "Quantity.y"
|
||||
{ yyval = Quantity(sinh(yyvsp[-1].getValue())); }
|
||||
#line 1366 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 26: /* num: TAN '(' num ')' */
|
||||
#line 70 "Quantity.y"
|
||||
{ yyval = Quantity(tan(yyvsp[-1].getValue())); }
|
||||
#line 1372 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 27: /* num: TANH '(' num ')' */
|
||||
#line 71 "Quantity.y"
|
||||
{ yyval = Quantity(tanh(yyvsp[-1].getValue())); }
|
||||
#line 1378 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 28: /* num: SQRT '(' num ')' */
|
||||
#line 72 "Quantity.y"
|
||||
{ yyval = Quantity(sqrt(yyvsp[-1].getValue())); }
|
||||
#line 1384 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 29: /* num: COS '(' num ')' */
|
||||
#line 73 "Quantity.y"
|
||||
{ yyval = Quantity(cos(yyvsp[-1].getValue())); }
|
||||
#line 1390 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 30: /* unit: UNIT */
|
||||
#line 76 "Quantity.y"
|
||||
{ yyval = yyvsp[0]; }
|
||||
#line 1396 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 31: /* unit: ONE '/' unit */
|
||||
#line 77 "Quantity.y"
|
||||
{ yyval = Quantity(1.0)/yyvsp[0]; }
|
||||
#line 1402 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 32: /* unit: unit '*' unit */
|
||||
#line 78 "Quantity.y"
|
||||
{ yyval = yyvsp[-2] * yyvsp[0]; }
|
||||
#line 1408 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 33: /* unit: unit '/' unit */
|
||||
#line 79 "Quantity.y"
|
||||
{ yyval = yyvsp[-2] / yyvsp[0]; }
|
||||
#line 1414 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 34: /* unit: unit '^' num */
|
||||
#line 80 "Quantity.y"
|
||||
{ yyval = yyvsp[-2].pow (yyvsp[0]); }
|
||||
#line 1420 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 35: /* unit: '(' unit ')' */
|
||||
#line 81 "Quantity.y"
|
||||
{ yyval = yyvsp[-1]; }
|
||||
#line 1426 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 36: /* quantity: num unit */
|
||||
#line 83 "Quantity.y"
|
||||
{ yyval = yyvsp[-1]*yyvsp[0]; }
|
||||
#line 1432 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
case 37: /* quantity: num '/' unit */
|
||||
#line 84 "Quantity.y"
|
||||
{ yyval = Quantity(yyvsp[-2])/yyvsp[0]; }
|
||||
#line 1438 "Quantity.tab.c"
|
||||
break;
|
||||
|
||||
|
||||
#line 1442 "Quantity.tab.c"
|
||||
|
||||
default: break;
|
||||
}
|
||||
@@ -1633,5 +1558,3 @@ yyreturnlab:
|
||||
|
||||
return yyresult;
|
||||
}
|
||||
|
||||
#line 87 "Quantity.y"
|
||||
|
||||
@@ -102,6 +102,7 @@ constexpr auto unitSpecs = std::to_array<UnitSpec>({
|
||||
{ "VacuumPermittivity" , { -3, -1, 4, 2 } },
|
||||
{ "Velocity" , { 1, 0, -1 } },
|
||||
{ "Volume" , { 3 } },
|
||||
{ "Concentration" , { -3, 0, 0, 0, 0, 1 } },
|
||||
{ "VolumeChargeDensity" , { -3, 0, 1, 1 } },
|
||||
{ "VolumeFlowRate" , { 3, 0, -1 } },
|
||||
{ "VolumetricThermalExpansionCoefficient" , { 0, 0, 0, 0, -1 } },
|
||||
@@ -327,6 +328,7 @@ constexpr Unit Unit::Angle = make("Angle"
|
||||
constexpr Unit Unit::Acceleration = make("Acceleration" );
|
||||
constexpr Unit Unit::AngleOfFriction = make("Angle" );
|
||||
constexpr Unit Unit::Area = make("Area" );
|
||||
constexpr Unit Unit::Concentration = make("Concentration" );
|
||||
constexpr Unit Unit::CompressiveStrength = make("Pressure" );
|
||||
constexpr Unit Unit::CurrentDensity = make("CurrentDensity" );
|
||||
constexpr Unit Unit::Density = make("Density" );
|
||||
|
||||
@@ -120,6 +120,7 @@ public:
|
||||
static const Unit AngleOfFriction;
|
||||
static const Unit Area;
|
||||
static const Unit CompressiveStrength;
|
||||
static const Unit Concentration;
|
||||
static const Unit CurrentDensity;
|
||||
static const Unit Density;
|
||||
static const Unit DissipationRate;
|
||||
|
||||
@@ -112,6 +112,12 @@ inline const UnitsSchemaSpec s3
|
||||
{ "Angle", {
|
||||
{ 0 , "°" , 1.0 }}
|
||||
},
|
||||
{ "ElectricCurrent", {
|
||||
{ 1e-6 , "nA" , 1e-9 },
|
||||
{ 1e-3 , "\xC2\xB5""A", 1e-6 },
|
||||
{ 1 , "mA" , 1e-3 },
|
||||
{ 0 , "A" , 1.0 }}
|
||||
},
|
||||
{ "Mass", {
|
||||
{ 1e-6 , "\xC2\xB5g" , 1e-9 },
|
||||
{ 1e-3 , "mg" , 1e-6 },
|
||||
@@ -124,6 +130,17 @@ inline const UnitsSchemaSpec s3
|
||||
{ 1.0 , "kg/cm^3" , 1e-3 },
|
||||
{ 0 , "kg/mm^3" , 1.0 }}
|
||||
},
|
||||
{ "Concentration", {
|
||||
{ 1e-9 , "\xC2\xB5mol/l", 1e-12 },
|
||||
{ 1e-6 , "mmol/l" , 1e-9 },
|
||||
{ 0 , "mol/l" , 1e-6 }}
|
||||
},
|
||||
{ "AmountOfSubstance", {
|
||||
{ 1e-6 , "nmol" , 1e-9 },
|
||||
{ 1e-3 , "\xC2\xB5mol", 1e-6 },
|
||||
{ 1 , "mmol" , 1e-3 },
|
||||
{ 0 , "mol" , 1.0 }}
|
||||
},
|
||||
{ "ThermalConductivity", {
|
||||
{ 1e6 , "W/m/K" , 1e3 },
|
||||
{ 0 , "W/mm/K" , 1e6 }}
|
||||
@@ -175,6 +192,8 @@ inline const UnitsSchemaSpec s3
|
||||
{ 0 , "MN" , 1e9 }}
|
||||
},
|
||||
{ "Power", {
|
||||
{ 1 , "nW" , 1e-3 },
|
||||
{ 1e3 , "\xC2\xB5W" , 1 },
|
||||
{ 1e6 , "mW" , 1e3 },
|
||||
{ 1e9 , "W" , 1e6 },
|
||||
{ 0 , "kW" , 1e9 }}
|
||||
|
||||
@@ -254,6 +254,47 @@ TEST_F(SchemaTest, internal_20000_mm_precision_2)
|
||||
EXPECT_EQ(result, expect);
|
||||
}
|
||||
|
||||
TEST_F(SchemaTest, internal_20nA_precision_0)
|
||||
{
|
||||
const std::string result = setWithPrecision("Internal", 20 * 1e-9, Unit::ElectricCurrent, 0);
|
||||
const auto expect {"20 nA"};
|
||||
|
||||
EXPECT_EQ(result, expect);
|
||||
}
|
||||
|
||||
TEST_F(SchemaTest, internal_100uA_precision_0)
|
||||
{
|
||||
const std::string result = setWithPrecision("Internal", 100 * 1e-6, Unit::ElectricCurrent, 0);
|
||||
const auto expect {"100 \xC2\xB5"
|
||||
"A"};
|
||||
|
||||
EXPECT_EQ(result, expect);
|
||||
}
|
||||
|
||||
TEST_F(SchemaTest, internal_20nW_precision_0)
|
||||
{
|
||||
const std::string result = setWithPrecision("Internal", 0.2, Unit::Power, 0);
|
||||
const auto expect {"200 nW"};
|
||||
|
||||
EXPECT_EQ(result, expect);
|
||||
}
|
||||
|
||||
TEST_F(SchemaTest, internal_20uW_precision_0)
|
||||
{
|
||||
const std::string result = setWithPrecision("Internal", 20, Unit::Power, 0);
|
||||
const auto expect {"20 \xC2\xB5W"};
|
||||
|
||||
EXPECT_EQ(result, expect);
|
||||
}
|
||||
|
||||
TEST_F(SchemaTest, internal_1mol_p_l_precision_1)
|
||||
{
|
||||
const std::string result = setWithPrecision("Internal", 1e-6, Unit::Concentration, 1);
|
||||
const auto expect {"1.0 mol/l"};
|
||||
|
||||
EXPECT_EQ(result, expect);
|
||||
}
|
||||
|
||||
TEST_F(SchemaTest, imperial_decimal_1_mm_precision_0)
|
||||
{
|
||||
const std::string result = setWithPrecision("ImperialDecimal", 1.0, Unit::Length, 0);
|
||||
@@ -557,6 +598,7 @@ TEST_F(SchemaTest, round_trip_test)
|
||||
Unit::Area,
|
||||
Unit::Density,
|
||||
Unit::Volume,
|
||||
Unit::Concentration,
|
||||
Unit::TimeSpan,
|
||||
Unit::Frequency,
|
||||
Unit::Velocity,
|
||||
@@ -775,6 +817,36 @@ TEST_F(SchemaTest, sweep_internal)
|
||||
"1 m^3",
|
||||
"10 m^3",
|
||||
/* default */ "1e+06 m^3"},
|
||||
// Amount of Substance
|
||||
{"1 nmol",
|
||||
"1 \xC2\xB5mol",
|
||||
"10 mmol",
|
||||
"100 mol",
|
||||
/* default */ "1e+06 mol"},
|
||||
// Concentration
|
||||
{"1 \xC2\xB5mol/l",
|
||||
"10 \xC2\xB5mol/l",
|
||||
"100 \xC2\xB5mol/l",
|
||||
"1 mmol/l",
|
||||
"10 mmol/l",
|
||||
"100 mmol/l",
|
||||
"1 mol/l",
|
||||
/* default */ "1e+06 mol/l"},
|
||||
// ElectricCurrent
|
||||
{"1 nA",
|
||||
"10 nA",
|
||||
"100 nA",
|
||||
"1 \xC2\xB5"
|
||||
"A",
|
||||
"10 \xC2\xB5"
|
||||
"A",
|
||||
"100 \xC2\xB5"
|
||||
"A",
|
||||
"1 mA",
|
||||
"1 A",
|
||||
"10 A",
|
||||
"100 A",
|
||||
/* default */ "1e+07 A"},
|
||||
// Pressure
|
||||
{"1 Pa",
|
||||
"10 Pa",
|
||||
@@ -804,7 +876,13 @@ TEST_F(SchemaTest, sweep_internal)
|
||||
"10 MN",
|
||||
/* default */ "1e+06 MN"},
|
||||
// Power
|
||||
{"1 mW",
|
||||
{"1 nW",
|
||||
"10 nW",
|
||||
"100 nW",
|
||||
"1 \xC2\xB5W",
|
||||
"10 \xC2\xB5W",
|
||||
"100 \xC2\xB5W",
|
||||
"1 mW",
|
||||
"10 mW",
|
||||
"100 mW",
|
||||
"1 W",
|
||||
|
||||
Reference in New Issue
Block a user