1(Message inbox:32) 2Date: Mon, 03 Jul 89 21:15:32 CET 3From: V61%DHDURZ1.BITNET@lbl.gov 4Subject: Flex, bug fix, improvments, patches for Minix & TOS 5To: vern@lbl-csam.arpa 6 7At first I have to thank you for your wonderful program. I had ported the 8old version to OS9,TOS (Atari ST) and Minix and the new version 2.1 Beta 9to Minix and TOS. 10 11While porting and using flex I detected a bug and made some improvements. 12I have included a shared, compressed and uuencoded file contaning all cdiffs 13and additional files (Sorry, but I'm on EBCDIC-Bitnet) and a short discussion 14of the changes. Even some of the TOS specific changes might be of general 15interest ! 16 17I posted these cdiffs to the minix discussion group, but I think it's up 18to you to post them to the unix-sources group. If you plan to post even 19the TOS compiler specific patches please contact me because there might be 20further compiler (P.D.) additions. If you have an interest I could also 21port the new version to OS9 -- this is a little bit more difficult, because 22OS9 uses CR as end of line character (the EOL char. is coded into the 23initscan.c tables,...). It is necessary to change all occurences of '\n' to 24macros and variables and it's useful to add a new -n options (see commented 25line in main.c) 26 27 28 29The changes: (1.7.89 RAL) 30 31 - Bug fix: The original flex didn't like trailing spaces in exclusive start 32 condition lists ! If you add an trailing space to line 68 in scan.l 33 34 "%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE " 35 36 you get a misleading error message: 37 38 "Syntax error at line 69: bad start condition list" 39 40 This bug can either be fixed in parse.y or in scan.l . I have chosen the 41 last because there the fix is minimal: Just change the rule (line 128) 42 43 "\n" to "{OPTWS}\n" 44 45 - Enhancements: 46 - new option "-?" that provides some help information about the other 47 flags (main.c) 48 - new option "-aTMPPATH" that allows a redefinition of the standard 49 path for the temporary file (this might be rather large >200k if 50 F,f options are selected). (main.c, flexdef.h (l.376)) 51 - hexdump of illegal characters -- this proved to be a useful debugging 52 tool especialy if invisible control characters occur which weren't 53 covered by the rules. (scan.l fprintf statement line 129,...) 54 55 - Patches due to TOS 56 - General: TOS uses CR,LF as end of line char., Flex wants only a single 57 LF as EOL char. Therefore all I/O must be translated using f* calls. 58 This is done everywhere besides the YY_INPUT macro (flex.skel (scan.c), 59 line 31) that uses a low level 'read'. This should be definitly changed 60 to fread, so that all I/O calls occur on the same level. 61 - the short action_file_name has been "flexXXXXXX.tmp", but that's too 62 much for TOS,MSDOS ! I changed it to "flexXXXX.tmp" in main.c (patch 63 covered by the -a option additions) 64 - some compilers don't like external names that are ambiguous within 65 the first 8 characters. I defined macros that change all these long 66 external names to names that are unique within the first 8 characters. 67 Just define SHORT_EXTERNAL_NAMES to use this feature (flexdef.h) 68 - some statement changes that some compiler don't like: 69 typedef *xxx[] -> typedef **xxx (flexdef.h.,l.308) 70 "/*" -> '/','*' within a comment in (scan.l, l.209) 71 - changed short "lexyy.c" to "lex_yy.c" what's more similar to the unix 72 "lex.yy.c" (main.c). 73 - a few further really compiler dependent changes provided with 74 #ifdef ATARI && LATTICE res. TURBO braces. 75 76 - Additional TOS only files 77 - Makefile.tos: Common makefile for all TOS compilers. If you add further 78 ones please email me the new makefile. 79 - flex.lnk: Lattice - GST linker argument extension file 80 - flex.tlk: Turbo linker argument extension file 81 82 83Additional remarks: 84 85I didn't add a new initscan.c (= flex -ist scan.l). The current one is good 86enough for a first compilation. With this first version of flex you can 87rebuild your own scan.c and the final flex version ! 88 89Minix ST : 90 - I had to "chmem =70000 cv" (>50000) to get flex linked 91 - 'memset' (PC 1.3, EFTH40,...) is necessary 92 - chmem =90000 flex may be sufficient 93 94Minix PC : 95 It should be possible to port Flex to Minix PC. The current sizes of flex 96 are: 97 Minix ST (ACK) Lattice (TOS) Turbo (TOS) 98 99 size 75300 83305 57957 100 compilation time 22' 15' 3'40" 101 flex -is scan.l 1'49" 43" 30" 102 103 The Minix ST size includes the bad generated code using only a subset of 104 the 68000 commands, long addresses only and a huge relocation table. 105 Therefore the PC size will be <64 k ! More serious is the fact that I had 106 to chmem =90000 flex to get scan.l converted to scan.c . But I never saw 107 a more complex lex source than scan.l -- so it should be possible to 108 reduce some array sizes without limitation for all day usage. 109 110 No one volunteered yet for a Minix PC port -- but if someone will try it 111 I would provide him with a new scan.c and some hints. 112 113TOS: 114 Don't forget to adapt the flexskel path within flexdef.h ! 115 116 117Bitnet: V61@DHDURZ1 Ronald Lamprecht 118UUCP: ...!unido!DHDURZ1.bitnet!V61 Theoretische Physik 119ARPAnet: V61%DHDURZ1.BITNET@CUNYVM.CUNY.EDU (Heidelberg, West Germany) 120(Message inbox:36) 121Date: Wed, 05 Jul 89 21:16:07 CET 122From: V61%DHDURZ1.BITNET@csa2.lbl.gov 123Subject: Re: What is TOS 124To: vern@lbl-csam.arpa 125 126TOS is the name of the Atari ST operating system that is very similar 127to MSDOS (Both use CR,LF as end of line character). Therefore I have 128been astonished that no EOL convertion porblems occur within MSDOS. 129 130I have been aware of the double buffering when changing read to fread and I 131accept your argument of a possible slow down. But if you integrate the other 132Atari - TOS changes, please insert a 133 #ifdef ATARI 134 fread .... 135 #else 136 read .... 137 #endif 138in flex.skel . 139 140Bitnet: V61@DHDURZ1 Ronald Lamprecht 141UUCP: ...!unido!DHDURZ1.bitnet!V61 Theoretische Physik 142ARPAnet: V61%DHDURZ1.BITNET@CUNYVM.CUNY.EDU (Heidelberg, West Germany) 143 144 145 146 147echo x - Makefile_cdiff 148sed '/^X/s///' > Makefile_cdiff << '/' 149X*** Src_2.1/Makefile Thu Jun 28 00:06:42 1989 150X--- Makefile Thu Jul 3 02:12:48 1989 151X*************** 152X*** 5,10 **** 153X--- 5,11 ---- 154X # Porting considerations: 155X # 156X # For System V Unix machines, add -DSYS_V to CFLAGS. 157X+ # For Minix (ST), add -DSYS_V to CFLAGS 158X # For Vax/VMS, add -DSYS_V to CFLAGS. 159X # For MS-DOS, add "-DMS_DOS -DSYS_V" to CFLAGS. Create \tmp if not present. 160X # You will also want to rename flex.skel to something with a three 161X*************** 162X*** 21,28 **** 163X SKELETON_DIR = /usr/local/lib 164X SKELETON_FILE = flex.skel 165X SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\" 166X! CFLAGS = -O 167X! LDFLAGS = -s 168X 169X FLEX_FLAGS = 170X FLEX = ./flex 171X--- 22,29 ---- 172X SKELETON_DIR = /usr/local/lib 173X SKELETON_FILE = flex.skel 174X SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\" 175X! CFLAGS = -O -DSYS_V 176X! LDFLAGS = 177X 178X FLEX_FLAGS = 179X FLEX = ./flex 180X*************** 181X*** 57,63 **** 182X yylex.c 183X 184X flex : $(FLEXOBJS) 185X! $(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS) 186X 187X first_flex: 188X cp initscan.c scan.c 189X--- 58,65 ---- 190X yylex.c 191X 192X flex : $(FLEXOBJS) 193X! $(CC) $(CFLAGS) -o flex $(FLEXOBJS) $(LDFLAGS) 194X! chmem =150000 flex 195X 196X first_flex: 197X cp initscan.c scan.c 198/ 199echo x - flex.skel_cdif 200sed '/^X/s///' > flex.skel_cdif << '/' 201X*** Src_2.1/flex.skel Thu Jun 28 00:19:20 1989 202X--- flex.skel Thu Jul 2 22:18:31 1989 203X*************** 204X*** 28,34 **** 205X * is returned in "result". 206X */ 207X #define YY_INPUT(buf,result,max_size) \ 208X! if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \ 209X YY_FATAL_ERROR( "read() in flex scanner failed" ); 210X #define YY_NULL 0 211X #define yyterminate() return ( YY_NULL ) 212X--- 28,34 ---- 213X * is returned in "result". 214X */ 215X #define YY_INPUT(buf,result,max_size) \ 216X! if ( (result = fread( buf,1, max_size, yyin )) < 0 ) \ 217X YY_FATAL_ERROR( "read() in flex scanner failed" ); 218X #define YY_NULL 0 219X #define yyterminate() return ( YY_NULL ) 220/ 221echo x - flexdef.h_cdif 222sed '/^X/s///' > flexdef.h_cdif << '/' 223X*** Src_2.1/flexdef.h Thu Jun 28 00:43:27 1989 224X--- flexdef.h Thu Jul 3 02:45:50 1989 225X*************** 226X*** 26,31 **** 227X--- 26,40 ---- 228X 229X /* @(#) $Header: /projects/cvsroot/src/router/flex/MISC/Atari/Atari.patches,v 1.1.1.1 2001/04/08 23:53:37 mhuang Exp $ (LBL) */ 230X 231X+ #ifdef ATARI 232X+ #define SYS_V 233X+ #define abs(x) ((x) < 0 ? -(x) : (x)) 234X+ #define SHORT_FILE_NAMES 235X+ #ifdef TURBO 236X+ #define SHORT_EXTERNAL_NAMES 237X+ #endif 238X+ #endif 239X+ 240X #ifndef FILE 241X #include <stdio.h> 242X #endif 243X*************** 244X*** 41,47 **** 245X #endif 246X 247X #ifndef VMS 248X! char *memset(); 249X #else 250X /* memset is needed for old versions of the VMS C runtime library */ 251X #define memset(s, c, n) \ 252X--- 50,58 ---- 253X #endif 254X 255X #ifndef VMS 256X! #ifndef ATARI && TURBO 257X! char *memset(); 258X! #endif 259X #else 260X /* memset is needed for old versions of the VMS C runtime library */ 261X #define memset(s, c, n) \ 262X*************** 263X*** 81,91 **** 264X--- 92,129 ---- 265X #define true 1 266X #define false 0 267X 268X+ #ifdef ATARI 269X+ #define DEFAULT_SKELETON_FILE "D:\\include\\flexskel" 270X+ #endif 271X+ 272X 273X #ifndef DEFAULT_SKELETON_FILE 274X #define DEFAULT_SKELETON_FILE "flex.skel" 275X #endif 276X 277X+ #ifdef SHORT_EXTERNAL_NAMES 278X+ /* avoid long external names that are ambiguous within the first 8 characters */ 279X+ #define current_mns c__mns 280X+ #define current_max_rules c__max_rules 281X+ #define current_max_state_type c__max_state_type 282X+ #define current_max_scs c__max_scs 283X+ #define current_max_dfa_size c__max__size 284X+ #define current_max_xpairs c__max_xpairs 285X+ #define current_max_template_xpairs c__max_template_xpairs 286X+ #define current_max_dfas c__max_dfas 287X+ #define current_maxccls c__maxccles 288X+ #define current_max_ccl_tbl_size c__max_ccl_tbl_size 289X+ #define indent_puts ind_puts 290X+ #define indent_put2s ind_put2s 291X+ #define gen_next_compressed_state gen_n_comressed_state 292X+ #define gen_next_match gen_n_match 293X+ #define gen_next_state gen_n_state 294X+ #define variable_trailing_context_rules var_tr_context_rules 295X+ #define variable_trailing_rule var_tr_rule 296X+ #define backtrack_report backtr_report 297X+ #define backtrack_file backtr_file 298X+ #endif 299X+ 300X /* special chk[] values marking the slots taking by end-of-buffer and action 301X * numbers 302X */ 303X*************** 304X*** 305,311 **** 305X int int_val; 306X } ; 307X 308X! typedef struct hash_entry *hash_table[]; 309X 310X #define NAME_TABLE_HASH_SIZE 101 311X #define START_COND_HASH_SIZE 101 312X--- 343,349 ---- 313X int int_val; 314X } ; 315X 316X! typedef struct hash_entry **hash_table; 317X 318X #define NAME_TABLE_HASH_SIZE 101 319X #define START_COND_HASH_SIZE 101 320X*************** 321X*** 372,378 **** 322X extern int datapos, dataline, linenum; 323X extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file; 324X extern char *infilename; 325X! extern char action_file_name[]; 326X 327X 328X /* variables for stack of states having only one out-transition: 329X--- 410,416 ---- 330X extern int datapos, dataline, linenum; 331X extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file; 332X extern char *infilename; 333X! extern char *action_file_name; 334X 335X 336X /* variables for stack of states having only one out-transition: 337/ 338echo x - main.c_cdiff 339sed '/^X/s///' > main.c_cdiff << '/' 340X*** Src_2.1/main.c Thu Jun 28 00:30:39 1989 341X--- main.c Thu Jul 3 02:27:47 1989 342X*************** 343X*** 81,96 **** 344X FILE *temp_action_file; 345X FILE *backtrack_file; 346X int end_of_buffer_state; 347X! #ifndef SHORT_FILE_NAMES 348X! char action_file_name[] = "/tmp/flexXXXXXX"; 349X! #else 350X! char action_file_name[] = "flexXXXXXX.tmp"; 351X! #endif 352X! 353X #ifndef SHORT_FILE_NAMES 354X static char outfile[] = "lex.yy.c"; 355X #else 356X! static char outfile[] = "lexyy.c"; 357X #endif 358X static int outfile_created = 0; 359X 360X--- 81,91 ---- 361X FILE *temp_action_file; 362X FILE *backtrack_file; 363X int end_of_buffer_state; 364X! char *action_file_name; 365X #ifndef SHORT_FILE_NAMES 366X static char outfile[] = "lex.yy.c"; 367X #else 368X! static char outfile[] = "lex_yy.c"; 369X #endif 370X static int outfile_created = 0; 371X 372X*************** 373X*** 328,333 **** 374X--- 323,329 ---- 375X { 376X int i, sawcmpflag, use_stdout; 377X char *arg, *skelname = NULL, *flex_gettime(), clower(), *mktemp(); 378X+ char *tmp_action =(char *)0, *malloc(); 379X 380X printstats = syntaxerror = trace = spprdflt = interactive = caseins = false; 381X backtrack_report = performance_report = ddebug = fulltbl = fullspd = false; 382X*************** 383X*** 349,354 **** 384X--- 345,355 ---- 385X for ( i = 1; arg[i] != '\0'; ++i ) 386X switch ( arg[i] ) 387X { 388X+ case 'a': 389X+ if ( i != 1 ) 390X+ flexerror( "-a flag must be given separately" ); 391X+ tmp_action = &arg[i+1]; 392X+ goto get_next_arg; 393X case 'b': 394X backtrack_report = true; 395X break; 396X*************** 397X*** 445,452 **** 398X printstats = true; 399X break; 400X 401X! default: 402X! lerrif( "unknown flag %c", (int) arg[i] ); 403X break; 404X } 405X 406X--- 446,458 ---- 407X printstats = true; 408X break; 409X 410X! case '?': 411X! flexinfo(0); 412X! break; 413X! 414X! default: 415X! fprintf(stderr,"flex : unknown flag %c\n", (int) arg[i] ); 416X! flexinfo(1); 417X break; 418X } 419X 420X*************** 421X*** 454,459 **** 422X--- 460,493 ---- 423X ; 424X } 425X 426X+ 427X+ /* if you change the default tmp file names don't forget to change the 428X+ initialization for i, too ! 429X+ 430X+ */ 431X+ #ifndef SHORT_FILE_NAMES 432X+ i = 10; 433X+ if (!tmp_action) i += 5; 434X+ #else 435X+ i = 12; 436X+ #endif 437X+ if (tmp_action) 438X+ i += strlen(tmp_action) + 1; 439X+ if((action_file_name = malloc(i+1)) == (char *)0) 440X+ flexerror("No memory for action_file_name"); 441X+ *action_file_name = (char) NULL; 442X+ if (tmp_action) 443X+ strcat(action_file_name,tmp_action); 444X+ #ifndef SHORT_FILE_NAMES 445X+ else 446X+ strcat(action_file_name,"/tmp"); 447X+ strcat(action_file_name,"/flexXXXXXX"); 448X+ #else 449X+ if (tmp_action) 450X+ strcat(action_file_name,"/"); 451X+ strcat(action_file_name,"flexXXXX.tmp"); 452X+ #endif 453X+ 454X if ( (fulltbl || fullspd) && usemecs ) 455X flexerror( "full table and -cm don't make sense together" ); 456X 457X*************** 458X*** 520,526 **** 459X if ( (skelfile = fopen( skelname, "r" )) == NULL ) 460X lerrsf( "can't open skeleton file %s", skelname ); 461X 462X! (void) mktemp( action_file_name ); 463X 464X if ( (temp_action_file = fopen( action_file_name, "w" )) == NULL ) 465X lerrsf( "can't open temporary action file %s", action_file_name ); 466X--- 554,562 ---- 467X if ( (skelfile = fopen( skelname, "r" )) == NULL ) 468X lerrsf( "can't open skeleton file %s", skelname ); 469X 470X! #ifndef ATARI && LATTICE 471X! (void) mktemp( action_file_name ); 472X! #endif 473X 474X if ( (temp_action_file = fopen( action_file_name, "w" )) == NULL ) 475X lerrsf( "can't open temporary action file %s", action_file_name ); 476X*************** 477X*** 566,571 **** 478X--- 602,640 ---- 479X } 480X 481X 482X+ flexinfo(status) 483X+ int status; 484X+ { 485X+ fprintf(stderr,"Syntax : FLEX inp_file\n"); 486X+ fprintf(stderr,"Function: fast lexical analyzer generator V%s\n",flex_version); 487X+ fprintf(stderr,"Options : a dir_path : directory path for temporary files\n"); 488X+ fprintf(stderr," - b : generate backtracking information to lex.backtrack\n"); 489X+ fprintf(stderr," - c : compressed table, no equiv., no meta equiv.classes\n"); 490X+ fprintf(stderr," e : equivalence classes\n"); 491X+ fprintf(stderr," F : fast table\n"); 492X+ fprintf(stderr," |f : full table\n"); 493X+ fprintf(stderr," |m : meta equivalence classes\n"); 494X+ fprintf(stderr," - d : generate debugging scanner\n"); 495X+ fprintf(stderr," - F : fast table\n"); 496X+ fprintf(stderr," - f : full (not compressed) table\n"); 497X+ fprintf(stderr," - I : generate interactive scanner\n"); 498X+ fprintf(stderr," - i : generate case-insensitive scanner\n"); 499X+ fprintf(stderr," - L : supress #line directives\n"); 500X+ /* fprintf(stderr," - n hexnum : generate scanner using <hexnum> as newline char.\n");*/ 501X+ fprintf(stderr," - p : generate performance report to stderr\n"); 502X+ fprintf(stderr," - S skeleton_path : file path for skeleton file\n"); 503X+ fprintf(stderr," - s : suppress echo of unmatched scanner input to stdout\n"); 504X+ fprintf(stderr," - T : run flex in trace mode\n"); 505X+ #ifdef ATARI 506X+ fprintf(stderr," - t : place result on stdout instead of lex_yy.c\n"); 507X+ #else 508X+ fprintf(stderr," - t : place result on stdout instead of lex.yy.c\n"); 509X+ #endif 510X+ fprintf(stderr," - v : print statistics of generated scanner\n"); 511X+ fprintf(stderr," default = -cem\n"); 512X+ exit(status); 513X+ } 514X+ 515X /* readin - read in the rules section of the input file(s) 516X * 517X * synopsis 518/ 519echo x - scan.l_cdiff 520sed '/^X/s///' > scan.l_cdiff << '/' 521X*** Src_2.1/scan.l Thu Jun 30 19:42:00 1989 522X--- scan.l Thu Jul 2 22:19:26 1989 523X*************** 524X*** 125,132 **** 525X 526X {SCNAME} RETURNNAME; 527X ^{OPTWS}\n ++linenum; /* allows blank lines in section 1 */ 528X! \n ++linenum; return ( '\n' ); 529X! . synerr( "illegal character" ); BEGIN(RECOVER); 530X 531X 532X <C_COMMENT>"*/" ECHO; BEGIN(0); 533X--- 125,136 ---- 534X 535X {SCNAME} RETURNNAME; 536X ^{OPTWS}\n ++linenum; /* allows blank lines in section 1 */ 537X! {OPTWS}\n ++linenum; return ( '\n' ); 538X! . { 539X! synerr( "illegal character" ); 540X! fprintf(stderr,"Char : $%x\n",yytext[yyleng-1]); 541X! BEGIN(RECOVER); 542X! } 543X 544X 545X <C_COMMENT>"*/" ECHO; BEGIN(0); 546X*************** 547X*** 206,212 **** 548X <SECT2>^{OPTWS}\n ++linenum; /* allow blank lines in section 2 */ 549X 550X /* this horrible mess of a rule matches indented lines which 551X! * do not contain "/*". We need to make the distinction because 552X * otherwise this rule will be taken instead of the rule which 553X * matches the beginning of comments like this one 554X */ 555X--- 210,216 ---- 556X <SECT2>^{OPTWS}\n ++linenum; /* allow blank lines in section 2 */ 557X 558X /* this horrible mess of a rule matches indented lines which 559X! * do not contain '/','*'. We need to make the distinction because 560X * otherwise this rule will be taken instead of the rule which 561X * matches the beginning of comments like this one 562X */ 563/ 564echo x - Makefile.tos 565sed '/^X/s///' > Makefile.tos << '/' 566X# make file for "flex" tool 567X 568X# @(#) $Header: /projects/cvsroot/src/router/flex/MISC/Atari/Atari.patches,v 1.1.1.1 2001/04/08 23:53:37 mhuang Exp $ (LBL) 569X 570X# Porting considerations: 571X# 572X# For System V Unix machines, add -DSYS_V to CFLAGS. 573X# For Vax/VMS, add -DSYS_V to CFLAGS. 574X# For MS-DOS, add "-DMS_DOS -DSYS_V" to CFLAGS. Create \tmp if not present. 575X# You will also want to rename flex.skel to something with a three 576X# character extension, change SKELETON_FILE below appropriately, 577X# For Amiga, add "-DAMIGA -DSYS_V" to CFLAGS. 578X# 579X# A long time ago, flex was successfully built using Microsoft C and 580X# the following options: /AL, /stack:10000, -LARGE, -Ml, -Mt128, -DSYS_V 581X 582X 583X# the first time around use "make first_flex" 584X 585X# The following definitions must be set according to your compiler - 586X# examples for a Lattice Compiler with GST assembler and TURBO C with 587X# assembler are provided below and must just be updated (don't forget to 588X# update the linker argument extension files (*.lnk,*.tlk), too) : 589X# 590X#CCPATH = path to compiler directory without trailing \ 591X#CHPATH = path to header files without trailing \ 592X#CC = filename of the compiler 593X#CFLAGS = compiler option flags 594X#CIEXT = extension of C sources that should be used for input filenames 595X#ASMPATH = path to assembler directory without trailing \ 596X#ASM = filename of the assembler 597X#AFLAGS = assembler option flags 598X#AIEXT = extension of assembler sources that should be used for assembler 599X# input filenames 600X#AEXT = general assembler filename extension 601X#LNKPATH = path to linker directory without trailing \ 602X#LINK = filename of the linker 603X#LFLAG0 = first option (full pathname of C startupcode) 604X#LFLAG1 = further options + option flag for argument extension filename 605X#LFLAG2 = further options + option flag for output-filename 606X#LNKEXT = extension of linker argument extension file 607X#OIEXT = extension of objects that should be used for linker input files 608X#OEXT = general object file extension 609X 610X# Lattice definitions 611XCCPATH = d:\latt 612XCHPATH = d:\latt\include 613XCC = lc.ttp 614XCFLAGS = -h -n -cw -cc -i$(CHPATH)\ -g$(CCPATH)\ -dLATTICE -dATARI 615XCIEXT = 616XASMPATH = d:\gst 617XASM = assem.ttp 618XAFLAGS = -nolist -errors errors.out 619XAIEXT = 620XAEXT = .asm 621XLNKPATH = d:\gst 622XLINK = ld.ttp 623XLFLAG0 = 624XLFLAG1 = -with 625XLFLAG2 = -nolist -sec -mem 200 -prog 626XLNKEXT = .lnk 627XOIEXT = 628XOEXT = .bin 629X 630X# Turbo definitions 631X#CCPATH = d:\turbo 632X#CHPATH = d:\turbo\include 633X#CC = tcc.prg 634X#CFLAGS = -GJMPRZ -H=$(CHPATH)\ -w- -DTURBO -DATARI 635X#CIEXT = .c 636X#ASMPATH = d:\turbo 637X#ASM = mas.prg 638X#AFLAGS = 639X#AIEXT = .s 640X#AEXT = .s 641X#LNKPATH = d:\turbo 642X#LINK = tlink.ttp 643X#LFLAG0 = $(LNKPATH)\lib\tcstart.o 644X#LFLAG1 = -I= 645X#LFLAG2 = -O= 646X#LNKEXT = .tlk 647X#OIEXT = .o 648X#OEXT = .o 649X 650X# Other definitions 651X# (not used for Atari because of short argument string - defined in flexdef.h 652X 653XSKELETON_DIR = /usr/lib 654XSKELETON_FILE = flex.skel 655XSKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\" 656X 657X 658XFLEX = d:\etc\flex.ttp 659XFLEX_FLAGS = -is 660XYACC = d:\etc\yacc.ttp 661XRENAME = d:\bin\rename 662XDEL = d:\bin\del 663X 664X# Internal definitions 665XLNK = $(LNKPATH)\$(LINK) 666X 667XFLEXOBJS = \ 668X ccl$(OEXT) \ 669X dfa$(OEXT) \ 670X ecs$(OEXT) \ 671X gen$(OEXT) \ 672X main$(OEXT) \ 673X misc$(OEXT) \ 674X nfa$(OEXT) \ 675X parse$(OEXT) \ 676X scan$(OEXT) \ 677X sym$(OEXT) \ 678X tblcmp$(OEXT) \ 679X yylex$(OEXT) 680X 681XFLEX_C_SOURCES = \ 682X ccl.c \ 683X dfa.c \ 684X ecs.c \ 685X gen.c \ 686X main.c \ 687X misc.c \ 688X nfa.c \ 689X parse.c \ 690X scan.c \ 691X sym.c \ 692X tblcmp.c \ 693X yylex.c 694X 695Xflex : $(FLEXOBJS) 696X $(LNK) $(LFLAG0) $(LFLAG1)flex$(LNKEXT) $(LFLAG2)flex.ttp 697X 698Xfirst_flex: 699X cp initscan.c scan.c 700X make $(MFLAGS) flex 701X 702Xparse.h parse.c : parse.y 703X $(YACC) -d parse.y 704X $(DEL) parse.c 705X $(RENAME) y_tab.c parse.c 706X $(DEL) parse.h 707X $(RENAME) y_tab.h parse.h 708X 709Xscan.c : scan.l 710X $(FLEX) $(FLEX_FLAGS) scan.l 711X $(RENAME) lex_yy.c scan.c 712X 713Xscan$(OEXT) : scan.c parse.h flexdef.h 714X $(CCPATH)\$(CC) $(CFLAGS) scan$(CIEXT) 715X 716Xmain$(OEXT) : main.c flexdef.h 717X $(CCPATH)\$(CC) $(CFLAGS) main$(CIEXT) 718X 719Xccl$(OEXT) : ccl.c flexdef.h 720X $(CCPATH)\$(CC) $(CFLAGS) ccl$(CIEXT) 721X 722Xdfa$(OEXT) : dfa.c flexdef.h 723X $(CCPATH)\$(CC) $(CFLAGS) dfa$(CIEXT) 724X 725Xecs$(OEXT) : ecs.c flexdef.h 726X $(CCPATH)\$(CC) $(CFLAGS) ecs$(CIEXT) 727X 728Xgen$(OEXT) : gen.c flexdef.h 729X $(CCPATH)\$(CC) $(CFLAGS) gen$(CIEXT) 730X 731Xmisc$(OEXT) : misc.c flexdef.h 732X $(CCPATH)\$(CC) $(CFLAGS) misc$(CIEXT) 733X 734Xnfa$(OEXT) : nfa.c flexdef.h 735X $(CCPATH)\$(CC) $(CFLAGS) nfa$(CIEXT) 736X 737Xparse$(OEXT) : parse.c flexdef.h 738X $(CCPATH)\$(CC) $(CFLAGS) parse$(CIEXT) 739X 740Xsym$(OEXT) : sym.c flexdef.h 741X $(CCPATH)\$(CC) $(CFLAGS) sym$(CIEXT) 742X 743Xtblcmp$(OEXT) : tblcmp.c flexdef.h 744X $(CCPATH)\$(CC) $(CFLAGS) tblcmp$(CIEXT) 745X 746Xyylex$(OEXT) : yylex.c flexdef.h 747X $(CCPATH)\$(CC) $(CFLAGS) yylex$(CIEXT) 748X 749Xflex.man : flex.1 750X nroff -man flex.1 >flex.man 751X 752Xlint : $(FLEX_C_SOURCES) 753X lint $(FLEX_C_SOURCES) > flex.lint 754X 755Xdistrib : 756X mv scan.c initscan.c 757X chmod 444 initscan.c 758X $(MAKE) $(MFLAGS) clean 759X 760Xclean : 761X rm -f core errs flex *$(OEXT) parse.c *.lint parse.h flex.man tags 762X 763Xtags : 764X ctags $(FLEX_C_SOURCES) 765X 766Xvms : flex.man 767X $(MAKE) $(MFLAGS) distrib 768X 769Xtest : 770X $(FLEX) $(FLEX_FLAGS) scan.l 771X $(RENAME) lex_yy.c scan.ctest 772X cmp scan.c scan.ctest 773X 774/ 775echo x - Readme2 776sed '/^X/s///' > Readme2 << '/' 777XThe changes: (1.7.89 RAL) 778X 779X - Bug fix: The original flex didn't like trailing spaces in exclusive start 780X condition lists ! If you add an trailing space to line 68 in scan.l 781X 782X "%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE " 783X 784X you get a misleading error message: 785X 786X "Syntax error at line 69: bad start condition list" 787X 788X This bug can either be fixed in parse.y or in scan.l . I have chosen the 789X last because there the fix is minimal: Just change the rule (line 128) 790X 791X "\n" to "{OPTWS}\n" 792X 793X - Enhancements: 794X - new option "-?" that provides some help information about the other 795X flags (main.c) 796X - new option "-aTMPPATH" that allows a redefinition of the standard 797X path for the temporary file (this might be rather large >200k if 798X F,f options are selected). (main.c, flexdef.h (l.376)) 799X - hexdump of illegal characters -- this proved to be a useful debugging 800X tool especialy if invisible control characters occur which weren't 801X covered by the rules. (scan.l fprintf statement line 129,...) 802X 803X - Patches due to TOS 804X - General: TOS uses CR,LF as end of line char., Flex wants only a single 805X LF as EOL char. Therefore all I/O must be translated using f* calls. 806X This is done everywhere besides the YY_INPUT macro (flex.skel (scan.c), 807X line 31) that uses a low level 'read'. This should be definitly changed 808X to fread, so that all I/O calls occur on the same level. 809X - the short action_file_name has been "flexXXXXXX.tmp", but that's too 810X much for TOS,MSDOS ! I changed it to "flexXXXX.tmp" in main.c (patch 811X covered by the -a option additions) 812X - some compilers don't like external names that are ambiguous within 813X the first 8 characters. I defined macros that change all these long 814X external names to names that are unique within the first 8 characters. 815X Just define SHORT_EXTERNAL_NAMES to use this feature (flexdef.h) 816X - some statement changes that some compiler don't like: 817X typedef *xxx[] -> typedef **xxx (flexdef.h.,l.308) 818X "/*" -> '/','*' within a comment in (scan.l, l.209) 819X - changed short "lexyy.c" to "lex_yy.c" what's more similar to the unix 820X "lex.yy.c" (main.c). 821X - a few further really compiler dependent changes provided with 822X #ifdef ATARI && LATTICE res. TURBO braces. 823X 824X - Additional TOS only files 825X - Makefile.tos: Common makefile for all TOS compilers. If you add further 826X ones please email me the new makefile. 827X - flex.lnk: Lattice - GST linker argument extension file 828X - flex.tlk: Turbo linker argument extension file 829X 830X 831XAdditional remarks: 832X 833XI didn't add a new initscan.c (= flex -ist scan.l). The current one is good 834Xenough for a first compilation. With this first version of flex you can 835Xrebuild your own scan.c and the final flex version ! 836X 837XMinix ST : 838X - I had to "chmem =70000 cv" (>50000) to get flex linked 839X - 'memset' (PC 1.3, EFTH40,...) is necessary 840X - chmem =90000 flex may be sufficient 841X 842XMinix PC : 843X It should be possible to port Flex to Minix PC. The current sizes of flex 844X are: 845X Minix ST (ACK) Lattice (TOS) Turbo (TOS) 846X 847X size 75300 83305 57957 848X compilation time 22' 15' 3'40" 849X flex -is scan.l 1'49" 43" 30" 850X 851X The Minix ST size includes the bad generated code using only a subset of 852X the 68000 commands, long addresses only and a huge relocation table. 853X Therefore the PC size will be <64 k ! More serious is the fact that I had 854X to chmem =90000 flex to get scan.l converted to scan.c . But I never saw 855X a more complex lex source than scan.l -- so it should be possible to 856X reduce some array sizes without limitation for all day usage. 857X 858X No one volunteered yet for a Minix PC port -- but if someone will try it 859X I would provide him with a new scan.c and some hints. 860X 861XTOS: 862X Don't forget to adapt the flexskel path within flexdef.h ! 863X 864X 865/ 866echo x - flex.lnk 867sed '/^X/s///' > flex.lnk << '/' 868X* 869X* 870X* linker control file for flex.ttp 871X* 872X* 873X* 874XINPUT d:\latt\lib\startup.bin 875X* 876XINPUT ccl.bin 877XINPUT dfa.bin 878XINPUT ecs.bin 879XINPUT gen.bin 880XINPUT misc.bin 881XINPUT nfa.bin 882XINPUT parse.bin 883XINPUT sym.bin 884XINPUT tblcmp.bin 885XINPUT main.bin 886XINPUT yylex.bin 887XINPUT scan.bin 888X* 889XLIBRARY d:\latt\lib\clib.bin 890X 891/ 892echo x - flex.tlk 893sed '/^X/s///' > flex.tlk << '/' 894Xccl.o 895Xdfa.o 896Xecs.o 897Xgen.o 898Xmisc.o 899Xnfa.o 900Xparse.o 901Xsym.o 902Xtblcmp.o 903Xyylex.o 904Xmain.o 905Xscan.o 906Xd:\turbo\lib\tcstdlib.lib ; standard lib 907Xd:\turbo\lib\tcextlib.lib ; extended lib 908Xd:\turbo\lib\tctoslib.lib ; TOS lib 909Xd:\turbo\lib\tcgemlib.lib ; AES and VDI lib 910X-S=200000 911/ 912