Changeset df595d in git
- Timestamp:
- Apr 27, 1998, 12:55:56 PM (25 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- e9a5b9f04c03846bd8c017cf227e7f9b1dc2e264
- Parents:
- 1387fc63c740eb636ccead6aacbb9969235f1dfd
- Location:
- Singular
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/libparse.l
r1387fc6 rdf595d 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 /* $Id: libparse.l,v 1.1 0 1998-04-22 14:29:26 krueger Exp $ */5 /* $Id: libparse.l,v 1.11 1998-04-27 10:55:55 Singular Exp $ */ 6 6 #include <stdio.h> 7 7 #include <string.h> … … 51 51 int yylplineno = 1; 52 52 53 char *yylp_errlist[]= { 53 char *yylp_errlist[]= { 54 54 "", 55 55 "missing close bracket ')' for proc definition in line %d.", /* 1 */ … … 156 156 # undef YY_DECL 157 157 # define YY_DECL int yylex(char *newlib, char *libfile, \ 158 159 158 lib_style_types *lib_style, \ 159 lp_modes mode) 160 160 161 161 # undef YY_INPUT 162 162 # define YY_INPUT(buf,result,max_size) \ 163 163 if ( ((result = libread( (yyin), (char *) buf, max_size )) < 0 ) \ 164 165 164 && ferror( yyin ) ) \ 165 YY_FATAL_ERROR( "read in flex scanner failed" ); 166 166 167 167 # define YY_USER_INIT { \ … … 174 174 175 175 # if 0 176 <pbody>proc[ \t]+{name} { 176 <pbody>proc[ \t]+{name} { 177 177 printf("MISSING: PROC-cmd found. ERROR!\n"); } 178 <pbody>example[ \t]*\n { 178 <pbody>example[ \t]*\n { 179 179 yylplineno++; 180 180 printf("MISSING: EXAMPLE-cmd found. ERROR!\n"); } … … 219 219 *lib_style = NEW_LIBSTYLE; 220 220 last_cmd = LP_INFO; 221 } 221 } 222 222 223 223 (version=+{quote}+{strings}+{quote})|(version+{tos}+=+{quote}+{strings}+{quote})|(version+{tos}+=+{tos}+{quote}+{strings}+{quote})|(version=+{tos}+{quote}+{strings}+{quote}) { … … 248 248 pi = (procinfo *)malloc(sizeof(procinfo)); 249 249 iiInitSingularProcinfo(pi, newlib, yytext+5, yylplineno, 250 250 current_pos(0), p_static); 251 251 #else STANDALONE_PARSER 252 252 if( mode == LOAD_LIB) { … … 255 255 if(strlen(proc)<1) sscanf( yytext, "proc %s", proc); 256 256 h0 = enterid( mstrdup(proc), myynest, PROC_CMD, 257 257 &idroot, FALSE ); 258 258 if (h0!=NULL) { 259 259 iiInitSingularProcinfo(IDPROC(h0), newlib, proc, 260 260 yylplineno, current_pos(0),p_static); 261 261 if (BVERBOSE(V_LOAD_PROC)) 262 262 Warn( " proc %s loaded", proc ); … … 266 266 #if YYLPDEBUG 267 267 printf("PROC %d at %d/%d: (%d) %s\n", p_static, 268 268 yylplineno, current_pos(0), brace1, yytext); 269 269 #endif 270 270 p_static=FALSE; … … 278 278 #if YYLPDEBUG 279 279 printf("EXAMPLE at %d/%d (%d)\n", yylplineno, 280 280 current_pos(0), brace1); 281 281 #endif 282 282 } … … 287 287 288 288 <header>({comment}+{tos}+{dolar}+Id:+{string}+[^\n]*)|({comment}+{tos}+{dolar}+Header:+{string}+[^\n]*) { 289 make_version(yytext, 0); 289 make_version(yytext, 0); 290 290 //print_version(mode, ""); 291 291 #if YYLPDEBUG > 1 … … 293 293 #endif 294 294 } 295 <header>(^{comment}+[^\n]*) { 295 <header>(^{comment}+[^\n]*) { 296 296 #if YYLPDEBUG > 1 297 297 printf("+(cmt)HEAD:%s\n", yytext); 298 298 #endif 299 299 } 300 <header>(^#![^\n]*) { 300 <header>(^#![^\n]*) { 301 301 #if YYLPDEBUG > 1 302 302 printf("-HEAD:%s\n", yytext); … … 319 319 } 320 320 <header>\n { yylplineno++; } 321 <header>. { 321 <header>. { 322 322 #if YYLPDEBUG > 1 323 323 printf(" HEAD:%s\n", yytext); … … 326 326 BEGIN(help); 327 327 } 328 <help>(^{comment}+[^\n]*) { 328 <help>(^{comment}+[^\n]*) { 329 329 #if YYLPDEBUG > 1 330 330 printf(" HELP:%s\n", yytext); 331 331 #endif 332 332 BEGIN(INITIAL); } 333 <help>(^#![^\n]*) { 333 <help>(^#![^\n]*) { 334 334 #if YYLPDEBUG > 1 335 335 printf(" HELP:%s\n", yytext); … … 353 353 354 354 <help>\n { yylplineno++; } 355 <help>. { 355 <help>. { 356 356 #if YYLPDEBUG > 1 357 357 printf("-HELP:%s\n", yytext); … … 374 374 375 375 <pdef>[ \t] { } 376 <pdef>\( { 376 <pdef>\( { 377 377 brace2++; 378 378 #if YYLPDEBUG … … 380 380 #endif 381 381 } 382 <pdef>\) { 382 <pdef>\) { 383 383 brace2--; 384 384 #if YYLPDEBUG … … 395 395 } 396 396 } 397 <pdef>"{" { 397 <pdef>"{" { 398 398 if(brace2>0) { 399 399 #if YYLPDEBUG … … 402 402 yylp_errno = YYLP_DEF_BR2; 403 403 return(1); 404 } else { 404 } else { 405 405 brace1++; BEGIN(pbody); 406 406 SET_BODY_START(mode, pi, yylplineno, current_pos(0)); … … 408 408 } 409 409 <pdef>\n { yylplineno++; 410 if(brace2<=0) { 410 if(brace2<=0) { 411 411 #if YYLPDEBUG 412 412 printf("BEGIN(phead-2){=%d, (=%d, [=%d\n", brace1, brace2, brace3); … … 416 416 } 417 417 } 418 <pdef>. { 419 if(brace2<=0) { 418 <pdef>. { 419 if(brace2<=0) { 420 420 SET_HELP_START(mode, pi, current_pos(0)); 421 421 BEGIN(phead); … … 441 441 BEGIN(string); /* printf("%s", yytext); */ 442 442 } 443 <pbody>"{" { 443 <pbody>"{" { 444 444 brace1++; 445 445 #if YYLPDEBUG … … 447 447 #endif 448 448 } 449 <pbody>"}" { 449 <pbody>"}" { 450 450 #if YYLPDEBUG 451 451 printf("line: %d, (%d)%s\n", yylplineno, brace1, yytext); 452 452 #endif 453 453 brace1--; 454 if(brace2>0) { 454 if(brace2>0) { 455 455 yylp_errno = YYLP_BODY_BR2; 456 456 return(1); … … 469 469 } 470 470 } 471 <pbody>"(" { 471 <pbody>"(" { 472 472 brace2++; /* printf("%s", yytext); */ 473 473 } 474 <pbody>")" { 474 <pbody>")" { 475 475 brace2--; /* printf("%s", yytext); */ 476 if(brace2<0) { 476 if(brace2<0) { 477 477 yylp_errno = YYLP_BODY_TMBR2; 478 478 return(1); 479 479 } 480 480 } 481 <pbody>"[" { 481 <pbody>"[" { 482 482 brace3++; /* printf("%s", yytext); */ 483 483 } 484 <pbody>"]" { 484 <pbody>"]" { 485 485 brace3--; /* printf("%s", yytext); */ 486 486 if(brace3<0) { … … 505 505 BEGIN(string); /* printf("%s", yytext); */ 506 506 } 507 <pexample>"{" { 507 <pexample>"{" { 508 508 brace1++; /* printf("(%d)%s", brace1, yytext); */ 509 509 } 510 <pexample>"}" { 510 <pexample>"}" { 511 511 brace1--; /* printf("(%d)%s", brace1, yytext); */ 512 512 if(brace1<=0) { … … 517 517 } 518 518 } 519 <pexample>"(" { 519 <pexample>"(" { 520 520 brace2++; /* printf("%s", yytext); */ 521 521 } 522 <pexample>")" { 522 <pexample>")" { 523 523 brace2--; /* printf("%s", yytext); */ 524 524 } 525 <pexample>"[" { 525 <pexample>"[" { 526 526 brace3++; /* printf("%s", yytext); */ 527 527 } 528 <pexample>"]" { 528 <pexample>"]" { 529 529 brace3--; /* printf("%s", yytext); */ 530 530 } … … 551 551 #endif 552 552 } 553 . { p_static = FALSE; 553 . { p_static = FALSE; 554 554 yylp_errno = YYLP_BAD_CHAR; 555 printf("[% s\d]", *yytext);555 printf("[%d]", *yytext); 556 556 #if YYLPDEBUG 557 557 printf("[%s]", yytext); … … 587 587 588 588 extern "C" { 589 int yylpwrap() { 589 int yylpwrap() { 590 590 //printf("======================= YYWRAP ====================\n"); 591 591 if(brace1>0) { yylp_errno=YYLP_MISS_BR1; } … … 627 627 { 628 628 # ifndef STANDALONE_PARSER 629 if((last_cmd == LP_INFO)&&(mode == GET_INFO)) { 629 if((last_cmd == LP_INFO)&&(mode == GET_INFO)) 630 { 630 631 long current_location = ftell(yylpin); 631 632 int len = (int)(current_pos(0) - string_start); 632 633 fseek(yylpin, string_start, SEEK_SET); 633 634 text_buffer = (char *)AllocL(len+1); 635 text_buffer[len]='\0'; 634 636 fread(text_buffer, len, 1, yylpin); 635 637 fseek(yylpin, current_location, SEEK_SET); … … 666 668 667 669 printf( " %-15s %20s %s,%s %s,%s %s,%s\n", "Library", 668 669 670 "function", "line", "start-eod", "line", "body-eob", 671 "line", "example-eoe"); 670 672 yylplex(argv[0], argv[0], &lib_style); 671 673 if(yylp_errno) { … … 673 675 printf(yylp_errlist[yylp_errno], yylplineno); 674 676 printf("\n"); 675 } 677 } 676 678 else if(pi!=NULL) printpi(pi); 677 679 } -
Singular/misc.cc
r1387fc6 rdf595d 373 373 extern FILE *yylpin; 374 374 lib_style_types lib_style; // = OLD_LIBSTYLE; 375 375 376 376 yylpin = fp; 377 377 yylplex(str, libnamebuf, &lib_style, GET_INFO); 378 378 reinit_yylp(); 379 if(lib_style == OLD_LIBSTYLE) { 380 char buf[256]; 381 fseek(fp, 0, SEEK_SET); 379 if(lib_style == OLD_LIBSTYLE) 380 { 381 char buf[256]; 382 fseek(fp, 0, SEEK_SET); 382 383 #else /* HAVE_LIBPARSER */ 383 384 { char buf[256]; 384 385 #endif /* HAVE_LIBPARSER */ 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 386 Warn( "library %s has an old format. Please fix it for the next time", 387 str); 388 BOOLEAN found=FALSE; 389 while (fgets( buf, sizeof(buf), fp)) 390 { 391 if (strncmp(buf,"//",2)==0) 392 { 393 if (found) return; 394 } 395 else if ((strncmp(buf,"proc ",5)==0)||(strncmp(buf,"LIB ",4)==0)) 396 { 397 if (!found) Warn("no help part in library found"); 398 return; 399 } 400 else 401 { 402 found=TRUE; 403 PrintS(buf); 404 } 405 } 405 406 } 406 407 #ifdef HAVE_LIBPARSER 407 else { 408 fclose( yylpin ); 409 PrintS(text_buffer); 410 FreeL(text_buffer); 408 else 409 { 410 fclose( yylpin ); 411 PrintS(text_buffer); 412 FreeL(text_buffer); 411 413 } 412 414 #endif /* HAVE_LIBPARSER */
Note: See TracChangeset
for help on using the changeset viewer.