Merge branch 'master' of ssh://git.code.sf.net/p/free-cad/code

This commit is contained in:
wmayer 2013-11-10 20:10:06 +01:00
commit fab311cb00
8 changed files with 652 additions and 463 deletions

View File

@ -198,7 +198,7 @@ Quantity Quantity::parse(const char* buffer)
// free the scan buffer // free the scan buffer
QuantityParser::yy_delete_buffer (my_string_buffer); QuantityParser::yy_delete_buffer (my_string_buffer);
if (QuantResult == Quantity(DOUBLE_MIN)) //if (QuantResult == Quantity(DOUBLE_MIN))
throw Base::Exception("Unknown error in Quantity expression"); // throw Base::Exception("Unknown error in Quantity expression");
return QuantResult; return QuantResult;
} }

View File

@ -361,8 +361,8 @@ static void yy_fatal_error (yyconst char msg[] );
*yy_cp = '\0'; \ *yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp; (yy_c_buf_p) = yy_cp;
#define YY_NUM_RULES 63 #define YY_NUM_RULES 76
#define YY_END_OF_BUFFER 64 #define YY_END_OF_BUFFER 77
/* This struct is not used in this scanner, /* This struct is not used in this scanner,
but its presence is necessary. */ but its presence is necessary. */
struct yy_trans_info struct yy_trans_info
@ -370,20 +370,22 @@ struct yy_trans_info
flex_int32_t yy_verify; flex_int32_t yy_verify;
flex_int32_t yy_nxt; flex_int32_t yy_nxt;
}; };
static yyconst flex_int16_t yy_accept[107] = static yyconst flex_int16_t yy_accept[126] =
{ 0, { 0,
0, 0, 64, 63, 1, 2, 33, 35, 3, 44, 0, 0, 0, 0, 77, 76, 4, 5, 36, 38,
20, 24, 63, 63, 63, 63, 46, 63, 14, 19, 6, 57, 23, 76, 50, 27, 76, 45, 76, 76,
63, 63, 11, 9, 63, 63, 63, 63, 17, 16, 48, 1, 76, 76, 76, 59, 76, 17, 22, 76,
63, 2, 43, 44, 23, 0, 0, 0, 0, 28, 76, 14, 12, 76, 76, 76, 76, 20, 19, 76,
7, 0, 0, 0, 8, 0, 34, 0, 32, 22, 3, 2, 5, 56, 57, 53, 26, 51, 46, 49,
15, 10, 38, 0, 21, 25, 13, 0, 6, 0, 54, 0, 0, 0, 0, 31, 10, 0, 0, 0,
4, 39, 45, 0, 0, 0, 0, 40, 0, 36, 11, 0, 37, 0, 35, 25, 18, 13, 41, 0,
26, 12, 5, 37, 43, 0, 53, 0, 0, 0, 24, 28, 16, 0, 9, 0, 7, 42, 58, 0,
51, 41, 29, 52, 31, 55, 18, 54, 27, 57, 0, 0, 0, 0, 43, 0, 39, 29, 15, 8,
30, 58, 0, 60, 0, 42, 47, 48, 49, 0, 40, 56, 0, 52, 66, 0, 0, 0, 64, 44,
59, 62, 61, 50, 56, 0 32, 65, 34, 68, 21, 67, 30, 70, 47, 33,
71, 0, 73, 0, 55, 60, 61, 62, 0, 72,
75, 74, 63, 69, 0
} ; } ;
static yyconst flex_int32_t yy_ec[256] = static yyconst flex_int32_t yy_ec[256] =
@ -394,14 +396,14 @@ static yyconst flex_int32_t yy_ec[256] =
1, 2, 1, 4, 1, 1, 1, 1, 5, 6, 1, 2, 1, 4, 1, 1, 1, 1, 5, 6,
6, 6, 7, 8, 7, 8, 6, 9, 10, 11, 6, 6, 7, 8, 7, 8, 6, 9, 10, 11,
12, 12, 12, 12, 12, 12, 12, 1, 1, 1, 12, 12, 12, 12, 12, 12, 12, 1, 1, 1,
6, 1, 1, 1, 13, 1, 1, 1, 14, 1, 6, 1, 1, 1, 13, 1, 14, 1, 15, 1,
1, 1, 1, 1, 15, 1, 16, 1, 1, 1, 1, 1, 1, 16, 17, 1, 18, 19, 1, 20,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 21, 22, 1, 1, 1,
1, 1, 1, 6, 1, 1, 17, 18, 19, 20, 23, 1, 24, 6, 1, 1, 25, 26, 27, 28,
21, 22, 23, 24, 25, 1, 26, 27, 28, 29, 29, 30, 31, 32, 33, 1, 34, 35, 36, 37,
30, 31, 32, 33, 34, 35, 1, 1, 36, 37, 38, 39, 40, 41, 42, 43, 1, 1, 44, 45,
38, 39, 1, 1, 1, 1, 1, 1, 1, 1, 46, 47, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -418,90 +420,105 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1 1, 1, 1, 1, 1
} ; } ;
static yyconst flex_int32_t yy_meta[40] = static yyconst flex_int32_t yy_meta[48] =
{ 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
} ;
static yyconst flex_int16_t yy_base[109] =
{ 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,
135, 135, 135, 135, 135, 135, 105, 106
} ;
static yyconst flex_int16_t yy_def[109] =
{ 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,
106, 106, 106, 106, 106, 0, 106, 106
} ;
static yyconst flex_int16_t yy_nxt[175] =
{ 0,
4, 5, 6, 7, 8, 9, 9, 4, 10, 10,
10, 10, 11, 4, 12, 13, 14, 4, 15, 16,
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,
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] =
{ 0, { 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
14, 14, 15, 10, 16, 22, 100, 23, 27, 99, 1, 1, 1, 1, 1, 1, 1
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,
95, 95, 96, 96, 96, 96, 107, 107, 108, 108, static yyconst flex_int16_t yy_base[127] =
65, 64, 58, 54, 48, 46, 44, 43, 42, 39, { 0,
38, 37, 36, 32, 28, 26, 25, 21, 19, 18, 0, 0, 45, 46, 167, 168, 168, 163, 168, 168,
17, 13, 6, 3, 106, 106, 106, 106, 106, 106, 168, 46, 168, 144, 168, 168, 151, 127, 137, 148,
106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 118, 168, 25, 35, 24, 114, 120, 119, 168, 119,
106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 46, 36, 59, 119, 107, 42, 128, 45, 61, 70,
106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 168, 168, 149, 93, 105, 168, 168, 168, 168, 109,
106, 106, 106, 106 168, 108, 111, 115, 122, 168, 168, 104, 102, 113,
168, 104, 168, 105, 168, 168, 168, 168, 168, 110,
168, 168, 168, 103, 168, 61, 168, 168, 168, 95,
104, 84, 73, 66, 168, 63, 168, 168, 168, 168,
168, 109, 116, 168, 168, 57, 61, 57, 168, 168,
168, 168, 168, 81, 168, 168, 168, 168, 168, 168,
51, 38, 34, 120, 124, 168, 168, 54, 55, 168,
168, 168, 168, 168, 168, 60
} ;
static yyconst flex_int16_t yy_def[127] =
{ 0,
125, 1, 126, 126, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 0, 125
} ;
static yyconst flex_int16_t yy_nxt[216] =
{ 0,
6, 7, 8, 9, 10, 11, 11, 6, 12, 12,
12, 12, 13, 14, 6, 15, 16, 17, 18, 19,
20, 21, 22, 6, 23, 6, 24, 25, 26, 27,
28, 29, 30, 31, 32, 33, 34, 35, 36, 6,
37, 38, 39, 6, 6, 40, 6, 6, 6, 44,
52, 53, 60, 44, 45, 45, 45, 45, 66, 61,
41, 69, 56, 124, 123, 122, 54, 55, 42, 42,
57, 71, 58, 70, 79, 72, 67, 83, 59, 80,
121, 68, 120, 81, 84, 86, 88, 85, 106, 73,
119, 74, 87, 118, 75, 107, 76, 117, 116, 113,
89, 92, 92, 92, 92, 90, 112, 93, 44, 111,
91, 110, 44, 45, 45, 45, 45, 92, 92, 92,
92, 93, 114, 93, 115, 115, 115, 115, 115, 115,
115, 115, 115, 115, 115, 115, 109, 93, 108, 105,
104, 103, 102, 101, 100, 99, 98, 97, 96, 95,
94, 43, 82, 78, 77, 65, 64, 63, 62, 51,
50, 49, 48, 47, 46, 43, 125, 5, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125
} ;
static yyconst flex_int16_t yy_chk[216] =
{ 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, 1,
1, 1, 1, 1, 1, 1, 1, 3, 4, 12,
23, 23, 25, 12, 12, 12, 12, 12, 31, 25,
126, 32, 24, 119, 118, 113, 23, 23, 3, 4,
24, 33, 24, 32, 36, 33, 31, 38, 24, 36,
112, 31, 111, 36, 38, 39, 40, 38, 76, 33,
104, 33, 39, 98, 33, 76, 33, 97, 96, 86,
40, 44, 44, 44, 44, 40, 84, 44, 45, 83,
40, 82, 45, 45, 45, 45, 45, 92, 92, 92,
92, 44, 93, 92, 93, 93, 93, 93, 114, 114,
114, 114, 115, 115, 115, 115, 81, 92, 80, 74,
70, 64, 62, 60, 59, 58, 55, 54, 53, 52,
50, 43, 37, 35, 34, 30, 28, 27, 26, 21,
20, 19, 18, 17, 14, 8, 5, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125
} ; } ;
static yy_state_type yy_last_accepting_state; static yy_state_type yy_last_accepting_state;
@ -531,9 +548,11 @@ char *yytext;
/*** Flex Declarations and Options ***/ /*** Flex Declarations and Options ***/
/* the manual says "somewhat more optimized" */ /* the manual says "somewhat more optimized" */
/* no support for include files is planned */ /* no support for include files is planned */
#line 535 "QuantityLexer.c"
#line 553 "QuantityLexer.c"
#define INITIAL 0 #define INITIAL 0
#define C_COMMENT 1
#ifndef YY_NO_UNISTD_H #ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way /* Special case for "unistd.h", since it is non-ANSI. We include it way
@ -711,11 +730,10 @@ YY_DECL
register char *yy_cp, *yy_bp; register char *yy_cp, *yy_bp;
register int yy_act; register int yy_act;
#line 27 "QuantityParser.l" #line 28 "QuantityParser.l"
#line 737 "QuantityLexer.c"
#line 719 "QuantityLexer.c"
if ( !(yy_init) ) if ( !(yy_init) )
{ {
@ -768,13 +786,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 107 ) if ( yy_current_state >= 126 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp; ++yy_cp;
} }
while ( yy_current_state != 106 ); while ( yy_current_state != 125 );
yy_cp = (yy_last_accepting_cpos); yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state); yy_current_state = (yy_last_accepting_state);
@ -797,321 +815,387 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
YY_RULE_SETUP YY_RULE_SETUP
#line 30 "QuantityParser.l" #line 30 "QuantityParser.l"
; { BEGIN(C_COMMENT); }
YY_BREAK YY_BREAK
case 2: case 2:
/* rule 2 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 31 "QuantityParser.l" #line 31 "QuantityParser.l"
; { BEGIN(INITIAL); }
YY_BREAK YY_BREAK
case 3: case 3:
YY_RULE_SETUP YY_RULE_SETUP
#line 33 "QuantityParser.l" #line 32 "QuantityParser.l"
{ return *yytext; } { ;}
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 35 "QuantityParser.l" #line 35 "QuantityParser.l"
yylval = Quantity(1.0e-6 ,Unit(1)); return UNIT; // nano meter ;
YY_BREAK YY_BREAK
case 5: case 5:
/* rule 5 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 36 "QuantityParser.l" #line 36 "QuantityParser.l"
yylval = Quantity(1.0e-3 ,Unit(1)); return UNIT; // micro meter ;
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 37 "QuantityParser.l" #line 38 "QuantityParser.l"
yylval = Quantity(1.0 ,Unit(1)); return UNIT; // milli meter { return *yytext; }
YY_BREAK YY_BREAK
case 7: case 7:
YY_RULE_SETUP YY_RULE_SETUP
#line 38 "QuantityParser.l" #line 40 "QuantityParser.l"
yylval = Quantity(10.0 ,Unit(1)); return UNIT; // centi meter yylval = Quantity(1.0e-6 ,Unit(1)); return UNIT; // nano meter
YY_BREAK YY_BREAK
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 39 "QuantityParser.l" #line 41 "QuantityParser.l"
yylval = Quantity(100.0 ,Unit(1)); return UNIT; // deci meter yylval = Quantity(1.0e-3 ,Unit(1)); return UNIT; // micro meter
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 40 "QuantityParser.l" #line 42 "QuantityParser.l"
yylval = Quantity(1.0e3 ,Unit(1)); return UNIT; // meter yylval = Quantity(1.0 ,Unit(1)); return UNIT; // milli meter
YY_BREAK YY_BREAK
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 41 "QuantityParser.l" #line 43 "QuantityParser.l"
yylval = Quantity(1.0e6 ,Unit(1)); return UNIT; // kilo meter yylval = Quantity(10.0 ,Unit(1)); return UNIT; // centi meter
YY_BREAK YY_BREAK
case 11: case 11:
YY_RULE_SETUP YY_RULE_SETUP
#line 42 "QuantityParser.l" #line 44 "QuantityParser.l"
yylval = Quantity(1000000.0 ,Unit(3)); return UNIT; // Liter dm^3 yylval = Quantity(100.0 ,Unit(1)); return UNIT; // deci meter
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 44 "QuantityParser.l" #line 45 "QuantityParser.l"
yylval = Quantity(1.0e-9 ,Unit(0,1)); return UNIT; // milli gram yylval = Quantity(1.0e3 ,Unit(1)); return UNIT; // meter
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 45 "QuantityParser.l" #line 46 "QuantityParser.l"
yylval = Quantity(1.0e-6 ,Unit(0,1)); return UNIT; // milli gram yylval = Quantity(1.0e6 ,Unit(1)); return UNIT; // kilo meter
YY_BREAK YY_BREAK
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 46 "QuantityParser.l" #line 47 "QuantityParser.l"
yylval = Quantity(1.0e-3 ,Unit(0,1)); return UNIT; // gram yylval = Quantity(1000000.0 ,Unit(3)); return UNIT; // Liter dm^3
YY_BREAK YY_BREAK
case 15: case 15:
YY_RULE_SETUP YY_RULE_SETUP
#line 47 "QuantityParser.l" #line 49 "QuantityParser.l"
yylval = Quantity(1.0 ,Unit(0,1)); return UNIT; // kilo gram yylval = Quantity(1.0e-9 ,Unit(0,1)); return UNIT; // milli gram
YY_BREAK YY_BREAK
case 16: case 16:
YY_RULE_SETUP YY_RULE_SETUP
#line 48 "QuantityParser.l" #line 50 "QuantityParser.l"
yylval = Quantity(1000.0 ,Unit(0,1)); return UNIT; // ton yylval = Quantity(1.0e-6 ,Unit(0,1)); return UNIT; // milli gram
YY_BREAK YY_BREAK
case 17: case 17:
YY_RULE_SETUP YY_RULE_SETUP
#line 50 "QuantityParser.l" #line 51 "QuantityParser.l"
yylval = Quantity(1.0 ,Unit(0,0,1)); return UNIT; // second (internal standard time) yylval = Quantity(1.0e-3 ,Unit(0,1)); return UNIT; // gram
YY_BREAK YY_BREAK
case 18: case 18:
YY_RULE_SETUP YY_RULE_SETUP
#line 51 "QuantityParser.l" #line 52 "QuantityParser.l"
yylval = Quantity(60.0 ,Unit(0,0,1)); return UNIT; // minute yylval = Quantity(1.0 ,Unit(0,1)); return UNIT; // kilo gram (internal standard for mass)
YY_BREAK YY_BREAK
case 19: case 19:
YY_RULE_SETUP YY_RULE_SETUP
#line 52 "QuantityParser.l" #line 53 "QuantityParser.l"
yylval = Quantity(3600.0 ,Unit(0,0,1)); return UNIT; // hour yylval = Quantity(1000.0 ,Unit(0,1)); return UNIT; // ton
YY_BREAK YY_BREAK
case 20: case 20:
YY_RULE_SETUP YY_RULE_SETUP
#line 54 "QuantityParser.l" #line 55 "QuantityParser.l"
yylval = Quantity(1.0 ,Unit(0,0,0,1)); return UNIT; // Ampere (internal standard electric current) yylval = Quantity(1.0 ,Unit(0,0,1)); return UNIT; // second (internal standard time)
YY_BREAK YY_BREAK
case 21: case 21:
YY_RULE_SETUP YY_RULE_SETUP
#line 55 "QuantityParser.l" #line 56 "QuantityParser.l"
yylval = Quantity(0.001 ,Unit(0,0,0,1)); return UNIT; // milli Ampere yylval = Quantity(60.0 ,Unit(0,0,1)); return UNIT; // minute
YY_BREAK YY_BREAK
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
#line 56 "QuantityParser.l" #line 57 "QuantityParser.l"
yylval = Quantity(1000.0 ,Unit(0,0,0,1)); return UNIT; // kilo Ampere yylval = Quantity(3600.0 ,Unit(0,0,1)); return UNIT; // hour
YY_BREAK YY_BREAK
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 57 "QuantityParser.l" #line 59 "QuantityParser.l"
yylval = Quantity(1.0e6 ,Unit(0,0,0,1)); return UNIT; // Mega Ampere yylval = Quantity(1.0 ,Unit(0,0,0,1)); return UNIT; // Ampere (internal standard electric current)
YY_BREAK YY_BREAK
case 24: case 24:
YY_RULE_SETUP YY_RULE_SETUP
#line 59 "QuantityParser.l" #line 60 "QuantityParser.l"
yylval = Quantity(1.0 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin (internal standard thermodynamic temperature) yylval = Quantity(0.001 ,Unit(0,0,0,1)); return UNIT; // milli Ampere
YY_BREAK YY_BREAK
case 25: case 25:
YY_RULE_SETUP YY_RULE_SETUP
#line 60 "QuantityParser.l" #line 61 "QuantityParser.l"
yylval = Quantity(0.001 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin yylval = Quantity(1000.0 ,Unit(0,0,0,1)); return UNIT; // kilo Ampere
YY_BREAK YY_BREAK
case 26: case 26:
YY_RULE_SETUP YY_RULE_SETUP
#line 61 "QuantityParser.l" #line 62 "QuantityParser.l"
yylval = Quantity(0.000001 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin yylval = Quantity(1.0e6 ,Unit(0,0,0,1)); return UNIT; // Mega Ampere
YY_BREAK YY_BREAK
case 27: case 27:
YY_RULE_SETUP YY_RULE_SETUP
#line 63 "QuantityParser.l" #line 64 "QuantityParser.l"
yylval = Quantity(1.0 ,Unit(0,0,0,0,0,1)); return UNIT; // Mole (internal standard amount of substance) yylval = Quantity(1.0 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin (internal standard thermodynamic temperature)
YY_BREAK YY_BREAK
case 28: case 28:
YY_RULE_SETUP YY_RULE_SETUP
#line 65 "QuantityParser.l" #line 65 "QuantityParser.l"
yylval = Quantity(1.0 ,Unit(0,0,0,0,0,0,1)); return UNIT; // Candela (internal standard luminous intensity) yylval = Quantity(0.001 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin
YY_BREAK YY_BREAK
case 29: case 29:
YY_RULE_SETUP YY_RULE_SETUP
#line 67 "QuantityParser.l" #line 66 "QuantityParser.l"
yylval = Quantity(1.0 ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // degree (internal standard angle) yylval = Quantity(0.000001 ,Unit(0,0,0,0,1)); return UNIT; // Kelvin
YY_BREAK YY_BREAK
case 30: case 30:
YY_RULE_SETUP YY_RULE_SETUP
#line 68 "QuantityParser.l" #line 68 "QuantityParser.l"
yylval = Quantity(180/M_PI ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // radian yylval = Quantity(1.0 ,Unit(0,0,0,0,0,1)); return UNIT; // Mole (internal standard amount of substance)
YY_BREAK YY_BREAK
case 31: case 31:
YY_RULE_SETUP YY_RULE_SETUP
#line 69 "QuantityParser.l" #line 70 "QuantityParser.l"
yylval = Quantity(360.0/400.0 ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // gon yylval = Quantity(1.0 ,Unit(0,0,0,0,0,0,1)); return UNIT; // Candela (internal standard luminous intensity)
YY_BREAK YY_BREAK
case 32: case 32:
YY_RULE_SETUP YY_RULE_SETUP
#line 71 "QuantityParser.l" #line 72 "QuantityParser.l"
yylval = Quantity(25.4 ,Unit(1)); return UNIT; // inch yylval = Quantity(1.0 ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // degree (internal standard angle)
YY_BREAK YY_BREAK
case 33: case 33:
YY_RULE_SETUP YY_RULE_SETUP
#line 72 "QuantityParser.l" #line 73 "QuantityParser.l"
yylval = Quantity(25.4 ,Unit(1)); return UNIT; // inch yylval = Quantity(180/M_PI ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // radian
YY_BREAK YY_BREAK
case 34: case 34:
YY_RULE_SETUP YY_RULE_SETUP
#line 73 "QuantityParser.l" #line 74 "QuantityParser.l"
yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot yylval = Quantity(360.0/400.0 ,Unit(0,0,0,0,0,0,0,1)); return UNIT; // gon
YY_BREAK YY_BREAK
case 35: case 35:
YY_RULE_SETUP YY_RULE_SETUP
#line 74 "QuantityParser.l" #line 76 "QuantityParser.l"
yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot yylval = Quantity(25.4 ,Unit(1)); return UNIT; // inch
YY_BREAK YY_BREAK
case 36: case 36:
YY_RULE_SETUP YY_RULE_SETUP
#line 75 "QuantityParser.l" #line 77 "QuantityParser.l"
yylval = Quantity(0.0254 ,Unit(1)); return UNIT; // thou yylval = Quantity(25.4 ,Unit(1)); return UNIT; // inch
YY_BREAK YY_BREAK
case 37: case 37:
YY_RULE_SETUP YY_RULE_SETUP
#line 76 "QuantityParser.l" #line 78 "QuantityParser.l"
yylval = Quantity(914.4 ,Unit(1)); return UNIT; // yard yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot
YY_BREAK YY_BREAK
case 38: case 38:
YY_RULE_SETUP YY_RULE_SETUP
#line 79 "QuantityParser.l" #line 79 "QuantityParser.l"
yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // pound yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot
YY_BREAK YY_BREAK
case 39: case 39:
YY_RULE_SETUP YY_RULE_SETUP
#line 80 "QuantityParser.l" #line 80 "QuantityParser.l"
yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // ounce yylval = Quantity(0.0254 ,Unit(1)); return UNIT; // thou
YY_BREAK YY_BREAK
case 40: case 40:
YY_RULE_SETUP YY_RULE_SETUP
#line 81 "QuantityParser.l" #line 81 "QuantityParser.l"
yylval = Quantity(6.35029318 ,Unit(0,1)); return UNIT; // Stone yylval = Quantity(914.4 ,Unit(1)); return UNIT; // yard
YY_BREAK YY_BREAK
case 41: case 41:
YY_RULE_SETUP YY_RULE_SETUP
#line 82 "QuantityParser.l" #line 84 "QuantityParser.l"
yylval = Quantity(50.80234544 ,Unit(0,1)); return UNIT; // hundredweights yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // pound
YY_BREAK YY_BREAK
case 42: case 42:
YY_RULE_SETUP YY_RULE_SETUP
#line 86 "QuantityParser.l" #line 85 "QuantityParser.l"
{for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;} yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // ounce
YY_BREAK YY_BREAK
case 43: case 43:
YY_RULE_SETUP YY_RULE_SETUP
#line 87 "QuantityParser.l" #line 86 "QuantityParser.l"
{for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;} yylval = Quantity(6.35029318 ,Unit(0,1)); return UNIT; // Stone
YY_BREAK YY_BREAK
case 44: case 44:
YY_RULE_SETUP YY_RULE_SETUP
#line 88 "QuantityParser.l" #line 87 "QuantityParser.l"
{yylval = atof( yytext ); return NUM;} yylval = Quantity(50.80234544 ,Unit(0,1)); return UNIT; // hundredweights
YY_BREAK YY_BREAK
case 45: case 45:
YY_RULE_SETUP YY_RULE_SETUP
#line 90 "QuantityParser.l" #line 89 "QuantityParser.l"
{yylval = M_PI ; return NUM;} // constant pi yylval = Quantity(1000.0 ,Unit(1,1,-2)); return UNIT; // Newton (kg*m/s^2)
YY_BREAK YY_BREAK
case 46: case 46:
YY_RULE_SETUP YY_RULE_SETUP
#line 91 "QuantityParser.l" #line 91 "QuantityParser.l"
{yylval = M_E ; return NUM;} // constant e yylval = Quantity(0.001 ,Unit(-1,1,-2)); return UNIT; // Pascal (kg/m*s^2)
YY_BREAK YY_BREAK
case 47: case 47:
YY_RULE_SETUP YY_RULE_SETUP
#line 93 "QuantityParser.l" #line 92 "QuantityParser.l"
return ACOS; yylval = Quantity(0.145038 ,Unit(-1,1,-2)); return UNIT; // pounds/in^2
YY_BREAK YY_BREAK
case 48: case 48:
YY_RULE_SETUP YY_RULE_SETUP
#line 94 "QuantityParser.l" #line 94 "QuantityParser.l"
return ASIN; yylval = Quantity(1e+6 ,Unit(2,1,-3)); return UNIT; // Watt (kg*m^2/s^3)
YY_BREAK YY_BREAK
case 49: case 49:
YY_RULE_SETUP YY_RULE_SETUP
#line 95 "QuantityParser.l" #line 95 "QuantityParser.l"
return ATAN; yylval = Quantity(1e+6 ,Unit(2,1,-3)); return UNIT; // VoltAmpere (kg*m^2/s^3)
YY_BREAK YY_BREAK
case 50: case 50:
YY_RULE_SETUP YY_RULE_SETUP
#line 96 "QuantityParser.l" #line 97 "QuantityParser.l"
return ATAN2; yylval = Quantity(1e+6 ,Unit(2,1,-2)); return UNIT; // Joule (kg*m^2/s^2)
YY_BREAK YY_BREAK
case 51: case 51:
YY_RULE_SETUP YY_RULE_SETUP
#line 97 "QuantityParser.l" #line 98 "QuantityParser.l"
return COS; yylval = Quantity(1e+6 ,Unit(2,1,-2)); return UNIT; // Joule (kg*m^2/s^2)
YY_BREAK YY_BREAK
case 52: case 52:
YY_RULE_SETUP YY_RULE_SETUP
#line 98 "QuantityParser.l" #line 99 "QuantityParser.l"
return EXP; yylval = Quantity(1e+6 ,Unit(2,1,-2)); return UNIT; // Joule (kg*m^2/s^2)
YY_BREAK YY_BREAK
case 53: case 53:
YY_RULE_SETUP YY_RULE_SETUP
#line 99 "QuantityParser.l" #line 100 "QuantityParser.l"
return ABS; yylval = Quantity(1e+6 ,Unit(2,1,-2)); return UNIT; // Joule (kg*m^2/s^2)
YY_BREAK YY_BREAK
case 54: case 54:
YY_RULE_SETUP YY_RULE_SETUP
#line 100 "QuantityParser.l" #line 101 "QuantityParser.l"
return MOD; yylval = Quantity(1e+6 ,Unit(2,1,-2)); return UNIT; // Joule (kg*m^2/s^2)
YY_BREAK YY_BREAK
case 55: case 55:
YY_RULE_SETUP YY_RULE_SETUP
#line 101 "QuantityParser.l" #line 103 "QuantityParser.l"
return LOG; {for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
YY_BREAK YY_BREAK
case 56: case 56:
YY_RULE_SETUP YY_RULE_SETUP
#line 102 "QuantityParser.l" #line 104 "QuantityParser.l"
return LOG10; {for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
YY_BREAK YY_BREAK
case 57: case 57:
YY_RULE_SETUP YY_RULE_SETUP
#line 103 "QuantityParser.l" #line 105 "QuantityParser.l"
return POW; {yylval = atof( yytext ); return NUM;}
YY_BREAK YY_BREAK
case 58: case 58:
YY_RULE_SETUP YY_RULE_SETUP
#line 104 "QuantityParser.l" #line 107 "QuantityParser.l"
return SIN; {yylval = M_PI ; return NUM;} // constant pi
YY_BREAK YY_BREAK
case 59: case 59:
YY_RULE_SETUP YY_RULE_SETUP
#line 105 "QuantityParser.l" #line 108 "QuantityParser.l"
return SINH; {yylval = M_E ; return NUM;} // constant e
YY_BREAK YY_BREAK
case 60: case 60:
YY_RULE_SETUP YY_RULE_SETUP
#line 106 "QuantityParser.l" #line 110 "QuantityParser.l"
return TAN; return ACOS;
YY_BREAK YY_BREAK
case 61: case 61:
YY_RULE_SETUP YY_RULE_SETUP
#line 107 "QuantityParser.l" #line 111 "QuantityParser.l"
return TANH; return ASIN;
YY_BREAK YY_BREAK
case 62: case 62:
YY_RULE_SETUP YY_RULE_SETUP
#line 108 "QuantityParser.l" #line 112 "QuantityParser.l"
return SQRT; return ATAN;
YY_BREAK YY_BREAK
case 63: case 63:
YY_RULE_SETUP YY_RULE_SETUP
#line 110 "QuantityParser.l" #line 113 "QuantityParser.l"
return ATAN2;
YY_BREAK
case 64:
YY_RULE_SETUP
#line 114 "QuantityParser.l"
return COS;
YY_BREAK
case 65:
YY_RULE_SETUP
#line 115 "QuantityParser.l"
return EXP;
YY_BREAK
case 66:
YY_RULE_SETUP
#line 116 "QuantityParser.l"
return ABS;
YY_BREAK
case 67:
YY_RULE_SETUP
#line 117 "QuantityParser.l"
return MOD;
YY_BREAK
case 68:
YY_RULE_SETUP
#line 118 "QuantityParser.l"
return LOG;
YY_BREAK
case 69:
YY_RULE_SETUP
#line 119 "QuantityParser.l"
return LOG10;
YY_BREAK
case 70:
YY_RULE_SETUP
#line 120 "QuantityParser.l"
return POW;
YY_BREAK
case 71:
YY_RULE_SETUP
#line 121 "QuantityParser.l"
return SIN;
YY_BREAK
case 72:
YY_RULE_SETUP
#line 122 "QuantityParser.l"
return SINH;
YY_BREAK
case 73:
YY_RULE_SETUP
#line 123 "QuantityParser.l"
return TAN;
YY_BREAK
case 74:
YY_RULE_SETUP
#line 124 "QuantityParser.l"
return TANH;
YY_BREAK
case 75:
YY_RULE_SETUP
#line 125 "QuantityParser.l"
return SQRT;
YY_BREAK
case 76:
YY_RULE_SETUP
#line 127 "QuantityParser.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1114 "QuantityLexer.c" #line 1197 "QuantityLexer.c"
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(C_COMMENT):
yyterminate(); yyterminate();
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
@ -1403,7 +1487,7 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 107 ) if ( yy_current_state >= 126 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@ -1431,11 +1515,11 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 107 ) if ( yy_current_state >= 126 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (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 == 125);
return yy_is_jam ? 0 : yy_current_state; return yy_is_jam ? 0 : yy_current_state;
} }
@ -2068,4 +2152,4 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables" #define YYTABLES_NAME "yytables"
#line 110 "QuantityParser.l" #line 127 "QuantityParser.l"

View File

@ -65,12 +65,19 @@
/* Line 371 of yacc.c */ /* Line 371 of yacc.c */
#line 6 "QuantityParser.y" #line 6 "QuantityParser.y"
#define YYSTYPE Quantity #define YYSTYPE Quantity
#define yyparse Quantity_yyparse #define yyparse Quantity_yyparse
#define yyerror Quantity_yyerror #define yyerror Quantity_yyerror
#ifndef DOUBLE_MAX
# define DOUBLE_MAX 1.7976931348623157E+308 /* max decimal value of a "double"*/
#endif
#ifndef DOUBLE_MIN
# define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/
#endif
/* Line 371 of yacc.c */ /* Line 371 of yacc.c */
#line 74 "QuantityParser.c" #line 81 "QuantityParser.c"
# ifndef YY_NULL # ifndef YY_NULL
# if defined __cplusplus && 201103L <= __cplusplus # if defined __cplusplus && 201103L <= __cplusplus
@ -154,7 +161,7 @@ int yyparse ();
/* Copy the second part of user declarations. */ /* Copy the second part of user declarations. */
/* Line 390 of yacc.c */ /* Line 390 of yacc.c */
#line 158 "QuantityParser.c" #line 165 "QuantityParser.c"
#ifdef short #ifdef short
# undef short # undef short
@ -381,18 +388,18 @@ union yyalloc
#endif /* !YYCOPY_NEEDED */ #endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */ /* YYFINAL -- State number of the termination state. */
#define YYFINAL 43 #define YYFINAL 45
/* YYLAST -- Last index in YYTABLE. */ /* YYLAST -- Last index in YYTABLE. */
#define YYLAST 259 #define YYLAST 262
/* YYNTOKENS -- Number of terminals. */ /* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 30 #define YYNTOKENS 30
/* YYNNTS -- Number of nonterminals. */ /* YYNNTS -- Number of nonterminals. */
#define YYNNTS 5 #define YYNNTS 5
/* YYNRULES -- Number of rules. */ /* YYNRULES -- Number of rules. */
#define YYNRULES 34 #define YYNRULES 36
/* YYNRULES -- Number of states. */ /* YYNRULES -- Number of states. */
#define YYNSTATES 102 #define YYNSTATES 106
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2 #define YYUNDEFTOK 2
@ -439,39 +446,39 @@ static const yytype_uint8 yytranslate[] =
YYRHS. */ YYRHS. */
static const yytype_uint8 yyprhs[] = static const yytype_uint8 yyprhs[] =
{ {
0, 0, 3, 5, 7, 9, 12, 14, 18, 22, 0, 0, 3, 4, 6, 8, 10, 13, 15, 19,
26, 30, 33, 37, 41, 46, 51, 56, 63, 68, 23, 27, 31, 34, 38, 42, 47, 52, 57, 64,
73, 80, 85, 90, 97, 102, 107, 112, 117, 122, 69, 74, 81, 86, 91, 98, 103, 108, 113, 118,
127, 129, 133, 137, 141 123, 128, 130, 134, 138, 142, 146
}; };
/* YYRHS -- A `-1'-separated list of the rules' RHS. */ /* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] = static const yytype_int8 yyrhs[] =
{ {
31, 0, -1, 32, -1, 33, -1, 34, -1, 34, 31, 0, -1, -1, 32, -1, 33, -1, 34, -1,
34, -1, 4, -1, 32, 22, 32, -1, 32, 21, 34, 34, -1, 4, -1, 32, 22, 32, -1, 32,
32, -1, 32, 23, 32, -1, 32, 24, 32, -1, 21, 32, -1, 32, 23, 32, -1, 32, 24, 32,
21, 32, -1, 32, 26, 32, -1, 27, 32, 28, -1, 21, 32, -1, 32, 26, 32, -1, 27, 32,
-1, 5, 27, 32, 28, -1, 6, 27, 32, 28, 28, -1, 5, 27, 32, 28, -1, 6, 27, 32,
-1, 7, 27, 32, 28, -1, 8, 27, 32, 29, 28, -1, 7, 27, 32, 28, -1, 8, 27, 32,
32, 28, -1, 11, 27, 32, 28, -1, 10, 27, 29, 32, 28, -1, 11, 27, 32, 28, -1, 10,
32, 28, -1, 12, 27, 32, 29, 32, 28, -1, 27, 32, 28, -1, 12, 27, 32, 29, 32, 28,
13, 27, 32, 28, -1, 14, 27, 32, 28, -1, -1, 13, 27, 32, 28, -1, 14, 27, 32, 28,
15, 27, 32, 29, 32, 28, -1, 16, 27, 32, -1, 15, 27, 32, 29, 32, 28, -1, 16, 27,
28, -1, 17, 27, 32, 28, -1, 18, 27, 32, 32, 28, -1, 17, 27, 32, 28, -1, 18, 27,
28, -1, 19, 27, 32, 28, -1, 20, 27, 32, 32, 28, -1, 19, 27, 32, 28, -1, 20, 27,
28, -1, 9, 27, 32, 28, -1, 3, -1, 33, 32, 28, -1, 9, 27, 32, 28, -1, 3, -1,
23, 33, -1, 33, 24, 33, -1, 33, 26, 32, 33, 23, 33, -1, 33, 24, 33, -1, 33, 26,
-1, 32, 33, -1 32, -1, 27, 33, 28, -1, 32, 33, -1
}; };
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] = static const yytype_uint8 yyrline[] =
{ {
0, 26, 26, 27, 28, 29, 31, 32, 33, 34, 0, 33, 33, 34, 35, 36, 37, 39, 40, 41,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
57, 58, 59, 60, 62 62, 65, 66, 67, 68, 69, 71
}; };
#endif #endif
@ -501,19 +508,19 @@ static const yytype_uint16 yytoknum[] =
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] = static const yytype_uint8 yyr1[] =
{ {
0, 30, 31, 31, 31, 31, 32, 32, 32, 32, 0, 30, 31, 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, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
33, 33, 33, 33, 34 32, 33, 33, 33, 33, 33, 34
}; };
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] = static const yytype_uint8 yyr2[] =
{ {
0, 2, 1, 1, 1, 2, 1, 3, 3, 3, 0, 2, 0, 1, 1, 1, 2, 1, 3, 3,
3, 2, 3, 3, 4, 4, 4, 6, 4, 4, 3, 3, 2, 3, 3, 4, 4, 4, 6, 4,
6, 4, 4, 6, 4, 4, 4, 4, 4, 4, 4, 6, 4, 4, 6, 4, 4, 4, 4, 4,
1, 3, 3, 3, 2 4, 1, 3, 3, 3, 3, 2
}; };
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
@ -521,47 +528,47 @@ static const yytype_uint8 yyr2[] =
means the default is an error. */ means the default is an error. */
static const yytype_uint8 yydefact[] = static const yytype_uint8 yydefact[] =
{ {
0, 30, 6, 0, 0, 0, 0, 0, 0, 0, 2, 31, 7, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 3, 4, 5, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 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, 12, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 6, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 13, 8, 7, 9, 10, 12, 31, 32, 33, 0, 0, 0, 0, 14, 35, 9, 8, 10, 11,
14, 15, 16, 0, 29, 19, 18, 0, 21, 22, 13, 32, 33, 34, 15, 16, 17, 0, 30, 20,
0, 24, 25, 26, 27, 28, 0, 0, 0, 17, 19, 0, 22, 23, 0, 25, 26, 27, 28, 29,
20, 23 0, 0, 0, 18, 21, 24
}; };
/* YYDEFGOTO[NTERM-NUM]. */ /* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] = 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 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */ STATE-NUM. */
#define YYPACT_NINF -25 #define YYPACT_NINF -23
static const yytype_int16 yypact[] = static const yytype_int16 yypact[] =
{ {
69, -25, -25, -24, -23, -5, -4, -3, 3, 4, 92, -23, -23, -22, -19, -13, -10, -5, -4, 16,
5, 27, 28, 29, 35, 40, 72, 78, 86, 30, 17, 36, 39, 44, 54, 65, 89, 111, 124, 116,
30, 70, 88, 229, 30, 30, 30, 30, 30, 30, 92, 7, 38, 91, 116, 116, 116, 116, 116, 116,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
30, 81, 80, -25, 30, 30, 30, 30, 30, 229, 116, 116, 31, 30, 62, -23, 116, 116, 116, 116,
95, 95, 30, 88, -25, 103, 111, 119, 37, 127, 116, 18, 91, 18, 18, 116, 38, -23, 56, 118,
135, 143, 71, 151, 159, 94, 167, 175, 183, 191, 126, -20, 134, 142, 150, -11, 158, 166, 46, 174,
199, -25, 233, 233, 81, 81, 81, 93, 93, 43, 182, 190, 198, 206, -23, -23, 236, 236, 31, 31,
-25, -25, -25, 30, -25, -25, -25, 30, -25, -25, 31, 57, 57, 67, -23, -23, -23, 116, -23, -23,
30, -25, -25, -25, -25, -25, 207, 215, 223, -25, -23, 116, -23, -23, 116, -23, -23, -23, -23, -23,
-25, -25 214, 222, 230, -23, -23, -23
}; };
/* YYPGOTO[NTERM-NUM]. */ /* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] = 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 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@ -570,68 +577,70 @@ static const yytype_int8 yypgoto[] =
#define YYTABLE_NINF -1 #define YYTABLE_NINF -1
static const yytype_uint8 yytable[] = static const yytype_uint8 yytable[] =
{ {
41, 42, 23, 25, 26, 53, 55, 56, 57, 58, 22, 46, 47, 48, 49, 25, 50, 45, 26, 87,
59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 46, 47, 48, 49, 27, 50, 57, 28, 91, 42,
69, 70, 27, 28, 29, 72, 73, 74, 75, 76, 23, 1, 29, 30, 56, 58, 59, 60, 61, 62,
30, 31, 32, 79, 2, 3, 4, 5, 6, 7, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 73, 1, 52, 31, 32, 51, 76, 77, 78, 79,
18, 19, 77, 78, 33, 34, 35, 20, 44, 45, 80, 46, 47, 48, 49, 83, 50, 50, 74, 46,
46, 47, 36, 48, 96, 45, 83, 37, 97, 48, 47, 48, 49, 33, 50, 51, 34, 46, 47, 48,
43, 98, 1, 2, 3, 4, 5, 6, 7, 8, 49, 35, 50, 81, 82, 94, 52, 46, 47, 48,
9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 49, 36, 50, 55, 84, 53, 54, 100, 55, 47,
19, 1, 44, 45, 46, 47, 20, 48, 1, 38, 75, 101, 37, 50, 102, 1, 2, 3, 4, 5,
87, 44, 45, 46, 47, 39, 48, 48, 71, 44, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
45, 46, 47, 40, 48, 44, 45, 46, 47, 52, 16, 17, 18, 19, 53, 54, 38, 55, 0, 20,
48, 54, 0, 90, 44, 45, 46, 47, 0, 48, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
0, 80, 44, 45, 46, 47, 0, 48, 0, 81, 12, 13, 14, 15, 16, 17, 18, 19, 39, 46,
44, 45, 46, 47, 0, 48, 0, 82, 44, 45, 47, 48, 49, 41, 50, 0, 85, 46, 47, 48,
46, 47, 0, 48, 0, 84, 44, 45, 46, 47, 49, 40, 50, 0, 86, 46, 47, 48, 49, 0,
0, 48, 0, 85, 44, 45, 46, 47, 0, 48, 50, 0, 88, 46, 47, 48, 49, 0, 50, 0,
0, 86, 44, 45, 46, 47, 0, 48, 0, 88, 89, 46, 47, 48, 49, 0, 50, 0, 90, 46,
44, 45, 46, 47, 0, 48, 0, 89, 44, 45, 47, 48, 49, 0, 50, 0, 92, 46, 47, 48,
46, 47, 0, 48, 0, 91, 44, 45, 46, 47, 49, 0, 50, 0, 93, 46, 47, 48, 49, 0,
0, 48, 0, 92, 44, 45, 46, 47, 0, 48, 50, 0, 95, 46, 47, 48, 49, 0, 50, 0,
0, 93, 44, 45, 46, 47, 0, 48, 0, 94, 96, 46, 47, 48, 49, 0, 50, 0, 97, 46,
44, 45, 46, 47, 0, 48, 0, 95, 44, 45, 47, 48, 49, 0, 50, 0, 98, 46, 47, 48,
46, 47, 0, 48, 0, 99, 44, 45, 46, 47, 49, 0, 50, 0, 99, 46, 47, 48, 49, 0,
0, 48, 0, 100, 44, 45, 46, 47, 0, 48, 50, 0, 103, 46, 47, 48, 49, 0, 50, 0,
0, 101, 50, 51, 0, 52, 46, 47, 0, 48 104, 46, 47, 48, 49, 0, 50, 0, 105, 48,
49, 0, 50
}; };
#define yypact_value_is_default(Yystate) \ #define yypact_value_is_default(Yystate) \
(!!((Yystate) == (-25))) (!!((Yystate) == (-23)))
#define yytable_value_is_error(Yytable_value) \ #define yytable_value_is_error(Yytable_value) \
YYID (0) YYID (0)
static const yytype_int8 yycheck[] = static const yytype_int8 yycheck[] =
{ {
19, 20, 0, 27, 27, 24, 25, 26, 27, 28, 0, 21, 22, 23, 24, 27, 26, 0, 27, 29,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 21, 22, 23, 24, 27, 26, 24, 27, 29, 19,
39, 40, 27, 27, 27, 44, 45, 46, 47, 48, 0, 3, 27, 27, 24, 25, 26, 27, 28, 29,
27, 27, 27, 52, 4, 5, 6, 7, 8, 9, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 40, 3, 22, 27, 27, 27, 46, 47, 48, 49,
20, 21, 50, 51, 27, 27, 27, 27, 21, 22, 50, 21, 22, 23, 24, 55, 26, 26, 28, 21,
23, 24, 27, 26, 83, 22, 29, 27, 87, 26, 22, 23, 24, 27, 26, 27, 27, 21, 22, 23,
0, 90, 3, 4, 5, 6, 7, 8, 9, 10, 24, 27, 26, 53, 54, 29, 56, 21, 22, 23,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 24, 27, 26, 26, 28, 23, 24, 87, 26, 22,
21, 3, 21, 22, 23, 24, 27, 26, 3, 27, 28, 91, 27, 26, 94, 3, 4, 5, 6, 7,
29, 21, 22, 23, 24, 27, 26, 26, 28, 21, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
22, 23, 24, 27, 26, 21, 22, 23, 24, 26, 18, 19, 20, 21, 23, 24, 27, 26, -1, 27,
26, 24, -1, 29, 21, 22, 23, 24, -1, 26, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
-1, 28, 21, 22, 23, 24, -1, 26, -1, 28, 14, 15, 16, 17, 18, 19, 20, 21, 27, 21,
21, 22, 23, 24, -1, 26, -1, 28, 21, 22, 22, 23, 24, 27, 26, -1, 28, 21, 22, 23,
23, 24, -1, 26, -1, 28, 21, 22, 23, 24, 24, 27, 26, -1, 28, 21, 22, 23, 24, -1,
-1, 26, -1, 28, 21, 22, 23, 24, -1, 26, 26, -1, 28, 21, 22, 23, 24, -1, 26, -1,
-1, 28, 21, 22, 23, 24, -1, 26, -1, 28, 28, 21, 22, 23, 24, -1, 26, -1, 28, 21,
21, 22, 23, 24, -1, 26, -1, 28, 21, 22, 22, 23, 24, -1, 26, -1, 28, 21, 22, 23,
23, 24, -1, 26, -1, 28, 21, 22, 23, 24, 24, -1, 26, -1, 28, 21, 22, 23, 24, -1,
-1, 26, -1, 28, 21, 22, 23, 24, -1, 26, 26, -1, 28, 21, 22, 23, 24, -1, 26, -1,
-1, 28, 21, 22, 23, 24, -1, 26, -1, 28, 28, 21, 22, 23, 24, -1, 26, -1, 28, 21,
21, 22, 23, 24, -1, 26, -1, 28, 21, 22, 22, 23, 24, -1, 26, -1, 28, 21, 22, 23,
23, 24, -1, 26, -1, 28, 21, 22, 23, 24, 24, -1, 26, -1, 28, 21, 22, 23, 24, -1,
-1, 26, -1, 28, 21, 22, 23, 24, -1, 26, 26, -1, 28, 21, 22, 23, 24, -1, 26, -1,
-1, 28, 23, 24, -1, 26, 23, 24, -1, 26 28, 21, 22, 23, 24, -1, 26, -1, 28, 23,
24, -1, 26
}; };
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@ -642,13 +651,13 @@ static const yytype_uint8 yystos[] =
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
27, 31, 32, 33, 34, 27, 27, 27, 27, 27, 27, 31, 32, 33, 34, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 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, 27, 27, 32, 32, 33, 0, 21, 22, 23, 24,
23, 24, 26, 32, 34, 32, 32, 32, 32, 32, 26, 27, 33, 23, 24, 26, 32, 34, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 28, 32, 32, 32, 32, 32, 33, 33, 32, 32, 32, 32, 32, 28, 28, 32, 32, 32, 32,
28, 28, 28, 29, 28, 28, 28, 29, 28, 28, 32, 33, 33, 32, 28, 28, 28, 29, 28, 28,
29, 28, 28, 28, 28, 28, 32, 32, 32, 28, 28, 29, 28, 28, 29, 28, 28, 28, 28, 28,
28, 28 32, 32, 32, 28, 28, 28
}; };
#define yyerrok (yyerrstatus = 0) #define yyerrok (yyerrstatus = 0)
@ -1441,205 +1450,217 @@ yyreduce:
{ {
case 2: case 2:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 26 "QuantityParser.y" #line 33 "QuantityParser.y"
{ QuantResult = (yyvsp[(1) - (1)]) ; } { QuantResult = Quantity(DOUBLE_MIN); /* empty input */ }
break; break;
case 3: case 3:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 27 "QuantityParser.y" #line 34 "QuantityParser.y"
{ QuantResult = (yyvsp[(1) - (1)]) ; } { QuantResult = (yyvsp[(1) - (1)]) ; }
break; break;
case 4: case 4:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 28 "QuantityParser.y" #line 35 "QuantityParser.y"
{ QuantResult = (yyvsp[(1) - (1)]) ; } { QuantResult = (yyvsp[(1) - (1)]) ; }
break; break;
case 5: case 5:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 29 "QuantityParser.y" #line 36 "QuantityParser.y"
{ QuantResult = (yyvsp[(1) - (2)]) + (yyvsp[(2) - (2)]); } { QuantResult = (yyvsp[(1) - (1)]) ; }
break; break;
case 6: case 6:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 31 "QuantityParser.y" #line 37 "QuantityParser.y"
{ (yyval) = (yyvsp[(1) - (1)]); } { QuantResult = (yyvsp[(1) - (2)]) + (yyvsp[(2) - (2)]); }
break; break;
case 7: case 7:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 32 "QuantityParser.y" #line 39 "QuantityParser.y"
{ (yyval) = (yyvsp[(1) - (3)]).getValue() + (yyvsp[(3) - (3)]).getValue(); } { (yyval) = (yyvsp[(1) - (1)]); }
break; break;
case 8: case 8:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 33 "QuantityParser.y" #line 40 "QuantityParser.y"
{ (yyval) = (yyvsp[(1) - (3)]).getValue() - (yyvsp[(3) - (3)]).getValue(); } { (yyval) = (yyvsp[(1) - (3)]).getValue() + (yyvsp[(3) - (3)]).getValue(); }
break; break;
case 9: case 9:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 34 "QuantityParser.y" #line 41 "QuantityParser.y"
{ (yyval) = (yyvsp[(1) - (3)]).getValue() * (yyvsp[(3) - (3)]).getValue(); } { (yyval) = (yyvsp[(1) - (3)]).getValue() - (yyvsp[(3) - (3)]).getValue(); }
break; break;
case 10: case 10:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 35 "QuantityParser.y" #line 42 "QuantityParser.y"
{ (yyval) = (yyvsp[(1) - (3)]).getValue() / (yyvsp[(3) - (3)]).getValue(); } { (yyval) = (yyvsp[(1) - (3)]).getValue() * (yyvsp[(3) - (3)]).getValue(); }
break; break;
case 11: case 11:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 36 "QuantityParser.y" #line 43 "QuantityParser.y"
{ (yyval) = -(yyvsp[(2) - (2)]).getValue(); } { (yyval) = (yyvsp[(1) - (3)]).getValue() / (yyvsp[(3) - (3)]).getValue(); }
break; break;
case 12: case 12:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 37 "QuantityParser.y" #line 44 "QuantityParser.y"
{ (yyval) = pow ((yyvsp[(1) - (3)]).getValue(), (yyvsp[(3) - (3)]).getValue());} { (yyval) = -(yyvsp[(2) - (2)]).getValue(); }
break; break;
case 13: case 13:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 38 "QuantityParser.y" #line 45 "QuantityParser.y"
{ (yyval) = (yyvsp[(2) - (3)]); } { (yyval) = pow ((yyvsp[(1) - (3)]).getValue(), (yyvsp[(3) - (3)]).getValue());}
break; break;
case 14: case 14:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 39 "QuantityParser.y" #line 46 "QuantityParser.y"
{ (yyval) = acos((yyvsp[(3) - (4)]).getValue()); } { (yyval) = (yyvsp[(2) - (3)]); }
break; break;
case 15: case 15:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 40 "QuantityParser.y" #line 47 "QuantityParser.y"
{ (yyval) = asin((yyvsp[(3) - (4)]).getValue()); } { (yyval) = acos((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 16: case 16:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 41 "QuantityParser.y" #line 48 "QuantityParser.y"
{ (yyval) = atan((yyvsp[(3) - (4)]).getValue()); } { (yyval) = asin((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 17: case 17:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 42 "QuantityParser.y" #line 49 "QuantityParser.y"
{ (yyval) = atan2((yyvsp[(3) - (6)]).getValue(),(yyvsp[(5) - (6)]).getValue());} { (yyval) = atan((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 18: case 18:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 43 "QuantityParser.y" #line 50 "QuantityParser.y"
{ (yyval) = fabs((yyvsp[(3) - (4)]).getValue()); } { (yyval) = atan2((yyvsp[(3) - (6)]).getValue(),(yyvsp[(5) - (6)]).getValue());}
break; break;
case 19: case 19:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 44 "QuantityParser.y" #line 51 "QuantityParser.y"
{ (yyval) = exp((yyvsp[(3) - (4)]).getValue()); } { (yyval) = fabs((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 20: case 20:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 45 "QuantityParser.y" #line 52 "QuantityParser.y"
{ (yyval) = fmod((yyvsp[(3) - (6)]).getValue(),(yyvsp[(5) - (6)]).getValue()); } { (yyval) = exp((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 21: case 21:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 46 "QuantityParser.y" #line 53 "QuantityParser.y"
{ (yyval) = log((yyvsp[(3) - (4)]).getValue()); } { (yyval) = fmod((yyvsp[(3) - (6)]).getValue(),(yyvsp[(5) - (6)]).getValue()); }
break; break;
case 22: case 22:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 47 "QuantityParser.y" #line 54 "QuantityParser.y"
{ (yyval) = log10((yyvsp[(3) - (4)]).getValue()); } { (yyval) = log((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 23: case 23:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 48 "QuantityParser.y" #line 55 "QuantityParser.y"
{ (yyval) = pow((yyvsp[(3) - (6)]).getValue(),(yyvsp[(5) - (6)]).getValue()); } { (yyval) = log10((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 24: case 24:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 49 "QuantityParser.y" #line 56 "QuantityParser.y"
{ (yyval) = sin((yyvsp[(3) - (4)]).getValue()); } { (yyval) = pow((yyvsp[(3) - (6)]).getValue(),(yyvsp[(5) - (6)]).getValue()); }
break; break;
case 25: case 25:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 50 "QuantityParser.y" #line 57 "QuantityParser.y"
{ (yyval) = sinh((yyvsp[(3) - (4)]).getValue()); } { (yyval) = sin((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 26: case 26:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 51 "QuantityParser.y" #line 58 "QuantityParser.y"
{ (yyval) = tan((yyvsp[(3) - (4)]).getValue()); } { (yyval) = sinh((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 27: case 27:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 52 "QuantityParser.y" #line 59 "QuantityParser.y"
{ (yyval) = tanh((yyvsp[(3) - (4)]).getValue()); } { (yyval) = tan((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 28: case 28:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 53 "QuantityParser.y" #line 60 "QuantityParser.y"
{ (yyval) = tanh((yyvsp[(3) - (4)]).getValue()); } { (yyval) = tanh((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 29: case 29:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 54 "QuantityParser.y" #line 61 "QuantityParser.y"
{ (yyval) = cos((yyvsp[(3) - (4)]).getValue()); } { (yyval) = tanh((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 30: case 30:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 57 "QuantityParser.y" #line 62 "QuantityParser.y"
{ (yyval) = (yyvsp[(1) - (1)]); } { (yyval) = cos((yyvsp[(3) - (4)]).getValue()); }
break; break;
case 31: case 31:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 58 "QuantityParser.y" #line 65 "QuantityParser.y"
{ (yyval) = (yyvsp[(1) - (3)]) * (yyvsp[(3) - (3)]); } { (yyval) = (yyvsp[(1) - (1)]); }
break; break;
case 32: case 32:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 59 "QuantityParser.y" #line 66 "QuantityParser.y"
{ (yyval) = (yyvsp[(1) - (3)]) / (yyvsp[(3) - (3)]); } { (yyval) = (yyvsp[(1) - (3)]) * (yyvsp[(3) - (3)]); }
break; break;
case 33: case 33:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 60 "QuantityParser.y" #line 67 "QuantityParser.y"
{ (yyval) = (yyvsp[(1) - (3)]).pow ((yyvsp[(3) - (3)])); } { (yyval) = (yyvsp[(1) - (3)]) / (yyvsp[(3) - (3)]); }
break; break;
case 34: case 34:
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 62 "QuantityParser.y" #line 68 "QuantityParser.y"
{ (yyval) = (yyvsp[(1) - (2)])*(yyvsp[(2) - (2)]); } { (yyval) = (yyvsp[(1) - (3)]).pow ((yyvsp[(3) - (3)])); }
break;
case 35:
/* Line 1787 of yacc.c */
#line 69 "QuantityParser.y"
{ (yyval) = (yyvsp[(2) - (3)]); }
break;
case 36:
/* Line 1787 of yacc.c */
#line 71 "QuantityParser.y"
{ (yyval) = (yyvsp[(1) - (2)])*(yyvsp[(2) - (2)]); }
break; break;
/* Line 1787 of yacc.c */ /* Line 1787 of yacc.c */
#line 1643 "QuantityParser.c" #line 1664 "QuantityParser.c"
default: break; default: break;
} }
/* User semantic actions sometimes alter yychar, and that requires /* User semantic actions sometimes alter yychar, and that requires
@ -1871,5 +1892,5 @@ yyreturn:
/* Line 2050 of yacc.c */ /* Line 2050 of yacc.c */
#line 66 "QuantityParser.y" #line 75 "QuantityParser.y"

View File

@ -23,9 +23,14 @@
DIGIT [0-9] DIGIT [0-9]
ID [a-z][a-z0-9]* ID [a-z][a-z0-9]*
%x C_COMMENT
%% /*** Filter language Part ***/ %% /*** Filter language Part ***/
"\[" { BEGIN(C_COMMENT); }
<C_COMMENT>"\]" { BEGIN(INITIAL); }
<C_COMMENT>. { ;}
[ \t] ; [ \t] ;
[\n]+ ; [\n]+ ;
@ -41,47 +46,59 @@ ID [a-z][a-z0-9]*
"km" yylval = Quantity(1.0e6 ,Unit(1)); return UNIT; // kilo meter "km" yylval = Quantity(1.0e6 ,Unit(1)); return UNIT; // kilo meter
"l" yylval = Quantity(1000000.0 ,Unit(3)); return UNIT; // Liter dm^3 "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 "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 "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 "g" yylval = Quantity(1.0e-3 ,Unit(0,1)); return UNIT; // gram
"kg" yylval = Quantity(1.0 ,Unit(0,1)); return UNIT; // kilo 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 "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) "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 "min" yylval = Quantity(60.0 ,Unit(0,0,1)); return UNIT; // minute
"h" yylval = Quantity(3600.0 ,Unit(0,0,1)); return UNIT; // hour "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) "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 "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 "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 "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) "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 "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 "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) "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 "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 "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 "in" yylval = Quantity(25.4 ,Unit(1)); return UNIT; // inch
"\"" 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 "fo" yylval = Quantity(304.8 ,Unit(1)); return UNIT; // foot
"'" 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 "th" yylval = Quantity(0.0254 ,Unit(1)); return UNIT; // thou
"yr" yylval = Quantity(914.4 ,Unit(1)); return UNIT; // yard "yr" yylval = Quantity(914.4 ,Unit(1)); return UNIT; // yard
"lb" yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // pound "lb" yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // pound
"oz" yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // ounce "oz" yylval = Quantity(0.45359237 ,Unit(0,1)); return UNIT; // ounce
"st" yylval = Quantity(6.35029318 ,Unit(0,1)); return UNIT; // Stone "st" yylval = Quantity(6.35029318 ,Unit(0,1)); return UNIT; // Stone
"cwt" yylval = Quantity(50.80234544 ,Unit(0,1)); return UNIT; // hundredweights "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)
"psi" yylval = Quantity(0.145038 ,Unit(-1,1,-2)); return UNIT; // pounds/in^2
"W" yylval = Quantity(1e+6 ,Unit(2,1,-3)); return UNIT; // Watt (kg*m^2/s^3)
"VA" yylval = Quantity(1e+6 ,Unit(2,1,-3)); return UNIT; // VoltAmpere (kg*m^2/s^3)
"J" yylval = Quantity(1e+6 ,Unit(2,1,-2)); return UNIT; // Joule (kg*m^2/s^2)
"Nm" yylval = Quantity(1e+6 ,Unit(2,1,-2)); return UNIT; // Joule (kg*m^2/s^2)
"VAs" yylval = Quantity(1e+6 ,Unit(2,1,-2)); return UNIT; // Joule (kg*m^2/s^2)
"CV" yylval = Quantity(1e+6 ,Unit(2,1,-2)); return UNIT; // Joule (kg*m^2/s^2)
"Ws" yylval = Quantity(1e+6 ,Unit(2,1,-2)); return UNIT; // Joule (kg*m^2/s^2)
{DIGIT}+["."","]{DIGIT}*[eE][-+]?[0-9]+ {for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;} {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;} {DIGIT}+["."","]{DIGIT}* {for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}

View File

@ -4,9 +4,16 @@
/* Represents the many different ways we can access our data */ /* Represents the many different ways we can access our data */
%{ %{
#define YYSTYPE Quantity #define YYSTYPE Quantity
#define yyparse Quantity_yyparse #define yyparse Quantity_yyparse
#define yyerror Quantity_yyerror #define yyerror Quantity_yyerror
#ifndef DOUBLE_MAX
# define DOUBLE_MAX 1.7976931348623157E+308 /* max decimal value of a "double"*/
#endif
#ifndef DOUBLE_MIN
# define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/
#endif
%} %}
/* Bison declarations. */ /* Bison declarations. */
@ -23,7 +30,8 @@
%% %%
input: num { QuantResult = $1 ; } input: { QuantResult = Quantity(DOUBLE_MIN); /* empty input */ }
| num { QuantResult = $1 ; }
| unit { QuantResult = $1 ; } | unit { QuantResult = $1 ; }
| quantity { QuantResult = $1 ; } | quantity { QuantResult = $1 ; }
| quantity quantity { QuantResult = $1 + $2; } | quantity quantity { QuantResult = $1 + $2; }
@ -58,8 +66,9 @@
| unit '*' unit { $$ = $1 * $3; } | unit '*' unit { $$ = $1 * $3; }
| unit '/' unit { $$ = $1 / $3; } | unit '/' unit { $$ = $1 / $3; }
| unit '^' num { $$ = $1.pow ($3); } | unit '^' num { $$ = $1.pow ($3); }
| '(' unit ')' { $$ = $2; }
; ;
quantity: num unit { $$ = $1*$2; } quantity: num unit { $$ = $1*$2; }
; ;

View File

@ -174,42 +174,59 @@ std::string Unit::getString(void) const
Sig.AmountOfSubstance > 0 || Sig.AmountOfSubstance > 0 ||
Sig.LuminoseIntensity > 0 || Sig.LuminoseIntensity > 0 ||
Sig.Angle > 0 ){ Sig.Angle > 0 ){
bool mult = false;
if(Sig.Length > 0){ if(Sig.Length > 0){
mult = true;
ret << "mm"; ret << "mm";
if(Sig.Length >1) if(Sig.Length >1)
ret << "^" << Sig.Length; ret << "^" << Sig.Length;
} }
if(Sig.Mass > 0){ if(Sig.Mass > 0){
if(mult) ret<<'*';
mult = true;
ret << "kg"; ret << "kg";
if(Sig.Mass >1) if(Sig.Mass >1)
ret << "^" << Sig.Mass; ret << "^" << Sig.Mass;
} }
if(Sig.Time > 0){ if(Sig.Time > 0){
if(mult) ret<<'*';
mult = true;
ret << "s"; ret << "s";
if(Sig.Time >1) if(Sig.Time >1)
ret << "^" << Sig.Time; ret << "^" << Sig.Time;
} }
if(Sig.ElectricCurrent > 0){ if(Sig.ElectricCurrent > 0){
if(mult) ret<<'*';
mult = true;
ret << "A"; ret << "A";
if(Sig.ElectricCurrent >1) if(Sig.ElectricCurrent >1)
ret << "^" << Sig.ElectricCurrent; ret << "^" << Sig.ElectricCurrent;
} }
if(Sig.ThermodynamicTemperature > 0){ if(Sig.ThermodynamicTemperature > 0){
if(mult) ret<<'*';
mult = true;
ret << "K"; ret << "K";
if(Sig.ThermodynamicTemperature >1) if(Sig.ThermodynamicTemperature >1)
ret << "^" << Sig.ThermodynamicTemperature; ret << "^" << Sig.ThermodynamicTemperature;
} }
if(Sig.AmountOfSubstance > 0){ if(Sig.AmountOfSubstance > 0){
if(mult) ret<<'*';
mult = true;
ret << "mol"; ret << "mol";
if(Sig.AmountOfSubstance >1) if(Sig.AmountOfSubstance >1)
ret << "^" << Sig.AmountOfSubstance; ret << "^" << Sig.AmountOfSubstance;
} }
if(Sig.LuminoseIntensity > 0){ if(Sig.LuminoseIntensity > 0){
if(mult) ret<<'*';
mult = true;
ret << "cd"; ret << "cd";
if(Sig.LuminoseIntensity >1) if(Sig.LuminoseIntensity >1)
ret << "^" << Sig.LuminoseIntensity; ret << "^" << Sig.LuminoseIntensity;
} }
if(Sig.Angle > 0){ if(Sig.Angle > 0){
if(mult) ret<<'*';
mult = true;
ret << "deg"; ret << "deg";
if(Sig.Angle >1) if(Sig.Angle >1)
ret << "^" << Sig.Angle; ret << "^" << Sig.Angle;
@ -227,46 +244,73 @@ std::string Unit::getString(void) const
Sig.LuminoseIntensity < 0 || Sig.LuminoseIntensity < 0 ||
Sig.Angle < 0 ){ Sig.Angle < 0 ){
ret << "/"; 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){ if(Sig.Length < 0){
ret << "mm"; ret << "mm";
mult = true;
if(Sig.Length <-1) if(Sig.Length <-1)
ret << "^" << abs(Sig.Length); ret << "^" << abs(Sig.Length);
} }
if(Sig.Mass < 0){ if(Sig.Mass < 0){
ret << "kg"; if(mult) ret<<'*';
mult = true;
ret << "kg";
if(Sig.Mass <-1) if(Sig.Mass <-1)
ret << "^" << abs(Sig.Mass); ret << "^" << abs(Sig.Mass);
} }
if(Sig.Time < 0){ if(Sig.Time < 0){
if(mult) ret<<'*';
mult = true;
ret << "s"; ret << "s";
if(Sig.Time <-1) if(Sig.Time <-1)
ret << "^" << abs(Sig.Time); ret << "^" << abs(Sig.Time);
} }
if(Sig.ElectricCurrent < 0){ if(Sig.ElectricCurrent < 0){
if(mult) ret<<'*';
mult = true;
ret << "A"; ret << "A";
if(Sig.ElectricCurrent <-1) if(Sig.ElectricCurrent <-1)
ret << "^" << abs(Sig.ElectricCurrent); ret << "^" << abs(Sig.ElectricCurrent);
} }
if(Sig.ThermodynamicTemperature < 0){ if(Sig.ThermodynamicTemperature < 0){
if(mult) ret<<'*';
mult = true;
ret << "K"; ret << "K";
if(Sig.ThermodynamicTemperature <-1) if(Sig.ThermodynamicTemperature <-1)
ret << "^" << abs(Sig.ThermodynamicTemperature); ret << "^" << abs(Sig.ThermodynamicTemperature);
} }
if(Sig.AmountOfSubstance < 0){ if(Sig.AmountOfSubstance < 0){
if(mult) ret<<'*';
mult = true;
ret << "mol"; ret << "mol";
if(Sig.AmountOfSubstance <-1) if(Sig.AmountOfSubstance <-1)
ret << "^" << abs(Sig.AmountOfSubstance); ret << "^" << abs(Sig.AmountOfSubstance);
} }
if(Sig.LuminoseIntensity < 0){ if(Sig.LuminoseIntensity < 0){
if(mult) ret<<'*';
mult = true;
ret << "cd"; ret << "cd";
if(Sig.LuminoseIntensity <-1) if(Sig.LuminoseIntensity <-1)
ret << "^" << abs(Sig.LuminoseIntensity); ret << "^" << abs(Sig.LuminoseIntensity);
} }
if(Sig.Angle < 0){ if(Sig.Angle < 0){
if(mult) ret<<'*';
mult = true;
ret << "deg"; ret << "deg";
if(Sig.Angle <-1) if(Sig.Angle <-1)
ret << "^" << abs(Sig.Angle); ret << "^" << abs(Sig.Angle);
} }
if (nnom > 1) ret << ')';
} }
return ret.str(); return ret.str();

View File

@ -535,13 +535,13 @@ def mergeCells(objectslist):
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
return base return base
def download(url): def download(url,force=False):
'''downloads a file from the given URL and saves it in the '''downloads a file from the given URL and saves it in the
user directory. Returns the path to the saved file''' user directory. Returns the path to the saved file'''
import urllib2, os import urllib2, os
name = url.split('/')[-1] name = url.split('/')[-1]
filepath = os.path.join(FreeCAD.ConfigGet("UserAppData"),name) filepath = os.path.join(FreeCAD.ConfigGet("UserAppData"),name)
if os.path.exists(filepath): if os.path.exists(filepath) and not(force):
return filepath return filepath
try: try:
FreeCAD.Console.PrintMessage("downloading "+url+" ...\n") FreeCAD.Console.PrintMessage("downloading "+url+" ...\n")

View File

@ -40,6 +40,7 @@ texts, colors,layers (from groups)
''' '''
TEXTSCALING = 1.35 # scaling factor between autocad font sizes and coin font sizes TEXTSCALING = 1.35 # scaling factor between autocad font sizes and coin font sizes
CURRENTDXFLIB = 1.35 # the minimal version of the dxfLibrary needed to run
import sys, FreeCAD, os, Part, math, re, string, Mesh, Draft, DraftVecUtils, DraftGeomUtils import sys, FreeCAD, os, Part, math, re, string, Mesh, Draft, DraftVecUtils, DraftGeomUtils
from Draft import _Dimension, _ViewProviderDimension from Draft import _Dimension, _ViewProviderDimension
@ -50,24 +51,37 @@ try:
draftui = FreeCADGui.draftToolBar draftui = FreeCADGui.draftToolBar
except: except:
draftui = None draftui = None
files = ['dxfColorMap.py','dxfImportObjects.py','dxfLibrary.py','dxfReader.py'] # check dxfLibrary version
baseurl = 'https://raw.github.com/yorikvanhavre/Draft-dxf-importer/master/' try:
for f in files: import dxfLibrary
p = os.path.join(FreeCAD.ConfigGet("UserAppData"),f) import dxfColorMap
if not os.path.exists(p): import dxfReader
import ArchCommands except:
libsok = False
FreeCAD.Console.PrintWarning("DXF libraries not found. Downloading...\n")
else:
if "v"+str(CURRENTDXFLIB) in dxfLibrary.__version__:
libsok = True
else:
FreeCAD.Console.PrintWarning("DXF libraries need to be updated. Downloading...\n")
libsok = False
if not libsok:
files = ['dxfColorMap.py','dxfImportObjects.py','dxfLibrary.py','dxfReader.py']
baseurl = 'https://raw.github.com/yorikvanhavre/Draft-dxf-importer/master/'
import ArchCommands
for f in files:
p = None p = None
p = ArchCommands.download(baseurl+f) p = ArchCommands.download(baseurl+f,force=True)
if not p: if not p:
FreeCAD.Console.PrintWarning("Download of dxf libraries failed. Please download them manually from https://github.com/yorikvanhavre/Draft-dxf-importer\n") FreeCAD.Console.PrintWarning("Download of dxf libraries failed. Please download them manually from https://github.com/yorikvanhavre/Draft-dxf-importer\n")
sys.path.append(FreeCAD.ConfigGet("UserAppData")) sys.path.append(FreeCAD.ConfigGet("UserAppData"))
try: try:
import dxfColorMap, dxfLibrary, dxfReader import dxfColorMap, dxfLibrary, dxfReader
except: except:
dxfReader = None dxfReader = None
dxfLibrary = None dxfLibrary = None
if open.__module__ == '__builtin__': if open.__module__ == '__builtin__':
pythonopen = open # to distinguish python built-in open function from the one declared here pythonopen = open # to distinguish python built-in open function from the one declared here