From: Vern Paxson Date: Tue, 20 Jun 1989 15:44:28 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: flex-2-5-5b~596 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d450ace2c484b7a70932e1423d2121a1d00f04f;p=flex *** empty log message *** --- diff --git a/NEWS b/NEWS index c382644..3915e75 100644 --- a/NEWS +++ b/NEWS @@ -1,17 +1,104 @@ -Changes between beta-test release of Feb. '88 and initial release: - - - many files renamed to remove "flex" prefix - - input() routine added to compressed and fast skeletons - - unput() routine added to compressed skeleton - - -d, -ce support for fast scanners - - symbol table extended to avoid ugly casts of ints <-> char *'s; - this may relieve MS-DOS woes - - actions are now separated with YY_BREAK instead of simple "break"'s - - fixed bug causing core-dumps if skeleton file could not be opened - - fixed bugs in logic deciding which options cannot be intermixed - - initial start condition can now be referred to as - - fixed bug which would incorrectly computer trailing context - count for a pattern like "(foo){3}"; now this is considered - "variable length", even though it isn't. - - block comments allowed between rules - - misc. typos corrected +Changes between beta-test release of June '88 and previous release: + + User-visible: + + - -p flag generates a performance report to stderr. The report + consists of comments regarding features of the scanner rules + which result in slower scanners. + + - -b flag generates backtracking information to lex.backtrack. + This is a list of scanner states which require backtracking + and the characters on which they do so. By adding rules + one can remove backtracking states. If all backtracking states + are eliminated, the generated scanner will run faster. + Backtracking is not yet documented in the manual entry. + + - Variable trailing context now works, i.e., one can have + rules like "(foo)*/[ \t]*bletch". Some trailing context + patterns still cannot be properly matched and generate + error messages. These are patterns where the ending of the + first part of the rule matches the beginning of the second + part, such as "zx*/xy*", where the 'x*' matches the 'x' at + the beginning of the trailing context. Lex won't get these + patterns right either. + + - Faster scanners. + + - End-of-file rules. The special rule "<>" indicates + actions which are to be taken when an end-of-file is + encountered and yywrap() returns non-zero (i.e., indicates + no further files to process). See manual entry for example. + + - The -r (reject used) flag is gone. flex now scans the input + for occurrences of the string "REJECT" to determine if the + action is needed. It tries to be intelligent about this but + can be fooled. One can force the presence or absence of + REJECT by adding a line in the first section of the form + "%used REJECT" or "%unused REJECT". + + - yymore() has been implemented. Similarly to REJECT, flex + detects the use of yymore(), which can be overridden using + "%used" or "%unused". + + - Patterns like "x{0,3}" now work (i.e., with lower-limit == 0). + + - Removed '\^x' for ctrl-x misfeature. + + - Added '\a' and '\v' escape sequences. + + - \ now works for octal escape sequences; previously + \0 was required. + + - Better error reporting; line numbers are associated with rules. + + - yyleng is a macro; it cannot be accessed outside of the + scanner source file. + + - yytext and yyleng should not be modified within a flex action. + + - Generated scanners #define the name FLEX_SCANNER. + + - Rules are internally separated by YY_BREAK in lex.yy.c rather + than break, to allow redefinition. + + - The macro YY_USER_ACTION can be redefined to provide an action + which is always executed prior to the matched rule's action. + + - yyrestart() is a new action which can be used to restart + the scanner after it has seen an end-of-file (a "real" one, + that is, one for which yywrap() returned non-zero). It takes + a FILE* argument indicating a new file to scan and sets + things up so that a subsequent call to yylex() will start + scanning that file. + + - Internal scanner names all preceded by "yy_" + + - lex.yy.c is deleted if errors are encountered during processing. + + - Comments may be put in the first section of the input by preceding + them with '#'. + + + + Other changes: + + - Some portability-related bugs fixed, in particular for machines + with unsigned characters or sizeof( int* ) != sizeof( int ). + Also, tweaks for VMS and Microsoft C (MS-DOS), and identifiers all + trimmed to be 31 or fewer characters. Shortened file names + for dinosaur OS's. Checks for allocating > 64K memory + on 16 bit'ers. Amiga tweaks. Compiles using gcc on a Sun-3. + + - Compressed and fast scanner skeletons merged. + + - Skeleton header files done away with. + + - Generated scanner uses prototypes and "const" for __STDC__. + + - -DSV flag is now -DSYS_V for System V compilation. + + - Removed all references to FTL language. + + - Software now covered by BSD Copyright. + + - flex will replace lex in subsequent BSD releases. diff --git a/main.c b/main.c index 063417d..14ccccf 100644 --- a/main.c +++ b/main.c @@ -39,12 +39,14 @@ static char rcsid[] = #include "flexdef.h" +static char flex_version[] = "2.0.1 (beta)"; + /* these globals are all defined and commented in flexdef.h */ int printstats, syntaxerror, eofseen, ddebug, trace, spprdflt; int interactive, caseins, useecs, fulltbl, usemecs; int fullspd, gen_line_dirs, performance_report, backtrack_report; -int yymore_used, reject, real_reject; +int yymore_used, reject, real_reject, continued_action; int yymore_really_used, reject_really_used; int datapos, dataline, linenum; FILE *skelfile = NULL; @@ -60,7 +62,8 @@ int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP]; int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE]; int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs, tecfwd[CSIZE + 1]; int tecbck[CSIZE + 1]; -int lastsc, current_max_scs, *scset, *scbol, *scxclu, *actvsc; +int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc; +char **scname; int current_max_dfa_size, current_max_xpairs; int current_max_template_xpairs, current_max_dfas; int lastdfa, *nxt, *chk, *tnxt; @@ -84,6 +87,13 @@ char action_file_name[] = "/tmp/flexXXXXXX"; char action_file_name[] = "flexXXXXXX.tmp"; #endif +#ifndef SHORT_FILE_NAMES +static char outfile[] = "lex.yy.c"; +#else +static char outfile[] = "lexyy.c"; +#endif +static int outfile_created = 0; + /* flex - main program * @@ -100,55 +110,59 @@ char **argv; readin(); - if ( ! syntaxerror ) - { - if ( yymore_really_used == REALLY_USED ) - yymore_used = true; - else if ( yymore_really_used == REALLY_NOT_USED ) - yymore_used = false; + if ( syntaxerror ) + flexend( 1 ); - if ( reject_really_used == REALLY_USED ) - reject = true; - else if ( reject_really_used == REALLY_NOT_USED ) - reject = false; + if ( yymore_really_used == REALLY_USED ) + yymore_used = true; + else if ( yymore_really_used == REALLY_NOT_USED ) + yymore_used = false; - if ( performance_report ) - { - if ( yymore_used ) - fprintf( stderr, - "yymore() entails a minor performance penalty\n" ); + if ( reject_really_used == REALLY_USED ) + reject = true; + else if ( reject_really_used == REALLY_NOT_USED ) + reject = false; - if ( reject ) - fprintf( stderr, - "REJECT entails a large performance penalty\n" ); + if ( performance_report ) + { + if ( yymore_used ) + fprintf( stderr, + "yymore() entails a minor performance penalty\n" ); - if ( variable_trailing_context_rules ) - fprintf( stderr, - "Variable trailing context rules entail a large performance penalty\n" ); - } + if ( interactive ) + fprintf( stderr, + "-I (interactive) entails a minor performance penalty\n" ); if ( reject ) - real_reject = true; + fprintf( stderr, + "REJECT entails a large performance penalty\n" ); if ( variable_trailing_context_rules ) - reject = true; + fprintf( stderr, +"Variable trailing context rules entail a large performance penalty\n" ); + } - if ( (fulltbl || fullspd) && reject ) - { - if ( real_reject ) - flexerror( "REJECT cannot be used with -f or -F" ); - else - flexerror( - "variable trailing context rules cannot be used with -f or -F" ); - } + if ( reject ) + real_reject = true; - /* convert the ndfa to a dfa */ - ntod(); + if ( variable_trailing_context_rules ) + reject = true; - /* generate the C state transition tables from the DFA */ - make_tables(); + if ( (fulltbl || fullspd) && reject ) + { + if ( real_reject ) + flexerror( "REJECT cannot be used with -f or -F" ); + else + flexerror( + "variable trailing context rules cannot be used with -f or -F" ); } + /* convert the ndfa to a dfa */ + ntod(); + + /* generate the C state transition tables from the DFA */ + make_tables(); + /* note, flexend does not return. It exits with its argument as status. */ flexend( 0 ); @@ -174,7 +188,7 @@ int status; { int tblsiz; - char *gettime(); + char *flex_gettime(); if ( skelfile != NULL ) (void) fclose( skelfile ); @@ -185,6 +199,12 @@ int status; (void) unlink( action_file_name ); } + if ( status != 0 && outfile_created ) + { + (void) fclose( stdout ); + (void) unlink( outfile ); + } + if ( backtrack_report ) { if ( num_backtracking == 0 ) @@ -201,9 +221,9 @@ int status; if ( printstats ) { - endtime = gettime(); + endtime = flex_gettime(); - fprintf( stderr, "flex usage statistics:\n" ); + fprintf( stderr, "flex version %s usage statistics:\n", flex_version ); fprintf( stderr, " started at %s, finished at %s\n", starttime, endtime ); @@ -251,12 +271,12 @@ int status; { tblsiz = 2 * (lastdfa + numtemps) + 2 * tblend; - fprintf( stderr, " %d/%d base/def entries created\n", + fprintf( stderr, " %d/%d base-def entries created\n", lastdfa + numtemps, current_max_dfas ); - fprintf( stderr, " %d/%d (peak %d) nxt/chk entries created\n", + fprintf( stderr, " %d/%d (peak %d) nxt-chk entries created\n", tblend, current_max_xpairs, peakpairs ); fprintf( stderr, - " %d/%d (peak %d) template nxt/chk entries created\n", + " %d/%d (peak %d) template nxt-chk entries created\n", numtemps * nummecs, current_max_template_xpairs, numtemps * numecs ); fprintf( stderr, " %d empty table entries\n", nummt ); @@ -307,11 +327,11 @@ char **argv; { int i, sawcmpflag, use_stdout; - char *arg, *skelname = NULL, *gettime(), clower(), *mktemp(); + char *arg, *skelname = NULL, *flex_gettime(), clower(), *mktemp(); printstats = syntaxerror = trace = spprdflt = interactive = caseins = false; backtrack_report = performance_report = ddebug = fulltbl = fullspd = false; - yymore_used = reject = false; + yymore_used = continued_action = reject = false; yymore_really_used = reject_really_used = false; gen_line_dirs = usemecs = useecs = true; @@ -453,14 +473,12 @@ get_next_arg: /* used by -c and -S flags in lieu of a "continue 2" control */ if ( ! use_stdout ) { -#ifndef SHORT_FILE_NAMES - FILE *prev_stdout = freopen( "lex.yy.c", "w", stdout ); -#else - FILE *prev_stdout = freopen( "lexyy.c", "w", stdout ); -#endif + FILE *prev_stdout = freopen( outfile, "w", stdout ); if ( prev_stdout == NULL ) flexerror( "could not create lex.yy.c" ); + + outfile_created = 1; } if ( argc ) @@ -497,7 +515,7 @@ get_next_arg: /* used by -c and -S flags in lieu of a "continue 2" control */ lastsc = 0; /* initialize the statistics */ - starttime = gettime(); + starttime = flex_gettime(); if ( (skelfile = fopen( skelname, "r" )) == NULL ) lerrsf( "can't open skeleton file %s", skelname ); @@ -611,6 +629,8 @@ set_up_initial_allocations() scset = allocate_integer_array( current_max_scs ); scbol = allocate_integer_array( current_max_scs ); scxclu = allocate_integer_array( current_max_scs ); + sceof = allocate_integer_array( current_max_scs ); + scname = allocate_char_ptr_array( current_max_scs ); actvsc = allocate_integer_array( current_max_scs ); current_maxccls = INITIAL_MAX_CCLS;