From 4b99ee28ce116f6ecaa3db02c2dac3d6e35e7a97 Mon Sep 17 00:00:00 2001 From: donovaly Date: Wed, 18 Dec 2019 00:37:48 +0100 Subject: [PATCH] generate QuantityLexer.c - also set proper unit conversions - fix MilliWatt and MilliMole --- src/Base/Quantity.cpp | 1 + src/Base/Quantity.h | 1 + src/Base/QuantityLexer.c | 874 ++++++++++++++++++------------- src/Base/QuantityParser.l | 9 +- src/Base/UnitsSchemaInternal.cpp | 124 ++++- src/Base/UnitsSchemaMKS.cpp | 40 +- 6 files changed, 661 insertions(+), 388 deletions(-) diff --git a/src/Base/Quantity.cpp b/src/Base/Quantity.cpp index 4e6cecc7fb..58a08cc11f 100644 --- a/src/Base/Quantity.cpp +++ b/src/Base/Quantity.cpp @@ -312,6 +312,7 @@ Quantity Quantity::PSI (6.894744825494,Unit(-1,1,-2)); // pounds/in Quantity Quantity::KSI (6894.744825494,Unit(-1,1,-2)); // 1000 x pounds/in^2 Quantity Quantity::Watt (1e+6 ,Unit(2,1,-3)); // Watt (kg*m^2/s^3) +Quantity Quantity::MilliWatt (1e+3 ,Unit(2,1,-3)); Quantity Quantity::VoltAmpere (1e+6 ,Unit(2,1,-3)); // VoltAmpere (kg*m^2/s^3) Quantity Quantity::Volt (1e+6 ,Unit(2,1,-3,-1)); // Volt (kg*m^2/A/s^3) diff --git a/src/Base/Quantity.h b/src/Base/Quantity.h index 97a09c119f..1273d12b34 100644 --- a/src/Base/Quantity.h +++ b/src/Base/Quantity.h @@ -252,6 +252,7 @@ public: static Quantity KSI; static Quantity Watt; + static Quantity MilliWatt; static Quantity VoltAmpere; static Quantity Volt; diff --git a/src/Base/QuantityLexer.c b/src/Base/QuantityLexer.c index ec0c82b083..75e1a27b52 100644 --- a/src/Base/QuantityLexer.c +++ b/src/Base/QuantityLexer.c @@ -1,6 +1,6 @@ -#line 2 "QuantityLexer.c" +#line 1 "QuantityLexer.c" -#line 4 "QuantityLexer.c" +#line 3 "QuantityLexer.c" #define YY_INT_ALIGNED short int @@ -353,8 +353,8 @@ static void yynoreturn yy_fatal_error ( const char* msg ); (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 109 -#define YY_END_OF_BUFFER 110 +#define YY_NUM_RULES 132 +#define YY_END_OF_BUFFER 133 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -362,31 +362,33 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[202] = +static const flex_int16_t yy_accept[228] = { 0, - 0, 0, 0, 0, 110, 108, 4, 5, 42, 44, - 6, 108, 7, 108, 86, 85, 31, 108, 108, 108, - 72, 35, 81, 55, 108, 83, 108, 71, 69, 1, - 108, 108, 108, 91, 108, 25, 30, 108, 108, 17, - 15, 108, 108, 108, 108, 28, 27, 108, 108, 108, - 108, 3, 109, 2, 5, 89, 87, 88, 86, 86, - 0, 75, 0, 0, 18, 34, 0, 57, 0, 73, - 59, 0, 70, 76, 0, 0, 0, 0, 40, 13, - 0, 0, 0, 14, 0, 43, 0, 41, 33, 0, - 56, 0, 26, 16, 0, 49, 0, 32, 36, 58, + 0, 0, 0, 0, 133, 131, 4, 5, 44, 46, + 6, 131, 7, 131, 109, 108, 32, 79, 81, 131, + 87, 92, 36, 104, 57, 131, 106, 80, 76, 73, + 1, 131, 131, 131, 131, 114, 131, 26, 31, 131, + 131, 17, 15, 131, 131, 131, 131, 29, 28, 131, + 131, 131, 131, 3, 132, 2, 5, 112, 110, 111, + 109, 109, 0, 96, 0, 0, 19, 35, 0, 59, + 0, 94, 61, 0, 75, 97, 0, 0, 0, 0, + 0, 42, 13, 0, 0, 0, 14, 99, 0, 45, + 0, 43, 34, 0, 93, 58, 0, 77, 0, 27, - 0, 24, 48, 12, 0, 9, 51, 90, 0, 0, - 0, 0, 0, 52, 0, 0, 38, 0, 22, 10, - 47, 77, 0, 0, 0, 0, 0, 88, 0, 86, - 0, 0, 86, 21, 62, 20, 61, 0, 74, 98, - 0, 0, 0, 96, 53, 78, 97, 80, 19, 60, - 68, 54, 50, 100, 0, 46, 29, 99, 39, 102, - 67, 79, 103, 0, 105, 0, 0, 37, 0, 23, - 11, 82, 84, 8, 0, 89, 0, 87, 0, 88, - 0, 86, 63, 92, 93, 94, 0, 0, 104, 107, - 106, 45, 0, 0, 95, 101, 64, 65, 0, 66, + 16, 0, 51, 0, 33, 82, 88, 37, 60, 0, + 78, 74, 0, 25, 50, 18, 12, 0, 85, 91, + 9, 53, 86, 113, 0, 0, 0, 0, 0, 54, + 0, 0, 84, 90, 39, 0, 23, 10, 49, 100, + 0, 0, 0, 0, 0, 111, 0, 109, 0, 0, + 109, 22, 64, 21, 63, 0, 95, 121, 0, 0, + 0, 65, 119, 55, 101, 120, 103, 20, 62, 98, + 72, 56, 52, 123, 0, 0, 48, 30, 0, 122, + 40, 125, 71, 102, 126, 0, 128, 0, 0, 83, + 89, 38, 0, 24, 11, 105, 107, 8, 0, 112, - 0 + 0, 110, 0, 111, 0, 109, 67, 115, 116, 117, + 0, 0, 66, 41, 127, 130, 129, 47, 0, 0, + 118, 124, 68, 69, 0, 70, 0 } ; static const YY_CHAR yy_ec[256] = @@ -397,31 +399,31 @@ static const YY_CHAR yy_ec[256] = 1, 2, 1, 4, 1, 1, 1, 1, 5, 6, 6, 6, 7, 8, 9, 10, 6, 11, 12, 13, 14, 14, 14, 14, 14, 14, 14, 1, 1, 1, - 6, 1, 1, 1, 15, 1, 16, 1, 17, 1, - 18, 19, 1, 20, 21, 1, 22, 23, 1, 24, - 1, 1, 25, 26, 1, 27, 28, 1, 1, 1, - 29, 1, 30, 6, 1, 1, 31, 32, 33, 34, + 6, 1, 1, 1, 15, 1, 16, 1, 17, 18, + 19, 20, 1, 21, 22, 1, 23, 24, 1, 25, + 1, 1, 26, 27, 1, 28, 29, 1, 1, 1, + 30, 1, 31, 6, 1, 1, 32, 33, 34, 35, - 35, 36, 37, 38, 39, 1, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 1, 51, 52, - 53, 54, 1, 1, 1, 1, 1, 55, 1, 1, - 1, 1, 1, 1, 1, 56, 1, 1, 1, 1, + 36, 37, 38, 39, 40, 1, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 1, 52, 53, + 54, 55, 1, 1, 1, 1, 1, 56, 1, 1, 1, 1, 1, 1, 1, 57, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 58, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 58, 1, 59, 60, 1, - 61, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 62, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 59, 1, 60, 61, 1, + 62, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 63, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 63, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 64, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; -static const YY_CHAR yy_meta[64] = +static const YY_CHAR yy_meta[65] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -429,112 +431,119 @@ static const YY_CHAR yy_meta[64] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1 + 1, 1, 1, 1 } ; -static const flex_int16_t yy_base[203] = +static const flex_int16_t yy_base[229] = { 0, - 0, 0, 61, 62, 332, 333, 333, 328, 333, 333, - 333, 55, 333, 59, 66, 76, 333, 303, 75, 275, - 333, 333, 81, 286, 296, 333, 282, 310, 276, 333, - 49, 68, 71, 271, 273, 277, 333, 277, 99, 63, - 106, 277, 264, 76, 286, 89, 78, 116, 282, 72, - 70, 333, 333, 333, 312, 143, 150, 157, 169, 183, - 194, 333, 260, 282, 333, 333, 258, 333, 280, 333, - 333, 263, 261, 333, 260, 263, 267, 274, 333, 333, - 256, 254, 265, 333, 256, 333, 257, 333, 333, 245, - 333, 267, 333, 333, 258, 98, 220, 333, 333, 333, + 0, 0, 62, 63, 357, 358, 358, 353, 358, 358, + 358, 56, 358, 60, 67, 75, 358, 327, 358, 70, + 299, 358, 358, 76, 310, 320, 358, 306, 335, 300, + 358, 64, 316, 64, 69, 74, 297, 301, 358, 301, + 113, 73, 148, 97, 289, 86, 311, 82, 91, 126, + 307, 62, 63, 358, 358, 358, 338, 183, 190, 197, + 204, 217, 171, 358, 285, 307, 358, 358, 283, 358, + 305, 358, 358, 288, 286, 358, 285, 288, 292, 299, + 282, 358, 358, 280, 278, 246, 358, 358, 236, 358, + 237, 358, 358, 224, 358, 358, 246, 358, 230, 358, - 211, 333, 103, 333, 118, 333, 333, 333, 202, 213, - 209, 196, 181, 333, 183, 180, 333, 179, 333, 333, - 333, 333, 188, 106, 159, 208, 220, 224, 233, 237, - 249, 176, 199, 333, 333, 333, 333, 155, 333, 333, - 151, 155, 141, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 167, 130, 333, 333, 333, 333, 333, - 333, 333, 138, 126, 135, 122, 104, 333, 105, 333, - 333, 333, 333, 333, 253, 257, 262, 266, 270, 274, - 278, 282, 333, 333, 333, 126, 120, 70, 333, 333, - 333, 333, 61, 56, 333, 333, 333, 333, 38, 333, + 358, 225, 39, 213, 358, 358, 358, 358, 358, 205, + 358, 358, 217, 358, 66, 358, 197, 101, 358, 358, + 358, 358, 358, 358, 186, 196, 197, 180, 175, 358, + 178, 175, 358, 358, 358, 168, 358, 358, 358, 358, + 217, 89, 154, 234, 245, 250, 259, 263, 276, 146, + 280, 358, 358, 358, 358, 158, 358, 358, 156, 155, + 154, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 180, 141, 139, 358, 358, 137, 358, + 358, 358, 358, 358, 135, 123, 132, 116, 117, 358, + 358, 358, 116, 358, 358, 358, 358, 358, 284, 289, - 333, 74 + 293, 297, 301, 305, 309, 313, 358, 358, 358, 142, + 143, 104, 358, 358, 358, 358, 358, 358, 99, 97, + 358, 358, 358, 358, 91, 358, 358, 124 } ; -static const flex_int16_t yy_def[203] = +static const flex_int16_t yy_def[229] = { 0, - 201, 1, 202, 202, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 227, 1, 228, 228, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, - 0, 201 + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 0, 227 } ; -static const flex_int16_t yy_nxt[397] = +static const flex_int16_t yy_nxt[423] = { 0, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 15, 15, 17, 18, 6, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 6, - 31, 6, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 6, 45, 46, 47, 48, - 6, 6, 49, 6, 6, 6, 6, 6, 6, 6, - 6, 50, 51, 53, 53, 56, 56, 56, 56, 57, - 57, 57, 57, 58, 52, 59, 60, 60, 60, 60, - 75, 76, 61, 58, 200, 59, 60, 60, 60, 60, - 54, 54, 61, 63, 96, 66, 77, 78, 64, 67, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 6, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 6, 47, 48, 49, + 50, 6, 6, 51, 6, 6, 6, 6, 6, 6, + 6, 6, 52, 53, 55, 55, 58, 58, 58, 58, + 59, 59, 59, 59, 60, 172, 61, 62, 62, 62, + 62, 173, 60, 63, 61, 62, 62, 62, 62, 65, + 68, 63, 56, 56, 66, 69, 77, 78, 82, 70, - 61, 79, 199, 68, 69, 83, 97, 198, 115, 80, - 61, 81, 84, 89, 108, 116, 197, 90, 82, 109, - 98, 91, 92, 110, 124, 125, 99, 112, 100, 122, - 196, 101, 123, 152, 113, 93, 117, 114, 195, 153, - 94, 118, 102, 156, 103, 157, 95, 104, 194, 105, - 193, 158, 119, 56, 56, 56, 56, 120, 159, 126, - 57, 57, 57, 57, 172, 173, 127, 128, 128, 128, - 128, 192, 191, 129, 190, 189, 188, 126, 187, 130, - 130, 130, 130, 186, 127, 131, 133, 133, 133, 133, - 58, 129, 59, 60, 60, 60, 60, 185, 184, 61, + 71, 88, 63, 123, 86, 103, 83, 177, 84, 178, + 63, 87, 79, 80, 119, 85, 120, 104, 142, 143, + 140, 128, 131, 141, 54, 124, 89, 93, 129, 132, + 125, 130, 94, 95, 126, 180, 96, 97, 226, 121, + 98, 99, 181, 133, 225, 134, 224, 135, 196, 197, + 100, 223, 136, 222, 221, 101, 151, 151, 151, 151, + 220, 102, 105, 137, 219, 106, 218, 107, 138, 108, + 217, 109, 216, 215, 110, 111, 112, 150, 214, 150, + 113, 151, 151, 151, 151, 114, 213, 115, 212, 116, + 117, 211, 118, 58, 58, 58, 58, 210, 209, 144, - 132, 183, 132, 131, 133, 133, 133, 133, 168, 133, - 133, 133, 133, 169, 175, 174, 175, 61, 176, 176, - 176, 176, 167, 166, 170, 165, 177, 164, 177, 171, - 178, 178, 178, 178, 128, 128, 128, 128, 163, 179, - 129, 179, 162, 180, 180, 180, 180, 130, 130, 130, - 130, 161, 160, 131, 155, 181, 154, 181, 129, 182, - 182, 182, 182, 176, 176, 176, 176, 176, 176, 176, - 176, 131, 178, 178, 178, 178, 178, 178, 178, 178, - 180, 180, 180, 180, 180, 180, 180, 180, 182, 182, - 182, 182, 182, 182, 182, 182, 151, 150, 149, 148, + 59, 59, 59, 59, 208, 207, 145, 146, 146, 146, + 146, 198, 189, 147, 148, 148, 148, 148, 144, 188, + 149, 187, 186, 185, 60, 145, 61, 62, 62, 62, + 62, 184, 147, 63, 190, 183, 191, 182, 192, 149, + 199, 179, 199, 193, 200, 200, 200, 200, 176, 175, + 174, 201, 63, 201, 194, 202, 202, 202, 202, 195, + 146, 146, 146, 146, 171, 203, 147, 203, 170, 204, + 204, 204, 204, 148, 148, 148, 148, 169, 168, 149, + 167, 166, 205, 165, 205, 147, 206, 206, 206, 206, + 151, 151, 151, 151, 200, 200, 200, 200, 149, 200, - 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, - 137, 136, 135, 134, 55, 121, 111, 107, 106, 88, - 87, 86, 85, 74, 73, 72, 71, 70, 65, 62, - 55, 201, 5, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201 + 200, 200, 200, 202, 202, 202, 202, 202, 202, 202, + 202, 204, 204, 204, 204, 204, 204, 204, 204, 206, + 206, 206, 206, 206, 206, 206, 206, 164, 163, 162, + 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, + 57, 139, 127, 122, 92, 91, 90, 81, 76, 75, + 74, 73, 72, 67, 64, 57, 227, 5, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227 } ; -static const flex_int16_t yy_chk[397] = +static const flex_int16_t yy_chk[423] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -542,44 +551,47 @@ static const flex_int16_t yy_chk[397] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 4, 12, 12, 12, 12, 14, - 14, 14, 14, 15, 202, 15, 15, 15, 15, 15, - 31, 31, 15, 16, 199, 16, 16, 16, 16, 16, - 3, 4, 16, 19, 40, 23, 31, 31, 19, 23, + 1, 1, 1, 1, 3, 4, 12, 12, 12, 12, + 14, 14, 14, 14, 15, 103, 15, 15, 15, 15, + 15, 103, 16, 15, 16, 16, 16, 16, 16, 20, + 24, 16, 3, 4, 20, 24, 32, 32, 34, 24, - 15, 32, 194, 23, 23, 33, 40, 193, 47, 32, - 16, 32, 33, 39, 44, 47, 188, 39, 32, 44, - 41, 39, 39, 44, 51, 51, 41, 46, 41, 50, - 187, 41, 50, 96, 46, 39, 48, 46, 186, 96, - 39, 48, 41, 103, 41, 103, 39, 41, 169, 41, - 167, 105, 48, 56, 56, 56, 56, 48, 105, 56, - 57, 57, 57, 57, 124, 124, 57, 58, 58, 58, - 58, 166, 165, 58, 164, 163, 155, 56, 154, 59, - 59, 59, 59, 143, 57, 59, 132, 132, 132, 132, - 60, 58, 60, 60, 60, 60, 60, 142, 141, 60, + 24, 36, 15, 46, 35, 42, 34, 115, 34, 115, + 16, 35, 32, 32, 44, 34, 44, 42, 53, 53, + 52, 48, 49, 52, 228, 46, 36, 41, 48, 49, + 46, 48, 41, 41, 46, 118, 41, 41, 225, 44, + 41, 41, 118, 50, 220, 50, 219, 50, 142, 142, + 41, 212, 50, 211, 210, 41, 150, 150, 150, 150, + 193, 41, 43, 50, 189, 43, 188, 43, 50, 43, + 187, 43, 186, 185, 43, 43, 43, 63, 179, 63, + 43, 63, 63, 63, 63, 43, 176, 43, 175, 43, + 43, 174, 43, 58, 58, 58, 58, 161, 160, 58, - 61, 138, 61, 59, 61, 61, 61, 61, 123, 133, - 133, 133, 133, 123, 126, 125, 126, 60, 126, 126, - 126, 126, 118, 116, 123, 115, 127, 113, 127, 123, - 127, 127, 127, 127, 128, 128, 128, 128, 112, 129, - 128, 129, 111, 129, 129, 129, 129, 130, 130, 130, - 130, 110, 109, 130, 101, 131, 97, 131, 128, 131, - 131, 131, 131, 175, 175, 175, 175, 176, 176, 176, - 176, 130, 177, 177, 177, 177, 178, 178, 178, 178, - 179, 179, 179, 179, 180, 180, 180, 180, 181, 181, - 181, 181, 182, 182, 182, 182, 95, 92, 90, 87, + 59, 59, 59, 59, 159, 156, 59, 60, 60, 60, + 60, 143, 136, 60, 61, 61, 61, 61, 58, 132, + 61, 131, 129, 128, 62, 59, 62, 62, 62, 62, + 62, 127, 60, 62, 141, 126, 141, 125, 141, 61, + 144, 117, 144, 141, 144, 144, 144, 144, 113, 110, + 104, 145, 62, 145, 141, 145, 145, 145, 145, 141, + 146, 146, 146, 146, 102, 147, 146, 147, 99, 147, + 147, 147, 147, 148, 148, 148, 148, 97, 94, 148, + 91, 89, 149, 86, 149, 146, 149, 149, 149, 149, + 151, 151, 151, 151, 199, 199, 199, 199, 148, 200, - 85, 83, 82, 81, 78, 77, 76, 75, 73, 72, - 69, 67, 64, 63, 55, 49, 45, 43, 42, 38, - 36, 35, 34, 29, 28, 27, 25, 24, 20, 18, - 8, 5, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201 + 200, 200, 200, 201, 201, 201, 201, 202, 202, 202, + 202, 203, 203, 203, 203, 204, 204, 204, 204, 205, + 205, 205, 205, 206, 206, 206, 206, 85, 84, 81, + 80, 79, 78, 77, 75, 74, 71, 69, 66, 65, + 57, 51, 47, 45, 40, 38, 37, 33, 30, 29, + 28, 26, 25, 21, 18, 8, 5, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227 } ; static yy_state_type yy_last_accepting_state; @@ -596,23 +608,28 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "" -#line 2 "" +#line 1 "QuantityParser.l" +#line 2 "QuantityParser.l" /* Lexer for the FreeCAD Units language */ /* (c) 2013 Juergen Riegel LGPL */ +/* use this file to generate the file 'QuantityLexer.c' using the program flex +/* the command for this operation is: /* flex --outfile=QuantityLexer.c QuantityParser.l */ +/* (flex for Windows is available here: */ +/* https://sourceforge.net/projects/winflexbison/ */ +/* (you must then change 'flex' to 'win_flex' in the command)) */ /* This disables inclusion of unistd.h, which is not available under Visual C++ * on Win32. The C++ scanner uses STL streams instead. */ #define YY_NO_UNISTD_H -#line 611 "QuantityLexer.c" +#line 627 "QuantityLexer.c" /*** Flex Declarations and Options ***/ /* the manual says "somewhat more optimized" */ /* no support for include files is planned */ -#line 616 "QuantityLexer.c" +#line 632 "QuantityLexer.c" #define INITIAL 0 #define C_COMMENT 1 @@ -624,7 +641,7 @@ char *yytext; */ #include #endif - + #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif @@ -828,10 +845,10 @@ YY_DECL } { -#line 32 "" +#line 37 "QuantityParser.l" -#line 835 "QuantityLexer.c" +#line 851 "QuantityLexer.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -858,13 +875,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 202 ) + if ( yy_current_state >= 228 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_current_state != 201 ); + while ( yy_current_state != 227 ); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); @@ -886,551 +903,666 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 34 "" +#line 39 "QuantityParser.l" { BEGIN(C_COMMENT); } YY_BREAK case 2: YY_RULE_SETUP -#line 35 "" +#line 40 "QuantityParser.l" { BEGIN(INITIAL); } YY_BREAK case 3: YY_RULE_SETUP -#line 36 "" +#line 41 "QuantityParser.l" { ;} YY_BREAK case 4: YY_RULE_SETUP -#line 39 "" +#line 44 "QuantityParser.l" ; YY_BREAK case 5: /* rule 5 can match eol */ YY_RULE_SETUP -#line 40 "" +#line 45 "QuantityParser.l" ; YY_BREAK case 6: YY_RULE_SETUP -#line 42 "" +#line 47 "QuantityParser.l" { return *yytext; } YY_BREAK case 7: YY_RULE_SETUP -#line 44 "" +#line 49 "QuantityParser.l" return MINUSSIGN; YY_BREAK case 8: YY_RULE_SETUP -#line 45 "" +#line 50 "QuantityParser.l" return MINUSSIGN; YY_BREAK case 9: YY_RULE_SETUP -#line 47 "" +#line 52 "QuantityParser.l" yylval = Quantity::NanoMetre; return UNIT; // nano meter YY_BREAK case 10: YY_RULE_SETUP -#line 48 "" +#line 53 "QuantityParser.l" yylval = Quantity::MicroMetre; return UNIT; // micro meter YY_BREAK case 11: YY_RULE_SETUP -#line 49 "" +#line 54 "QuantityParser.l" yylval = Quantity::MicroMetre; return UNIT; // micro meter (greek micro in UTF8) YY_BREAK case 12: YY_RULE_SETUP -#line 50 "" +#line 55 "QuantityParser.l" yylval = Quantity::MilliMetre; return UNIT; // milli meter (internal standard length) YY_BREAK case 13: YY_RULE_SETUP -#line 51 "" +#line 56 "QuantityParser.l" yylval = Quantity::CentiMetre; return UNIT; // centi meter YY_BREAK case 14: YY_RULE_SETUP -#line 52 "" +#line 57 "QuantityParser.l" yylval = Quantity::DeciMetre; return UNIT; // deci meter YY_BREAK case 15: YY_RULE_SETUP -#line 53 "" +#line 58 "QuantityParser.l" yylval = Quantity::Metre; return UNIT; // metre YY_BREAK case 16: YY_RULE_SETUP -#line 54 "" +#line 59 "QuantityParser.l" yylval = Quantity::KiloMetre; return UNIT; // kilo meter YY_BREAK case 17: YY_RULE_SETUP -#line 56 "" -yylval = Quantity::Liter; return UNIT; // Liter dm^3 +#line 61 "QuantityParser.l" +yylval = Quantity::Liter; return UNIT; // Liter (dm^3) YY_BREAK case 18: YY_RULE_SETUP -#line 58 "" -yylval = Quantity::Hertz; return UNIT; // Hertz +#line 62 "QuantityParser.l" +yylval = Quantity::MilliLiter; return UNIT; // milli Liter YY_BREAK case 19: YY_RULE_SETUP -#line 59 "" -yylval = Quantity::KiloHertz; return UNIT; // Kilo Hertz +#line 64 "QuantityParser.l" +yylval = Quantity::Hertz; return UNIT; // Hertz YY_BREAK case 20: YY_RULE_SETUP -#line 60 "" -yylval = Quantity::MegaHertz; return UNIT; // Mega Hertz +#line 65 "QuantityParser.l" +yylval = Quantity::KiloHertz; return UNIT; // Kilo Hertz YY_BREAK case 21: YY_RULE_SETUP -#line 61 "" -yylval = Quantity::GigaHertz; return UNIT; // Giga Hertz +#line 66 "QuantityParser.l" +yylval = Quantity::MegaHertz; return UNIT; // Mega Hertz YY_BREAK case 22: YY_RULE_SETUP -#line 63 "" -yylval = Quantity::MicroGram; return UNIT; // micro gram +#line 67 "QuantityParser.l" +yylval = Quantity::GigaHertz; return UNIT; // Giga Hertz YY_BREAK case 23: YY_RULE_SETUP -#line 64 "" +#line 69 "QuantityParser.l" yylval = Quantity::MicroGram; return UNIT; // micro gram YY_BREAK case 24: YY_RULE_SETUP -#line 65 "" -yylval = Quantity::MilliGram; return UNIT; // milli gram +#line 70 "QuantityParser.l" +yylval = Quantity::MicroGram; return UNIT; // micro gram YY_BREAK case 25: YY_RULE_SETUP -#line 66 "" -yylval = Quantity::Gram; return UNIT; // gram +#line 71 "QuantityParser.l" +yylval = Quantity::MilliGram; return UNIT; // milli gram YY_BREAK case 26: YY_RULE_SETUP -#line 67 "" -yylval = Quantity::KiloGram; return UNIT; // kilo gram (internal standard for mass) +#line 72 "QuantityParser.l" +yylval = Quantity::Gram; return UNIT; // gram YY_BREAK case 27: YY_RULE_SETUP -#line 68 "" -yylval = Quantity::Ton; return UNIT; // Metric Tonne +#line 73 "QuantityParser.l" +yylval = Quantity::KiloGram; return UNIT; // kilo gram (internal standard for mass) YY_BREAK case 28: YY_RULE_SETUP -#line 70 "" -yylval = Quantity::Second; return UNIT; // second (internal standard time) +#line 74 "QuantityParser.l" +yylval = Quantity::Ton; return UNIT; // Metric Tonne YY_BREAK case 29: YY_RULE_SETUP -#line 71 "" -yylval = Quantity::Minute; return UNIT; // minute +#line 76 "QuantityParser.l" +yylval = Quantity::Second; return UNIT; // second (internal standard time) YY_BREAK case 30: YY_RULE_SETUP -#line 72 "" -yylval = Quantity::Hour; return UNIT; // hour +#line 77 "QuantityParser.l" +yylval = Quantity::Minute; return UNIT; // minute YY_BREAK case 31: YY_RULE_SETUP -#line 74 "" -yylval = Quantity::Ampere; return UNIT; // Ampere (internal standard electric current) +#line 78 "QuantityParser.l" +yylval = Quantity::Hour; return UNIT; // hour YY_BREAK case 32: YY_RULE_SETUP -#line 75 "" -yylval = Quantity::MilliAmpere; return UNIT; // milli Ampere +#line 80 "QuantityParser.l" +yylval = Quantity::Ampere; return UNIT; // Ampere (internal standard electric current) YY_BREAK case 33: YY_RULE_SETUP -#line 76 "" -yylval = Quantity::KiloAmpere; return UNIT; // kilo Ampere +#line 81 "QuantityParser.l" +yylval = Quantity::MilliAmpere; return UNIT; // milli Ampere YY_BREAK case 34: YY_RULE_SETUP -#line 77 "" -yylval = Quantity::MegaAmpere; return UNIT; // Mega Ampere +#line 82 "QuantityParser.l" +yylval = Quantity::KiloAmpere; return UNIT; // kilo Ampere YY_BREAK case 35: YY_RULE_SETUP -#line 79 "" -yylval = Quantity::Kelvin; return UNIT; // Kelvin (internal standard thermodynamic temperature) +#line 83 "QuantityParser.l" +yylval = Quantity::MegaAmpere; return UNIT; // Mega Ampere YY_BREAK case 36: YY_RULE_SETUP -#line 80 "" -yylval = Quantity::MilliKelvin; return UNIT; // Kelvin +#line 85 "QuantityParser.l" +yylval = Quantity::Kelvin; return UNIT; // Kelvin (internal standard thermodynamic temperature) YY_BREAK case 37: YY_RULE_SETUP -#line 81 "" -yylval = Quantity::MicroKelvin; return UNIT; // Kelvin +#line 86 "QuantityParser.l" +yylval = Quantity::MilliKelvin; return UNIT; // Kelvin YY_BREAK case 38: YY_RULE_SETUP -#line 82 "" +#line 87 "QuantityParser.l" yylval = Quantity::MicroKelvin; return UNIT; // Kelvin YY_BREAK case 39: YY_RULE_SETUP -#line 84 "" -yylval = Quantity::Mole; return UNIT; // Mole (internal standard amount of substance) +#line 88 "QuantityParser.l" +yylval = Quantity::MicroKelvin; return UNIT; // Kelvin YY_BREAK case 40: YY_RULE_SETUP -#line 86 "" -yylval = Quantity::Candela; return UNIT; // Candela (internal standard luminous intensity) +#line 90 "QuantityParser.l" +yylval = Quantity::Mole; return UNIT; // Mole (internal standard amount of substance) YY_BREAK case 41: YY_RULE_SETUP -#line 88 "" -yylval = Quantity::Inch; return UNIT; // inch +#line 91 "QuantityParser.l" +yylval = Quantity::MilliMole; return UNIT; // Milli Mole YY_BREAK case 42: YY_RULE_SETUP -#line 89 "" -yylval = Quantity::Inch; return UNIT; // inch +#line 93 "QuantityParser.l" +yylval = Quantity::Candela; return UNIT; // Candela (internal standard luminous intensity) YY_BREAK case 43: YY_RULE_SETUP -#line 90 "" -yylval = Quantity::Foot; return UNIT; // foot +#line 95 "QuantityParser.l" +yylval = Quantity::Inch; return UNIT; // inch YY_BREAK case 44: YY_RULE_SETUP -#line 91 "" -yylval = Quantity::Foot; return UNIT; // foot +#line 96 "QuantityParser.l" +yylval = Quantity::Inch; return UNIT; // inch YY_BREAK case 45: YY_RULE_SETUP -#line 92 "" -yylval = Quantity::Thou; return UNIT; // thou (in/1000) +#line 97 "QuantityParser.l" +yylval = Quantity::Foot; return UNIT; // foot YY_BREAK case 46: YY_RULE_SETUP -#line 93 "" -yylval = Quantity::Thou; return UNIT; // mil (the thou in US) +#line 98 "QuantityParser.l" +yylval = Quantity::Foot; return UNIT; // foot YY_BREAK case 47: YY_RULE_SETUP -#line 94 "" -yylval = Quantity::Yard; return UNIT; // yard +#line 99 "QuantityParser.l" +yylval = Quantity::Thou; return UNIT; // thou (in/1000) YY_BREAK case 48: YY_RULE_SETUP -#line 95 "" -yylval = Quantity::Mile; return UNIT; // mile +#line 100 "QuantityParser.l" +yylval = Quantity::Thou; return UNIT; // mil (the thou in US) YY_BREAK case 49: YY_RULE_SETUP -#line 99 "" -yylval = Quantity::Pound; return UNIT; // pound +#line 101 "QuantityParser.l" +yylval = Quantity::Yard; return UNIT; // yard YY_BREAK case 50: YY_RULE_SETUP -#line 100 "" -yylval = Quantity::Pound; return UNIT; // pound +#line 102 "QuantityParser.l" +yylval = Quantity::Mile; return UNIT; // mile YY_BREAK case 51: YY_RULE_SETUP -#line 101 "" -yylval = Quantity::Ounce; return UNIT; // ounce +#line 104 "QuantityParser.l" +yylval = Quantity::Pound; return UNIT; // pound YY_BREAK case 52: YY_RULE_SETUP -#line 102 "" -yylval = Quantity::Stone; return UNIT; // Stone +#line 105 "QuantityParser.l" +yylval = Quantity::Pound; return UNIT; // pound YY_BREAK case 53: YY_RULE_SETUP -#line 103 "" -yylval = Quantity::Hundredweights; return UNIT; // hundredweights +#line 106 "QuantityParser.l" +yylval = Quantity::Ounce; return UNIT; // ounce YY_BREAK case 54: YY_RULE_SETUP -#line 105 "" -yylval = Quantity::PoundForce; return UNIT; // pound +#line 107 "QuantityParser.l" +yylval = Quantity::Stone; return UNIT; // Stone YY_BREAK case 55: YY_RULE_SETUP -#line 107 "" -yylval = Quantity::Newton; return UNIT; // Newton (kg*m/s^2) +#line 108 "QuantityParser.l" +yylval = Quantity::Hundredweights; return UNIT; // hundredweights YY_BREAK case 56: YY_RULE_SETUP -#line 108 "" -yylval = Quantity::KiloNewton; return UNIT; // Newton +#line 110 "QuantityParser.l" +yylval = Quantity::PoundForce; return UNIT; // pound YY_BREAK case 57: YY_RULE_SETUP -#line 109 "" -yylval = Quantity::MegaNewton; return UNIT; // Newton +#line 112 "QuantityParser.l" +yylval = Quantity::Newton; return UNIT; // Newton (kg*m/s^2) YY_BREAK case 58: YY_RULE_SETUP -#line 110 "" -yylval = Quantity::MilliNewton; return UNIT; // Newton +#line 113 "QuantityParser.l" +yylval = Quantity::KiloNewton; return UNIT; // Newton YY_BREAK case 59: YY_RULE_SETUP -#line 112 "" -yylval = Quantity::Pascal; return UNIT; // Pascal (kg/m/s^2 or N/m^2) +#line 114 "QuantityParser.l" +yylval = Quantity::MegaNewton; return UNIT; // Newton YY_BREAK case 60: YY_RULE_SETUP -#line 113 "" -yylval = Quantity::KiloPascal; return UNIT; // Pascal +#line 115 "QuantityParser.l" +yylval = Quantity::MilliNewton; return UNIT; // Newton YY_BREAK case 61: YY_RULE_SETUP -#line 114 "" -yylval = Quantity::MegaPascal; return UNIT; // Pascal +#line 117 "QuantityParser.l" +yylval = Quantity::Pascal; return UNIT; // Pascal (kg/m/s^2 or N/m^2) YY_BREAK case 62: YY_RULE_SETUP -#line 115 "" -yylval = Quantity::GigaPascal; return UNIT; // Pascal +#line 118 "QuantityParser.l" +yylval = Quantity::KiloPascal; return UNIT; // Pascal YY_BREAK case 63: YY_RULE_SETUP -#line 117 "" -yylval = Quantity::Torr; return UNIT; // portion of Pascal ( 101325/760 ) +#line 119 "QuantityParser.l" +yylval = Quantity::MegaPascal; return UNIT; // Pascal YY_BREAK case 64: YY_RULE_SETUP -#line 118 "" -yylval = Quantity::mTorr; return UNIT; // +#line 120 "QuantityParser.l" +yylval = Quantity::GigaPascal; return UNIT; // Pascal YY_BREAK case 65: YY_RULE_SETUP -#line 119 "" -yylval = Quantity::yTorr; return UNIT; // +#line 122 "QuantityParser.l" +yylval = Quantity::Bar; return UNIT; // 1 bar = 100 kPa YY_BREAK case 66: YY_RULE_SETUP -#line 120 "" -yylval = Quantity::yTorr; return UNIT; // +#line 123 "QuantityParser.l" +yylval = Quantity::MilliBar; return UNIT; // Milli Bar YY_BREAK case 67: YY_RULE_SETUP -#line 122 "" -yylval = Quantity::PSI; return UNIT; // pounds/in^2 +#line 125 "QuantityParser.l" +yylval = Quantity::Torr; return UNIT; // portion of Pascal ( 101325/760 ) YY_BREAK case 68: YY_RULE_SETUP -#line 123 "" -yylval = Quantity::KSI; return UNIT; // 1000 x pounds/in^2 +#line 126 "QuantityParser.l" +yylval = Quantity::mTorr; return UNIT; // YY_BREAK case 69: YY_RULE_SETUP -#line 125 "" -yylval = Quantity::Watt; return UNIT; // Watt (kg*m^2/s^3) +#line 127 "QuantityParser.l" +yylval = Quantity::yTorr; return UNIT; // YY_BREAK case 70: YY_RULE_SETUP -#line 126 "" -yylval = Quantity::VoltAmpere; return UNIT; // VoltAmpere (kg*m^2/s^3) +#line 128 "QuantityParser.l" +yylval = Quantity::yTorr; return UNIT; // YY_BREAK case 71: YY_RULE_SETUP -#line 128 "" -yylval = Quantity::Volt; return UNIT; // Volt (kg*m^2/A/s^3) +#line 130 "QuantityParser.l" +yylval = Quantity::PSI; return UNIT; // pounds/in^2 YY_BREAK case 72: YY_RULE_SETUP -#line 130 "" -yylval = Quantity::Joule; return UNIT; // Joule (kg*m^2/s^2) +#line 131 "QuantityParser.l" +yylval = Quantity::KSI; return UNIT; // 1000 x pounds/in^2 YY_BREAK case 73: YY_RULE_SETUP -#line 131 "" -yylval = Quantity::NewtonMeter; return UNIT; // N*m = Joule +#line 133 "QuantityParser.l" +yylval = Quantity::Watt; return UNIT; // Watt (kg*m^2/s^3) YY_BREAK case 74: YY_RULE_SETUP -#line 132 "" -yylval = Quantity::VoltAmpereSecond; return UNIT; // V*A*s = Joule +#line 134 "QuantityParser.l" +yylval = Quantity::MilliWatt; return UNIT; // Milli Watt YY_BREAK case 75: YY_RULE_SETUP -#line 133 "" -yylval = Quantity::WattSecond; return UNIT; // +#line 135 "QuantityParser.l" +yylval = Quantity::VoltAmpere; return UNIT; // VoltAmpere (kg*m^2/s^3) YY_BREAK case 76: YY_RULE_SETUP -#line 134 "" -yylval = Quantity::WattSecond; return UNIT; // W*s = Joule +#line 137 "QuantityParser.l" +yylval = Quantity::Volt; return UNIT; // Volt (kg*m^2/A/s^3) YY_BREAK case 77: YY_RULE_SETUP -#line 136 "" -yylval = Quantity::Degree; return UNIT; // degree (internal standard angle) +#line 138 "QuantityParser.l" +yylval = Quantity::KiloVolt; return UNIT; // Kilo Volt YY_BREAK case 78: YY_RULE_SETUP -#line 137 "" -yylval = Quantity::Degree; return UNIT; // degree (internal standard angle) +#line 139 "QuantityParser.l" +yylval = Quantity::MilliVolt; return UNIT; // Milli Volt YY_BREAK case 79: YY_RULE_SETUP -#line 138 "" -yylval = Quantity::Radian; return UNIT; // radian +#line 141 "QuantityParser.l" +yylval = Quantity::Coulomb; return UNIT; // Coulomb (A*s) YY_BREAK case 80: YY_RULE_SETUP -#line 139 "" -yylval = Quantity::Gon; return UNIT; // gon +#line 143 "QuantityParser.l" +yylval = Quantity::Tesla; return UNIT; // Tesla (kg/s^2/A) YY_BREAK case 81: YY_RULE_SETUP -#line 140 "" -yylval = Quantity::AngMinute; return UNIT; // minute(Angular) +#line 145 "QuantityParser.l" +yylval = Quantity::Farad; return UNIT; // Farad (s^4*A^2/m^2/kg) YY_BREAK case 82: YY_RULE_SETUP -#line 141 "" -yylval = Quantity::AngMinute; return UNIT; // minute(Angular) +#line 146 "QuantityParser.l" +yylval = Quantity::MilliFarad; return UNIT; // Milli Farad YY_BREAK case 83: YY_RULE_SETUP -#line 142 "" -yylval = Quantity::AngSecond; return UNIT; // second(Angular) +#line 147 "QuantityParser.l" +yylval = Quantity::MicroFarad; return UNIT; // Micro Farad YY_BREAK case 84: YY_RULE_SETUP -#line 143 "" -yylval = Quantity::AngSecond; return UNIT; // second(Angular) +#line 148 "QuantityParser.l" +yylval = Quantity::MicroFarad; return UNIT; // Micro Farad YY_BREAK case 85: YY_RULE_SETUP -#line 145 "" -yylval = Quantity(1.0); return ONE; +#line 149 "QuantityParser.l" +yylval = Quantity::NanoFarad; return UNIT; // Nano Farad YY_BREAK case 86: YY_RULE_SETUP -#line 146 "" -{ yylval = Quantity(num_change(yytext,'.',','));return NUM; } +#line 150 "QuantityParser.l" +yylval = Quantity::PicoFarad; return UNIT; // Pico Farad YY_BREAK case 87: YY_RULE_SETUP -#line 147 "" -{ yylval = Quantity(num_change(yytext,'.',','));return NUM; } +#line 152 "QuantityParser.l" +yylval = Quantity::Henry; return UNIT; // Henry (kg*m^2/s^2/A^2) YY_BREAK case 88: YY_RULE_SETUP -#line 148 "" -{ yylval = Quantity(num_change(yytext,',','.'));return NUM; } +#line 153 "QuantityParser.l" +yylval = Quantity::MilliHenry; return UNIT; // Milli Henry YY_BREAK case 89: YY_RULE_SETUP -#line 149 "" -{ yylval = Quantity(num_change(yytext,',','.'));return NUM; } +#line 154 "QuantityParser.l" +yylval = Quantity::MicroHenry; return UNIT; // Micro Henry YY_BREAK case 90: YY_RULE_SETUP -#line 152 "" -{yylval = Quantity(M_PI) ; return NUM;} // constant pi +#line 155 "QuantityParser.l" +yylval = Quantity::MicroHenry; return UNIT; // Micro Henry YY_BREAK case 91: YY_RULE_SETUP -#line 153 "" -{yylval = Quantity(M_E) ; return NUM;} // constant e +#line 156 "QuantityParser.l" +yylval = Quantity::NanoHenry; return UNIT; // Nano Henry YY_BREAK case 92: YY_RULE_SETUP -#line 155 "" -return ACOS; +#line 158 "QuantityParser.l" +yylval = Quantity::Joule; return UNIT; // Joule (kg*m^2/s^2) YY_BREAK case 93: YY_RULE_SETUP -#line 156 "" -return ASIN; +#line 159 "QuantityParser.l" +yylval = Quantity::KiloJoule; return UNIT; // Kilo Joule YY_BREAK case 94: YY_RULE_SETUP -#line 157 "" -return ATAN; +#line 160 "QuantityParser.l" +yylval = Quantity::NewtonMeter; return UNIT; // N*m = Joule YY_BREAK case 95: YY_RULE_SETUP -#line 158 "" -return ATAN2; +#line 161 "QuantityParser.l" +yylval = Quantity::VoltAmpereSecond; return UNIT; // V*A*s = Joule YY_BREAK case 96: YY_RULE_SETUP -#line 159 "" -return COS; +#line 162 "QuantityParser.l" +yylval = Quantity::WattSecond; return UNIT; // YY_BREAK case 97: YY_RULE_SETUP -#line 160 "" -return EXP; +#line 163 "QuantityParser.l" +yylval = Quantity::WattSecond; return UNIT; // W*s = Joule YY_BREAK case 98: YY_RULE_SETUP -#line 161 "" -return ABS; +#line 164 "QuantityParser.l" +yylval = Quantity::KiloWattHour; return UNIT; // 1 kWh = 3.6e6 J YY_BREAK case 99: YY_RULE_SETUP -#line 162 "" -return MOD; +#line 165 "QuantityParser.l" +yylval = Quantity::ElectronVolt; return UNIT; // 1 eV = 1.602176634e-19 J YY_BREAK case 100: YY_RULE_SETUP -#line 163 "" -return LOG; +#line 167 "QuantityParser.l" +yylval = Quantity::Degree; return UNIT; // degree (internal standard angle) YY_BREAK case 101: YY_RULE_SETUP -#line 164 "" -return LOG10; +#line 168 "QuantityParser.l" +yylval = Quantity::Degree; return UNIT; // degree (internal standard angle) YY_BREAK case 102: YY_RULE_SETUP -#line 165 "" -return POW; +#line 169 "QuantityParser.l" +yylval = Quantity::Radian; return UNIT; // radian YY_BREAK case 103: YY_RULE_SETUP -#line 166 "" -return SIN; +#line 170 "QuantityParser.l" +yylval = Quantity::Gon; return UNIT; // gon YY_BREAK case 104: YY_RULE_SETUP -#line 167 "" -return SINH; +#line 171 "QuantityParser.l" +yylval = Quantity::AngMinute; return UNIT; // minute(Angular) YY_BREAK case 105: YY_RULE_SETUP -#line 168 "" -return TAN; +#line 172 "QuantityParser.l" +yylval = Quantity::AngMinute; return UNIT; // minute(Angular) YY_BREAK case 106: YY_RULE_SETUP -#line 169 "" -return TANH; +#line 173 "QuantityParser.l" +yylval = Quantity::AngSecond; return UNIT; // second(Angular) YY_BREAK case 107: YY_RULE_SETUP -#line 170 "" -return SQRT; +#line 174 "QuantityParser.l" +yylval = Quantity::AngSecond; return UNIT; // second(Angular) YY_BREAK case 108: YY_RULE_SETUP -#line 172 "" -return *yytext; +#line 176 "QuantityParser.l" +yylval = Quantity(1.0); return ONE; YY_BREAK case 109: YY_RULE_SETUP -#line 173 "" +#line 177 "QuantityParser.l" +{ yylval = Quantity(num_change(yytext,'.',','));return NUM; } + YY_BREAK +case 110: +YY_RULE_SETUP +#line 178 "QuantityParser.l" +{ yylval = Quantity(num_change(yytext,'.',','));return NUM; } + YY_BREAK +case 111: +YY_RULE_SETUP +#line 179 "QuantityParser.l" +{ yylval = Quantity(num_change(yytext,',','.'));return NUM; } + YY_BREAK +case 112: +YY_RULE_SETUP +#line 180 "QuantityParser.l" +{ yylval = Quantity(num_change(yytext,',','.'));return NUM; } + YY_BREAK +case 113: +YY_RULE_SETUP +#line 183 "QuantityParser.l" +{yylval = Quantity(M_PI) ; return NUM;} // constant pi + YY_BREAK +case 114: +YY_RULE_SETUP +#line 184 "QuantityParser.l" +{yylval = Quantity(M_E) ; return NUM;} // constant e + YY_BREAK +case 115: +YY_RULE_SETUP +#line 186 "QuantityParser.l" +return ACOS; + YY_BREAK +case 116: +YY_RULE_SETUP +#line 187 "QuantityParser.l" +return ASIN; + YY_BREAK +case 117: +YY_RULE_SETUP +#line 188 "QuantityParser.l" +return ATAN; + YY_BREAK +case 118: +YY_RULE_SETUP +#line 189 "QuantityParser.l" +return ATAN2; + YY_BREAK +case 119: +YY_RULE_SETUP +#line 190 "QuantityParser.l" +return COS; + YY_BREAK +case 120: +YY_RULE_SETUP +#line 191 "QuantityParser.l" +return EXP; + YY_BREAK +case 121: +YY_RULE_SETUP +#line 192 "QuantityParser.l" +return ABS; + YY_BREAK +case 122: +YY_RULE_SETUP +#line 193 "QuantityParser.l" +return MOD; + YY_BREAK +case 123: +YY_RULE_SETUP +#line 194 "QuantityParser.l" +return LOG; + YY_BREAK +case 124: +YY_RULE_SETUP +#line 195 "QuantityParser.l" +return LOG10; + YY_BREAK +case 125: +YY_RULE_SETUP +#line 196 "QuantityParser.l" +return POW; + YY_BREAK +case 126: +YY_RULE_SETUP +#line 197 "QuantityParser.l" +return SIN; + YY_BREAK +case 127: +YY_RULE_SETUP +#line 198 "QuantityParser.l" +return SINH; + YY_BREAK +case 128: +YY_RULE_SETUP +#line 199 "QuantityParser.l" +return TAN; + YY_BREAK +case 129: +YY_RULE_SETUP +#line 200 "QuantityParser.l" +return TANH; + YY_BREAK +case 130: +YY_RULE_SETUP +#line 201 "QuantityParser.l" +return SQRT; + YY_BREAK +case 131: +YY_RULE_SETUP +#line 203 "QuantityParser.l" +return *yytext; + YY_BREAK +case 132: +YY_RULE_SETUP +#line 204 "QuantityParser.l" ECHO; YY_BREAK -#line 1434 "QuantityLexer.c" +#line 1565 "QuantityLexer.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(C_COMMENT): yyterminate(); @@ -1729,7 +1861,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 202 ) + if ( yy_current_state >= 228 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1757,11 +1889,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 202 ) + if ( yy_current_state >= 228 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 201); + yy_is_jam = (yy_current_state == 227); return yy_is_jam ? 0 : yy_current_state; } @@ -2400,4 +2532,4 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 173 "" +#line 204 "QuantityParser.l" diff --git a/src/Base/QuantityParser.l b/src/Base/QuantityParser.l index 1c77354f67..18dbc83f15 100644 --- a/src/Base/QuantityParser.l +++ b/src/Base/QuantityParser.l @@ -2,7 +2,12 @@ /* Lexer for the FreeCAD Units language */ /* (c) 2013 Juergen Riegel LGPL */ +/* use this file to generate the file 'QuantityLexer.c' using the program flex +/* the command for this operation is: /* flex --outfile=QuantityLexer.c QuantityParser.l */ +/* (flex for Windows is available here: */ +/* https://sourceforge.net/projects/winflexbison/ */ +/* (you must then change 'flex' to 'win_flex' in the command)) */ /* This disables inclusion of unistd.h, which is not available under Visual C++ * on Win32. The C++ scanner uses STL streams instead. */ @@ -83,7 +88,7 @@ CGRP '\,'[0-9][0-9][0-9] "uK" yylval = Quantity::MicroKelvin; return UNIT; // Kelvin "mol" yylval = Quantity::Mole; return UNIT; // Mole (internal standard amount of substance) -"mmol" yylval = Quantity::Mole; return UNIT; // Milli Mole +"mmol" yylval = Quantity::MilliMole; return UNIT; // Milli Mole "cd" yylval = Quantity::Candela; return UNIT; // Candela (internal standard luminous intensity) @@ -126,7 +131,7 @@ CGRP '\,'[0-9][0-9][0-9] "ksi" yylval = Quantity::KSI; return UNIT; // 1000 x pounds/in^2 "W" yylval = Quantity::Watt; return UNIT; // Watt (kg*m^2/s^3) -"mW" yylval = Quantity::Watt; return UNIT; // Milli Watt +"mW" yylval = Quantity::MilliWatt; return UNIT; // Milli Watt "VA" yylval = Quantity::VoltAmpere; return UNIT; // VoltAmpere (kg*m^2/s^3) "V" yylval = Quantity::Volt; return UNIT; // Volt (kg*m^2/A/s^3) diff --git a/src/Base/UnitsSchemaInternal.cpp b/src/Base/UnitsSchemaInternal.cpp index fae865a09f..60fa2914c4 100644 --- a/src/Base/UnitsSchemaInternal.cpp +++ b/src/Base/UnitsSchemaInternal.cpp @@ -82,10 +82,40 @@ QString UnitsSchemaInternal::schemaTranslate(const Quantity &quant, double &fact } } else if (unit == Unit::Area) { - // TODO Cascade for the Areas - // default action for all cases without special treatment: - unitString = quant.getUnit().getString(); - factor = 1.0; + if (UnitValue < 100) { + unitString = QString::fromLatin1("mm^2"); + factor = 1.0; + } + else if (UnitValue < 1e6) { + unitString = QString::fromLatin1("cm^2"); + factor = 100; + } + else if (UnitValue < 1e12) { + unitString = QString::fromLatin1("m^2"); + factor = 1e6; + } + else { // bigger than 1 square kilometer + unitString = QString::fromLatin1("km^2"); + factor = 1e12; + } + } + else if (unit == Unit::Volume) { + if (UnitValue < 1e3) {// smaller than 1 ul + unitString = QString::fromLatin1("mm^3"); + factor = 1.0; + } + else if (UnitValue < 1e6) { + unitString = QString::fromLatin1("ml"); + factor = 1e3; + } + else if (UnitValue < 1e9) { + unitString = QString::fromLatin1("l"); + factor = 1e6; + } + else { // bigger than 1000 l + unitString = QString::fromLatin1("m^3"); + factor = 1e9; + } } else if (unit == Unit::Angle) { // TODO Cascade for the Areas @@ -164,12 +194,50 @@ QString UnitsSchemaInternal::schemaTranslate(const Quantity &quant, double &fact } } else if (unit == Unit::Power) { - unitString = QString::fromLatin1("W"); - factor = 1000000; + if (UnitValue < 1e6) { + unitString = QString::fromLatin1("mW"); + factor = 1e3; + } + else { + unitString = QString::fromLatin1("W"); + factor = 1e6; + } } else if (unit == Unit::ElectricPotential) { - unitString = QString::fromLatin1("V"); - factor = 1000000; + if (UnitValue < 1e6) { + unitString = QString::fromLatin1("mV"); + factor = 1e3; + } + else if (UnitValue < 1e9) { + unitString = QString::fromLatin1("V"); + factor = 1e6; + } + else if (UnitValue < 1e12) { + unitString = QString::fromLatin1("kV"); + factor = 1e9; + } + else { // > 1000 kV scientificc notation + unitString = QString::fromLatin1("V"); + factor = 1.0; + } + } + else if (unit == Unit::Work) { + if (UnitValue < 1.602176634e-10) { + unitString = QString::fromLatin1("eV"); + factor = 1.602176634e-13; + } + else if (UnitValue < 1e9) { + unitString = QString::fromLatin1("J"); + factor = 1e6; + } + else if (UnitValue < 1e12) { + unitString = QString::fromLatin1("kJ"); + factor = 1e9; + } + else { // bigger than 1000 kJ -> scientific notation + unitString = QString::fromLatin1("J"); + factor = 1.0; + } } else if (unit == Unit::SpecificEnergy) { unitString = QString::fromLatin1("m^2/s^2"); @@ -179,6 +247,46 @@ QString UnitsSchemaInternal::schemaTranslate(const Quantity &quant, double &fact unitString = QString::fromLatin1("W/m^2"); factor = 1.0; } + else if (unit == Unit::ElectricalCapacitance) { + if (UnitValue < 1e-15) { + unitString = QString::fromLatin1("pF"); + factor = 1e-18; + } + else if (UnitValue < 1e-12) { + unitString = QString::fromLatin1("nF"); + factor = 1e-15; + } + else if (UnitValue < 1e-9) { + unitString = QString::fromUtf8("µF"); + factor = 1e-12; + } + else if (UnitValue < 1e-6) { + unitString = QString::fromLatin1("mF"); + factor = 1e-9; + } + else { + unitString = QString::fromLatin1("F"); + factor = 1e-6; + } + } + else if (unit == Unit::ElectricalInductance) { + if (UnitValue < 1.0) { + unitString = QString::fromLatin1("nH"); + factor = 1e-3; + } + else if (UnitValue < 1e3) { + unitString = QString::fromUtf8("µH"); + factor = 1.0; + } + else if (UnitValue < 1e6) { + unitString = QString::fromLatin1("mH"); + factor = 1e3; + } + else { + unitString = QString::fromLatin1("H"); + factor = 1e6; + } + } else if (unit == Unit::Frequency) { if (UnitValue < 1000.0) { unitString = QString::fromLatin1("Hz"); diff --git a/src/Base/UnitsSchemaMKS.cpp b/src/Base/UnitsSchemaMKS.cpp index 7ebc853839..1839fb7837 100644 --- a/src/Base/UnitsSchemaMKS.cpp +++ b/src/Base/UnitsSchemaMKS.cpp @@ -73,17 +73,39 @@ QString UnitsSchemaMKS::schemaTranslate(const Quantity &quant, double &factor, Q } } else if (unit == Unit::Area) { - if (UnitValue < 100.0) {// smaller than 1 square cm + if (UnitValue < 100) { unitString = QString::fromLatin1("mm^2"); factor = 1.0; } - else if (UnitValue < 10000000000000.0) { - unitString = QString::fromLatin1("m^2"); - factor = 1000000.0; + else if (UnitValue < 1e6) { + unitString = QString::fromLatin1("cm^2"); + factor = 100; } - else { // bigger then 1 square kilometer + else if (UnitValue < 1e12) { + unitString = QString::fromLatin1("m^2"); + factor = 1e6; + } + else { // bigger than 1 square kilometer unitString = QString::fromLatin1("km^2"); - factor = 1000000000000.0; + factor = 1e12; + } + } + else if (unit == Unit::Volume) { + if (UnitValue < 1e3) {// smaller than 1 ul + unitString = QString::fromLatin1("mm^3"); + factor = 1.0; + } + else if (UnitValue < 1e6) { + unitString = QString::fromLatin1("ml"); + factor = 1e3; + } + else if (UnitValue < 1e9) { + unitString = QString::fromLatin1("l"); + factor = 1e6; + } + else { // bigger than 1000 l + unitString = QString::fromLatin1("m^3"); + factor = 1e9; } } else if (unit == Unit::Mass) { @@ -237,7 +259,11 @@ QString UnitsSchemaMKS::schemaTranslate(const Quantity &quant, double &factor, Q } } else if (unit == Unit::Work) { - if (UnitValue < 1e3) { + if (UnitValue < 1.602176634e-10) { + unitString = QString::fromLatin1("eV"); + factor = 1.602176634e-13; + } + if (UnitValue < 1e9) { unitString = QString::fromLatin1("J"); factor = 1e6; }