Make Unit string output parsably and add Pascale and Newtons
This commit is contained in:
parent
23eb4c7a08
commit
714f591294
|
@ -361,8 +361,8 @@ static void yy_fatal_error (yyconst char msg[] );
|
|||
*yy_cp = '\0'; \
|
||||
(yy_c_buf_p) = yy_cp;
|
||||
|
||||
#define YY_NUM_RULES 63
|
||||
#define YY_END_OF_BUFFER 64
|
||||
#define YY_NUM_RULES 65
|
||||
#define YY_END_OF_BUFFER 66
|
||||
/* This struct is not used in this scanner,
|
||||
but its presence is necessary. */
|
||||
struct yy_trans_info
|
||||
|
@ -370,20 +370,20 @@ struct yy_trans_info
|
|||
flex_int32_t yy_verify;
|
||||
flex_int32_t yy_nxt;
|
||||
};
|
||||
static yyconst flex_int16_t yy_accept[107] =
|
||||
static yyconst flex_int16_t yy_accept[110] =
|
||||
{ 0,
|
||||
0, 0, 64, 63, 1, 2, 33, 35, 3, 44,
|
||||
20, 24, 63, 63, 63, 63, 46, 63, 14, 19,
|
||||
63, 63, 11, 9, 63, 63, 63, 63, 17, 16,
|
||||
63, 2, 43, 44, 23, 0, 0, 0, 0, 28,
|
||||
7, 0, 0, 0, 8, 0, 34, 0, 32, 22,
|
||||
15, 10, 38, 0, 21, 25, 13, 0, 6, 0,
|
||||
4, 39, 45, 0, 0, 0, 0, 40, 0, 36,
|
||||
26, 12, 5, 37, 43, 0, 53, 0, 0, 0,
|
||||
51, 41, 29, 52, 31, 55, 18, 54, 27, 57,
|
||||
30, 58, 0, 60, 0, 42, 47, 48, 49, 0,
|
||||
0, 0, 66, 65, 1, 2, 33, 35, 3, 46,
|
||||
20, 24, 65, 42, 65, 65, 65, 65, 48, 65,
|
||||
14, 19, 65, 65, 11, 9, 65, 65, 65, 65,
|
||||
17, 16, 65, 2, 45, 46, 23, 43, 0, 0,
|
||||
0, 0, 28, 7, 0, 0, 0, 8, 0, 34,
|
||||
0, 32, 22, 15, 10, 38, 0, 21, 25, 13,
|
||||
0, 6, 0, 4, 39, 47, 0, 0, 0, 0,
|
||||
40, 0, 36, 26, 12, 5, 37, 45, 0, 55,
|
||||
0, 0, 0, 53, 41, 29, 54, 31, 57, 18,
|
||||
56, 27, 59, 30, 60, 0, 62, 0, 44, 49,
|
||||
|
||||
59, 62, 61, 50, 56, 0
|
||||
50, 51, 0, 61, 64, 63, 52, 58, 0
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_ec[256] =
|
||||
|
@ -395,13 +395,13 @@ static yyconst flex_int32_t yy_ec[256] =
|
|||
6, 6, 7, 8, 7, 8, 6, 9, 10, 11,
|
||||
12, 12, 12, 12, 12, 12, 12, 1, 1, 1,
|
||||
6, 1, 1, 1, 13, 1, 1, 1, 14, 1,
|
||||
1, 1, 1, 1, 15, 1, 16, 1, 1, 1,
|
||||
1, 1, 1, 1, 15, 1, 16, 17, 1, 18,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 6, 1, 1, 17, 18, 19, 20,
|
||||
1, 1, 1, 6, 1, 1, 19, 20, 21, 22,
|
||||
|
||||
21, 22, 23, 24, 25, 1, 26, 27, 28, 29,
|
||||
30, 31, 32, 33, 34, 35, 1, 1, 36, 37,
|
||||
38, 39, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
23, 24, 25, 26, 27, 1, 28, 29, 30, 31,
|
||||
32, 33, 34, 35, 36, 37, 1, 1, 38, 39,
|
||||
40, 41, 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, 1,
|
||||
|
@ -418,90 +418,97 @@ static yyconst flex_int32_t yy_ec[256] =
|
|||
1, 1, 1, 1, 1
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_meta[40] =
|
||||
static yyconst flex_int32_t yy_meta[42] =
|
||||
{ 0,
|
||||
1, 1, 1, 2, 1, 1, 1, 2, 3, 3,
|
||||
3, 3, 1, 4, 1, 1, 1, 1, 1, 1,
|
||||
4, 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, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_base[109] =
|
||||
static yyconst flex_int16_t yy_base[110] =
|
||||
{ 0,
|
||||
0, 0, 134, 135, 135, 130, 135, 135, 135, 36,
|
||||
135, 135, 119, 23, 23, 24, 94, 100, 99, 135,
|
||||
99, 33, 30, 49, 99, 87, 24, 108, 38, 51,
|
||||
61, 121, 57, 61, 135, 89, 92, 96, 103, 135,
|
||||
135, 85, 83, 94, 135, 85, 135, 86, 135, 135,
|
||||
135, 135, 135, 91, 135, 135, 135, 84, 135, 60,
|
||||
135, 135, 135, 76, 91, 63, 58, 135, 61, 135,
|
||||
135, 135, 135, 135, 67, 86, 135, 52, 56, 54,
|
||||
135, 135, 135, 135, 135, 72, 135, 135, 135, 135,
|
||||
135, 43, 31, 31, 90, 94, 135, 135, 39, 38,
|
||||
0, 0, 149, 150, 150, 145, 150, 150, 150, 38,
|
||||
150, 150, 134, 150, 127, 23, 23, 28, 106, 112,
|
||||
111, 150, 111, 39, 34, 50, 111, 99, 30, 120,
|
||||
44, 48, 58, 135, 75, 91, 150, 150, 101, 104,
|
||||
108, 115, 150, 150, 97, 95, 106, 150, 97, 150,
|
||||
98, 150, 150, 150, 150, 150, 103, 150, 150, 150,
|
||||
96, 150, 50, 150, 150, 150, 88, 103, 93, 88,
|
||||
150, 66, 150, 150, 150, 150, 150, 95, 101, 150,
|
||||
60, 63, 61, 150, 150, 150, 150, 150, 81, 150,
|
||||
150, 150, 150, 150, 64, 39, 44, 105, 110, 150,
|
||||
|
||||
135, 135, 135, 135, 135, 135, 105, 106
|
||||
150, 57, 47, 150, 150, 150, 150, 150, 150
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_def[109] =
|
||||
static yyconst flex_int16_t yy_def[110] =
|
||||
{ 0,
|
||||
106, 1, 106, 106, 106, 106, 106, 106, 106, 107,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 108, 107, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 108, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
109, 1, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
|
||||
106, 106, 106, 106, 106, 0, 106, 106
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 0
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_nxt[175] =
|
||||
static yyconst flex_int16_t yy_nxt[192] =
|
||||
{ 0,
|
||||
4, 5, 6, 7, 8, 9, 9, 4, 10, 10,
|
||||
10, 10, 11, 4, 12, 13, 14, 4, 15, 16,
|
||||
10, 10, 11, 4, 12, 13, 14, 15, 16, 4,
|
||||
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
|
||||
27, 4, 28, 29, 30, 4, 4, 31, 4, 33,
|
||||
36, 37, 40, 33, 44, 50, 105, 53, 63, 104,
|
||||
41, 45, 42, 64, 103, 51, 38, 39, 43, 54,
|
||||
52, 55, 66, 56, 33, 102, 101, 69, 33, 67,
|
||||
76, 57, 68, 58, 70, 71, 59, 76, 60, 88,
|
||||
76, 100, 99, 72, 98, 97, 89, 76, 73, 94,
|
||||
93, 92, 95, 74, 96, 96, 96, 96, 96, 96,
|
||||
27, 28, 29, 4, 30, 31, 32, 4, 4, 33,
|
||||
4, 35, 39, 40, 43, 35, 36, 36, 36, 36,
|
||||
47, 53, 44, 56, 45, 108, 66, 48, 41, 42,
|
||||
46, 67, 58, 54, 59, 57, 72, 107, 55, 106,
|
||||
69, 91, 74, 73, 60, 105, 61, 70, 92, 62,
|
||||
71, 63, 75, 78, 78, 78, 78, 76, 79, 104,
|
||||
103, 102, 77, 101, 35, 100, 97, 79, 35, 36,
|
||||
|
||||
36, 36, 36, 78, 78, 78, 78, 98, 79, 99,
|
||||
99, 99, 99, 99, 99, 99, 99, 79, 99, 99,
|
||||
99, 99, 96, 95, 94, 93, 90, 89, 88, 87,
|
||||
86, 85, 84, 83, 82, 81, 80, 34, 68, 65,
|
||||
64, 52, 51, 50, 49, 38, 37, 34, 109, 3,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109
|
||||
|
||||
96, 96, 96, 96, 96, 96, 34, 34, 75, 75,
|
||||
91, 90, 87, 86, 85, 84, 83, 82, 81, 80,
|
||||
79, 78, 77, 32, 65, 62, 61, 49, 48, 47,
|
||||
46, 35, 32, 106, 3, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_chk[175] =
|
||||
static yyconst flex_int16_t yy_chk[192] =
|
||||
{ 0,
|
||||
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, 1, 1, 10,
|
||||
14, 14, 15, 10, 16, 22, 100, 23, 27, 99,
|
||||
15, 16, 15, 27, 94, 22, 14, 14, 15, 23,
|
||||
22, 24, 29, 24, 34, 93, 92, 30, 34, 29,
|
||||
33, 24, 29, 24, 30, 31, 24, 33, 24, 60,
|
||||
75, 86, 80, 31, 79, 78, 60, 75, 31, 69,
|
||||
67, 66, 76, 31, 76, 76, 76, 76, 95, 95,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 10, 16, 16, 17, 10, 10, 10, 10, 10,
|
||||
18, 24, 17, 25, 17, 103, 29, 18, 16, 16,
|
||||
17, 29, 26, 24, 26, 25, 32, 102, 24, 97,
|
||||
31, 63, 33, 32, 26, 96, 26, 31, 63, 26,
|
||||
31, 26, 33, 35, 35, 35, 35, 33, 35, 95,
|
||||
89, 83, 33, 82, 36, 81, 72, 35, 36, 36,
|
||||
|
||||
36, 36, 36, 78, 78, 78, 78, 79, 78, 79,
|
||||
79, 79, 79, 98, 98, 98, 98, 78, 99, 99,
|
||||
99, 99, 70, 69, 68, 67, 61, 57, 51, 49,
|
||||
47, 46, 45, 42, 41, 40, 39, 34, 30, 28,
|
||||
27, 23, 21, 20, 19, 15, 13, 6, 3, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
|
||||
109
|
||||
|
||||
95, 95, 96, 96, 96, 96, 107, 107, 108, 108,
|
||||
65, 64, 58, 54, 48, 46, 44, 43, 42, 39,
|
||||
38, 37, 36, 32, 28, 26, 25, 21, 19, 18,
|
||||
17, 13, 6, 3, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106
|
||||
} ;
|
||||
|
||||
static yy_state_type yy_last_accepting_state;
|
||||
|
@ -531,7 +538,7 @@ char *yytext;
|
|||
/*** Flex Declarations and Options ***/
|
||||
/* the manual says "somewhat more optimized" */
|
||||
/* no support for include files is planned */
|
||||
#line 535 "QuantityLexer.c"
|
||||
#line 542 "QuantityLexer.c"
|
||||
|
||||
#define INITIAL 0
|
||||
|
||||
|
@ -715,7 +722,7 @@ YY_DECL
|
|||
|
||||
|
||||
|
||||
#line 719 "QuantityLexer.c"
|
||||
#line 726 "QuantityLexer.c"
|
||||
|
||||
if ( !(yy_init) )
|
||||
{
|
||||
|
@ -768,13 +775,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 >= 107 )
|
||||
if ( yy_current_state >= 110 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
++yy_cp;
|
||||
}
|
||||
while ( yy_current_state != 106 );
|
||||
while ( yy_current_state != 109 );
|
||||
yy_cp = (yy_last_accepting_cpos);
|
||||
yy_current_state = (yy_last_accepting_state);
|
||||
|
||||
|
@ -868,7 +875,7 @@ yylval = Quantity(1.0e-3 ,Unit(0,1)); return UNIT; // gram
|
|||
case 15:
|
||||
YY_RULE_SETUP
|
||||
#line 47 "QuantityParser.l"
|
||||
yylval = Quantity(1.0 ,Unit(0,1)); return UNIT; // kilo gram
|
||||
yylval = Quantity(1.0 ,Unit(0,1)); return UNIT; // kilo gram (internal standard for mass)
|
||||
YY_BREAK
|
||||
case 16:
|
||||
YY_RULE_SETUP
|
||||
|
@ -968,149 +975,159 @@ yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot
|
|||
case 35:
|
||||
YY_RULE_SETUP
|
||||
#line 74 "QuantityParser.l"
|
||||
yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot
|
||||
yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot
|
||||
YY_BREAK
|
||||
case 36:
|
||||
YY_RULE_SETUP
|
||||
#line 75 "QuantityParser.l"
|
||||
yylval = Quantity(0.0254 ,Unit(1)); return UNIT; // thou
|
||||
yylval = Quantity(0.0254 ,Unit(1)); return UNIT; // thou
|
||||
YY_BREAK
|
||||
case 37:
|
||||
YY_RULE_SETUP
|
||||
#line 76 "QuantityParser.l"
|
||||
yylval = Quantity(914.4 ,Unit(1)); return UNIT; // yard
|
||||
yylval = Quantity(914.4 ,Unit(1)); return UNIT; // yard
|
||||
YY_BREAK
|
||||
case 38:
|
||||
YY_RULE_SETUP
|
||||
#line 79 "QuantityParser.l"
|
||||
yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // pound
|
||||
yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // pound
|
||||
YY_BREAK
|
||||
case 39:
|
||||
YY_RULE_SETUP
|
||||
#line 80 "QuantityParser.l"
|
||||
yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // ounce
|
||||
yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // ounce
|
||||
YY_BREAK
|
||||
case 40:
|
||||
YY_RULE_SETUP
|
||||
#line 81 "QuantityParser.l"
|
||||
yylval = Quantity(6.35029318 ,Unit(0,1)); return UNIT; // Stone
|
||||
yylval = Quantity(6.35029318 ,Unit(0,1)); return UNIT; // Stone
|
||||
YY_BREAK
|
||||
case 41:
|
||||
YY_RULE_SETUP
|
||||
#line 82 "QuantityParser.l"
|
||||
yylval = Quantity(50.80234544 ,Unit(0,1)); return UNIT; // hundredweights
|
||||
yylval = Quantity(50.80234544 ,Unit(0,1)); return UNIT; // hundredweights
|
||||
YY_BREAK
|
||||
case 42:
|
||||
YY_RULE_SETUP
|
||||
#line 86 "QuantityParser.l"
|
||||
{for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
|
||||
#line 84 "QuantityParser.l"
|
||||
yylval = Quantity(1000.0 ,Unit(1,1,-2)); return UNIT; // Newton (kg*m/s^2)
|
||||
YY_BREAK
|
||||
case 43:
|
||||
YY_RULE_SETUP
|
||||
#line 87 "QuantityParser.l"
|
||||
{for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
|
||||
#line 85 "QuantityParser.l"
|
||||
yylval = Quantity(0.001 ,Unit(-1,1,-2)); return UNIT; // Pascal (kg/m*s^2)
|
||||
YY_BREAK
|
||||
case 44:
|
||||
YY_RULE_SETUP
|
||||
#line 88 "QuantityParser.l"
|
||||
{yylval = atof( yytext ); return NUM;}
|
||||
#line 89 "QuantityParser.l"
|
||||
{for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
|
||||
YY_BREAK
|
||||
case 45:
|
||||
YY_RULE_SETUP
|
||||
#line 90 "QuantityParser.l"
|
||||
{yylval = M_PI ; return NUM;} // constant pi
|
||||
{for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
|
||||
YY_BREAK
|
||||
case 46:
|
||||
YY_RULE_SETUP
|
||||
#line 91 "QuantityParser.l"
|
||||
{yylval = M_E ; return NUM;} // constant e
|
||||
{yylval = atof( yytext ); return NUM;}
|
||||
YY_BREAK
|
||||
case 47:
|
||||
YY_RULE_SETUP
|
||||
#line 93 "QuantityParser.l"
|
||||
return ACOS;
|
||||
{yylval = M_PI ; return NUM;} // constant pi
|
||||
YY_BREAK
|
||||
case 48:
|
||||
YY_RULE_SETUP
|
||||
#line 94 "QuantityParser.l"
|
||||
return ASIN;
|
||||
{yylval = M_E ; return NUM;} // constant e
|
||||
YY_BREAK
|
||||
case 49:
|
||||
YY_RULE_SETUP
|
||||
#line 95 "QuantityParser.l"
|
||||
return ATAN;
|
||||
#line 96 "QuantityParser.l"
|
||||
return ACOS;
|
||||
YY_BREAK
|
||||
case 50:
|
||||
YY_RULE_SETUP
|
||||
#line 96 "QuantityParser.l"
|
||||
return ATAN2;
|
||||
#line 97 "QuantityParser.l"
|
||||
return ASIN;
|
||||
YY_BREAK
|
||||
case 51:
|
||||
YY_RULE_SETUP
|
||||
#line 97 "QuantityParser.l"
|
||||
return COS;
|
||||
#line 98 "QuantityParser.l"
|
||||
return ATAN;
|
||||
YY_BREAK
|
||||
case 52:
|
||||
YY_RULE_SETUP
|
||||
#line 98 "QuantityParser.l"
|
||||
return EXP;
|
||||
#line 99 "QuantityParser.l"
|
||||
return ATAN2;
|
||||
YY_BREAK
|
||||
case 53:
|
||||
YY_RULE_SETUP
|
||||
#line 99 "QuantityParser.l"
|
||||
return ABS;
|
||||
#line 100 "QuantityParser.l"
|
||||
return COS;
|
||||
YY_BREAK
|
||||
case 54:
|
||||
YY_RULE_SETUP
|
||||
#line 100 "QuantityParser.l"
|
||||
return MOD;
|
||||
#line 101 "QuantityParser.l"
|
||||
return EXP;
|
||||
YY_BREAK
|
||||
case 55:
|
||||
YY_RULE_SETUP
|
||||
#line 101 "QuantityParser.l"
|
||||
return LOG;
|
||||
#line 102 "QuantityParser.l"
|
||||
return ABS;
|
||||
YY_BREAK
|
||||
case 56:
|
||||
YY_RULE_SETUP
|
||||
#line 102 "QuantityParser.l"
|
||||
return LOG10;
|
||||
#line 103 "QuantityParser.l"
|
||||
return MOD;
|
||||
YY_BREAK
|
||||
case 57:
|
||||
YY_RULE_SETUP
|
||||
#line 103 "QuantityParser.l"
|
||||
return POW;
|
||||
#line 104 "QuantityParser.l"
|
||||
return LOG;
|
||||
YY_BREAK
|
||||
case 58:
|
||||
YY_RULE_SETUP
|
||||
#line 104 "QuantityParser.l"
|
||||
return SIN;
|
||||
#line 105 "QuantityParser.l"
|
||||
return LOG10;
|
||||
YY_BREAK
|
||||
case 59:
|
||||
YY_RULE_SETUP
|
||||
#line 105 "QuantityParser.l"
|
||||
return SINH;
|
||||
#line 106 "QuantityParser.l"
|
||||
return POW;
|
||||
YY_BREAK
|
||||
case 60:
|
||||
YY_RULE_SETUP
|
||||
#line 106 "QuantityParser.l"
|
||||
return TAN;
|
||||
#line 107 "QuantityParser.l"
|
||||
return SIN;
|
||||
YY_BREAK
|
||||
case 61:
|
||||
YY_RULE_SETUP
|
||||
#line 107 "QuantityParser.l"
|
||||
return TANH;
|
||||
#line 108 "QuantityParser.l"
|
||||
return SINH;
|
||||
YY_BREAK
|
||||
case 62:
|
||||
YY_RULE_SETUP
|
||||
#line 108 "QuantityParser.l"
|
||||
return SQRT;
|
||||
#line 109 "QuantityParser.l"
|
||||
return TAN;
|
||||
YY_BREAK
|
||||
case 63:
|
||||
YY_RULE_SETUP
|
||||
#line 110 "QuantityParser.l"
|
||||
return TANH;
|
||||
YY_BREAK
|
||||
case 64:
|
||||
YY_RULE_SETUP
|
||||
#line 111 "QuantityParser.l"
|
||||
return SQRT;
|
||||
YY_BREAK
|
||||
case 65:
|
||||
YY_RULE_SETUP
|
||||
#line 113 "QuantityParser.l"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 1114 "QuantityLexer.c"
|
||||
#line 1131 "QuantityLexer.c"
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
yyterminate();
|
||||
|
||||
|
@ -1403,7 +1420,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 >= 107 )
|
||||
if ( yy_current_state >= 110 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
|
@ -1431,11 +1448,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 >= 107 )
|
||||
if ( yy_current_state >= 110 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_is_jam = (yy_current_state == 106);
|
||||
yy_is_jam = (yy_current_state == 109);
|
||||
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
}
|
||||
|
@ -2068,4 +2085,4 @@ void yyfree (void * ptr )
|
|||
|
||||
#define YYTABLES_NAME "yytables"
|
||||
|
||||
#line 110 "QuantityParser.l"
|
||||
#line 113 "QuantityParser.l"
|
||||
|
|
|
@ -381,18 +381,18 @@ union yyalloc
|
|||
#endif /* !YYCOPY_NEEDED */
|
||||
|
||||
/* YYFINAL -- State number of the termination state. */
|
||||
#define YYFINAL 43
|
||||
#define YYFINAL 45
|
||||
/* YYLAST -- Last index in YYTABLE. */
|
||||
#define YYLAST 259
|
||||
#define YYLAST 262
|
||||
|
||||
/* YYNTOKENS -- Number of terminals. */
|
||||
#define YYNTOKENS 30
|
||||
/* YYNNTS -- Number of nonterminals. */
|
||||
#define YYNNTS 5
|
||||
/* YYNRULES -- Number of rules. */
|
||||
#define YYNRULES 34
|
||||
#define YYNRULES 35
|
||||
/* YYNRULES -- Number of states. */
|
||||
#define YYNSTATES 102
|
||||
#define YYNSTATES 106
|
||||
|
||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||
#define YYUNDEFTOK 2
|
||||
|
@ -442,7 +442,7 @@ static const yytype_uint8 yyprhs[] =
|
|||
0, 0, 3, 5, 7, 9, 12, 14, 18, 22,
|
||||
26, 30, 33, 37, 41, 46, 51, 56, 63, 68,
|
||||
73, 80, 85, 90, 97, 102, 107, 112, 117, 122,
|
||||
127, 129, 133, 137, 141
|
||||
127, 129, 133, 137, 141, 145
|
||||
};
|
||||
|
||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
||||
|
@ -462,7 +462,7 @@ static const yytype_int8 yyrhs[] =
|
|||
28, -1, 19, 27, 32, 28, -1, 20, 27, 32,
|
||||
28, -1, 9, 27, 32, 28, -1, 3, -1, 33,
|
||||
23, 33, -1, 33, 24, 33, -1, 33, 26, 32,
|
||||
-1, 32, 33, -1
|
||||
-1, 27, 33, 28, -1, 32, 33, -1
|
||||
};
|
||||
|
||||
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||
|
@ -471,7 +471,7 @@ static const yytype_uint8 yyrline[] =
|
|||
0, 26, 26, 27, 28, 29, 31, 32, 33, 34,
|
||||
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
|
||||
45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
|
||||
57, 58, 59, 60, 62
|
||||
57, 58, 59, 60, 61, 63
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -504,7 +504,7 @@ static const yytype_uint8 yyr1[] =
|
|||
0, 30, 31, 31, 31, 31, 32, 32, 32, 32,
|
||||
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
|
||||
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
|
||||
33, 33, 33, 33, 34
|
||||
33, 33, 33, 33, 33, 34
|
||||
};
|
||||
|
||||
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
||||
|
@ -513,7 +513,7 @@ static const yytype_uint8 yyr2[] =
|
|||
0, 2, 1, 1, 1, 2, 1, 3, 3, 3,
|
||||
3, 2, 3, 3, 4, 4, 4, 6, 4, 4,
|
||||
6, 4, 4, 6, 4, 4, 4, 4, 4, 4,
|
||||
1, 3, 3, 3, 2
|
||||
1, 3, 3, 3, 3, 2
|
||||
};
|
||||
|
||||
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
|
||||
|
@ -525,43 +525,43 @@ static const yytype_uint8 yydefact[] =
|
|||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 2, 3, 4, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 11, 0, 1, 0, 0, 0, 0, 0, 34,
|
||||
0, 0, 0, 0, 5, 0, 0, 0, 0, 0,
|
||||
0, 0, 11, 0, 0, 1, 0, 0, 0, 0,
|
||||
0, 0, 35, 0, 0, 0, 0, 5, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 13, 8, 7, 9, 10, 12, 31, 32, 33,
|
||||
14, 15, 16, 0, 29, 19, 18, 0, 21, 22,
|
||||
0, 24, 25, 26, 27, 28, 0, 0, 0, 17,
|
||||
20, 23
|
||||
0, 0, 0, 0, 13, 34, 8, 7, 9, 10,
|
||||
12, 31, 32, 33, 14, 15, 16, 0, 29, 19,
|
||||
18, 0, 21, 22, 0, 24, 25, 26, 27, 28,
|
||||
0, 0, 0, 17, 20, 23
|
||||
};
|
||||
|
||||
/* YYDEFGOTO[NTERM-NUM]. */
|
||||
static const yytype_int8 yydefgoto[] =
|
||||
{
|
||||
-1, 21, 22, 49, 24
|
||||
-1, 21, 43, 44, 24
|
||||
};
|
||||
|
||||
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
||||
STATE-NUM. */
|
||||
#define YYPACT_NINF -25
|
||||
#define YYPACT_NINF -23
|
||||
static const yytype_int16 yypact[] =
|
||||
{
|
||||
69, -25, -25, -24, -23, -5, -4, -3, 3, 4,
|
||||
5, 27, 28, 29, 35, 40, 72, 78, 86, 30,
|
||||
30, 70, 88, 229, 30, 30, 30, 30, 30, 30,
|
||||
30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
|
||||
30, 81, 80, -25, 30, 30, 30, 30, 30, 229,
|
||||
95, 95, 30, 88, -25, 103, 111, 119, 37, 127,
|
||||
135, 143, 71, 151, 159, 94, 167, 175, 183, 191,
|
||||
199, -25, 233, 233, 81, 81, 81, 93, 93, 43,
|
||||
-25, -25, -25, 30, -25, -25, -25, 30, -25, -25,
|
||||
30, -25, -25, -25, -25, -25, 207, 215, 223, -25,
|
||||
-25, -25
|
||||
92, -23, -23, -22, -19, -13, -10, -5, -4, 16,
|
||||
17, 36, 39, 44, 54, 65, 89, 111, 124, 116,
|
||||
92, 7, 38, 91, 116, 116, 116, 116, 116, 116,
|
||||
116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
|
||||
116, 116, 31, 30, 62, -23, 116, 116, 116, 116,
|
||||
116, 18, 91, 18, 18, 116, 38, -23, 56, 118,
|
||||
126, -20, 134, 142, 150, -11, 158, 166, 46, 174,
|
||||
182, 190, 198, 206, -23, -23, 236, 236, 31, 31,
|
||||
31, 57, 57, 67, -23, -23, -23, 116, -23, -23,
|
||||
-23, 116, -23, -23, 116, -23, -23, -23, -23, -23,
|
||||
214, 222, 230, -23, -23, -23
|
||||
};
|
||||
|
||||
/* YYPGOTO[NTERM-NUM]. */
|
||||
static const yytype_int8 yypgoto[] =
|
||||
{
|
||||
-25, -25, -19, 2, 97
|
||||
-23, -23, 0, 20, -8
|
||||
};
|
||||
|
||||
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
||||
|
@ -570,68 +570,70 @@ static const yytype_int8 yypgoto[] =
|
|||
#define YYTABLE_NINF -1
|
||||
static const yytype_uint8 yytable[] =
|
||||
{
|
||||
41, 42, 23, 25, 26, 53, 55, 56, 57, 58,
|
||||
59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
|
||||
69, 70, 27, 28, 29, 72, 73, 74, 75, 76,
|
||||
30, 31, 32, 79, 2, 3, 4, 5, 6, 7,
|
||||
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
18, 19, 77, 78, 33, 34, 35, 20, 44, 45,
|
||||
46, 47, 36, 48, 96, 45, 83, 37, 97, 48,
|
||||
43, 98, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
|
||||
19, 1, 44, 45, 46, 47, 20, 48, 1, 38,
|
||||
87, 44, 45, 46, 47, 39, 48, 48, 71, 44,
|
||||
45, 46, 47, 40, 48, 44, 45, 46, 47, 52,
|
||||
48, 54, 0, 90, 44, 45, 46, 47, 0, 48,
|
||||
0, 80, 44, 45, 46, 47, 0, 48, 0, 81,
|
||||
44, 45, 46, 47, 0, 48, 0, 82, 44, 45,
|
||||
46, 47, 0, 48, 0, 84, 44, 45, 46, 47,
|
||||
0, 48, 0, 85, 44, 45, 46, 47, 0, 48,
|
||||
0, 86, 44, 45, 46, 47, 0, 48, 0, 88,
|
||||
44, 45, 46, 47, 0, 48, 0, 89, 44, 45,
|
||||
46, 47, 0, 48, 0, 91, 44, 45, 46, 47,
|
||||
0, 48, 0, 92, 44, 45, 46, 47, 0, 48,
|
||||
0, 93, 44, 45, 46, 47, 0, 48, 0, 94,
|
||||
44, 45, 46, 47, 0, 48, 0, 95, 44, 45,
|
||||
46, 47, 0, 48, 0, 99, 44, 45, 46, 47,
|
||||
0, 48, 0, 100, 44, 45, 46, 47, 0, 48,
|
||||
0, 101, 50, 51, 0, 52, 46, 47, 0, 48
|
||||
22, 46, 47, 48, 49, 25, 50, 45, 26, 87,
|
||||
46, 47, 48, 49, 27, 50, 57, 28, 91, 42,
|
||||
23, 1, 29, 30, 56, 58, 59, 60, 61, 62,
|
||||
63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
|
||||
73, 1, 52, 31, 32, 51, 76, 77, 78, 79,
|
||||
80, 46, 47, 48, 49, 83, 50, 50, 74, 46,
|
||||
47, 48, 49, 33, 50, 51, 34, 46, 47, 48,
|
||||
49, 35, 50, 81, 82, 94, 52, 46, 47, 48,
|
||||
49, 36, 50, 55, 84, 53, 54, 100, 55, 47,
|
||||
75, 101, 37, 50, 102, 1, 2, 3, 4, 5,
|
||||
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 53, 54, 38, 55, 0, 20,
|
||||
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
||||
12, 13, 14, 15, 16, 17, 18, 19, 39, 46,
|
||||
47, 48, 49, 41, 50, 0, 85, 46, 47, 48,
|
||||
49, 40, 50, 0, 86, 46, 47, 48, 49, 0,
|
||||
50, 0, 88, 46, 47, 48, 49, 0, 50, 0,
|
||||
89, 46, 47, 48, 49, 0, 50, 0, 90, 46,
|
||||
47, 48, 49, 0, 50, 0, 92, 46, 47, 48,
|
||||
49, 0, 50, 0, 93, 46, 47, 48, 49, 0,
|
||||
50, 0, 95, 46, 47, 48, 49, 0, 50, 0,
|
||||
96, 46, 47, 48, 49, 0, 50, 0, 97, 46,
|
||||
47, 48, 49, 0, 50, 0, 98, 46, 47, 48,
|
||||
49, 0, 50, 0, 99, 46, 47, 48, 49, 0,
|
||||
50, 0, 103, 46, 47, 48, 49, 0, 50, 0,
|
||||
104, 46, 47, 48, 49, 0, 50, 0, 105, 48,
|
||||
49, 0, 50
|
||||
};
|
||||
|
||||
#define yypact_value_is_default(Yystate) \
|
||||
(!!((Yystate) == (-25)))
|
||||
(!!((Yystate) == (-23)))
|
||||
|
||||
#define yytable_value_is_error(Yytable_value) \
|
||||
YYID (0)
|
||||
|
||||
static const yytype_int8 yycheck[] =
|
||||
{
|
||||
19, 20, 0, 27, 27, 24, 25, 26, 27, 28,
|
||||
29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
|
||||
39, 40, 27, 27, 27, 44, 45, 46, 47, 48,
|
||||
27, 27, 27, 52, 4, 5, 6, 7, 8, 9,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||
20, 21, 50, 51, 27, 27, 27, 27, 21, 22,
|
||||
23, 24, 27, 26, 83, 22, 29, 27, 87, 26,
|
||||
0, 90, 3, 4, 5, 6, 7, 8, 9, 10,
|
||||
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||
21, 3, 21, 22, 23, 24, 27, 26, 3, 27,
|
||||
29, 21, 22, 23, 24, 27, 26, 26, 28, 21,
|
||||
22, 23, 24, 27, 26, 21, 22, 23, 24, 26,
|
||||
26, 24, -1, 29, 21, 22, 23, 24, -1, 26,
|
||||
-1, 28, 21, 22, 23, 24, -1, 26, -1, 28,
|
||||
21, 22, 23, 24, -1, 26, -1, 28, 21, 22,
|
||||
23, 24, -1, 26, -1, 28, 21, 22, 23, 24,
|
||||
-1, 26, -1, 28, 21, 22, 23, 24, -1, 26,
|
||||
-1, 28, 21, 22, 23, 24, -1, 26, -1, 28,
|
||||
21, 22, 23, 24, -1, 26, -1, 28, 21, 22,
|
||||
23, 24, -1, 26, -1, 28, 21, 22, 23, 24,
|
||||
-1, 26, -1, 28, 21, 22, 23, 24, -1, 26,
|
||||
-1, 28, 21, 22, 23, 24, -1, 26, -1, 28,
|
||||
21, 22, 23, 24, -1, 26, -1, 28, 21, 22,
|
||||
23, 24, -1, 26, -1, 28, 21, 22, 23, 24,
|
||||
-1, 26, -1, 28, 21, 22, 23, 24, -1, 26,
|
||||
-1, 28, 23, 24, -1, 26, 23, 24, -1, 26
|
||||
0, 21, 22, 23, 24, 27, 26, 0, 27, 29,
|
||||
21, 22, 23, 24, 27, 26, 24, 27, 29, 19,
|
||||
0, 3, 27, 27, 24, 25, 26, 27, 28, 29,
|
||||
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
||||
40, 3, 22, 27, 27, 27, 46, 47, 48, 49,
|
||||
50, 21, 22, 23, 24, 55, 26, 26, 28, 21,
|
||||
22, 23, 24, 27, 26, 27, 27, 21, 22, 23,
|
||||
24, 27, 26, 53, 54, 29, 56, 21, 22, 23,
|
||||
24, 27, 26, 26, 28, 23, 24, 87, 26, 22,
|
||||
28, 91, 27, 26, 94, 3, 4, 5, 6, 7,
|
||||
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
18, 19, 20, 21, 23, 24, 27, 26, -1, 27,
|
||||
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
||||
14, 15, 16, 17, 18, 19, 20, 21, 27, 21,
|
||||
22, 23, 24, 27, 26, -1, 28, 21, 22, 23,
|
||||
24, 27, 26, -1, 28, 21, 22, 23, 24, -1,
|
||||
26, -1, 28, 21, 22, 23, 24, -1, 26, -1,
|
||||
28, 21, 22, 23, 24, -1, 26, -1, 28, 21,
|
||||
22, 23, 24, -1, 26, -1, 28, 21, 22, 23,
|
||||
24, -1, 26, -1, 28, 21, 22, 23, 24, -1,
|
||||
26, -1, 28, 21, 22, 23, 24, -1, 26, -1,
|
||||
28, 21, 22, 23, 24, -1, 26, -1, 28, 21,
|
||||
22, 23, 24, -1, 26, -1, 28, 21, 22, 23,
|
||||
24, -1, 26, -1, 28, 21, 22, 23, 24, -1,
|
||||
26, -1, 28, 21, 22, 23, 24, -1, 26, -1,
|
||||
28, 21, 22, 23, 24, -1, 26, -1, 28, 23,
|
||||
24, -1, 26
|
||||
};
|
||||
|
||||
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
||||
|
@ -642,13 +644,13 @@ static const yytype_uint8 yystos[] =
|
|||
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
|
||||
27, 31, 32, 33, 34, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 32, 32, 0, 21, 22, 23, 24, 26, 33,
|
||||
23, 24, 26, 32, 34, 32, 32, 32, 32, 32,
|
||||
27, 27, 32, 32, 33, 0, 21, 22, 23, 24,
|
||||
26, 27, 33, 23, 24, 26, 32, 34, 32, 32,
|
||||
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
|
||||
32, 28, 32, 32, 32, 32, 32, 33, 33, 32,
|
||||
28, 28, 28, 29, 28, 28, 28, 29, 28, 28,
|
||||
29, 28, 28, 28, 28, 28, 32, 32, 32, 28,
|
||||
28, 28
|
||||
32, 32, 32, 32, 28, 28, 32, 32, 32, 32,
|
||||
32, 33, 33, 32, 28, 28, 28, 29, 28, 28,
|
||||
28, 29, 28, 28, 29, 28, 28, 28, 28, 28,
|
||||
32, 32, 32, 28, 28, 28
|
||||
};
|
||||
|
||||
#define yyerrok (yyerrstatus = 0)
|
||||
|
@ -1633,13 +1635,19 @@ yyreduce:
|
|||
|
||||
case 34:
|
||||
/* Line 1787 of yacc.c */
|
||||
#line 62 "QuantityParser.y"
|
||||
#line 61 "QuantityParser.y"
|
||||
{ (yyval) = (yyvsp[(2) - (3)]); }
|
||||
break;
|
||||
|
||||
case 35:
|
||||
/* Line 1787 of yacc.c */
|
||||
#line 63 "QuantityParser.y"
|
||||
{ (yyval) = (yyvsp[(1) - (2)])*(yyvsp[(2) - (2)]); }
|
||||
break;
|
||||
|
||||
|
||||
/* Line 1787 of yacc.c */
|
||||
#line 1643 "QuantityParser.c"
|
||||
#line 1651 "QuantityParser.c"
|
||||
default: break;
|
||||
}
|
||||
/* User semantic actions sometimes alter yychar, and that requires
|
||||
|
@ -1871,5 +1879,5 @@ yyreturn:
|
|||
|
||||
|
||||
/* Line 2050 of yacc.c */
|
||||
#line 66 "QuantityParser.y"
|
||||
#line 67 "QuantityParser.y"
|
||||
|
||||
|
|
|
@ -41,47 +41,50 @@ ID [a-z][a-z0-9]*
|
|||
"km" yylval = Quantity(1.0e6 ,Unit(1)); return UNIT; // kilo meter
|
||||
"l" yylval = Quantity(1000000.0 ,Unit(3)); return UNIT; // Liter dm^3
|
||||
|
||||
"yg" yylval = Quantity(1.0e-9 ,Unit(0,1)); return UNIT; // milli gram
|
||||
"mg" yylval = Quantity(1.0e-6 ,Unit(0,1)); return UNIT; // milli gram
|
||||
"g" yylval = Quantity(1.0e-3 ,Unit(0,1)); return UNIT; // gram
|
||||
"kg" yylval = Quantity(1.0 ,Unit(0,1)); return UNIT; // kilo gram
|
||||
"t" yylval = Quantity(1000.0 ,Unit(0,1)); return UNIT; // ton
|
||||
"yg" yylval = Quantity(1.0e-9 ,Unit(0,1)); return UNIT; // milli gram
|
||||
"mg" yylval = Quantity(1.0e-6 ,Unit(0,1)); return UNIT; // milli gram
|
||||
"g" yylval = Quantity(1.0e-3 ,Unit(0,1)); return UNIT; // gram
|
||||
"kg" yylval = Quantity(1.0 ,Unit(0,1)); return UNIT; // kilo gram (internal standard for mass)
|
||||
"t" yylval = Quantity(1000.0 ,Unit(0,1)); return UNIT; // ton
|
||||
|
||||
"s" yylval = Quantity(1.0 ,Unit(0,0,1)); return UNIT; // second (internal standard time)
|
||||
"min" yylval = Quantity(60.0 ,Unit(0,0,1)); return UNIT; // minute
|
||||
"h" yylval = Quantity(3600.0 ,Unit(0,0,1)); return UNIT; // hour
|
||||
"s" yylval = Quantity(1.0 ,Unit(0,0,1)); return UNIT; // second (internal standard time)
|
||||
"min" yylval = Quantity(60.0 ,Unit(0,0,1)); return UNIT; // minute
|
||||
"h" yylval = Quantity(3600.0 ,Unit(0,0,1)); return UNIT; // hour
|
||||
|
||||
"A" yylval = Quantity(1.0 ,Unit(0,0,0,1)); return UNIT; // Ampere (internal standard electric current)
|
||||
"mA" yylval = Quantity(0.001 ,Unit(0,0,0,1)); return UNIT; // milli Ampere
|
||||
"kA" yylval = Quantity(1000.0 ,Unit(0,0,0,1)); return UNIT; // kilo Ampere
|
||||
"MA" yylval = Quantity(1.0e6 ,Unit(0,0,0,1)); return UNIT; // Mega Ampere
|
||||
"A" yylval = Quantity(1.0 ,Unit(0,0,0,1)); return UNIT; // Ampere (internal standard electric current)
|
||||
"mA" yylval = Quantity(0.001 ,Unit(0,0,0,1)); return UNIT; // milli Ampere
|
||||
"kA" yylval = Quantity(1000.0 ,Unit(0,0,0,1)); return UNIT; // kilo Ampere
|
||||
"MA" yylval = Quantity(1.0e6 ,Unit(0,0,0,1)); return UNIT; // Mega Ampere
|
||||
|
||||
"K" yylval = Quantity(1.0 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin (internal standard thermodynamic temperature)
|
||||
"mK" yylval = Quantity(0.001 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin
|
||||
"yK" yylval = Quantity(0.000001 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin
|
||||
"K" yylval = Quantity(1.0 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin (internal standard thermodynamic temperature)
|
||||
"mK" yylval = Quantity(0.001 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin
|
||||
"yK" yylval = Quantity(0.000001 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin
|
||||
|
||||
"mol" yylval = Quantity(1.0 ,Unit(0,0,0,0,0,1)); return UNIT; // Mole (internal standard amount of substance)
|
||||
"mol" yylval = Quantity(1.0 ,Unit(0,0,0,0,0,1)); return UNIT; // Mole (internal standard amount of substance)
|
||||
|
||||
"cd" yylval = Quantity(1.0 ,Unit(0,0,0,0,0,0,1)); return UNIT; // Candela (internal standard luminous intensity)
|
||||
"cd" yylval = Quantity(1.0 ,Unit(0,0,0,0,0,0,1)); return UNIT; // Candela (internal standard luminous intensity)
|
||||
|
||||
"deg" yylval = Quantity(1.0 ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // degree (internal standard angle)
|
||||
"rad" yylval = Quantity(180/M_PI ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // radian
|
||||
"gon" yylval = Quantity(360.0/400.0 ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // gon
|
||||
"deg" yylval = Quantity(1.0 ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // degree (internal standard angle)
|
||||
"rad" yylval = Quantity(180/M_PI ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // radian
|
||||
"gon" yylval = Quantity(360.0/400.0 ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // gon
|
||||
|
||||
"in" yylval = Quantity(25.4 ,Unit(1)); return UNIT; // inch
|
||||
"\"" yylval = Quantity(25.4 ,Unit(1)); return UNIT; // inch
|
||||
"fo" yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot
|
||||
"'" yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot
|
||||
"th" yylval = Quantity(0.0254 ,Unit(1)); return UNIT; // thou
|
||||
"yr" yylval = Quantity(914.4 ,Unit(1)); return UNIT; // yard
|
||||
"in" yylval = Quantity(25.4 ,Unit(1)); return UNIT; // inch
|
||||
"\"" yylval = Quantity(25.4 ,Unit(1)); return UNIT; // inch
|
||||
"fo" yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot
|
||||
"'" yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot
|
||||
"th" yylval = Quantity(0.0254 ,Unit(1)); return UNIT; // thou
|
||||
"yr" yylval = Quantity(914.4 ,Unit(1)); return UNIT; // yard
|
||||
|
||||
|
||||
"lb" yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // pound
|
||||
"oz" yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // ounce
|
||||
"st" yylval = Quantity(6.35029318 ,Unit(0,1)); return UNIT; // Stone
|
||||
"cwt" yylval = Quantity(50.80234544 ,Unit(0,1)); return UNIT; // hundredweights
|
||||
"lb" yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // pound
|
||||
"oz" yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // ounce
|
||||
"st" yylval = Quantity(6.35029318 ,Unit(0,1)); return UNIT; // Stone
|
||||
"cwt" yylval = Quantity(50.80234544 ,Unit(0,1)); return UNIT; // hundredweights
|
||||
|
||||
"N" yylval = Quantity(1000.0 ,Unit(1,1,-2)); return UNIT; // Newton (kg*m/s^2)
|
||||
"Pa" yylval = Quantity(0.001 ,Unit(-1,1,-2)); return UNIT; // Pascal (kg/m*s^2)
|
||||
|
||||
|
||||
|
||||
{DIGIT}+["."","]{DIGIT}*[eE][-+]?[0-9]+ {for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
|
||||
{DIGIT}+["."","]{DIGIT}* {for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
| unit '*' unit { $$ = $1 * $3; }
|
||||
| unit '/' unit { $$ = $1 / $3; }
|
||||
| unit '^' num { $$ = $1.pow ($3); }
|
||||
| '(' unit ')' { $$ = $2; }
|
||||
;
|
||||
quantity: num unit { $$ = $1*$2; }
|
||||
;
|
||||
|
|
|
@ -174,42 +174,59 @@ std::string Unit::getString(void) const
|
|||
Sig.AmountOfSubstance > 0 ||
|
||||
Sig.LuminoseIntensity > 0 ||
|
||||
Sig.Angle > 0 ){
|
||||
|
||||
bool mult = false;
|
||||
if(Sig.Length > 0){
|
||||
mult = true;
|
||||
ret << "mm";
|
||||
if(Sig.Length >1)
|
||||
ret << "^" << Sig.Length;
|
||||
}
|
||||
if(Sig.Mass > 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "kg";
|
||||
if(Sig.Mass >1)
|
||||
ret << "^" << Sig.Mass;
|
||||
}
|
||||
if(Sig.Time > 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "s";
|
||||
if(Sig.Time >1)
|
||||
ret << "^" << Sig.Time;
|
||||
}
|
||||
if(Sig.ElectricCurrent > 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "A";
|
||||
if(Sig.ElectricCurrent >1)
|
||||
ret << "^" << Sig.ElectricCurrent;
|
||||
}
|
||||
if(Sig.ThermodynamicTemperature > 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "K";
|
||||
if(Sig.ThermodynamicTemperature >1)
|
||||
ret << "^" << Sig.ThermodynamicTemperature;
|
||||
}
|
||||
if(Sig.AmountOfSubstance > 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "mol";
|
||||
if(Sig.AmountOfSubstance >1)
|
||||
ret << "^" << Sig.AmountOfSubstance;
|
||||
}
|
||||
if(Sig.LuminoseIntensity > 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "cd";
|
||||
if(Sig.LuminoseIntensity >1)
|
||||
ret << "^" << Sig.LuminoseIntensity;
|
||||
}
|
||||
if(Sig.Angle > 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "deg";
|
||||
if(Sig.Angle >1)
|
||||
ret << "^" << Sig.Angle;
|
||||
|
@ -227,46 +244,73 @@ std::string Unit::getString(void) const
|
|||
Sig.LuminoseIntensity < 0 ||
|
||||
Sig.Angle < 0 ){
|
||||
ret << "/";
|
||||
|
||||
int nnom = Sig.Length<0?1:2 +
|
||||
Sig.Mass<0?1:2 +
|
||||
Sig.Time<0?1:2 +
|
||||
Sig.ElectricCurrent<0?1:2 +
|
||||
Sig.ThermodynamicTemperature<0?1:2 +
|
||||
Sig.AmountOfSubstance<0?1:2 +
|
||||
Sig.LuminoseIntensity<0?1:2 +
|
||||
Sig.Angle<0?1:2 ;
|
||||
if (nnom > 1) ret << '(';
|
||||
bool mult=false;
|
||||
if(Sig.Length < 0){
|
||||
ret << "mm";
|
||||
mult = true;
|
||||
if(Sig.Length <-1)
|
||||
ret << "^" << abs(Sig.Length);
|
||||
}
|
||||
if(Sig.Mass < 0){
|
||||
ret << "kg";
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "kg";
|
||||
if(Sig.Mass <-1)
|
||||
ret << "^" << abs(Sig.Mass);
|
||||
}
|
||||
if(Sig.Time < 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "s";
|
||||
if(Sig.Time <-1)
|
||||
ret << "^" << abs(Sig.Time);
|
||||
}
|
||||
if(Sig.ElectricCurrent < 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "A";
|
||||
if(Sig.ElectricCurrent <-1)
|
||||
ret << "^" << abs(Sig.ElectricCurrent);
|
||||
}
|
||||
if(Sig.ThermodynamicTemperature < 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "K";
|
||||
if(Sig.ThermodynamicTemperature <-1)
|
||||
ret << "^" << abs(Sig.ThermodynamicTemperature);
|
||||
}
|
||||
if(Sig.AmountOfSubstance < 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "mol";
|
||||
if(Sig.AmountOfSubstance <-1)
|
||||
ret << "^" << abs(Sig.AmountOfSubstance);
|
||||
}
|
||||
if(Sig.LuminoseIntensity < 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "cd";
|
||||
if(Sig.LuminoseIntensity <-1)
|
||||
ret << "^" << abs(Sig.LuminoseIntensity);
|
||||
}
|
||||
if(Sig.Angle < 0){
|
||||
if(mult) ret<<'*';
|
||||
mult = true;
|
||||
ret << "deg";
|
||||
if(Sig.Angle <-1)
|
||||
ret << "^" << abs(Sig.Angle);
|
||||
}
|
||||
if (nnom > 1) ret << ')';
|
||||
}
|
||||
|
||||
return ret.str();
|
||||
|
|
Loading…
Reference in New Issue
Block a user