diff options
author | nate <nate@FreeBSD.org> | 1996-06-19 20:48:06 +0000 |
---|---|---|
committer | nate <nate@FreeBSD.org> | 1996-06-19 20:48:06 +0000 |
commit | d4f014461bc07fca54b2cd433609b621fc41de13 (patch) | |
tree | ae643c558fdb5902ac3cf1acf047d18715e1846d /usr.bin/lex/dfa.c | |
parent | 5ef1dc8eacedf7cc26d0872db31307f1bcc25fae (diff) | |
download | FreeBSD-src-d4f014461bc07fca54b2cd433609b621fc41de13.zip FreeBSD-src-d4f014461bc07fca54b2cd433609b621fc41de13.tar.gz |
Finish the import and merge in FreeBSD specific changes.
Add a 'bootstrap' target which *must* be run before building the new
version, since the new scanner relies on the current version of flex to
build itself otherwise.
Diffstat (limited to 'usr.bin/lex/dfa.c')
-rw-r--r-- | usr.bin/lex/dfa.c | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/usr.bin/lex/dfa.c b/usr.bin/lex/dfa.c index 83eb454..3647c2c 100644 --- a/usr.bin/lex/dfa.c +++ b/usr.bin/lex/dfa.c @@ -6,7 +6,7 @@ * * This code is derived from software contributed to Berkeley by * Vern Paxson. - * + * * The United States Government has rights in this work pursuant * to contract no. DE-AC03-76SF00098 between the United States * Department of Energy and the University of California. @@ -26,7 +26,7 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -/* $Header: /home/ncvs/src/usr.bin/lex/dfa.c,v 1.1.1.1 1994/08/24 13:10:33 csgr Exp $ */ +/* $Header: /home/ncvs/src/usr.bin/lex/dfa.c,v 1.1.1.2 1996/06/19 20:26:04 nate Exp $ */ #include "flexdef.h" @@ -60,7 +60,7 @@ int state[]; if ( backing_up_report ) { fprintf( backing_up_file, - "State #%d is non-accepting -\n", ds ); + _( "State #%d is non-accepting -\n" ), ds ); /* identify the state */ dump_associated_rules( backing_up_file, ds ); @@ -101,7 +101,7 @@ int state[]; void check_trailing_context( nfa_states, num_states, accset, nacc ) int *nfa_states, num_states; int *accset; -register int nacc; +int nacc; { register int i, j; @@ -127,7 +127,7 @@ register int nacc; if ( accset[j] & YY_TRAILING_HEAD_MASK ) { line_warning( - "dangerous trailing context", + _( "dangerous trailing context" ), rule_linenum[ar] ); return; } @@ -170,7 +170,7 @@ int ds; bubble( rule_set, num_associated_rules ); - fprintf( file, " associated rule line numbers:" ); + fprintf( file, _( " associated rule line numbers:" ) ); for ( i = 1; i <= num_associated_rules; ++i ) { @@ -208,7 +208,7 @@ int state[]; out_char_set[i] = state[ec]; } - fprintf( file, " out-transitions: " ); + fprintf( file, _( " out-transitions: " ) ); list_character_set( file, out_char_set ); @@ -216,7 +216,7 @@ int state[]; for ( i = 0; i < csize; ++i ) out_char_set[i] = ! out_char_set[i]; - fprintf( file, "\n jam-transitions: EOF " ); + fprintf( file, _( "\n jam-transitions: EOF " ) ); list_character_set( file, out_char_set ); @@ -250,7 +250,7 @@ int *t, *ns_addr, accset[], *nacc_addr, *hv_addr; register int stkpos, ns, tsp; int numstates = *ns_addr, nacc, hashval, transsym, nfaccnum; int stkend, nstate; - static int did_stk_init = false, *stk; + static int did_stk_init = false, *stk; #define MARK_STATE(state) \ trans1[state] = trans1[state] - MARKER_DIFFERENCE; @@ -352,7 +352,8 @@ ADD_STATE(state) \ if ( IS_MARKED(stk[stkpos]) ) UNMARK_STATE(stk[stkpos]) else - flexfatal( "consistency check failed in epsclosure()" ); + flexfatal( + _( "consistency check failed in epsclosure()" ) ); } *ns_addr = numstates; @@ -398,7 +399,7 @@ void ntod() int num_full_table_rows; /* used only for -f */ int *nset, *dset; int targptr, totaltrans, i, comstate, comfreq, targ; - int *epsclosure(), snstods(), symlist[CSIZE + 1]; + int symlist[CSIZE + 1]; int num_start_states; int todo_head, todo_next; @@ -435,7 +436,7 @@ void ntod() if ( trace ) { dumpnfa( scset[1] ); - fputs( "\n\nDFA Dump:\n\n", stderr ); + fputs( _( "\n\nDFA Dump:\n\n" ), stderr ); } inittbl(); @@ -510,7 +511,7 @@ void ntod() state[i] = 0; place_state( state, 0, 0 ); - dfaacc[i].dfaacc_state = 0; + dfaacc[0].dfaacc_state = 0; } else if ( fulltbl ) @@ -531,19 +532,18 @@ void ntod() /* Unless -Ca, declare it "short" because it's a real * long-shot that that won't be large enough. */ - printf( "static const %s yy_nxt[][%d] =\n {\n", + out_str_dec( "static yyconst %s yy_nxt[][%d] =\n {\n", /* '}' so vi doesn't get too confused */ long_align ? "long" : "short", num_full_table_rows ); + outn( " {" ); + /* Generate 0 entries for state #0. */ for ( i = 0; i < num_full_table_rows; ++i ) mk2data( 0 ); - /* Force ',' and dataflush() next call to mk2data().*/ - datapos = NUMDATAITEMS; - - /* Force extra blank line next dataflush(). */ - dataline = NUMDATALINES; + dataflush(); + outn( " },\n" ); } /* Create the first states. */ @@ -582,7 +582,7 @@ void ntod() { if ( ! snstods( nset, 0, accset, 0, 0, &end_of_buffer_state ) ) flexfatal( - "could not create unique end-of-buffer state" ); + _( "could not create unique end-of-buffer state" ) ); ++numas; ++num_start_states; @@ -603,7 +603,7 @@ void ntod() dsize = dfasiz[ds]; if ( trace ) - fprintf( stderr, "state # %d:\n", ds ); + fprintf( stderr, _( "state # %d:\n" ), ds ); sympartition( dset, dsize, symlist, duplist ); @@ -677,16 +677,26 @@ void ntod() } } - numsnpairs = numsnpairs + totaltrans; - if ( caseins && ! useecs ) { register int j; for ( i = 'A', j = 'a'; i <= 'Z'; ++i, ++j ) + { + if ( state[i] == 0 && state[j] != 0 ) + /* We're adding a transition. */ + ++totaltrans; + + else if ( state[i] != 0 && state[j] == 0 ) + /* We're taking away a transition. */ + --totaltrans; + state[i] = state[j]; + } } + numsnpairs += totaltrans; + if ( ds > num_start_states ) check_for_backing_up( ds, state ); @@ -698,6 +708,8 @@ void ntod() if ( fulltbl ) { + outn( " {" ); + /* Supply array's 0-element. */ if ( ds == end_of_buffer_state ) mk2data( -end_of_buffer_state ); @@ -710,11 +722,8 @@ void ntod() */ mk2data( state[i] ? state[i] : -ds ); - /* Force ',' and dataflush() next call to mk2data().*/ - datapos = NUMDATAITEMS; - - /* Force extra blank line next dataflush(). */ - dataline = NUMDATALINES; + dataflush(); + outn( " },\n" ); } else if ( fullspd ) @@ -977,7 +986,8 @@ int ds[], dsize, transsym, nset[]; } else if ( sym >= 'A' && sym <= 'Z' && caseins ) - flexfatal( "consistency check failed in symfollowset" ); + flexfatal( + _( "consistency check failed in symfollowset" ) ); else if ( sym == SYM_EPSILON ) { /* do nothing */ @@ -1030,7 +1040,7 @@ int symlist[], duplist[]; if ( tch < -lastccl || tch >= csize ) { flexfatal( - "bad transition character detected in sympartition()" ); + _( "bad transition character detected in sympartition()" ) ); } if ( tch >= 0 ) |