fix error of gcc and remove old parser code.

This commit is contained in:
jriegel 2013-12-05 08:42:33 +01:00
parent f58ea31b6a
commit 894529a223
9 changed files with 20 additions and 4159 deletions

View File

@ -161,8 +161,6 @@ SET(FreeCADBase_UNITAPI_SRCS
UnitsSchemaMKS.cpp
UnitsSchemaImperial1.h
UnitsSchemaImperial1.cpp
UnitsApi.y
UnitsApi.l
Quantity.h
Quantity.cpp
QuantityPyImp.cpp

View File

@ -41,8 +41,6 @@
using namespace Base;
double Quantity::defaultFactor = 1.0;
Quantity::Quantity()
{

View File

@ -62,7 +62,12 @@ public:
//@}
/// transfer to user prefered unit/potence
QString getUserString(double &factor=defaultFactor,QString &unitString=QString())const;
QString getUserString(double &factor,QString &unitString)const;
QString getUserString(void)const{ // to satisfy GCC
double dummy1;
QString dummy2;
return getUserString(dummy1,dummy2);
}
//double getUserPrefered() const { QString dummy; return getUserPrefered(dummy); }
//double getUserPrefered(QString &unitString) const;
//std::string getUserString(void)const;
@ -168,7 +173,6 @@ public:
//@}
static double defaultFactor;
protected:

View File

@ -62,7 +62,12 @@ public:
*/
static void setSchema(UnitSystem s);
static QString schemaTranslate(Base::Quantity quant,double &factor=defaultFactor,QString &unitString=QString());
static QString schemaTranslate(Base::Quantity quant,double &factor,QString &unitString);
static QString schemaTranslate(Base::Quantity quant){ // to satisfy GCC
double dummy1;
QString dummy2;
return UnitsApi::schemaTranslate(quant,dummy1,dummy2);
}
/// generate a value for a quantity with default user prefered system
static double toDbl(PyObject *ArgObj,const Base::Unit &u=Base::Unit());
/// generate a value for a quantity with default user prefered system

View File

@ -1,101 +0,0 @@
%{
/* Lexer for the FreeCAD Units language */
/* (c) 2010 Juergen Riegel LGPL */
/* This disables inclusion of unistd.h, which is not available under Visual C++
* on Win32. The C++ scanner uses STL streams instead. */
#define YY_NO_UNISTD_H
%}
/*** Flex Declarations and Options ***/
/* change the name of the scanner class. */
%option prefix="UnitsApi"
/* the manual says "somewhat more optimized" */
%option batch
/* no support for include files is planned */
%option noyywrap nounput
DIGIT [0-9]
ID [a-z][a-z0-9]*
%% /*** Filter language Part ***/
[ \t] ;
[\n]+ ;
[-+()=/*^] { return *yytext; }
"mm" yylval = 1.0; return UNIT; // millimeter (internal standard length)
"m" yylval = 1000.0; return UNIT; // meter
"cm" yylval = 10.0; return UNIT; // centimeter
"dm" yylval = 100.0; return UNIT; // decimeter
"km" yylval = 1000000.0; return UNIT; // kilometer
"in" yylval = 25.4; return UNIT; // inch
"\"" yylval = 25.4; return UNIT; // inch
"fo" yylval = 304.8; return UNIT; // foot
"'" yylval = 304.8; return UNIT; // foot
"th" yylval = 0.0254; return UNIT; // thou
"yr" yylval = 914.4; return UNIT; // yard
"kg" yylval = 1.0; return UNIT; // kilogram (internal standard mass)
"g" yylval = 0.001; return UNIT; // gram
"mg" yylval = 0.000001; return UNIT; // milligram
"t" yylval = 1000.0; return UNIT; // ton
"lb" yylval = 0.45359237; return UNIT; // pound
"oz" yylval = 0.45359237; return UNIT; // ounce
"st" yylval = 6.35029318; return UNIT; // Stone
"cwt" yylval = 50.80234544;return UNIT; // hundredweights
"deg" yylval = 1.0; return UNIT; // degree (internal standard angle)
"rad" yylval = 180/M_PI; return UNIT; // radian
"gon" yylval = 360.0/400.0;return UNIT; // gon
"s" yylval = 1.0; return UNIT; // second (internal standard time)
"min" yylval = 60.0; return UNIT; // minute
"h" yylval = 3600.0; return UNIT; // hour
"A" yylval = 1.0; return UNIT; // Ampere (internal standard electric current)
"K" yylval = 1.0; return UNIT; // Kelvin (internal standard thermodynamic temperature)
"cd" yylval = 1.0; return UNIT; // Candela (internal standard luminous intensity)
"mol" yylval = 1.0; return UNIT; // Mole (internal standard amount of substance)
"yl" yylval = 1.0; return UNIT; // microliter mm^3(derived standard volume)
"ml" yylval = 1000.0; return UNIT; // milliliter cm^3
"l" yylval = 1000000.0; return UNIT; // Liter dm^3
{DIGIT}+"."{DIGIT}* {yylval = atof( yytext ); return NUM;}
{DIGIT}+ {yylval = atof( yytext ); return NUM;}
"pi" {yylval = M_PI ; return NUM;} // constant pi
"e" {yylval = M_E ; return NUM;} // constant e
"acos" return ACOS;
"asin" return ASIN;
"atan" return ATAN;
"atan2" return ATAN2;
"cos" return COS;
"exp" return EXP;
"abs" return ABS;
"mod" return MOD;
"log" return LOG;
"log10" return LOG10;
"pow" return POW;
"sin" return SIN;
"sinh" return SINH;
"tan" return TAN;
"tanh" return TANH;
"sqrt" return SQRT;

File diff suppressed because it is too large Load Diff

View File

@ -1,59 +0,0 @@
/* Parser for the FreeCAD Units language */
/* (c) 2010 Juergen Riegel LGPL */
/* Represents the many different ways we can access our data */
%{
#define YYSTYPE double
#define yyparse Unit_yyparse
#define yyerror Unit_yyerror
%}
/* Bison declarations. */
%token ACOS ASIN ATAN ATAN2 COS EXP ABS MOD LOG LOG10 POW SIN SINH TAN TANH SQRT;
%token UNIT NUM
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
%start input
%%
input: exp { ScanResult = $1 ; }
;
exp: NUM { $$ = $1; }
| UNIT { $$ = $1;UU=true; }
| NUM UNIT { $$ = $1*$2;UU=true; }
| exp '+' exp { $$ = $1 + $3; }
| exp '-' exp { $$ = $1 - $3; }
| exp '*' exp { $$ = $1 * $3; }
| exp '/' exp { $$ = $1 / $3; }
| '-' exp %prec NEG { $$ = -$2; }
| exp '^' exp { $$ = pow ($1, $3);}
| '(' exp ')' { $$ = $2; }
| ACOS '(' exp ')' { $$ = acos($3); }
| ASIN '(' exp ')' { $$ = asin($3); }
| ATAN '(' exp ')' { $$ = atan($3); }
| ATAN2 '(' exp ',' exp ')' { $$ = atan2($3,$5);}
| ABS '(' exp ')' { $$ = fabs($3); }
| EXP '(' exp ')' { $$ = exp($3); }
| MOD '(' exp ',' exp ')' { $$ = fmod($3,$5); }
| LOG '(' exp ')' { $$ = log($3); }
| LOG10 '(' exp ')' { $$ = log10($3); }
| POW '(' exp ',' exp ')' { $$ = pow($3,$5); }
| SIN '(' exp ')' { $$ = sin($3); }
| SINH '(' exp ')' { $$ = sinh($3); }
| TAN '(' exp ')' { $$ = tan($3); }
| TANH '(' exp ')' { $$ = tanh($3); }
| SQRT '(' exp ')' { $$ = tanh($3); }
| COS '(' exp ')' { $$ = cos($3); }
| exp exp { $$ = $1 * $2; }
;
%%

File diff suppressed because it is too large Load Diff

View File

@ -62,6 +62,13 @@ SET(Mod_SRCS
)
SOURCE_GROUP("Module" FILES ${Mod_SRCS})
SET(FemScripts_SRCS
convert2TetGen.py
FemLib.py
MechanicalAnalysis.py
MechanicalMaterial.py
)
#SOURCE_GROUP("Scripts" FILES ${FemScripts_SRCS})
SET(FemBase_SRCS
FemMeshObject.cpp
@ -141,10 +148,7 @@ fc_target_copy_resource(Fem
${CMAKE_BINARY_DIR}/Mod/Fem
${Driver_Resources}
Init.py
convert2TetGen.py
FemLib.py
MechanicalAnalysis.py
MechanicalMaterial.py
${FemScripts_SRCS}
)