Skip to content
Snippets Groups Projects
Commit 4cd92eab authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

Functions are added in the Parser

parent 7d07cc81
No related branches found
No related tags found
No related merge requests found
# $Id: Makefile,v 1.13 2000-12-06 22:25:24 geuzaine Exp $ # $Id: Makefile,v 1.14 2000-12-07 16:03:43 remacle Exp $
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Makefile for Gmsh # Makefile for Gmsh
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
MESA_STATIC_LIB = $(HOME)/SOURCES/Mesa-3.0-static/lib/libGLw.a\ MESA_STATIC_LIB = $(HOME)/SOURCES/Mesa-3.0-static/lib/libGLw.a\
$(HOME)/SOURCES/Mesa-3.0-static/lib/libGLU.a\ $(HOME)/SOURCES/Mesa-3.0-static/lib/libGLU.a\
$(HOME)/SOURCES/Mesa-3.0-static/lib/libGL.a $(HOME)/SOURCES/Mesa-3.0-static/lib/libGL.a
// MOTIF_LIB = /usr/local/lib/libXm.so.2 MOTIF_LIB = /usr/local/lib/libXm.so.2
MOTIF_LIB = -L/usr/local/lib -L/usr/X11R6/LessTif/Motif1.2/lib -lXm // MOTIF_LIB = -L/usr/local/lib -L/usr/X11R6/LessTif/Motif1.2/lib -lXm
X_LIB = -L/usr/X11R6/lib -lXt -lX11 -lXext X_LIB = -L/usr/X11R6/lib -lXt -lX11 -lXext
THREAD_LIB = -L/usr/lib -lpthread THREAD_LIB = -L/usr/lib -lpthread
......
%{ /* $Id: Gmsh.l,v 1.13 2000-12-07 09:21:33 geuzaine Exp $ */ %{ /* $Id: Gmsh.l,v 1.14 2000-12-07 16:03:43 remacle Exp $ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -182,9 +182,11 @@ With return tWith; ...@@ -182,9 +182,11 @@ With return tWith;
For return tFor; For return tFor;
EndFor return tEndFor; EndFor return tEndFor;
Script return tScript;
Exit return tExit; Exit return tExit;
Merge return tMerge; Merge return tMerge;
Function return tFunction;
Return return tReturn;
Call return tCall;
SS return tScalarTetrahedron; SS return tScalarTetrahedron;
VS return tVectorTetrahedron; VS return tVectorTetrahedron;
...@@ -309,3 +311,42 @@ void skipline(void) ...@@ -309,3 +311,42 @@ void skipline(void)
while (yyinput() != '\n') ; while (yyinput() != '\n') ;
} }
void skip_until(char *until)
{
int l = strlen(until);
char chars[256];
while(1)
{
while (1)
{
chars[0] = yyinput();
if(chars[0] == EOF)
{
fprintf(stderr, "Error, Unexpected End Of File\n") ;
exit(1);
}
if(chars[0] == until[0])break;
}
printf("%c",chars[0]);
for(int i=1;i<l;i++)
{
chars[i] = yyinput();
if(chars[i] == EOF)
{
fprintf(stderr, "Error, Unexpected End Of File\n") ;
exit(1);
}
}
chars[l] = '\0';
if(!strcmp(chars,until))
{
return;
}
for(int i=1;i<l-1;i++)
{
unput(chars[l-i]);
}
}
}
This diff is collapsed.
...@@ -7,161 +7,164 @@ typedef union { ...@@ -7,161 +7,164 @@ typedef union {
Shape s; Shape s;
List_T *l; List_T *l;
} YYSTYPE; } YYSTYPE;
#define tDOUBLE 258 #define tDOUBLE 257
#define tSTRING 259 #define tSTRING 258
#define tBIGSTR 260 #define tBIGSTR 259
#define tEND 261 #define tEND 260
#define tAFFECT 262 #define tAFFECT 261
#define tDOTS 263 #define tDOTS 262
#define tPi 264 #define tPi 263
#define tExp 265 #define tExp 264
#define tLog 266 #define tLog 265
#define tLog10 267 #define tLog10 266
#define tSqrt 268 #define tSqrt 267
#define tSin 269 #define tSin 268
#define tAsin 270 #define tAsin 269
#define tCos 271 #define tCos 270
#define tAcos 272 #define tAcos 271
#define tTan 273 #define tTan 272
#define tAtan 274 #define tAtan 273
#define tAtan2 275 #define tAtan2 274
#define tSinh 276 #define tSinh 275
#define tCosh 277 #define tCosh 276
#define tTanh 278 #define tTanh 277
#define tFabs 279 #define tFabs 278
#define tFloor 280 #define tFloor 279
#define tCeil 281 #define tCeil 280
#define tFmod 282 #define tFmod 281
#define tModulo 283 #define tModulo 282
#define tHypot 284 #define tHypot 283
#define tPrintf 285 #define tPrintf 284
#define tDraw 286 #define tDraw 285
#define tSleep 287 #define tSleep 286
#define tPoint 288 #define tPoint 287
#define tCircle 289 #define tCircle 288
#define tEllipsis 290 #define tEllipsis 289
#define tLine 291 #define tLine 290
#define tSurface 292 #define tSurface 291
#define tSpline 293 #define tSpline 292
#define tVolume 294 #define tVolume 293
#define tCharacteristic 295 #define tCharacteristic 294
#define tLength 296 #define tLength 295
#define tParametric 297 #define tParametric 296
#define tElliptic 298 #define tElliptic 297
#define tPlane 299 #define tPlane 298
#define tRuled 300 #define tRuled 299
#define tTransfinite 301 #define tTransfinite 300
#define tComplex 302 #define tComplex 301
#define tPhysical 303 #define tPhysical 302
#define tUsing 304 #define tUsing 303
#define tBump 305 #define tBump 304
#define tProgression 306 #define tProgression 305
#define tRotate 307 #define tRotate 306
#define tTranslate 308 #define tTranslate 307
#define tSymmetry 309 #define tSymmetry 308
#define tDilate 310 #define tDilate 309
#define tExtrude 311 #define tExtrude 310
#define tDuplicata 312 #define tDuplicata 311
#define tLoop 313 #define tLoop 312
#define tInclude 314 #define tInclude 313
#define tRecombine 315 #define tRecombine 314
#define tDelete 316 #define tDelete 315
#define tCoherence 317 #define tCoherence 316
#define tView 318 #define tView 317
#define tAttractor 319 #define tAttractor 318
#define tLayers 320 #define tLayers 319
#define tScalarTetrahedron 321 #define tScalarTetrahedron 320
#define tVectorTetrahedron 322 #define tVectorTetrahedron 321
#define tTensorTetrahedron 323 #define tTensorTetrahedron 322
#define tScalarTriangle 324 #define tScalarTriangle 323
#define tVectorTriangle 325 #define tVectorTriangle 324
#define tTensorTriangle 326 #define tTensorTriangle 325
#define tScalarLine 327 #define tScalarLine 326
#define tVectorLine 328 #define tVectorLine 327
#define tTensorLine 329 #define tTensorLine 328
#define tScalarPoint 330 #define tScalarPoint 329
#define tVectorPoint 331 #define tVectorPoint 330
#define tTensorPoint 332 #define tTensorPoint 331
#define tBSpline 333 #define tBSpline 332
#define tNurbs 334 #define tNurbs 333
#define tOrder 335 #define tOrder 334
#define tWith 336 #define tWith 335
#define tBounds 337 #define tBounds 336
#define tKnots 338 #define tKnots 337
#define tColor 339 #define tColor 338
#define tFor 340 #define tFor 339
#define tEndFor 341 #define tEndFor 340
#define tScript 342 #define tScript 341
#define tExit 343 #define tExit 342
#define tMerge 344 #define tMerge 343
#define tB_SPLINE_SURFACE_WITH_KNOTS 345 #define tReturn 344
#define tB_SPLINE_CURVE_WITH_KNOTS 346 #define tCall 345
#define tCARTESIAN_POINT 347 #define tFunction 346
#define tTRUE 348 #define tB_SPLINE_SURFACE_WITH_KNOTS 347
#define tFALSE 349 #define tB_SPLINE_CURVE_WITH_KNOTS 348
#define tUNSPECIFIED 350 #define tCARTESIAN_POINT 349
#define tU 351 #define tTRUE 350
#define tV 352 #define tFALSE 351
#define tEDGE_CURVE 353 #define tUNSPECIFIED 352
#define tVERTEX_POINT 354 #define tU 353
#define tORIENTED_EDGE 355 #define tV 354
#define tPLANE 356 #define tEDGE_CURVE 355
#define tFACE_OUTER_BOUND 357 #define tVERTEX_POINT 356
#define tEDGE_LOOP 358 #define tORIENTED_EDGE 357
#define tADVANCED_FACE 359 #define tPLANE 358
#define tVECTOR 360 #define tFACE_OUTER_BOUND 359
#define tDIRECTION 361 #define tEDGE_LOOP 360
#define tAXIS2_PLACEMENT_3D 362 #define tADVANCED_FACE 361
#define tISO 363 #define tVECTOR 362
#define tENDISO 364 #define tDIRECTION 363
#define tENDSEC 365 #define tAXIS2_PLACEMENT_3D 364
#define tDATA 366 #define tISO 365
#define tHEADER 367 #define tENDISO 366
#define tFILE_DESCRIPTION 368 #define tENDSEC 367
#define tFILE_SCHEMA 369 #define tDATA 368
#define tFILE_NAME 370 #define tHEADER 369
#define tMANIFOLD_SOLID_BREP 371 #define tFILE_DESCRIPTION 370
#define tCLOSED_SHELL 372 #define tFILE_SCHEMA 371
#define tADVANCED_BREP_SHAPE_REPRESENTATION 373 #define tFILE_NAME 372
#define tFACE_BOUND 374 #define tMANIFOLD_SOLID_BREP 373
#define tCYLINDRICAL_SURFACE 375 #define tCLOSED_SHELL 374
#define tCONICAL_SURFACE 376 #define tADVANCED_BREP_SHAPE_REPRESENTATION 375
#define tCIRCLE 377 #define tFACE_BOUND 376
#define tTRIMMED_CURVE 378 #define tCYLINDRICAL_SURFACE 377
#define tGEOMETRIC_SET 379 #define tCONICAL_SURFACE 378
#define tCOMPOSITE_CURVE_SEGMENT 380 #define tCIRCLE 379
#define tCONTINUOUS 381 #define tTRIMMED_CURVE 380
#define tCOMPOSITE_CURVE 382 #define tGEOMETRIC_SET 381
#define tTOROIDAL_SURFACE 383 #define tCOMPOSITE_CURVE_SEGMENT 382
#define tPRODUCT_DEFINITION 384 #define tCONTINUOUS 383
#define tPRODUCT_DEFINITION_SHAPE 385 #define tCOMPOSITE_CURVE 384
#define tSHAPE_DEFINITION_REPRESENTATION 386 #define tTOROIDAL_SURFACE 385
#define tELLIPSE 387 #define tPRODUCT_DEFINITION 386
#define tTrimmed 388 #define tPRODUCT_DEFINITION_SHAPE 387
#define tSolid 389 #define tSHAPE_DEFINITION_REPRESENTATION 388
#define tEndSolid 390 #define tELLIPSE 389
#define tVertex 391 #define tTrimmed 390
#define tFacet 392 #define tSolid 391
#define tNormal 393 #define tEndSolid 392
#define tOuter 394 #define tVertex 393
#define tLoopSTL 395 #define tFacet 394
#define tEndLoop 396 #define tNormal 395
#define tEndFacet 397 #define tOuter 396
#define tAND 398 #define tLoopSTL 397
#define tOR 399 #define tEndLoop 398
#define tNOTEQUAL 400 #define tEndFacet 399
#define tEQUAL 401 #define tAND 400
#define tAPPROXEQUAL 402 #define tOR 401
#define tAFFECTPLUS 403 #define tNOTEQUAL 402
#define tAFFECTMINUS 404 #define tEQUAL 403
#define tAFFECTTIMES 405 #define tAPPROXEQUAL 404
#define tAFFECTDIVIDE 406 #define tAFFECTPLUS 405
#define tLESSOREQUAL 407 #define tAFFECTMINUS 406
#define tGREATEROREQUAL 408 #define tAFFECTTIMES 407
#define tCROSSPRODUCT 409 #define tAFFECTDIVIDE 408
#define UNARYPREC 410 #define tLESSOREQUAL 409
#define tPLUSPLUS 411 #define tGREATEROREQUAL 410
#define tMINUSMINUS 412 #define tCROSSPRODUCT 411
#define UNARYPREC 412
#define tPLUSPLUS 413
#define tMINUSMINUS 414
extern YYSTYPE yylval; extern YYSTYPE yylval;
%{ /* $Id: Gmsh.y,v 1.25 2000-12-07 09:21:34 geuzaine Exp $ */ %{ /* $Id: Gmsh.y,v 1.26 2000-12-07 16:03:44 remacle Exp $ */
#include <stdarg.h> #include <stdarg.h>
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "Colors.h" #include "Colors.h"
#include "Parser.h" #include "Parser.h"
#include "Main.h" #include "Main.h"
#include "FunctionManager.h"
#ifdef __DECCXX // bug in bison #ifdef __DECCXX // bug in bison
#include <alloca.h> #include <alloca.h>
...@@ -86,6 +87,7 @@ void vyyerror (char *fmt, ...); ...@@ -86,6 +87,7 @@ void vyyerror (char *fmt, ...);
%token tScalarPoint tVectorPoint tTensorPoint %token tScalarPoint tVectorPoint tTensorPoint
%token tBSpline tNurbs tOrder tWith tBounds tKnots %token tBSpline tNurbs tOrder tWith tBounds tKnots
%token tColor tFor tEndFor tScript tExit tMerge %token tColor tFor tEndFor tScript tExit tMerge
%token tReturn tCall tFunction
%token tB_SPLINE_SURFACE_WITH_KNOTS %token tB_SPLINE_SURFACE_WITH_KNOTS
%token tB_SPLINE_CURVE_WITH_KNOTS %token tB_SPLINE_CURVE_WITH_KNOTS
...@@ -1737,7 +1739,31 @@ Loop : ...@@ -1737,7 +1739,31 @@ Loop :
ImbricatedLoop--; ImbricatedLoop--;
} }
} }
| tReturn
{
if(!FunctionManager::Instance()->leaveFunction(&yyin))
{
vyyerror("Error while exiting function");
}
}
| tCall tSTRING tEND
{
if(!FunctionManager::Instance()->enterFunction($2,&yyin))
{
vyyerror("Unknown Function %s",$2);
}
}
| tFunction tSTRING
{
// skip everything until return is found
if(!FunctionManager::Instance()->createFunction($2,yyin))
{
vyyerror("Redefinition of function %s",$2);
}
void skip_until(char *until);
skip_until("Return");
}
;
/* --------------- /* ---------------
S C R I P T S C R I P T
--------------- ---------------
......
This diff is collapsed.
# $Id: Makefile,v 1.6 2000-12-07 08:46:27 geuzaine Exp $ # $Id: Makefile,v 1.7 2000-12-07 16:03:44 remacle Exp $
# #
# Makefile for "libParser.a" # Makefile for "libParser.a"
# #
...@@ -23,7 +23,8 @@ INCLUDE = -I../includes -I../Common -I../DataStr -I../Geo -I../Graphics\ ...@@ -23,7 +23,8 @@ INCLUDE = -I../includes -I../Common -I../DataStr -I../Geo -I../Graphics\
CFLAGS = $(C_FLAGS) $(OS_FLAGS) $(INCLUDE) CFLAGS = $(C_FLAGS) $(OS_FLAGS) $(INCLUDE)
SRC = Gmsh.yy.cpp \ SRC = Gmsh.yy.cpp \
Gmsh.tab.cpp Gmsh.tab.cpp\
FunctionManager.cpp
OBJ = $(SRC:.cpp=.o) OBJ = $(SRC:.cpp=.o)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment