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

(1) If and EndIf now allowed in comments and variable names (with alpha-char...

(1) If and EndIf now allowed in comments and variable names (with alpha-char before or after); (2) Else now possible in If EndIf; (3) Warning if orphan EndIf.
parent 42ea7309
No related branches found
No related tags found
No related merge requests found
...@@ -155,6 +155,7 @@ SetChanged return tSetChanged; ...@@ -155,6 +155,7 @@ SetChanged return tSetChanged;
Exp return tExp; Exp return tExp;
Ellipsis return tEllipse; Ellipsis return tEllipse;
Ellipse return tEllipse; Ellipse return tEllipse;
Else return tElse;
Extrude return tExtrude; Extrude return tExtrude;
Elliptic return tElliptic; Elliptic return tElliptic;
EndFor return tEndFor; EndFor return tEndFor;
...@@ -275,6 +276,7 @@ SyncModel return tSyncModel; ...@@ -275,6 +276,7 @@ SyncModel return tSyncModel;
T2 return tText2D; T2 return tText2D;
T3 return tText3D; T3 return tText3D;
TestLevel return tTestLevel;
TextAttributes return tTextAttributes; TextAttributes return tTextAttributes;
TIME return tTime; TIME return tTime;
Transfinite return tTransfinite; Transfinite return tTransfinite;
...@@ -363,20 +365,89 @@ void skipline() ...@@ -363,20 +365,89 @@ void skipline()
} }
} }
bool is_alpha(const int c)
{
return (c>='a' && c<='z') || (c>='A' && c<='Z') || c=='_';
}
void skip_until(const char *skip, const char *until) void skip_until(const char *skip, const char *until)
{ {
int i, nb_skip; int i, nb_skip = 0;
int l, l_skip, l_until; int l, l_skip, l_until;
char chars[256]; char chars[256];
int c_next, c_next_skip, c_next_until, c_previous = 0;
nb_skip = 0; l_skip = (skip)? strlen(skip) : 0;
l_until = strlen(until);
if(skip) while(1){
l_skip = strlen(skip); while (1){
else chars[0] = yyinput();
l_skip = 0; if(gmsheof(yyin)){
Msg::Error("Unexpected end of file");
return;
}
if(chars[0] == '/'){
c_next = yyinput();
if (c_next == '*') skipcomments();
else if(c_next == '/') skipline();
else unput(c_next);
}
if(!c_previous || !is_alpha(c_previous)){
if(chars[0] == until[0]) break;
if(skip && chars[0] == skip[0]) break;
}
c_previous = chars[0];
}
l = std::max(l_skip,l_until);
if(l >= (int)sizeof(chars)){
Msg::Error("Search pattern too long in skip_until");
return;
}
for(i=1; i<l; i++){
chars[i] = yyinput();
if(gmsheof(yyin)){
l = i;
break;
}
}
c_next = yyinput(); unput(c_next);
c_next_skip = (l_skip<l)? chars[l_skip] : c_next;
c_next_until = (l_until<l)? chars[l_until] : c_next;
if(!strncmp(chars,until,l_until) && !is_alpha(c_next_until)){
if(!nb_skip){
return;
}
else{
nb_skip--;
}
}
else if(skip && !strncmp(chars,skip,l_skip) && !is_alpha(c_next_skip)){
nb_skip++;
}
else{
for(i=1;i<l-1;i++){
unput(chars[l-i]);
}
}
}
}
void skip_until_test(const char *skip, const char *until, const char *until2, int *flag_until2)
{
int i, nb_skip = 0;
int l, l_skip, l_until, l_until2;
char chars[256];
int c_next, c_next_skip, c_next_until, c_next_until2, c_previous = 0;
l_skip = (skip)? strlen(skip) : 0;
l_until = strlen(until); l_until = strlen(until);
l_until2 = (until2)? strlen(until2) : 0;
while(1){ while(1){
while (1){ while (1){
...@@ -385,11 +456,22 @@ void skip_until(const char *skip, const char *until) ...@@ -385,11 +456,22 @@ void skip_until(const char *skip, const char *until)
Msg::Error("Unexpected end of file"); Msg::Error("Unexpected end of file");
return; return;
} }
if(chars[0] == until[0]) break; if(chars[0] == '/'){
if(skip && chars[0] == skip[0]) break; c_next = yyinput();
if (c_next == '*') skipcomments();
else if(c_next == '/') skipline();
else unput(c_next);
}
if(!c_previous || !is_alpha(c_previous)){
if(chars[0] == until[0]) break;
if(skip && chars[0] == skip[0]) break;
if(until2 && chars[0] == until2[0]) break;
}
c_previous = chars[0];
} }
l = std::max(l_skip,l_until); l = std::max(l_skip,l_until);
l = std::max(l,l_until2);
if(l >= (int)sizeof(chars)){ if(l >= (int)sizeof(chars)){
Msg::Error("Search pattern too long in skip_until"); Msg::Error("Search pattern too long in skip_until");
return; return;
...@@ -402,7 +484,18 @@ void skip_until(const char *skip, const char *until) ...@@ -402,7 +484,18 @@ void skip_until(const char *skip, const char *until)
} }
} }
if(!strncmp(chars,until,l_until)){ c_next = yyinput(); unput(c_next);
c_next_skip = (l_skip<l)? chars[l_skip] : c_next;
c_next_until = (l_until<l)? chars[l_until] : c_next;
c_next_until2 = (l_until2<l)? chars[l_until2] : c_next;
if(!strncmp(chars,until2,l_until2) && !is_alpha(c_next_until2)){
if(!nb_skip){
*flag_until2 = 1;
return;
}
}
else if(!strncmp(chars,until,l_until) && !is_alpha(c_next_until)){
if(!nb_skip){ if(!nb_skip){
return; return;
} }
...@@ -410,7 +503,7 @@ void skip_until(const char *skip, const char *until) ...@@ -410,7 +503,7 @@ void skip_until(const char *skip, const char *until)
nb_skip--; nb_skip--;
} }
} }
else if(skip && !strncmp(chars,skip,l_skip)){ else if(skip && !strncmp(chars,skip,l_skip) && !is_alpha(c_next_skip)){
nb_skip++; nb_skip++;
} }
else{ else{
......
This diff is collapsed.
/* A Bison parser, made by GNU Bison 3.0.4. */ /* A Bison parser, made by GNU Bison 2.3. */
/* Bison interface for Yacc-like parsers in C /* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation; either version 2, or (at your option)
(at your option) any later version. any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -15,7 +16,9 @@ ...@@ -15,7 +16,9 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains /* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work part or all of the Bison parser skeleton and distribute that work
...@@ -30,212 +33,389 @@ ...@@ -30,212 +33,389 @@
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
#ifndef YY_GMSH_YY_GMSH_TAB_HPP_INCLUDED /* Tokens. */
# define YY_GMSH_YY_GMSH_TAB_HPP_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int gmsh_yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
enum yytokentype /* Put the tokens into the symbol table, so that GDB and other debuggers
{ know about them. */
tDOUBLE = 258, enum yytokentype {
tSTRING = 259, tDOUBLE = 258,
tBIGSTR = 260, tSTRING = 259,
tEND = 261, tBIGSTR = 260,
tAFFECT = 262, tEND = 261,
tDOTS = 263, tAFFECT = 262,
tPi = 264, tDOTS = 263,
tMPI_Rank = 265, tPi = 264,
tMPI_Size = 266, tMPI_Rank = 265,
tEuclidian = 267, tMPI_Size = 266,
tCoordinates = 268, tEuclidian = 267,
tExp = 269, tCoordinates = 268,
tLog = 270, tTestLevel = 269,
tLog10 = 271, tExp = 270,
tSqrt = 272, tLog = 271,
tSin = 273, tLog10 = 272,
tAsin = 274, tSqrt = 273,
tCos = 275, tSin = 274,
tAcos = 276, tAsin = 275,
tTan = 277, tCos = 276,
tRand = 278, tAcos = 277,
tAtan = 279, tTan = 278,
tAtan2 = 280, tRand = 279,
tSinh = 281, tAtan = 280,
tCosh = 282, tAtan2 = 281,
tTanh = 283, tSinh = 282,
tFabs = 284, tCosh = 283,
tFloor = 285, tTanh = 284,
tCeil = 286, tFabs = 285,
tRound = 287, tFloor = 286,
tFmod = 288, tCeil = 287,
tModulo = 289, tRound = 288,
tHypot = 290, tFmod = 289,
tList = 291, tModulo = 290,
tPrintf = 292, tHypot = 291,
tError = 293, tList = 292,
tStr = 294, tPrintf = 293,
tSprintf = 295, tError = 294,
tStrCat = 296, tStr = 295,
tStrPrefix = 297, tSprintf = 296,
tStrRelative = 298, tStrCat = 297,
tStrReplace = 299, tStrPrefix = 298,
tFind = 300, tStrRelative = 299,
tStrFind = 301, tStrReplace = 300,
tStrCmp = 302, tFind = 301,
tStrChoice = 303, tStrFind = 302,
tUpperCase = 304, tStrCmp = 303,
tLowerCase = 305, tStrChoice = 304,
tLowerCaseIn = 306, tUpperCase = 305,
tTextAttributes = 307, tLowerCase = 306,
tBoundingBox = 308, tLowerCaseIn = 307,
tDraw = 309, tTextAttributes = 308,
tSetChanged = 310, tBoundingBox = 309,
tToday = 311, tDraw = 310,
tFixRelativePath = 312, tSetChanged = 311,
tCurrentDirectory = 313, tToday = 312,
tSyncModel = 314, tFixRelativePath = 313,
tNewModel = 315, tCurrentDirectory = 314,
tOnelabAction = 316, tSyncModel = 315,
tOnelabRun = 317, tNewModel = 316,
tCpu = 318, tOnelabAction = 317,
tMemory = 319, tOnelabRun = 318,
tTotalMemory = 320, tCpu = 319,
tCreateTopology = 321, tMemory = 320,
tCreateTopologyNoHoles = 322, tTotalMemory = 321,
tDistanceFunction = 323, tCreateTopology = 322,
tDefineConstant = 324, tCreateTopologyNoHoles = 323,
tUndefineConstant = 325, tDistanceFunction = 324,
tDefineNumber = 326, tDefineConstant = 325,
tDefineString = 327, tUndefineConstant = 326,
tSetNumber = 328, tDefineNumber = 327,
tSetString = 329, tDefineString = 328,
tPoint = 330, tSetNumber = 329,
tCircle = 331, tSetString = 330,
tEllipse = 332, tPoint = 331,
tLine = 333, tCircle = 332,
tSphere = 334, tEllipse = 333,
tPolarSphere = 335, tLine = 334,
tSurface = 336, tSphere = 335,
tSpline = 337, tPolarSphere = 336,
tVolume = 338, tSurface = 337,
tCharacteristic = 339, tSpline = 338,
tLength = 340, tVolume = 339,
tParametric = 341, tCharacteristic = 340,
tElliptic = 342, tLength = 341,
tRefineMesh = 343, tParametric = 342,
tAdaptMesh = 344, tElliptic = 343,
tRelocateMesh = 345, tRefineMesh = 344,
tPlane = 346, tAdaptMesh = 345,
tRuled = 347, tRelocateMesh = 346,
tTransfinite = 348, tPlane = 347,
tComplex = 349, tRuled = 348,
tPhysical = 350, tTransfinite = 349,
tCompound = 351, tComplex = 350,
tPeriodic = 352, tPhysical = 351,
tUsing = 353, tCompound = 352,
tPlugin = 354, tPeriodic = 353,
tDegenerated = 355, tUsing = 354,
tRecursive = 356, tPlugin = 355,
tRotate = 357, tDegenerated = 356,
tTranslate = 358, tRecursive = 357,
tSymmetry = 359, tRotate = 358,
tDilate = 360, tTranslate = 359,
tExtrude = 361, tSymmetry = 360,
tLevelset = 362, tDilate = 361,
tAffine = 363, tExtrude = 362,
tRecombine = 364, tLevelset = 363,
tSmoother = 365, tAffine = 364,
tSplit = 366, tRecombine = 365,
tDelete = 367, tSmoother = 366,
tCoherence = 368, tSplit = 367,
tIntersect = 369, tDelete = 368,
tMeshAlgorithm = 370, tCoherence = 369,
tReverse = 371, tIntersect = 370,
tLayers = 372, tMeshAlgorithm = 371,
tScaleLast = 373, tReverse = 372,
tHole = 374, tLayers = 373,
tAlias = 375, tScaleLast = 374,
tAliasWithOptions = 376, tHole = 375,
tCopyOptions = 377, tAlias = 376,
tQuadTriAddVerts = 378, tAliasWithOptions = 377,
tQuadTriNoNewVerts = 379, tCopyOptions = 378,
tQuadTriSngl = 380, tQuadTriAddVerts = 379,
tQuadTriDbl = 381, tQuadTriNoNewVerts = 380,
tRecombLaterals = 382, tQuadTriSngl = 381,
tTransfQuadTri = 383, tQuadTriDbl = 382,
tText2D = 384, tRecombLaterals = 383,
tText3D = 385, tTransfQuadTri = 384,
tInterpolationScheme = 386, tText2D = 385,
tTime = 387, tText3D = 386,
tCombine = 388, tInterpolationScheme = 387,
tBSpline = 389, tTime = 388,
tBezier = 390, tCombine = 389,
tNurbs = 391, tBSpline = 390,
tNurbsOrder = 392, tBezier = 391,
tNurbsKnots = 393, tNurbs = 392,
tColor = 394, tNurbsOrder = 393,
tColorTable = 395, tNurbsKnots = 394,
tFor = 396, tColor = 395,
tIn = 397, tColorTable = 396,
tEndFor = 398, tFor = 397,
tIf = 399, tIn = 398,
tEndIf = 400, tEndFor = 399,
tExit = 401, tIf = 400,
tAbort = 402, tElse = 401,
tField = 403, tEndIf = 402,
tReturn = 404, tExit = 403,
tCall = 405, tAbort = 404,
tMacro = 406, tField = 405,
tShow = 407, tReturn = 406,
tHide = 408, tCall = 407,
tGetValue = 409, tMacro = 408,
tGetEnv = 410, tShow = 409,
tGetString = 411, tHide = 410,
tGetNumber = 412, tGetValue = 411,
tHomology = 413, tGetEnv = 412,
tCohomology = 414, tGetString = 413,
tBetti = 415, tGetNumber = 414,
tSetOrder = 416, tHomology = 415,
tExists = 417, tCohomology = 416,
tFileExists = 418, tBetti = 417,
tGMSH_MAJOR_VERSION = 419, tSetOrder = 418,
tGMSH_MINOR_VERSION = 420, tExists = 419,
tGMSH_PATCH_VERSION = 421, tFileExists = 420,
tGmshExecutableName = 422, tGMSH_MAJOR_VERSION = 421,
tSetPartition = 423, tGMSH_MINOR_VERSION = 422,
tNameFromString = 424, tGMSH_PATCH_VERSION = 423,
tStringFromName = 425, tGmshExecutableName = 424,
tAFFECTPLUS = 426, tSetPartition = 425,
tAFFECTMINUS = 427, tNameFromString = 426,
tAFFECTTIMES = 428, tStringFromName = 427,
tAFFECTDIVIDE = 429, tAFFECTDIVIDE = 428,
tOR = 430, tAFFECTTIMES = 429,
tAND = 431, tAFFECTMINUS = 430,
tEQUAL = 432, tAFFECTPLUS = 431,
tNOTEQUAL = 433, tOR = 432,
tLESSOREQUAL = 434, tAND = 433,
tGREATEROREQUAL = 435, tNOTEQUAL = 434,
tPLUSPLUS = 436, tEQUAL = 435,
tMINUSMINUS = 437, tGREATEROREQUAL = 436,
UNARYPREC = 438 tLESSOREQUAL = 437,
}; UNARYPREC = 438,
tMINUSMINUS = 439,
tPLUSPLUS = 440
};
#endif #endif
/* Tokens. */
#define tDOUBLE 258
#define tSTRING 259
#define tBIGSTR 260
#define tEND 261
#define tAFFECT 262
#define tDOTS 263
#define tPi 264
#define tMPI_Rank 265
#define tMPI_Size 266
#define tEuclidian 267
#define tCoordinates 268
#define tTestLevel 269
#define tExp 270
#define tLog 271
#define tLog10 272
#define tSqrt 273
#define tSin 274
#define tAsin 275
#define tCos 276
#define tAcos 277
#define tTan 278
#define tRand 279
#define tAtan 280
#define tAtan2 281
#define tSinh 282
#define tCosh 283
#define tTanh 284
#define tFabs 285
#define tFloor 286
#define tCeil 287
#define tRound 288
#define tFmod 289
#define tModulo 290
#define tHypot 291
#define tList 292
#define tPrintf 293
#define tError 294
#define tStr 295
#define tSprintf 296
#define tStrCat 297
#define tStrPrefix 298
#define tStrRelative 299
#define tStrReplace 300
#define tFind 301
#define tStrFind 302
#define tStrCmp 303
#define tStrChoice 304
#define tUpperCase 305
#define tLowerCase 306
#define tLowerCaseIn 307
#define tTextAttributes 308
#define tBoundingBox 309
#define tDraw 310
#define tSetChanged 311
#define tToday 312
#define tFixRelativePath 313
#define tCurrentDirectory 314
#define tSyncModel 315
#define tNewModel 316
#define tOnelabAction 317
#define tOnelabRun 318
#define tCpu 319
#define tMemory 320
#define tTotalMemory 321
#define tCreateTopology 322
#define tCreateTopologyNoHoles 323
#define tDistanceFunction 324
#define tDefineConstant 325
#define tUndefineConstant 326
#define tDefineNumber 327
#define tDefineString 328
#define tSetNumber 329
#define tSetString 330
#define tPoint 331
#define tCircle 332
#define tEllipse 333
#define tLine 334
#define tSphere 335
#define tPolarSphere 336
#define tSurface 337
#define tSpline 338
#define tVolume 339
#define tCharacteristic 340
#define tLength 341
#define tParametric 342
#define tElliptic 343
#define tRefineMesh 344
#define tAdaptMesh 345
#define tRelocateMesh 346
#define tPlane 347
#define tRuled 348
#define tTransfinite 349
#define tComplex 350
#define tPhysical 351
#define tCompound 352
#define tPeriodic 353
#define tUsing 354
#define tPlugin 355
#define tDegenerated 356
#define tRecursive 357
#define tRotate 358
#define tTranslate 359
#define tSymmetry 360
#define tDilate 361
#define tExtrude 362
#define tLevelset 363
#define tAffine 364
#define tRecombine 365
#define tSmoother 366
#define tSplit 367
#define tDelete 368
#define tCoherence 369
#define tIntersect 370
#define tMeshAlgorithm 371
#define tReverse 372
#define tLayers 373
#define tScaleLast 374
#define tHole 375
#define tAlias 376
#define tAliasWithOptions 377
#define tCopyOptions 378
#define tQuadTriAddVerts 379
#define tQuadTriNoNewVerts 380
#define tQuadTriSngl 381
#define tQuadTriDbl 382
#define tRecombLaterals 383
#define tTransfQuadTri 384
#define tText2D 385
#define tText3D 386
#define tInterpolationScheme 387
#define tTime 388
#define tCombine 389
#define tBSpline 390
#define tBezier 391
#define tNurbs 392
#define tNurbsOrder 393
#define tNurbsKnots 394
#define tColor 395
#define tColorTable 396
#define tFor 397
#define tIn 398
#define tEndFor 399
#define tIf 400
#define tElse 401
#define tEndIf 402
#define tExit 403
#define tAbort 404
#define tField 405
#define tReturn 406
#define tCall 407
#define tMacro 408
#define tShow 409
#define tHide 410
#define tGetValue 411
#define tGetEnv 412
#define tGetString 413
#define tGetNumber 414
#define tHomology 415
#define tCohomology 416
#define tBetti 417
#define tSetOrder 418
#define tExists 419
#define tFileExists 420
#define tGMSH_MAJOR_VERSION 421
#define tGMSH_MINOR_VERSION 422
#define tGMSH_PATCH_VERSION 423
#define tGmshExecutableName 424
#define tSetPartition 425
#define tNameFromString 426
#define tStringFromName 427
#define tAFFECTDIVIDE 428
#define tAFFECTTIMES 429
#define tAFFECTMINUS 430
#define tAFFECTPLUS 431
#define tOR 432
#define tAND 433
#define tNOTEQUAL 434
#define tEQUAL 435
#define tGREATEROREQUAL 436
#define tLESSOREQUAL 437
#define UNARYPREC 438
#define tMINUSMINUS 439
#define tPLUSPLUS 440
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 105 "Gmsh.y" /* yacc.c:1909 */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 109 "Gmsh.y"
{
char *c; char *c;
int i; int i;
unsigned int u; unsigned int u;
...@@ -243,18 +423,14 @@ union YYSTYPE ...@@ -243,18 +423,14 @@ union YYSTYPE
double v[5]; double v[5];
Shape s; Shape s;
List_T *l; List_T *l;
}
#line 248 "Gmsh.tab.hpp" /* yacc.c:1909 */ /* Line 1529 of yacc.c. */
}; #line 429 "Gmsh.tab.hpp"
YYSTYPE;
typedef union YYSTYPE YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif #endif
extern YYSTYPE gmsh_yylval; extern YYSTYPE gmsh_yylval;
int gmsh_yyparse (void);
#endif /* !YY_GMSH_YY_GMSH_TAB_HPP_INCLUDED */
...@@ -69,8 +69,10 @@ static std::vector<double> *ViewValueList = 0; ...@@ -69,8 +69,10 @@ static std::vector<double> *ViewValueList = 0;
static int *ViewNumList = 0; static int *ViewNumList = 0;
static ExtrudeParams extr; static ExtrudeParams extr;
static gmshSurface *myGmshSurface = 0; static gmshSurface *myGmshSurface = 0;
#define MAX_RECUR_TESTS 100
static int statusImbricatedTests[MAX_RECUR_TESTS];
#define MAX_RECUR_LOOPS 100 #define MAX_RECUR_LOOPS 100
static int ImbricatedLoop = 0; static int ImbricatedLoop = 0, ImbricatedTest = 0;
static gmshfpos_t yyposImbricatedLoopsTab[MAX_RECUR_LOOPS]; static gmshfpos_t yyposImbricatedLoopsTab[MAX_RECUR_LOOPS];
static int yylinenoImbricatedLoopsTab[MAX_RECUR_LOOPS]; static int yylinenoImbricatedLoopsTab[MAX_RECUR_LOOPS];
static double LoopControlVariablesTab[MAX_RECUR_LOOPS][3]; static double LoopControlVariablesTab[MAX_RECUR_LOOPS][3];
...@@ -80,7 +82,9 @@ static std::map<std::string, std::vector<std::string> > charOptions; ...@@ -80,7 +82,9 @@ static std::map<std::string, std::vector<std::string> > charOptions;
void yyerror(const char *s); void yyerror(const char *s);
void yymsg(int level, const char *fmt, ...); void yymsg(int level, const char *fmt, ...);
bool is_alpha(const int c);
void skip_until(const char *skip, const char *until); void skip_until(const char *skip, const char *until);
void skip_until_test(const char *skip, const char *until, const char *until2, int *flag_until2);
void assignVariable(const std::string &name, int index, int assignType, void assignVariable(const std::string &name, int index, int assignType,
double value); double value);
void assignVariables(const std::string &name, List_T *indices, int assignType, void assignVariables(const std::string &name, List_T *indices, int assignType,
...@@ -115,7 +119,7 @@ struct doubleXstring{ ...@@ -115,7 +119,7 @@ struct doubleXstring{
%token <d> tDOUBLE %token <d> tDOUBLE
%token <c> tSTRING tBIGSTR %token <c> tSTRING tBIGSTR
%token tEND tAFFECT tDOTS tPi tMPI_Rank tMPI_Size tEuclidian tCoordinates %token tEND tAFFECT tDOTS tPi tMPI_Rank tMPI_Size tEuclidian tCoordinates tTestLevel
%token tExp tLog tLog10 tSqrt tSin tAsin tCos tAcos tTan tRand %token tExp tLog tLog10 tSqrt tSin tAsin tCos tAcos tTan tRand
%token tAtan tAtan2 tSinh tCosh tTanh tFabs tFloor tCeil tRound %token tAtan tAtan2 tSinh tCosh tTanh tFabs tFloor tCeil tRound
%token tFmod tModulo tHypot tList %token tFmod tModulo tHypot tList
...@@ -142,7 +146,7 @@ struct doubleXstring{ ...@@ -142,7 +146,7 @@ struct doubleXstring{
%token tRecombLaterals tTransfQuadTri %token tRecombLaterals tTransfQuadTri
%token tText2D tText3D tInterpolationScheme tTime tCombine %token tText2D tText3D tInterpolationScheme tTime tCombine
%token tBSpline tBezier tNurbs tNurbsOrder tNurbsKnots %token tBSpline tBezier tNurbs tNurbsOrder tNurbsKnots
%token tColor tColorTable tFor tIn tEndFor tIf tEndIf tExit tAbort %token tColor tColorTable tFor tIn tEndFor tIf tElse tEndIf tExit tAbort
%token tField tReturn tCall tMacro tShow tHide tGetValue tGetEnv tGetString tGetNumber %token tField tReturn tCall tMacro tShow tHide tGetValue tGetEnv tGetString tGetNumber
%token tHomology tCohomology tBetti tSetOrder tExists tFileExists %token tHomology tCohomology tBetti tSetOrder tExists tFileExists
%token tGMSH_MAJOR_VERSION tGMSH_MINOR_VERSION tGMSH_PATCH_VERSION %token tGMSH_MAJOR_VERSION tGMSH_MINOR_VERSION tGMSH_PATCH_VERSION
...@@ -3230,10 +3234,36 @@ Loop : ...@@ -3230,10 +3234,36 @@ Loop :
} }
| tIf '(' FExpr ')' | tIf '(' FExpr ')'
{ {
if(!$3) skip_until("If", "EndIf"); ImbricatedTest++;
if(ImbricatedTest > MAX_RECUR_TESTS-1){
yymsg(0, "Reached maximum number of imbricated tests");
ImbricatedTest = MAX_RECUR_TESTS-1;
}
if(!$3){
statusImbricatedTests[ImbricatedTest] = 0; // Will be useful later for ElseIf
int flag_until2 = 0;
skip_until_test("If", "EndIf", "Else", &flag_until2);
if(!flag_until2)
ImbricatedTest--;
}
else{
statusImbricatedTests[ImbricatedTest] = 1;
}
}
| tElse
{
if (ImbricatedTest > 0 && statusImbricatedTests[ImbricatedTest]){
skip_until("If", "EndIf");
ImbricatedTest--;
}
} }
| tEndIf | tEndIf
{ {
ImbricatedTest--;
if (ImbricatedTest < 0)
yymsg(1, "Orphan EndIf");
} }
; ;
...@@ -4659,6 +4689,7 @@ FExpr_Single : ...@@ -4659,6 +4689,7 @@ FExpr_Single :
tDOUBLE { $$ = $1; } tDOUBLE { $$ = $1; }
| tPi { $$ = 3.141592653589793; } | tPi { $$ = 3.141592653589793; }
| tTestLevel { $$ = (double)ImbricatedTest; }
| tMPI_Rank { $$ = Msg::GetCommRank(); } | tMPI_Rank { $$ = Msg::GetCommRank(); }
| tMPI_Size { $$ = Msg::GetCommSize(); } | tMPI_Size { $$ = Msg::GetCommSize(); }
| tGMSH_MAJOR_VERSION { $$ = GetGmshMajorVersion(); } | tGMSH_MAJOR_VERSION { $$ = GetGmshMajorVersion(); }
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment