Skip to content
Snippets Groups Projects
Commit 6edd41e0 authored by Patrick Dular's avatar Patrick Dular
Browse files

Added data type in .geo files for Structures (e.g., nameOfStruct.value is 123....

Added data type in .geo files for Structures (e.g., nameOfStruct.value is 123. defined via DefineStruct nameOfStruct [value 123., isIn 1], also with NameSpaces)
parent 852a05cc
No related branches found
No related tags found
No related merge requests found
...@@ -158,6 +158,7 @@ Cylinder return tCylinder; ...@@ -158,6 +158,7 @@ Cylinder return tCylinder;
DefineConstant return tDefineConstant; DefineConstant return tDefineConstant;
DefineNumber return tDefineNumber; DefineNumber return tDefineNumber;
DefineString return tDefineString; DefineString return tDefineString;
DefineStruct return tDefineStruct;
Degenerated return tDegenerated; Degenerated return tDegenerated;
Delete return tDelete; Delete return tDelete;
Dilate return tDilate; Dilate return tDilate;
...@@ -234,6 +235,7 @@ MeshAlgorithm return tMeshAlgorithm; ...@@ -234,6 +235,7 @@ MeshAlgorithm return tMeshAlgorithm;
Modulo return tModulo; Modulo return tModulo;
N2S return tNameToString; N2S return tNameToString;
NameStruct return tNameStruct;
NameToString return tNameToString; NameToString return tNameToString;
NewModel return tNewModel; NewModel return tNewModel;
Nurbs return tNurbs; Nurbs return tNurbs;
......
This diff is collapsed.
...@@ -117,141 +117,143 @@ ...@@ -117,141 +117,143 @@
tDefineConstant = 333, tDefineConstant = 333,
tUndefineConstant = 334, tUndefineConstant = 334,
tDefineNumber = 335, tDefineNumber = 335,
tDefineString = 336, tDefineStruct = 336,
tSetNumber = 337, tNameStruct = 337,
tSetString = 338, tDefineString = 338,
tPoint = 339, tSetNumber = 339,
tCircle = 340, tSetString = 340,
tEllipse = 341, tPoint = 341,
tLine = 342, tCircle = 342,
tSphere = 343, tEllipse = 343,
tPolarSphere = 344, tLine = 344,
tSurface = 345, tSphere = 345,
tSpline = 346, tPolarSphere = 346,
tVolume = 347, tSurface = 347,
tBlock = 348, tSpline = 348,
tCylinder = 349, tVolume = 349,
tCone = 350, tBlock = 350,
tTorus = 351, tCylinder = 351,
tEllipsoid = 352, tCone = 352,
tQuadric = 353, tTorus = 353,
tShapeFromFile = 354, tEllipsoid = 354,
tRectangle = 355, tQuadric = 355,
tDisk = 356, tShapeFromFile = 356,
tWire = 357, tRectangle = 357,
tCharacteristic = 358, tDisk = 358,
tLength = 359, tWire = 359,
tParametric = 360, tCharacteristic = 360,
tElliptic = 361, tLength = 361,
tRefineMesh = 362, tParametric = 362,
tAdaptMesh = 363, tElliptic = 363,
tRelocateMesh = 364, tRefineMesh = 364,
tSetFactory = 365, tAdaptMesh = 365,
tThruSections = 366, tRelocateMesh = 366,
tWedge = 367, tSetFactory = 367,
tFillet = 368, tThruSections = 368,
tChamfer = 369, tWedge = 369,
tPlane = 370, tFillet = 370,
tRuled = 371, tChamfer = 371,
tTransfinite = 372, tPlane = 372,
tComplex = 373, tRuled = 373,
tPhysical = 374, tTransfinite = 374,
tCompound = 375, tComplex = 375,
tPeriodic = 376, tPhysical = 376,
tUsing = 377, tCompound = 377,
tPlugin = 378, tPeriodic = 378,
tDegenerated = 379, tUsing = 379,
tRecursive = 380, tPlugin = 380,
tRotate = 381, tDegenerated = 381,
tTranslate = 382, tRecursive = 382,
tSymmetry = 383, tRotate = 383,
tDilate = 384, tTranslate = 384,
tExtrude = 385, tSymmetry = 385,
tLevelset = 386, tDilate = 386,
tAffine = 387, tExtrude = 387,
tBooleanUnion = 388, tLevelset = 388,
tBooleanIntersection = 389, tAffine = 389,
tBooleanDifference = 390, tBooleanUnion = 390,
tBooleanSection = 391, tBooleanIntersection = 391,
tBooleanFragments = 392, tBooleanDifference = 392,
tThickSolid = 393, tBooleanSection = 393,
tRecombine = 394, tBooleanFragments = 394,
tSmoother = 395, tThickSolid = 395,
tSplit = 396, tRecombine = 396,
tDelete = 397, tSmoother = 397,
tCoherence = 398, tSplit = 398,
tIntersect = 399, tDelete = 399,
tMeshAlgorithm = 400, tCoherence = 400,
tReverse = 401, tIntersect = 401,
tLayers = 402, tMeshAlgorithm = 402,
tScaleLast = 403, tReverse = 403,
tHole = 404, tLayers = 404,
tAlias = 405, tScaleLast = 405,
tAliasWithOptions = 406, tHole = 406,
tCopyOptions = 407, tAlias = 407,
tQuadTriAddVerts = 408, tAliasWithOptions = 408,
tQuadTriNoNewVerts = 409, tCopyOptions = 409,
tRecombLaterals = 410, tQuadTriAddVerts = 410,
tTransfQuadTri = 411, tQuadTriNoNewVerts = 411,
tText2D = 412, tRecombLaterals = 412,
tText3D = 413, tTransfQuadTri = 413,
tInterpolationScheme = 414, tText2D = 414,
tTime = 415, tText3D = 415,
tCombine = 416, tInterpolationScheme = 416,
tBSpline = 417, tTime = 417,
tBezier = 418, tCombine = 418,
tNurbs = 419, tBSpline = 419,
tNurbsOrder = 420, tBezier = 420,
tNurbsKnots = 421, tNurbs = 421,
tColor = 422, tNurbsOrder = 422,
tColorTable = 423, tNurbsKnots = 423,
tFor = 424, tColor = 424,
tIn = 425, tColorTable = 425,
tEndFor = 426, tFor = 426,
tIf = 427, tIn = 427,
tElseIf = 428, tEndFor = 428,
tElse = 429, tIf = 429,
tEndIf = 430, tElseIf = 430,
tExit = 431, tElse = 431,
tAbort = 432, tEndIf = 432,
tField = 433, tExit = 433,
tReturn = 434, tAbort = 434,
tCall = 435, tField = 435,
tSlide = 436, tReturn = 436,
tMacro = 437, tCall = 437,
tShow = 438, tSlide = 438,
tHide = 439, tMacro = 439,
tGetValue = 440, tShow = 440,
tGetStringValue = 441, tHide = 441,
tGetEnv = 442, tGetValue = 442,
tGetString = 443, tGetStringValue = 443,
tGetNumber = 444, tGetEnv = 444,
tUnique = 445, tGetString = 445,
tHomology = 446, tGetNumber = 446,
tCohomology = 447, tUnique = 447,
tBetti = 448, tHomology = 448,
tExists = 449, tCohomology = 449,
tFileExists = 450, tBetti = 450,
tGMSH_MAJOR_VERSION = 451, tExists = 451,
tGMSH_MINOR_VERSION = 452, tFileExists = 452,
tGMSH_PATCH_VERSION = 453, tGMSH_MAJOR_VERSION = 453,
tGmshExecutableName = 454, tGMSH_MINOR_VERSION = 454,
tSetPartition = 455, tGMSH_PATCH_VERSION = 455,
tNameToString = 456, tGmshExecutableName = 456,
tStringToName = 457, tSetPartition = 457,
tAFFECTDIVIDE = 458, tNameToString = 458,
tAFFECTTIMES = 459, tStringToName = 459,
tAFFECTMINUS = 460, tAFFECTDIVIDE = 460,
tAFFECTPLUS = 461, tAFFECTTIMES = 461,
tOR = 462, tAFFECTMINUS = 462,
tAND = 463, tAFFECTPLUS = 463,
tNOTEQUAL = 464, tOR = 464,
tEQUAL = 465, tAND = 465,
tGREATEROREQUAL = 466, tNOTEQUAL = 466,
tLESSOREQUAL = 467, tEQUAL = 467,
UNARYPREC = 468, tGREATEROREQUAL = 468,
tMINUSMINUS = 469, tLESSOREQUAL = 469,
tPLUSPLUS = 470 UNARYPREC = 470,
tMINUSMINUS = 471,
tPLUSPLUS = 472
}; };
#endif #endif
/* Tokens. */ /* Tokens. */
...@@ -333,148 +335,150 @@ ...@@ -333,148 +335,150 @@
#define tDefineConstant 333 #define tDefineConstant 333
#define tUndefineConstant 334 #define tUndefineConstant 334
#define tDefineNumber 335 #define tDefineNumber 335
#define tDefineString 336 #define tDefineStruct 336
#define tSetNumber 337 #define tNameStruct 337
#define tSetString 338 #define tDefineString 338
#define tPoint 339 #define tSetNumber 339
#define tCircle 340 #define tSetString 340
#define tEllipse 341 #define tPoint 341
#define tLine 342 #define tCircle 342
#define tSphere 343 #define tEllipse 343
#define tPolarSphere 344 #define tLine 344
#define tSurface 345 #define tSphere 345
#define tSpline 346 #define tPolarSphere 346
#define tVolume 347 #define tSurface 347
#define tBlock 348 #define tSpline 348
#define tCylinder 349 #define tVolume 349
#define tCone 350 #define tBlock 350
#define tTorus 351 #define tCylinder 351
#define tEllipsoid 352 #define tCone 352
#define tQuadric 353 #define tTorus 353
#define tShapeFromFile 354 #define tEllipsoid 354
#define tRectangle 355 #define tQuadric 355
#define tDisk 356 #define tShapeFromFile 356
#define tWire 357 #define tRectangle 357
#define tCharacteristic 358 #define tDisk 358
#define tLength 359 #define tWire 359
#define tParametric 360 #define tCharacteristic 360
#define tElliptic 361 #define tLength 361
#define tRefineMesh 362 #define tParametric 362
#define tAdaptMesh 363 #define tElliptic 363
#define tRelocateMesh 364 #define tRefineMesh 364
#define tSetFactory 365 #define tAdaptMesh 365
#define tThruSections 366 #define tRelocateMesh 366
#define tWedge 367 #define tSetFactory 367
#define tFillet 368 #define tThruSections 368
#define tChamfer 369 #define tWedge 369
#define tPlane 370 #define tFillet 370
#define tRuled 371 #define tChamfer 371
#define tTransfinite 372 #define tPlane 372
#define tComplex 373 #define tRuled 373
#define tPhysical 374 #define tTransfinite 374
#define tCompound 375 #define tComplex 375
#define tPeriodic 376 #define tPhysical 376
#define tUsing 377 #define tCompound 377
#define tPlugin 378 #define tPeriodic 378
#define tDegenerated 379 #define tUsing 379
#define tRecursive 380 #define tPlugin 380
#define tRotate 381 #define tDegenerated 381
#define tTranslate 382 #define tRecursive 382
#define tSymmetry 383 #define tRotate 383
#define tDilate 384 #define tTranslate 384
#define tExtrude 385 #define tSymmetry 385
#define tLevelset 386 #define tDilate 386
#define tAffine 387 #define tExtrude 387
#define tBooleanUnion 388 #define tLevelset 388
#define tBooleanIntersection 389 #define tAffine 389
#define tBooleanDifference 390 #define tBooleanUnion 390
#define tBooleanSection 391 #define tBooleanIntersection 391
#define tBooleanFragments 392 #define tBooleanDifference 392
#define tThickSolid 393 #define tBooleanSection 393
#define tRecombine 394 #define tBooleanFragments 394
#define tSmoother 395 #define tThickSolid 395
#define tSplit 396 #define tRecombine 396
#define tDelete 397 #define tSmoother 397
#define tCoherence 398 #define tSplit 398
#define tIntersect 399 #define tDelete 399
#define tMeshAlgorithm 400 #define tCoherence 400
#define tReverse 401 #define tIntersect 401
#define tLayers 402 #define tMeshAlgorithm 402
#define tScaleLast 403 #define tReverse 403
#define tHole 404 #define tLayers 404
#define tAlias 405 #define tScaleLast 405
#define tAliasWithOptions 406 #define tHole 406
#define tCopyOptions 407 #define tAlias 407
#define tQuadTriAddVerts 408 #define tAliasWithOptions 408
#define tQuadTriNoNewVerts 409 #define tCopyOptions 409
#define tRecombLaterals 410 #define tQuadTriAddVerts 410
#define tTransfQuadTri 411 #define tQuadTriNoNewVerts 411
#define tText2D 412 #define tRecombLaterals 412
#define tText3D 413 #define tTransfQuadTri 413
#define tInterpolationScheme 414 #define tText2D 414
#define tTime 415 #define tText3D 415
#define tCombine 416 #define tInterpolationScheme 416
#define tBSpline 417 #define tTime 417
#define tBezier 418 #define tCombine 418
#define tNurbs 419 #define tBSpline 419
#define tNurbsOrder 420 #define tBezier 420
#define tNurbsKnots 421 #define tNurbs 421
#define tColor 422 #define tNurbsOrder 422
#define tColorTable 423 #define tNurbsKnots 423
#define tFor 424 #define tColor 424
#define tIn 425 #define tColorTable 425
#define tEndFor 426 #define tFor 426
#define tIf 427 #define tIn 427
#define tElseIf 428 #define tEndFor 428
#define tElse 429 #define tIf 429
#define tEndIf 430 #define tElseIf 430
#define tExit 431 #define tElse 431
#define tAbort 432 #define tEndIf 432
#define tField 433 #define tExit 433
#define tReturn 434 #define tAbort 434
#define tCall 435 #define tField 435
#define tSlide 436 #define tReturn 436
#define tMacro 437 #define tCall 437
#define tShow 438 #define tSlide 438
#define tHide 439 #define tMacro 439
#define tGetValue 440 #define tShow 440
#define tGetStringValue 441 #define tHide 441
#define tGetEnv 442 #define tGetValue 442
#define tGetString 443 #define tGetStringValue 443
#define tGetNumber 444 #define tGetEnv 444
#define tUnique 445 #define tGetString 445
#define tHomology 446 #define tGetNumber 446
#define tCohomology 447 #define tUnique 447
#define tBetti 448 #define tHomology 448
#define tExists 449 #define tCohomology 449
#define tFileExists 450 #define tBetti 450
#define tGMSH_MAJOR_VERSION 451 #define tExists 451
#define tGMSH_MINOR_VERSION 452 #define tFileExists 452
#define tGMSH_PATCH_VERSION 453 #define tGMSH_MAJOR_VERSION 453
#define tGmshExecutableName 454 #define tGMSH_MINOR_VERSION 454
#define tSetPartition 455 #define tGMSH_PATCH_VERSION 455
#define tNameToString 456 #define tGmshExecutableName 456
#define tStringToName 457 #define tSetPartition 457
#define tAFFECTDIVIDE 458 #define tNameToString 458
#define tAFFECTTIMES 459 #define tStringToName 459
#define tAFFECTMINUS 460 #define tAFFECTDIVIDE 460
#define tAFFECTPLUS 461 #define tAFFECTTIMES 461
#define tOR 462 #define tAFFECTMINUS 462
#define tAND 463 #define tAFFECTPLUS 463
#define tNOTEQUAL 464 #define tOR 464
#define tEQUAL 465 #define tAND 465
#define tGREATEROREQUAL 466 #define tNOTEQUAL 466
#define tLESSOREQUAL 467 #define tEQUAL 467
#define UNARYPREC 468 #define tGREATEROREQUAL 468
#define tMINUSMINUS 469 #define tLESSOREQUAL 469
#define tPLUSPLUS 470 #define UNARYPREC 470
#define tMINUSMINUS 471
#define tPLUSPLUS 472
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
#line 121 "Gmsh.y" #line 124 "Gmsh.y"
{ {
char *c; char *c;
int i; int i;
...@@ -485,7 +489,7 @@ typedef union YYSTYPE ...@@ -485,7 +489,7 @@ typedef union YYSTYPE
List_T *l; List_T *l;
} }
/* Line 1529 of yacc.c. */ /* Line 1529 of yacc.c. */
#line 489 "Gmsh.tab.hpp" #line 493 "Gmsh.tab.hpp"
YYSTYPE; YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
......
...@@ -86,6 +86,9 @@ static std::string LoopControlVariablesNameTab[MAX_RECUR_LOOPS]; ...@@ -86,6 +86,9 @@ static std::string LoopControlVariablesNameTab[MAX_RECUR_LOOPS];
static std::map<std::string, std::vector<double> > floatOptions; static std::map<std::string, std::vector<double> > floatOptions;
static std::map<std::string, std::vector<std::string> > charOptions; static std::map<std::string, std::vector<std::string> > charOptions;
static std::string factory; static std::string factory;
static std::map<std::string, Struct> StructTable_M;
static char *Struct_Name = 0, *Struct_NameSpace = 0;
static int flag_tSTRING_alloc = 0;
void yyerror(const char *s); void yyerror(const char *s);
void yymsg(int level, const char *fmt, ...); void yymsg(int level, const char *fmt, ...);
...@@ -145,7 +148,8 @@ struct doubleXstring{ ...@@ -145,7 +148,8 @@ struct doubleXstring{
%token tCpu tMemory tTotalMemory %token tCpu tMemory tTotalMemory
%token tCreateTopology tCreateTopologyNoHoles %token tCreateTopology tCreateTopologyNoHoles
%token tDistanceFunction tDefineConstant tUndefineConstant %token tDistanceFunction tDefineConstant tUndefineConstant
%token tDefineNumber tDefineString tSetNumber tSetString %token tDefineNumber tDefineStruct tNameStruct
%token tDefineString tSetNumber tSetString
%token tPoint tCircle tEllipse tLine tSphere tPolarSphere tSurface tSpline tVolume %token tPoint tCircle tEllipse tLine tSphere tPolarSphere tSurface tSpline tVolume
%token tBlock tCylinder tCone tTorus tEllipsoid tQuadric tShapeFromFile %token tBlock tCylinder tCone tTorus tEllipsoid tQuadric tShapeFromFile
%token tRectangle tDisk tWire %token tRectangle tDisk tWire
...@@ -171,13 +175,13 @@ struct doubleXstring{ ...@@ -171,13 +175,13 @@ struct doubleXstring{
%token tGmshExecutableName tSetPartition %token tGmshExecutableName tSetPartition
%token tNameToString tStringToName %token tNameToString tStringToName
%type <d> FExpr FExpr_Single %type <d> FExpr FExpr_Single DefineStruct NameStruct_Arg
%type <v> VExpr VExpr_Single CircleOptions TransfiniteType %type <v> VExpr VExpr_Single CircleOptions TransfiniteType
%type <i> NumericAffectation NumericIncrement BooleanOperator BooleanOption %type <i> NumericAffectation NumericIncrement BooleanOperator BooleanOption
%type <i> PhysicalId0 PhysicalId1 PhysicalId2 PhysicalId3 %type <i> PhysicalId0 PhysicalId1 PhysicalId2 PhysicalId3
%type <i> TransfiniteArrangement RecombineAngle InSphereCenter %type <i> TransfiniteArrangement RecombineAngle InSphereCenter
%type <u> ColorExpr %type <u> ColorExpr
%type <c> StringExpr StringExprVar SendToFile HomologyCommand %type <c> StringExpr StringExprVar SendToFile tSTRING_Member_Float HomologyCommand
%type <c> LP RP %type <c> LP RP
%type <c> StringIndex String__Index %type <c> StringIndex String__Index
%type <l> RecursiveListOfStringExprVar %type <l> RecursiveListOfStringExprVar
...@@ -696,6 +700,7 @@ Affectation : ...@@ -696,6 +700,7 @@ Affectation :
tDefineConstant '[' DefineConstants ']' tEND tDefineConstant '[' DefineConstants ']' tEND
| tUndefineConstant '[' UndefineConstants ']' tEND | tUndefineConstant '[' UndefineConstants ']' tEND
| DefineStruct tEND
| tSetNumber LP StringExpr ',' FExpr RP tEND | tSetNumber LP StringExpr ',' FExpr RP tEND
{ {
Msg::SetOnelabNumber($3, $5); Msg::SetOnelabNumber($3, $5);
...@@ -1117,6 +1122,7 @@ Affectation : ...@@ -1117,6 +1122,7 @@ Affectation :
StringOption(GMSH_SET|GMSH_GUI, $1, 0, $3, tmp); StringOption(GMSH_SET|GMSH_GUI, $1, 0, $3, tmp);
Free($1); Free($3); Free($5); Free($1); Free($3); Free($5);
} }
| tSTRING '[' FExpr ']' '.' tSTRING tAFFECT StringExpr tEND | tSTRING '[' FExpr ']' '.' tSTRING tAFFECT StringExpr tEND
{ {
std::string tmp($8); std::string tmp($8);
...@@ -1144,6 +1150,7 @@ Affectation : ...@@ -1144,6 +1150,7 @@ Affectation :
} }
Free($1); Free($3); Free($1); Free($3);
} }
| tSTRING '[' FExpr ']' '.' tSTRING NumericAffectation FExpr tEND | tSTRING '[' FExpr ']' '.' tSTRING NumericAffectation FExpr tEND
{ {
double d = 0.; double d = 0.;
...@@ -1162,6 +1169,7 @@ Affectation : ...@@ -1162,6 +1169,7 @@ Affectation :
} }
Free($1); Free($6); Free($1); Free($6);
} }
| tSTRING '.' tSTRING NumericIncrement tEND | tSTRING '.' tSTRING NumericIncrement tEND
{ {
double d = 0.; double d = 0.;
...@@ -1171,6 +1179,7 @@ Affectation : ...@@ -1171,6 +1179,7 @@ Affectation :
} }
Free($1); Free($3); Free($1); Free($3);
} }
| tSTRING '[' FExpr ']' '.' tSTRING NumericIncrement tEND | tSTRING '[' FExpr ']' '.' tSTRING NumericIncrement tEND
{ {
double d = 0.; double d = 0.;
...@@ -1188,6 +1197,7 @@ Affectation : ...@@ -1188,6 +1197,7 @@ Affectation :
ColorOption(GMSH_SET|GMSH_GUI, $1, 0, $5, $7); ColorOption(GMSH_SET|GMSH_GUI, $1, 0, $5, $7);
Free($1); Free($5); Free($1); Free($5);
} }
| tSTRING '[' FExpr ']' '.' tColor '.' tSTRING tAFFECT ColorExpr tEND | tSTRING '[' FExpr ']' '.' tColor '.' tSTRING tAFFECT ColorExpr tEND
{ {
ColorOption(GMSH_SET|GMSH_GUI, $1, (int)$3, $8, $10); ColorOption(GMSH_SET|GMSH_GUI, $1, (int)$3, $8, $10);
...@@ -1216,6 +1226,7 @@ Affectation : ...@@ -1216,6 +1226,7 @@ Affectation :
Free($1); Free($1);
List_Delete($5); List_Delete($5);
} }
| tSTRING '[' FExpr ']' '.' tColorTable tAFFECT ListOfColor tEND | tSTRING '[' FExpr ']' '.' tColorTable tAFFECT ListOfColor tEND
{ {
GmshColorTable *ct = GetColorTable((int)$3); GmshColorTable *ct = GetColorTable((int)$3);
...@@ -5179,6 +5190,8 @@ FExpr_Single : ...@@ -5179,6 +5190,8 @@ FExpr_Single :
Msg::ExchangeOnelabParameter("", val, floatOptions, charOptions); Msg::ExchangeOnelabParameter("", val, floatOptions, charOptions);
$$ = val[0]; $$ = val[0];
} }
| DefineStruct
{ $$ = $1; }
| tGetNumber LP StringExprVar RP | tGetNumber LP StringExprVar RP
{ {
$$ = Msg::GetOnelabNumber($3); $$ = Msg::GetOnelabNumber($3);
...@@ -5191,11 +5204,7 @@ FExpr_Single : ...@@ -5191,11 +5204,7 @@ FExpr_Single :
} }
| String__Index | String__Index
{ {
if(!gmsh_yysymbols.count($1)){ if(gmsh_yysymbols.count($1)){
yymsg(0, "Unknown variable '%s'", $1);
$$ = 0.;
}
else{
gmsh_yysymbol &s(gmsh_yysymbols[$1]); gmsh_yysymbol &s(gmsh_yysymbols[$1]);
if(s.value.empty()){ if(s.value.empty()){
yymsg(0, "Uninitialized variable '%s'", $1); yymsg(0, "Uninitialized variable '%s'", $1);
...@@ -5204,6 +5213,16 @@ FExpr_Single : ...@@ -5204,6 +5213,16 @@ FExpr_Single :
else else
$$ = s.value[0]; $$ = s.value[0];
} }
else{
std::string key($1);
if(StructTable_M.count(key)) {
$$ = (double)StructTable_M[key]._value;
}
else {
yymsg(0, "Unknown variable '%s'", $1);
$$ = 0.;
}
}
Free($1); Free($1);
} }
| tSTRING '[' FExpr ']' | tSTRING '[' FExpr ']'
...@@ -5405,18 +5424,38 @@ FExpr_Single : ...@@ -5405,18 +5424,38 @@ FExpr_Single :
} }
// Option Strings // Option Strings
/*
| tSTRING '.' tSTRING | tSTRING '.' tSTRING
{ {
NumberOption(GMSH_GET, $1, 0, $3, $$); NumberOption(GMSH_GET, $1, 0, $3, $$);
Free($1); Free($3); Free($1); Free($3);
} }
*/
//+++extention to structures
| String__Index '.' tSTRING_Member_Float
{
std::string key($1);
if(StructTable_M.count(key)) {
std::string key2($3);
if(StructTable_M[key]._fopt.count(key2)) {
$$ = StructTable_M[key]._fopt[key2][0];
}
else {
yymsg(0, "Unknown member '%s' of Struct %s", $3, $1); $$ = 0.;
}
}
else {
NumberOption(GMSH_GET, $1, 0, $3, $$);
}
Free($1);
if (flag_tSTRING_alloc) Free($3);
}
| tSTRING '[' FExpr ']' '.' tSTRING | tSTRING '[' FExpr ']' '.' tSTRING
{ {
NumberOption(GMSH_GET, $1, (int)$3, $6, $$); NumberOption(GMSH_GET, $1, (int)$3, $6, $$);
Free($1); Free($6); Free($1); Free($6);
} }
| tSTRING '.' tSTRING NumericIncrement | String__Index '.' tSTRING_Member_Float NumericIncrement
{ {
double d = 0.; double d = 0.;
if(NumberOption(GMSH_GET, $1, 0, $3, d)){ if(NumberOption(GMSH_GET, $1, 0, $3, d)){
...@@ -5497,6 +5536,47 @@ FExpr_Single : ...@@ -5497,6 +5536,47 @@ FExpr_Single :
} }
; ;
//+++
DefineStruct :
tDefineStruct Struct_FullName
{ floatOptions.clear(); charOptions.clear(); }
Option_SaveStructNameInConstant
'[' FExpr FloatParameterOptions ']'
{
std::string key(Struct_Name);
StructTable_M[key] = Struct((int)$6, 1, floatOptions, charOptions);
$$ = $6;
Free(Struct_Name);
}
;
Struct_FullName :
String__Index
{ Struct_NameSpace = NULL; Struct_Name = $1; }
| String__Index tDOTS tDOTS String__Index
{ Struct_NameSpace = $1; Struct_Name = $4; }
;
tSTRING_Member_Float :
tSTRING
{ $$ = $1; flag_tSTRING_alloc = 1; }
/*
| tType
{ $$ = (char*)"Type"; flag_tSTRING_alloc = 0; }
*/
;
Option_SaveStructNameInConstant :
// None
| '{' String__Index '}'
{
std::string key($2), val(Struct_Name);
gmsh_yystringsymbols[key] = std::vector<std::string>(1, val);
Free($2);
}
;
VExpr : VExpr :
VExpr_Single VExpr_Single
{ {
...@@ -6237,14 +6317,29 @@ StringExprVar : ...@@ -6237,14 +6317,29 @@ StringExprVar :
strcpy($$, val.c_str()); strcpy($$, val.c_str());
Free($1); Free($1);
} }
| tSTRING '.' tSTRING
| String__Index '.' tSTRING_Member_Float
{ {
std::string out; std::string out;
std::string key($1);
if(StructTable_M.count(key)) {
std::string key2($3);
if(StructTable_M[key]._copt.count(key2)) {
out = StructTable_M[key]._copt[key2][0];
}
else {
yymsg(0, "Unknown member '%s' of Struct %s", $3, $1);
}
}
else {
StringOption(GMSH_GET, $1, 0, $3, out); StringOption(GMSH_GET, $1, 0, $3, out);
}
$$ = (char*)Malloc((out.size() + 1) * sizeof(char)); $$ = (char*)Malloc((out.size() + 1) * sizeof(char));
strcpy($$, out.c_str()); strcpy($$, out.c_str());
Free($1); Free($3); Free($1);
if (flag_tSTRING_alloc) Free($3);
} }
| tSTRING '[' FExpr ']' '.' tSTRING | tSTRING '[' FExpr ']' '.' tSTRING
{ {
std::string out; std::string out;
...@@ -6501,8 +6596,28 @@ StringExpr : ...@@ -6501,8 +6596,28 @@ StringExpr :
strcpy($$, val.c_str()); strcpy($$, val.c_str());
Free($3); Free($3);
} }
| tNameStruct LP NameStruct_Arg RP
{
std::string out;
int val = (int)$3;
std::map<std::string, Struct>::iterator it;
for (it = StructTable_M.begin(); it != StructTable_M.end(); ++it )
if (it->second._value == val) out = it->first;
$$ = (char*)Malloc((out.size() + 1) * sizeof(char));
strcpy($$, out.c_str());
}
; ;
NameStruct_Arg :
'#' FExpr
{ Struct_NameSpace = NULL; $$ = $2; }
| String__Index tDOTS tDOTS '#' FExpr
{ Struct_NameSpace = $1; $$ = $5; }
;
RecursiveListOfStringExprVar : RecursiveListOfStringExprVar :
StringExprVar StringExprVar
{ {
......
This diff is collapsed.
...@@ -28,6 +28,22 @@ class Shape{ ...@@ -28,6 +28,22 @@ class Shape{
int Num; int Num;
}; };
class Struct {
public:
Struct() {}
Struct(int value, int type,
std::map<std::string, std::vector<double> > fopt,
std::map<std::string, std::vector<std::string> > copt) :
_value(value), _type(type), _fopt(fopt), _copt(copt) {}
~Struct() {}
public:
int _value;
int _type;
std::map<std::string, std::vector<double> > _fopt;
std::map<std::string, std::vector<std::string> > _copt;
};
// global parser variables that need to be exported // global parser variables that need to be exported
extern gmshFILE gmsh_yyin; extern gmshFILE gmsh_yyin;
extern int gmsh_yylineno; extern int gmsh_yylineno;
......
...@@ -6,6 +6,7 @@ Mesh.CharacteristicLengthMax = 0.1; ...@@ -6,6 +6,7 @@ Mesh.CharacteristicLengthMax = 0.1;
// 3D // 3D
x = 0; y = 0; x = 0; y = 0;
xxx=0; Printf("xxx++ = %g, %g", xxx++, xxx);
Sphere(newv) = {x++,y,0, 0.3}; Sphere(newv) = {x++,y,0, 0.3};
Sphere(newv) = {x++,y,0, 0.3, Pi/3}; Sphere(newv) = {x++,y,0, 0.3, Pi/3};
Cylinder(newv) = {x++,y,0, x-0.5,y,0, 0.5}; Cylinder(newv) = {x++,y,0, x-0.5,y,0, 0.5};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment