main.c (8874) | main.c (16519) |
---|---|
1/* flex - tool to generate fast lexical analyzers */ 2 3/*- 4 * Copyright (c) 1990 The Regents of the University of California. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Vern Paxson. --- 18 unchanged lines hidden (view full) --- 27 */ 28 29#ifndef lint 30char copyright[] = 31"@(#) Copyright (c) 1990 The Regents of the University of California.\n\ 32 All rights reserved.\n"; 33#endif /* not lint */ 34 | 1/* flex - tool to generate fast lexical analyzers */ 2 3/*- 4 * Copyright (c) 1990 The Regents of the University of California. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Vern Paxson. --- 18 unchanged lines hidden (view full) --- 27 */ 28 29#ifndef lint 30char copyright[] = 31"@(#) Copyright (c) 1990 The Regents of the University of California.\n\ 32 All rights reserved.\n"; 33#endif /* not lint */ 34 |
35/* $Header: /home/ncvs/src/usr.bin/lex/main.c,v 1.1.1.1 1994/08/24 13:10:32 csgr Exp $ */ | 35/* $Header: /home/ncvs/src/usr.bin/lex/main.c,v 1.1.1.2 1996/06/19 20:26:16 nate Exp $ */ |
36 37 38#include "flexdef.h" 39#include "version.h" 40 41static char flex_version[] = FLEX_VERSION; 42 43 44/* declare functions that have forward references */ 45 46void flexinit PROTO((int, char**)); 47void readin PROTO((void)); 48void set_up_initial_allocations PROTO((void)); 49 | 36 37 38#include "flexdef.h" 39#include "version.h" 40 41static char flex_version[] = FLEX_VERSION; 42 43 44/* declare functions that have forward references */ 45 46void flexinit PROTO((int, char**)); 47void readin PROTO((void)); 48void set_up_initial_allocations PROTO((void)); 49 |
50#ifdef NEED_ARGV_FIXUP 51extern void argv_fixup PROTO((int *, char ***)); 52#endif |
|
50 | 53 |
54 |
|
51/* these globals are all defined and commented in flexdef.h */ 52int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; | 55/* these globals are all defined and commented in flexdef.h */ 56int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; |
53int interactive, caseins, lex_compat, useecs, fulltbl, usemecs; | 57int interactive, caseins, lex_compat, do_yylineno, useecs, fulltbl, usemecs; |
54int fullspd, gen_line_dirs, performance_report, backing_up_report; | 58int fullspd, gen_line_dirs, performance_report, backing_up_report; |
55int C_plus_plus, long_align, use_read, yytext_is_array, csize; 56int yymore_used, reject, real_reject, continued_action; | 59int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap, csize; 60int yymore_used, reject, real_reject, continued_action, in_rule; |
57int yymore_really_used, reject_really_used; | 61int yymore_really_used, reject_really_used; |
58int datapos, dataline, linenum; | 62int datapos, dataline, linenum, out_linenum; |
59FILE *skelfile = NULL; 60int skel_ind = 0; 61char *action_array; 62int action_size, defs1_offset, prolog_offset, action_offset, action_index; | 63FILE *skelfile = NULL; 64int skel_ind = 0; 65char *action_array; 66int action_size, defs1_offset, prolog_offset, action_offset, action_index; |
63char *infilename = NULL; | 67char *infilename = NULL, *outfilename = NULL; 68int did_outfilename; 69char *prefix, *yyclass; 70int do_stdinit, use_stdout; |
64int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE]; 65int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; | 71int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE]; 72int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; |
66int current_mns, num_rules, num_eof_rules, default_rule; 67int current_max_rules, lastnfa; | 73int current_mns, current_max_rules; 74int num_rules, num_eof_rules, default_rule, lastnfa; |
68int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2; 69int *accptnum, *assoc_rule, *state_type; 70int *rule_type, *rule_linenum, *rule_useful; 71int current_state_type; 72int variable_trailing_context_rules; 73int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP]; 74int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE]; 75int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs, tecfwd[CSIZE + 1]; 76int tecbck[CSIZE + 1]; | 75int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2; 76int *accptnum, *assoc_rule, *state_type; 77int *rule_type, *rule_linenum, *rule_useful; 78int current_state_type; 79int variable_trailing_context_rules; 80int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP]; 81int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE]; 82int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs, tecfwd[CSIZE + 1]; 83int tecbck[CSIZE + 1]; |
77int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc; | 84int lastsc, *scset, *scbol, *scxclu, *sceof; 85int current_max_scs; |
78char **scname; 79int current_max_dfa_size, current_max_xpairs; 80int current_max_template_xpairs, current_max_dfas; 81int lastdfa, *nxt, *chk, *tnxt; 82int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz; 83union dfaacc_union *dfaacc; 84int *accsiz, *dhash, numas; 85int numsnpairs, jambase, jamstate; | 86char **scname; 87int current_max_dfa_size, current_max_xpairs; 88int current_max_template_xpairs, current_max_dfas; 89int lastdfa, *nxt, *chk, *tnxt; 90int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz; 91union dfaacc_union *dfaacc; 92int *accsiz, *dhash, numas; 93int numsnpairs, jambase, jamstate; |
86int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse; 87int current_max_ccl_tbl_size; | 94int lastccl, *cclmap, *ccllen, *cclng, cclreuse; 95int current_maxccls, current_max_ccl_tbl_size; |
88Char *ccltbl; 89char nmstr[MAXLINE]; 90int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; 91int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; 92int num_backing_up, bol_needed; 93FILE *backing_up_file; 94int end_of_buffer_state; 95char **input_files; 96int num_input_files; | 96Char *ccltbl; 97char nmstr[MAXLINE]; 98int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; 99int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; 100int num_backing_up, bol_needed; 101FILE *backing_up_file; 102int end_of_buffer_state; 103char **input_files; 104int num_input_files; |
97char *program_name; | |
98 | 105 |
106/* Make sure program_name is initialized so we don't crash if writing 107 * out an error message before getting the program name from argv[0]. 108 */ 109char *program_name = "flex"; 110 |
|
99#ifndef SHORT_FILE_NAMES 100static char *outfile_template = "lex.%s.%s"; | 111#ifndef SHORT_FILE_NAMES 112static char *outfile_template = "lex.%s.%s"; |
113static char *backing_name = "lex.backup"; |
|
101#else 102static char *outfile_template = "lex%s.%s"; | 114#else 115static char *outfile_template = "lex%s.%s"; |
116static char *backing_name = "lex.bck"; |
|
103#endif | 117#endif |
104static char outfile_path[64]; | |
105 | 118 |
119#ifdef THINK_C 120#include <console.h> 121#endif 122 123#ifdef MS_DOS 124extern unsigned _stklen = 16384; 125#endif 126 127static char outfile_path[MAXLINE]; |
|
106static int outfile_created = 0; | 128static int outfile_created = 0; |
107static int use_stdout; | |
108static char *skelname = NULL; | 129static char *skelname = NULL; |
109static char *prefix = "yy"; | |
110 111 112int main( argc, argv ) 113int argc; 114char **argv; 115 { 116 int i; 117 | 130 131 132int main( argc, argv ) 133int argc; 134char **argv; 135 { 136 int i; 137 |
138#ifdef THINK_C 139 argc = ccommand( &argv ); 140#endif 141#ifdef NEED_ARGV_FIXUP 142 argv_fixup( &argc, &argv ); 143#endif 144 |
|
118 flexinit( argc, argv ); 119 120 readin(); 121 122 ntod(); 123 124 for ( i = 1; i <= num_rules; ++i ) 125 if ( ! rule_useful[i] && i != default_rule ) | 145 flexinit( argc, argv ); 146 147 readin(); 148 149 ntod(); 150 151 for ( i = 1; i <= num_rules; ++i ) 152 if ( ! rule_useful[i] && i != default_rule ) |
126 line_warning( "rule cannot be matched", | 153 line_warning( _( "rule cannot be matched" ), |
127 rule_linenum[i] ); 128 129 if ( spprdflt && ! reject && rule_useful[default_rule] ) | 154 rule_linenum[i] ); 155 156 if ( spprdflt && ! reject && rule_useful[default_rule] ) |
130 line_warning( "-s option given but default rule can be matched", | 157 line_warning( 158 _( "-s option given but default rule can be matched" ), |
131 rule_linenum[default_rule] ); 132 133 /* Generate the C state transition tables from the DFA. */ 134 make_tables(); 135 136 /* Note, flexend does not return. It exits with its argument 137 * as status. 138 */ 139 flexend( 0 ); 140 141 return 0; /* keep compilers/lint happy */ 142 } 143 144 | 159 rule_linenum[default_rule] ); 160 161 /* Generate the C state transition tables from the DFA. */ 162 make_tables(); 163 164 /* Note, flexend does not return. It exits with its argument 165 * as status. 166 */ 167 flexend( 0 ); 168 169 return 0; /* keep compilers/lint happy */ 170 } 171 172 |
173/* check_options - check user-specified options */ 174 175void check_options() 176 { 177 int i; 178 179 if ( lex_compat ) 180 { 181 if ( C_plus_plus ) 182 flexerror( _( "Can't use -+ with -l option" ) ); 183 184 if ( fulltbl || fullspd ) 185 flexerror( _( "Can't use -f or -F with -l option" ) ); 186 187 /* Don't rely on detecting use of yymore() and REJECT, 188 * just assume they'll be used. 189 */ 190 yymore_really_used = reject_really_used = true; 191 192 yytext_is_array = true; 193 do_yylineno = true; 194 use_read = false; 195 } 196 197 if ( do_yylineno ) 198 /* This should really be "maintain_backup_tables = true" */ 199 reject_really_used = true; 200 201 if ( csize == unspecified ) 202 { 203 if ( (fulltbl || fullspd) && ! useecs ) 204 csize = DEFAULT_CSIZE; 205 else 206 csize = CSIZE; 207 } 208 209 if ( interactive == unspecified ) 210 { 211 if ( fulltbl || fullspd ) 212 interactive = false; 213 else 214 interactive = true; 215 } 216 217 if ( fulltbl || fullspd ) 218 { 219 if ( usemecs ) 220 flexerror( 221 _( "-Cf/-CF and -Cm don't make sense together" ) ); 222 223 if ( interactive ) 224 flexerror( _( "-Cf/-CF and -I are incompatible" ) ); 225 226 if ( lex_compat ) 227 flexerror( 228 _( "-Cf/-CF are incompatible with lex-compatibility mode" ) ); 229 230 if ( do_yylineno ) 231 flexerror( 232 _( "-Cf/-CF and %option yylineno are incompatible" ) ); 233 234 if ( fulltbl && fullspd ) 235 flexerror( _( "-Cf and -CF are mutually exclusive" ) ); 236 } 237 238 if ( C_plus_plus && fullspd ) 239 flexerror( _( "Can't use -+ with -CF option" ) ); 240 241 if ( C_plus_plus && yytext_is_array ) 242 { 243 warn( _( "%array incompatible with -+ option" ) ); 244 yytext_is_array = false; 245 } 246 247 if ( useecs ) 248 { /* Set up doubly-linked equivalence classes. */ 249 250 /* We loop all the way up to csize, since ecgroup[csize] is 251 * the position used for NUL characters. 252 */ 253 ecgroup[1] = NIL; 254 255 for ( i = 2; i <= csize; ++i ) 256 { 257 ecgroup[i] = i - 1; 258 nextecm[i - 1] = i; 259 } 260 261 nextecm[csize] = NIL; 262 } 263 264 else 265 { 266 /* Put everything in its own equivalence class. */ 267 for ( i = 1; i <= csize; ++i ) 268 { 269 ecgroup[i] = i; 270 nextecm[i] = BAD_SUBSCRIPT; /* to catch errors */ 271 } 272 } 273 274 if ( ! use_stdout ) 275 { 276 FILE *prev_stdout; 277 278 if ( ! did_outfilename ) 279 { 280 char *suffix; 281 282 if ( C_plus_plus ) 283 suffix = "cc"; 284 else 285 suffix = "c"; 286 287 sprintf( outfile_path, outfile_template, 288 prefix, suffix ); 289 290 outfilename = outfile_path; 291 } 292 293 prev_stdout = freopen( outfilename, "w", stdout ); 294 295 if ( prev_stdout == NULL ) 296 lerrsf( _( "could not create %s" ), outfilename ); 297 298 outfile_created = 1; 299 } 300 301 if ( skelname && (skelfile = fopen( skelname, "r" )) == NULL ) 302 lerrsf( _( "can't open skeleton file %s" ), skelname ); 303 304 if ( strcmp( prefix, "yy" ) ) 305 { 306#define GEN_PREFIX(name) out_str3( "#define yy%s %s%s\n", name, prefix, name ) 307 if ( C_plus_plus ) 308 GEN_PREFIX( "FlexLexer" ); 309 else 310 { 311 GEN_PREFIX( "_create_buffer" ); 312 GEN_PREFIX( "_delete_buffer" ); 313 GEN_PREFIX( "_scan_buffer" ); 314 GEN_PREFIX( "_scan_string" ); 315 GEN_PREFIX( "_scan_bytes" ); 316 GEN_PREFIX( "_flex_debug" ); 317 GEN_PREFIX( "_init_buffer" ); 318 GEN_PREFIX( "_flush_buffer" ); 319 GEN_PREFIX( "_load_buffer_state" ); 320 GEN_PREFIX( "_switch_to_buffer" ); 321 GEN_PREFIX( "in" ); 322 GEN_PREFIX( "leng" ); 323 GEN_PREFIX( "lex" ); 324 GEN_PREFIX( "out" ); 325 GEN_PREFIX( "restart" ); 326 GEN_PREFIX( "text" ); 327 328 if ( do_yylineno ) 329 GEN_PREFIX( "lineno" ); 330 } 331 332 if ( do_yywrap ) 333 GEN_PREFIX( "wrap" ); 334 335 outn( "" ); 336 } 337 338 if ( did_outfilename ) 339 line_directive_out( stdout, 0 ); 340 341 skelout(); 342 } 343 344 |
|
145/* flexend - terminate flex 146 * 147 * note 148 * This routine does not return. 149 */ 150 151void flexend( exit_status ) 152int exit_status; 153 154 { 155 int tblsiz; 156 int unlink(); 157 158 if ( skelfile != NULL ) 159 { 160 if ( ferror( skelfile ) ) | 345/* flexend - terminate flex 346 * 347 * note 348 * This routine does not return. 349 */ 350 351void flexend( exit_status ) 352int exit_status; 353 354 { 355 int tblsiz; 356 int unlink(); 357 358 if ( skelfile != NULL ) 359 { 360 if ( ferror( skelfile ) ) |
161 flexfatal( 162 "error occurred when reading skeleton file" ); | 361 lerrsf( _( "input error reading skeleton file %s" ), 362 skelname ); |
163 164 else if ( fclose( skelfile ) ) | 363 364 else if ( fclose( skelfile ) ) |
165 flexfatal( 166 "error occurred when closing skeleton file" ); | 365 lerrsf( _( "error closing skeleton file %s" ), 366 skelname ); |
167 } 168 169 if ( exit_status != 0 && outfile_created ) 170 { 171 if ( ferror( stdout ) ) | 367 } 368 369 if ( exit_status != 0 && outfile_created ) 370 { 371 if ( ferror( stdout ) ) |
172 flexfatal( "error occurred when writing output file" ); | 372 lerrsf( _( "error writing output file %s" ), 373 outfilename ); |
173 174 else if ( fclose( stdout ) ) | 374 375 else if ( fclose( stdout ) ) |
175 flexfatal( "error occurred when closing output file" ); | 376 lerrsf( _( "error closing output file %s" ), 377 outfilename ); |
176 | 378 |
177 else if ( unlink( outfile_path ) ) 178 flexfatal( "error occurred when deleting output file" ); | 379 else if ( unlink( outfilename ) ) 380 lerrsf( _( "error deleting output file %s" ), 381 outfilename ); |
179 } 180 181 if ( backing_up_report && backing_up_file ) 182 { 183 if ( num_backing_up == 0 ) | 382 } 383 384 if ( backing_up_report && backing_up_file ) 385 { 386 if ( num_backing_up == 0 ) |
184 fprintf( backing_up_file, "No backing up.\n" ); | 387 fprintf( backing_up_file, _( "No backing up.\n" ) ); |
185 else if ( fullspd || fulltbl ) 186 fprintf( backing_up_file, | 388 else if ( fullspd || fulltbl ) 389 fprintf( backing_up_file, |
187 "%d backing up (non-accepting) states.\n", | 390 _( "%d backing up (non-accepting) states.\n" ), |
188 num_backing_up ); 189 else 190 fprintf( backing_up_file, | 391 num_backing_up ); 392 else 393 fprintf( backing_up_file, |
191 "Compressed tables always back up.\n" ); | 394 _( "Compressed tables always back up.\n" ) ); |
192 193 if ( ferror( backing_up_file ) ) | 395 396 if ( ferror( backing_up_file ) ) |
194 flexfatal( "error occurred when writing backup file" ); | 397 lerrsf( _( "error writing backup file %s" ), 398 backing_name ); |
195 196 else if ( fclose( backing_up_file ) ) | 399 400 else if ( fclose( backing_up_file ) ) |
197 flexfatal( "error occurred when closing backup file" ); | 401 lerrsf( _( "error closing backup file %s" ), 402 backing_name ); |
198 } 199 200 if ( printstats ) 201 { | 403 } 404 405 if ( printstats ) 406 { |
202 fprintf( stderr, "%s version %s usage statistics:\n", | 407 fprintf( stderr, _( "%s version %s usage statistics:\n" ), |
203 program_name, flex_version ); 204 | 408 program_name, flex_version ); 409 |
205 fprintf( stderr, " scanner options: -" ); | 410 fprintf( stderr, _( " scanner options: -" ) ); |
206 207 if ( C_plus_plus ) 208 putc( '+', stderr ); 209 if ( backing_up_report ) 210 putc( 'b', stderr ); 211 if ( ddebug ) 212 putc( 'd', stderr ); 213 if ( caseins ) --- 7 unchanged lines hidden (view full) --- 221 if ( spprdflt ) 222 putc( 's', stderr ); 223 if ( use_stdout ) 224 putc( 't', stderr ); 225 if ( printstats ) 226 putc( 'v', stderr ); /* always true! */ 227 if ( nowarn ) 228 putc( 'w', stderr ); | 411 412 if ( C_plus_plus ) 413 putc( '+', stderr ); 414 if ( backing_up_report ) 415 putc( 'b', stderr ); 416 if ( ddebug ) 417 putc( 'd', stderr ); 418 if ( caseins ) --- 7 unchanged lines hidden (view full) --- 426 if ( spprdflt ) 427 putc( 's', stderr ); 428 if ( use_stdout ) 429 putc( 't', stderr ); 430 if ( printstats ) 431 putc( 'v', stderr ); /* always true! */ 432 if ( nowarn ) 433 putc( 'w', stderr ); |
229 if ( ! interactive ) | 434 if ( interactive == false ) |
230 putc( 'B', stderr ); | 435 putc( 'B', stderr ); |
231 if ( interactive ) | 436 if ( interactive == true ) |
232 putc( 'I', stderr ); 233 if ( ! gen_line_dirs ) 234 putc( 'L', stderr ); 235 if ( trace ) 236 putc( 'T', stderr ); | 437 putc( 'I', stderr ); 438 if ( ! gen_line_dirs ) 439 putc( 'L', stderr ); 440 if ( trace ) 441 putc( 'T', stderr ); |
442 443 if ( csize == unspecified ) 444 /* We encountered an error fairly early on, so csize 445 * never got specified. Define it now, to prevent 446 * bogus table sizes being written out below. 447 */ 448 csize = 256; 449 |
|
237 if ( csize == 128 ) 238 putc( '7', stderr ); 239 else 240 putc( '8', stderr ); 241 242 fprintf( stderr, " -C" ); 243 244 if ( long_align ) --- 4 unchanged lines hidden (view full) --- 249 putc( 'F', stderr ); 250 if ( useecs ) 251 putc( 'e', stderr ); 252 if ( usemecs ) 253 putc( 'm', stderr ); 254 if ( use_read ) 255 putc( 'r', stderr ); 256 | 450 if ( csize == 128 ) 451 putc( '7', stderr ); 452 else 453 putc( '8', stderr ); 454 455 fprintf( stderr, " -C" ); 456 457 if ( long_align ) --- 4 unchanged lines hidden (view full) --- 462 putc( 'F', stderr ); 463 if ( useecs ) 464 putc( 'e', stderr ); 465 if ( usemecs ) 466 putc( 'm', stderr ); 467 if ( use_read ) 468 putc( 'r', stderr ); 469 |
470 if ( did_outfilename ) 471 fprintf( stderr, " -o%s", outfilename ); 472 |
|
257 if ( skelname ) 258 fprintf( stderr, " -S%s", skelname ); 259 260 if ( strcmp( prefix, "yy" ) ) 261 fprintf( stderr, " -P%s", prefix ); 262 263 putc( '\n', stderr ); 264 | 473 if ( skelname ) 474 fprintf( stderr, " -S%s", skelname ); 475 476 if ( strcmp( prefix, "yy" ) ) 477 fprintf( stderr, " -P%s", prefix ); 478 479 putc( '\n', stderr ); 480 |
265 fprintf( stderr, " %d/%d NFA states\n", lastnfa, current_mns ); 266 fprintf( stderr, " %d/%d DFA states (%d words)\n", lastdfa, 267 current_max_dfas, totnst ); 268 fprintf( stderr, " %d rules\n", | 481 fprintf( stderr, _( " %d/%d NFA states\n" ), 482 lastnfa, current_mns ); 483 fprintf( stderr, _( " %d/%d DFA states (%d words)\n" ), 484 lastdfa, current_max_dfas, totnst ); 485 fprintf( stderr, _( " %d rules\n" ), |
269 num_rules + num_eof_rules - 1 /* - 1 for def. rule */ ); 270 271 if ( num_backing_up == 0 ) | 486 num_rules + num_eof_rules - 1 /* - 1 for def. rule */ ); 487 488 if ( num_backing_up == 0 ) |
272 fprintf( stderr, " No backing up\n" ); | 489 fprintf( stderr, _( " No backing up\n" ) ); |
273 else if ( fullspd || fulltbl ) 274 fprintf( stderr, | 490 else if ( fullspd || fulltbl ) 491 fprintf( stderr, |
275 " %d backing-up (non-accepting) states\n", | 492 _( " %d backing-up (non-accepting) states\n" ), |
276 num_backing_up ); 277 else 278 fprintf( stderr, | 493 num_backing_up ); 494 else 495 fprintf( stderr, |
279 " Compressed tables always back-up\n" ); | 496 _( " Compressed tables always back-up\n" ) ); |
280 281 if ( bol_needed ) 282 fprintf( stderr, | 497 498 if ( bol_needed ) 499 fprintf( stderr, |
283 " Beginning-of-line patterns used\n" ); | 500 _( " Beginning-of-line patterns used\n" ) ); |
284 | 501 |
285 fprintf( stderr, " %d/%d start conditions\n", lastsc, | 502 fprintf( stderr, _( " %d/%d start conditions\n" ), lastsc, |
286 current_max_scs ); 287 fprintf( stderr, | 503 current_max_scs ); 504 fprintf( stderr, |
288 " %d epsilon states, %d double epsilon states\n", | 505 _( " %d epsilon states, %d double epsilon states\n" ), |
289 numeps, eps2 ); 290 291 if ( lastccl == 0 ) | 506 numeps, eps2 ); 507 508 if ( lastccl == 0 ) |
292 fprintf( stderr, " no character classes\n" ); | 509 fprintf( stderr, _( " no character classes\n" ) ); |
293 else 294 fprintf( stderr, | 510 else 511 fprintf( stderr, |
295 " %d/%d character classes needed %d/%d words of storage, %d reused\n", | 512_( " %d/%d character classes needed %d/%d words of storage, %d reused\n" ), |
296 lastccl, current_maxccls, 297 cclmap[lastccl] + ccllen[lastccl], 298 current_max_ccl_tbl_size, cclreuse ); 299 | 513 lastccl, current_maxccls, 514 cclmap[lastccl] + ccllen[lastccl], 515 current_max_ccl_tbl_size, cclreuse ); 516 |
300 fprintf( stderr, " %d state/nextstate pairs created\n", | 517 fprintf( stderr, _( " %d state/nextstate pairs created\n" ), |
301 numsnpairs ); | 518 numsnpairs ); |
302 fprintf( stderr, " %d/%d unique/duplicate transitions\n", | 519 fprintf( stderr, _( " %d/%d unique/duplicate transitions\n" ), |
303 numuniq, numdup ); 304 305 if ( fulltbl ) 306 { 307 tblsiz = lastdfa * numecs; | 520 numuniq, numdup ); 521 522 if ( fulltbl ) 523 { 524 tblsiz = lastdfa * numecs; |
308 fprintf( stderr, " %d table entries\n", tblsiz ); | 525 fprintf( stderr, _( " %d table entries\n" ), tblsiz ); |
309 } 310 311 else 312 { 313 tblsiz = 2 * (lastdfa + numtemps) + 2 * tblend; 314 | 526 } 527 528 else 529 { 530 tblsiz = 2 * (lastdfa + numtemps) + 2 * tblend; 531 |
315 fprintf( stderr, " %d/%d base-def entries created\n", | 532 fprintf( stderr, 533 _( " %d/%d base-def entries created\n" ), |
316 lastdfa + numtemps, current_max_dfas ); 317 fprintf( stderr, | 534 lastdfa + numtemps, current_max_dfas ); 535 fprintf( stderr, |
318 " %d/%d (peak %d) nxt-chk entries created\n", | 536 _( " %d/%d (peak %d) nxt-chk entries created\n" ), |
319 tblend, current_max_xpairs, peakpairs ); 320 fprintf( stderr, | 537 tblend, current_max_xpairs, peakpairs ); 538 fprintf( stderr, |
321 " %d/%d (peak %d) template nxt-chk entries created\n", 322 numtemps * nummecs, current_max_template_xpairs, | 539 _( " %d/%d (peak %d) template nxt-chk entries created\n" ), 540 numtemps * nummecs, 541 current_max_template_xpairs, |
323 numtemps * numecs ); | 542 numtemps * numecs ); |
324 fprintf( stderr, " %d empty table entries\n", nummt ); 325 fprintf( stderr, " %d protos created\n", numprots ); 326 fprintf( stderr, " %d templates created, %d uses\n", | 543 fprintf( stderr, _( " %d empty table entries\n" ), 544 nummt ); 545 fprintf( stderr, _( " %d protos created\n" ), 546 numprots ); 547 fprintf( stderr, 548 _( " %d templates created, %d uses\n" ), |
327 numtemps, tmpuses ); 328 } 329 330 if ( useecs ) 331 { 332 tblsiz = tblsiz + csize; 333 fprintf( stderr, | 549 numtemps, tmpuses ); 550 } 551 552 if ( useecs ) 553 { 554 tblsiz = tblsiz + csize; 555 fprintf( stderr, |
334 " %d/%d equivalence classes created\n", | 556 _( " %d/%d equivalence classes created\n" ), |
335 numecs, csize ); 336 } 337 338 if ( usemecs ) 339 { 340 tblsiz = tblsiz + numecs; 341 fprintf( stderr, | 557 numecs, csize ); 558 } 559 560 if ( usemecs ) 561 { 562 tblsiz = tblsiz + numecs; 563 fprintf( stderr, |
342 " %d/%d meta-equivalence classes created\n", | 564 _( " %d/%d meta-equivalence classes created\n" ), |
343 nummecs, csize ); 344 } 345 346 fprintf( stderr, | 565 nummecs, csize ); 566 } 567 568 fprintf( stderr, |
347 " %d (%d saved) hash collisions, %d DFAs equal\n", | 569 _( " %d (%d saved) hash collisions, %d DFAs equal\n" ), |
348 hshcol, hshsave, dfaeql ); | 570 hshcol, hshsave, dfaeql ); |
349 fprintf( stderr, " %d sets of reallocations needed\n", | 571 fprintf( stderr, _( " %d sets of reallocations needed\n" ), |
350 num_reallocs ); | 572 num_reallocs ); |
351 fprintf( stderr, " %d total table entries needed\n", tblsiz ); | 573 fprintf( stderr, _( " %d total table entries needed\n" ), 574 tblsiz ); |
352 } 353 | 575 } 576 |
354#ifndef VMS | |
355 exit( exit_status ); | 577 exit( exit_status ); |
356#else 357 exit( exit_status + 1 ); 358#endif | |
359 } 360 361 362/* flexinit - initialize flex */ 363 364void flexinit( argc, argv ) 365int argc; 366char **argv; 367 { 368 int i, sawcmpflag; | 578 } 579 580 581/* flexinit - initialize flex */ 582 583void flexinit( argc, argv ) 584int argc; 585char **argv; 586 { 587 int i, sawcmpflag; |
369 int csize_given, interactive_given; 370 char *arg, *mktemp(); | 588 char *arg; |
371 372 printstats = syntaxerror = trace = spprdflt = caseins = false; | 589 590 printstats = syntaxerror = trace = spprdflt = caseins = false; |
373 lex_compat = false; 374 C_plus_plus = backing_up_report = ddebug = fulltbl = fullspd = false; 375 long_align = nowarn = yymore_used = continued_action = reject = false; 376 yytext_is_array = yymore_really_used = reject_really_used = false; 377 gen_line_dirs = usemecs = useecs = true; | 591 lex_compat = C_plus_plus = backing_up_report = ddebug = fulltbl = false; 592 fullspd = long_align = nowarn = yymore_used = continued_action = false; 593 do_yylineno = yytext_is_array = in_rule = reject = do_stdinit = false; 594 yymore_really_used = reject_really_used = unspecified; 595 interactive = csize = unspecified; 596 do_yywrap = gen_line_dirs = usemecs = useecs = true; |
378 performance_report = 0; | 597 performance_report = 0; |
598 did_outfilename = 0; 599 prefix = "yy"; 600 yyclass = 0; 601 use_read = use_stdout = false; |
|
379 380 sawcmpflag = false; | 602 603 sawcmpflag = false; |
381 use_read = use_stdout = false; 382 csize_given = false; 383 interactive_given = false; | |
384 385 /* Initialize dynamic array for holding the rule actions. */ 386 action_size = 2048; /* default size of action array in bytes */ 387 action_array = allocate_character_array( action_size ); 388 defs1_offset = prolog_offset = action_offset = action_index = 0; 389 action_array[0] = '\0'; 390 391 program_name = argv[0]; 392 393 if ( program_name[0] != '\0' && 394 program_name[strlen( program_name ) - 1] == '+' ) 395 C_plus_plus = true; 396 397 /* read flags */ 398 for ( --argc, ++argv; argc ; --argc, ++argv ) 399 { | 604 605 /* Initialize dynamic array for holding the rule actions. */ 606 action_size = 2048; /* default size of action array in bytes */ 607 action_array = allocate_character_array( action_size ); 608 defs1_offset = prolog_offset = action_offset = action_index = 0; 609 action_array[0] = '\0'; 610 611 program_name = argv[0]; 612 613 if ( program_name[0] != '\0' && 614 program_name[strlen( program_name ) - 1] == '+' ) 615 C_plus_plus = true; 616 617 /* read flags */ 618 for ( --argc, ++argv; argc ; --argc, ++argv ) 619 { |
400 if ( argv[0][0] != '-' || argv[0][1] == '\0' ) | 620 arg = argv[0]; 621 622 if ( arg[0] != '-' || arg[1] == '\0' ) |
401 break; 402 | 623 break; 624 |
403 arg = argv[0]; | 625 if ( arg[1] == '-' ) 626 { /* --option */ 627 if ( ! strcmp( arg, "--help" ) ) 628 arg = "-h"; |
404 | 629 |
630 else if ( ! strcmp( arg, "--version" ) ) 631 arg = "-V"; 632 633 else if ( ! strcmp( arg, "--" ) ) 634 { /* end of options */ 635 --argc; 636 ++argv; 637 break; 638 } 639 } 640 |
|
405 for ( i = 1; arg[i] != '\0'; ++i ) 406 switch ( arg[i] ) 407 { 408 case '+': 409 C_plus_plus = true; 410 break; 411 412 case 'B': 413 interactive = false; | 641 for ( i = 1; arg[i] != '\0'; ++i ) 642 switch ( arg[i] ) 643 { 644 case '+': 645 C_plus_plus = true; 646 break; 647 648 case 'B': 649 interactive = false; |
414 interactive_given = true; | |
415 break; 416 417 case 'b': 418 backing_up_report = true; 419 break; 420 421 case 'c': | 650 break; 651 652 case 'b': 653 backing_up_report = true; 654 break; 655 656 case 'c': |
422 fprintf( stderr, 423 "%s: Assuming use of deprecated -c flag is really intended to be -C\n", 424 program_name ); | 657 break; |
425 | 658 |
426 /* fall through */ 427 | |
428 case 'C': 429 if ( i != 1 ) 430 flexerror( | 659 case 'C': 660 if ( i != 1 ) 661 flexerror( |
431 "-C flag must be given separately" ); | 662 _( "-C flag must be given separately" ) ); |
432 433 if ( ! sawcmpflag ) 434 { 435 useecs = false; 436 usemecs = false; 437 fulltbl = false; 438 sawcmpflag = true; 439 } --- 23 unchanged lines hidden (view full) --- 463 break; 464 465 case 'r': 466 use_read = true; 467 break; 468 469 default: 470 lerrif( | 663 664 if ( ! sawcmpflag ) 665 { 666 useecs = false; 667 usemecs = false; 668 fulltbl = false; 669 sawcmpflag = true; 670 } --- 23 unchanged lines hidden (view full) --- 694 break; 695 696 case 'r': 697 use_read = true; 698 break; 699 700 default: 701 lerrif( |
471 "unknown -C option '%c'", | 702 _( "unknown -C option '%c'" ), |
472 (int) arg[i] ); 473 break; 474 } 475 476 goto get_next_arg; 477 478 case 'd': 479 ddebug = true; --- 4 unchanged lines hidden (view full) --- 484 use_read = fulltbl = true; 485 break; 486 487 case 'F': 488 useecs = usemecs = false; 489 use_read = fullspd = true; 490 break; 491 | 703 (int) arg[i] ); 704 break; 705 } 706 707 goto get_next_arg; 708 709 case 'd': 710 ddebug = true; --- 4 unchanged lines hidden (view full) --- 715 use_read = fulltbl = true; 716 break; 717 718 case 'F': 719 useecs = usemecs = false; 720 use_read = fullspd = true; 721 break; 722 |
723 case '?': |
|
492 case 'h': 493 usage(); 494 exit( 0 ); 495 496 case 'I': 497 interactive = true; | 724 case 'h': 725 usage(); 726 exit( 0 ); 727 728 case 'I': 729 interactive = true; |
498 interactive_given = true; | |
499 break; 500 501 case 'i': 502 caseins = true; 503 break; 504 505 case 'l': 506 lex_compat = true; --- 4 unchanged lines hidden (view full) --- 511 break; 512 513 case 'n': 514 /* Stupid do-nothing deprecated 515 * option. 516 */ 517 break; 518 | 730 break; 731 732 case 'i': 733 caseins = true; 734 break; 735 736 case 'l': 737 lex_compat = true; --- 4 unchanged lines hidden (view full) --- 742 break; 743 744 case 'n': 745 /* Stupid do-nothing deprecated 746 * option. 747 */ 748 break; 749 |
750 case 'o': 751 if ( i != 1 ) 752 flexerror( 753 _( "-o flag must be given separately" ) ); 754 755 outfilename = arg + i + 1; 756 did_outfilename = 1; 757 goto get_next_arg; 758 |
|
519 case 'P': 520 if ( i != 1 ) 521 flexerror( | 759 case 'P': 760 if ( i != 1 ) 761 flexerror( |
522 "-P flag must be given separately" ); | 762 _( "-P flag must be given separately" ) ); |
523 524 prefix = arg + i + 1; 525 goto get_next_arg; 526 527 case 'p': 528 ++performance_report; 529 break; 530 531 case 'S': 532 if ( i != 1 ) 533 flexerror( | 763 764 prefix = arg + i + 1; 765 goto get_next_arg; 766 767 case 'p': 768 ++performance_report; 769 break; 770 771 case 'S': 772 if ( i != 1 ) 773 flexerror( |
534 "-S flag must be given separately" ); | 774 _( "-S flag must be given separately" ) ); |
535 536 skelname = arg + i + 1; 537 goto get_next_arg; 538 539 case 's': 540 spprdflt = true; 541 break; 542 --- 5 unchanged lines hidden (view full) --- 548 trace = true; 549 break; 550 551 case 'v': 552 printstats = true; 553 break; 554 555 case 'V': | 775 776 skelname = arg + i + 1; 777 goto get_next_arg; 778 779 case 's': 780 spprdflt = true; 781 break; 782 --- 5 unchanged lines hidden (view full) --- 788 trace = true; 789 break; 790 791 case 'v': 792 printstats = true; 793 break; 794 795 case 'V': |
556 fprintf( stderr, "%s version %s\n", | 796 printf( _( "%s version %s\n" ), |
557 program_name, flex_version ); 558 exit( 0 ); 559 560 case 'w': 561 nowarn = true; 562 break; 563 564 case '7': 565 csize = 128; | 797 program_name, flex_version ); 798 exit( 0 ); 799 800 case 'w': 801 nowarn = true; 802 break; 803 804 case '7': 805 csize = 128; |
566 csize_given = true; | |
567 break; 568 569 case '8': 570 csize = CSIZE; | 806 break; 807 808 case '8': 809 csize = CSIZE; |
571 csize_given = true; | |
572 break; 573 574 default: 575 fprintf( stderr, | 810 break; 811 812 default: 813 fprintf( stderr, |
576 "%s: unknown flag '%c'\n", 577 program_name, (int) arg[i] ); 578 usage(); | 814 _( "%s: unknown flag '%c'. For usage, try\n\t%s --help\n" ), 815 program_name, (int) arg[i], 816 program_name ); |
579 exit( 1 ); 580 } 581 | 817 exit( 1 ); 818 } 819 |
582 /* Used by -C, -S and -P flags in lieu of a "continue 2" | 820 /* Used by -C, -S, -o, and -P flags in lieu of a "continue 2" |
583 * control. 584 */ 585 get_next_arg: ; 586 } 587 | 821 * control. 822 */ 823 get_next_arg: ; 824 } 825 |
588 if ( ! csize_given ) 589 { 590 if ( (fulltbl || fullspd) && ! useecs ) 591 csize = DEFAULT_CSIZE; 592 else 593 csize = CSIZE; 594 } 595 596 if ( ! interactive_given ) 597 { 598 if ( fulltbl || fullspd ) 599 interactive = false; 600 else 601 interactive = true; 602 } 603 604 if ( lex_compat ) 605 { 606 if ( C_plus_plus ) 607 flexerror( "Can't use -+ with -l option" ); 608 609 if ( fulltbl || fullspd ) 610 flexerror( "Can't use -f or -F with -l option" ); 611 612 /* Don't rely on detecting use of yymore() and REJECT, 613 * just assume they'll be used. 614 */ 615 yymore_really_used = reject_really_used = true; 616 617 yytext_is_array = true; 618 use_read = false; 619 } 620 621 if ( (fulltbl || fullspd) && usemecs ) 622 flexerror( "-Cf/-CF and -Cm don't make sense together" ); 623 624 if ( (fulltbl || fullspd) && interactive ) 625 flexerror( "-Cf/-CF and -I are incompatible" ); 626 627 if ( fulltbl && fullspd ) 628 flexerror( "-Cf and -CF are mutually exclusive" ); 629 630 if ( C_plus_plus && fullspd ) 631 flexerror( "Can't use -+ with -CF option" ); 632 633 if ( ! use_stdout ) 634 { 635 FILE *prev_stdout; 636 char *suffix; 637 638 if ( C_plus_plus ) 639 suffix = "cc"; 640 else 641 suffix = "c"; 642 643 sprintf( outfile_path, outfile_template, prefix, suffix ); 644 645 prev_stdout = freopen( outfile_path, "w", stdout ); 646 647 if ( prev_stdout == NULL ) 648 lerrsf( "could not create %s", outfile_path ); 649 650 outfile_created = 1; 651 } 652 | |
653 num_input_files = argc; 654 input_files = argv; 655 set_input_file( num_input_files > 0 ? input_files[0] : NULL ); 656 | 826 num_input_files = argc; 827 input_files = argv; 828 set_input_file( num_input_files > 0 ? input_files[0] : NULL ); 829 |
657 if ( backing_up_report ) 658 { 659#ifndef SHORT_FILE_NAMES 660 backing_up_file = fopen( "lex.backup", "w" ); 661#else 662 backing_up_file = fopen( "lex.bck", "w" ); 663#endif 664 665 if ( backing_up_file == NULL ) 666 flexerror( "could not create lex.backup" ); 667 } 668 669 else 670 backing_up_file = NULL; 671 672 673 lastccl = 0; 674 lastsc = 0; 675 676 if ( skelname && (skelfile = fopen( skelname, "r" )) == NULL ) 677 lerrsf( "can't open skeleton file %s", skelname ); 678 679 if ( strcmp( prefix, "yy" ) ) 680 { 681#define GEN_PREFIX(name) printf( "#define yy%s %s%s\n", name, prefix, name ); 682 GEN_PREFIX( "FlexLexer" ); 683 GEN_PREFIX( "_create_buffer" ); 684 GEN_PREFIX( "_delete_buffer" ); 685 GEN_PREFIX( "_flex_debug" ); 686 GEN_PREFIX( "_init_buffer" ); 687 GEN_PREFIX( "_load_buffer_state" ); 688 GEN_PREFIX( "_switch_to_buffer" ); 689 GEN_PREFIX( "in" ); 690 GEN_PREFIX( "leng" ); 691 GEN_PREFIX( "lex" ); 692 GEN_PREFIX( "out" ); 693 GEN_PREFIX( "restart" ); 694 GEN_PREFIX( "text" ); 695 GEN_PREFIX( "wrap" ); 696 printf( "\n" ); 697 } 698 699 700 lastdfa = lastnfa = 0; | 830 lastccl = lastsc = lastdfa = lastnfa = 0; |
701 num_rules = num_eof_rules = default_rule = 0; 702 numas = numsnpairs = tmpuses = 0; 703 numecs = numeps = eps2 = num_reallocs = hshcol = dfaeql = totnst = 0; 704 numuniq = numdup = hshsave = eofseen = datapos = dataline = 0; 705 num_backing_up = onesp = numprots = 0; 706 variable_trailing_context_rules = bol_needed = false; 707 | 831 num_rules = num_eof_rules = default_rule = 0; 832 numas = numsnpairs = tmpuses = 0; 833 numecs = numeps = eps2 = num_reallocs = hshcol = dfaeql = totnst = 0; 834 numuniq = numdup = hshsave = eofseen = datapos = dataline = 0; 835 num_backing_up = onesp = numprots = 0; 836 variable_trailing_context_rules = bol_needed = false; 837 |
708 linenum = sectnum = 1; | 838 out_linenum = linenum = sectnum = 1; |
709 firstprot = NIL; 710 711 /* Used in mkprot() so that the first proto goes in slot 1 712 * of the proto queue. 713 */ 714 lastprot = 1; 715 | 839 firstprot = NIL; 840 841 /* Used in mkprot() so that the first proto goes in slot 1 842 * of the proto queue. 843 */ 844 lastprot = 1; 845 |
716 if ( useecs ) 717 { 718 /* Set up doubly-linked equivalence classes. */ 719 720 /* We loop all the way up to csize, since ecgroup[csize] is 721 * the position used for NUL characters. 722 */ 723 ecgroup[1] = NIL; 724 725 for ( i = 2; i <= csize; ++i ) 726 { 727 ecgroup[i] = i - 1; 728 nextecm[i - 1] = i; 729 } 730 731 nextecm[csize] = NIL; 732 } 733 734 else 735 { 736 /* Put everything in its own equivalence class. */ 737 for ( i = 1; i <= csize; ++i ) 738 { 739 ecgroup[i] = i; 740 nextecm[i] = BAD_SUBSCRIPT; /* to catch errors */ 741 } 742 } 743 | |
744 set_up_initial_allocations(); 745 } 746 747 748/* readin - read in the rules section of the input file(s) */ 749 750void readin() 751 { | 846 set_up_initial_allocations(); 847 } 848 849 850/* readin - read in the rules section of the input file(s) */ 851 852void readin() 853 { |
752 skelout(); | 854 static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; 855 static char yy_nostdinit[] = 856 "FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;"; |
753 | 857 |
754 line_directive_out( (FILE *) 0 ); | 858 line_directive_out( (FILE *) 0, 1 ); |
755 756 if ( yyparse() ) 757 { | 859 860 if ( yyparse() ) 861 { |
758 pinpoint_message( "fatal parse error" ); | 862 pinpoint_message( _( "fatal parse error" ) ); |
759 flexend( 1 ); 760 } 761 762 if ( syntaxerror ) 763 flexend( 1 ); 764 | 863 flexend( 1 ); 864 } 865 866 if ( syntaxerror ) 867 flexend( 1 ); 868 |
765 if ( yymore_really_used == REALLY_USED ) | 869 if ( backing_up_report ) 870 { 871 backing_up_file = fopen( backing_name, "w" ); 872 if ( backing_up_file == NULL ) 873 lerrsf( 874 _( "could not create backing-up info file %s" ), 875 backing_name ); 876 } 877 878 else 879 backing_up_file = NULL; 880 881 if ( yymore_really_used == true ) |
766 yymore_used = true; | 882 yymore_used = true; |
767 else if ( yymore_really_used == REALLY_NOT_USED ) | 883 else if ( yymore_really_used == false ) |
768 yymore_used = false; 769 | 884 yymore_used = false; 885 |
770 if ( reject_really_used == REALLY_USED ) | 886 if ( reject_really_used == true ) |
771 reject = true; | 887 reject = true; |
772 else if ( reject_really_used == REALLY_NOT_USED ) | 888 else if ( reject_really_used == false ) |
773 reject = false; 774 775 if ( performance_report > 0 ) 776 { 777 if ( lex_compat ) 778 { 779 fprintf( stderr, | 889 reject = false; 890 891 if ( performance_report > 0 ) 892 { 893 if ( lex_compat ) 894 { 895 fprintf( stderr, |
780"-l AT&T lex compatibility option entails a large performance penalty\n" ); | 896_( "-l AT&T lex compatibility option entails a large performance penalty\n" ) ); |
781 fprintf( stderr, | 897 fprintf( stderr, |
782" and may be the actual source of other reported performance penalties\n" ); | 898_( " and may be the actual source of other reported performance penalties\n" ) ); |
783 } 784 | 899 } 900 |
901 else if ( do_yylineno ) 902 { 903 fprintf( stderr, 904 _( "%%option yylineno entails a large performance penalty\n" ) ); 905 } 906 |
|
785 if ( performance_report > 1 ) 786 { 787 if ( interactive ) 788 fprintf( stderr, | 907 if ( performance_report > 1 ) 908 { 909 if ( interactive ) 910 fprintf( stderr, |
789 "-I (interactive) entails a minor performance penalty\n" ); | 911 _( "-I (interactive) entails a minor performance penalty\n" ) ); |
790 791 if ( yymore_used ) 792 fprintf( stderr, | 912 913 if ( yymore_used ) 914 fprintf( stderr, |
793 "yymore() entails a minor performance penalty\n" ); | 915 _( "yymore() entails a minor performance penalty\n" ) ); |
794 } 795 796 if ( reject ) 797 fprintf( stderr, | 916 } 917 918 if ( reject ) 919 fprintf( stderr, |
798 "REJECT entails a large performance penalty\n" ); | 920 _( "REJECT entails a large performance penalty\n" ) ); |
799 800 if ( variable_trailing_context_rules ) 801 fprintf( stderr, | 921 922 if ( variable_trailing_context_rules ) 923 fprintf( stderr, |
802"Variable trailing context rules entail a large performance penalty\n" ); | 924_( "Variable trailing context rules entail a large performance penalty\n" ) ); |
803 } 804 805 if ( reject ) 806 real_reject = true; 807 808 if ( variable_trailing_context_rules ) 809 reject = true; 810 811 if ( (fulltbl || fullspd) && reject ) 812 { 813 if ( real_reject ) | 925 } 926 927 if ( reject ) 928 real_reject = true; 929 930 if ( variable_trailing_context_rules ) 931 reject = true; 932 933 if ( (fulltbl || fullspd) && reject ) 934 { 935 if ( real_reject ) |
814 flexerror( "REJECT cannot be used with -f or -F" ); | 936 flexerror( 937 _( "REJECT cannot be used with -f or -F" ) ); 938 else if ( do_yylineno ) 939 flexerror( 940 _( "%option yylineno cannot be used with -f or -F" ) ); |
815 else 816 flexerror( | 941 else 942 flexerror( |
817 "variable trailing context rules cannot be used with -f or -F" ); | 943 _( "variable trailing context rules cannot be used with -f or -F" ) ); |
818 } 819 | 944 } 945 |
946 if ( reject ) 947 outn( "\n#define YY_USES_REJECT" ); 948 949 if ( ! do_yywrap ) 950 { 951 outn( "\n#define yywrap() 1" ); 952 outn( "#define YY_SKIP_YYWRAP" ); 953 } 954 955 if ( ddebug ) 956 outn( "\n#define FLEX_DEBUG" ); 957 |
|
820 if ( csize == 256 ) | 958 if ( csize == 256 ) |
821 puts( "typedef unsigned char YY_CHAR;" ); | 959 outn( "typedef unsigned char YY_CHAR;" ); |
822 else | 960 else |
823 puts( "typedef char YY_CHAR;" ); | 961 outn( "typedef char YY_CHAR;" ); |
824 825 if ( C_plus_plus ) 826 { | 962 963 if ( C_plus_plus ) 964 { |
827 puts( "#define yytext_ptr yytext" ); | 965 outn( "#define yytext_ptr yytext" ); |
828 829 if ( interactive ) | 966 967 if ( interactive ) |
830 puts( "#define YY_INTERACTIVE" ); | 968 outn( "#define YY_INTERACTIVE" ); |
831 } 832 | 969 } 970 |
971 else 972 { 973 if ( do_stdinit ) 974 { 975 outn( "#ifdef VMS" ); 976 outn( "#ifndef __VMS_POSIX" ); 977 outn( yy_nostdinit ); 978 outn( "#else" ); 979 outn( yy_stdinit ); 980 outn( "#endif" ); 981 outn( "#else" ); 982 outn( yy_stdinit ); 983 outn( "#endif" ); 984 } 985 986 else 987 outn( yy_nostdinit ); 988 } 989 |
|
833 if ( fullspd ) | 990 if ( fullspd ) |
834 printf( 835 "typedef const struct yy_trans_info *yy_state_type;\n" ); | 991 outn( "typedef yyconst struct yy_trans_info *yy_state_type;" ); |
836 else if ( ! C_plus_plus ) | 992 else if ( ! C_plus_plus ) |
837 printf( "typedef int yy_state_type;\n" ); | 993 outn( "typedef int yy_state_type;" ); |
838 | 994 |
839 if ( reject ) 840 printf( "\n#define YY_USES_REJECT\n" ); 841 | |
842 if ( ddebug ) | 995 if ( ddebug ) |
843 puts( "\n#define FLEX_DEBUG" ); | 996 outn( "\n#define FLEX_DEBUG" ); |
844 845 if ( lex_compat ) | 997 998 if ( lex_compat ) |
999 outn( "#define YY_FLEX_LEX_COMPAT" ); 1000 1001 if ( do_yylineno && ! C_plus_plus ) |
|
846 { | 1002 { |
847 printf( "FILE *yyin = stdin, *yyout = stdout;\n" ); 848 printf( "extern int yylineno;\n" ); 849 printf( "int yylineno = 1;\n" ); | 1003 outn( "extern int yylineno;" ); 1004 outn( "int yylineno = 1;" ); |
850 } | 1005 } |
851 else if ( ! C_plus_plus ) 852 printf( "FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;\n" ); | |
853 854 if ( C_plus_plus ) | 1006 1007 if ( C_plus_plus ) |
855 printf( "\n#include <FlexLexer.h>\n" ); | 1008 { 1009 outn( "\n#include <FlexLexer.h>" ); |
856 | 1010 |
1011 if ( yyclass ) 1012 { 1013 outn( "int yyFlexLexer::yylex()" ); 1014 outn( "\t{" ); 1015 outn( 1016"\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );" ); 1017 outn( "\treturn 0;" ); 1018 outn( "\t}" ); 1019 1020 out_str( "\n#define YY_DECL int %s::yylex()\n", 1021 yyclass ); 1022 } 1023 } 1024 |
|
857 else 858 { 859 if ( yytext_is_array ) | 1025 else 1026 { 1027 if ( yytext_is_array ) |
860 puts( "extern char yytext[];\n" ); | 1028 outn( "extern char yytext[];\n" ); |
861 862 else 863 { | 1029 1030 else 1031 { |
864 puts( "extern char *yytext;" ); 865 puts( "#define yytext_ptr yytext" ); | 1032 outn( "extern char *yytext;" ); 1033 outn( "#define yytext_ptr yytext" ); |
866 } | 1034 } |
1035 1036 if ( yyclass ) 1037 flexerror( 1038 _( "%option yyclass only meaningful for C++ scanners" ) ); |
|
867 } 868 869 if ( useecs ) 870 numecs = cre8ecs( nextecm, ecgroup, csize ); 871 else 872 numecs = csize; 873 874 /* Now map the equivalence class for NUL to its expected place. */ --- 26 unchanged lines hidden (view full) --- 901 rule_useful = allocate_integer_array( current_max_rules ); 902 903 current_max_scs = INITIAL_MAX_SCS; 904 scset = allocate_integer_array( current_max_scs ); 905 scbol = allocate_integer_array( current_max_scs ); 906 scxclu = allocate_integer_array( current_max_scs ); 907 sceof = allocate_integer_array( current_max_scs ); 908 scname = allocate_char_ptr_array( current_max_scs ); | 1039 } 1040 1041 if ( useecs ) 1042 numecs = cre8ecs( nextecm, ecgroup, csize ); 1043 else 1044 numecs = csize; 1045 1046 /* Now map the equivalence class for NUL to its expected place. */ --- 26 unchanged lines hidden (view full) --- 1073 rule_useful = allocate_integer_array( current_max_rules ); 1074 1075 current_max_scs = INITIAL_MAX_SCS; 1076 scset = allocate_integer_array( current_max_scs ); 1077 scbol = allocate_integer_array( current_max_scs ); 1078 scxclu = allocate_integer_array( current_max_scs ); 1079 sceof = allocate_integer_array( current_max_scs ); 1080 scname = allocate_char_ptr_array( current_max_scs ); |
909 actvsc = allocate_integer_array( current_max_scs ); | |
910 911 current_maxccls = INITIAL_MAX_CCLS; 912 cclmap = allocate_integer_array( current_maxccls ); 913 ccllen = allocate_integer_array( current_maxccls ); 914 cclng = allocate_integer_array( current_maxccls ); 915 916 current_max_ccl_tbl_size = INITIAL_MAX_CCL_TBL_SIZE; 917 ccltbl = allocate_Character_array( current_max_ccl_tbl_size ); --- 17 unchanged lines hidden (view full) --- 935 dfaacc = allocate_dfaacc_union( current_max_dfas ); 936 937 nultrans = (int *) 0; 938 } 939 940 941void usage() 942 { | 1081 1082 current_maxccls = INITIAL_MAX_CCLS; 1083 cclmap = allocate_integer_array( current_maxccls ); 1084 ccllen = allocate_integer_array( current_maxccls ); 1085 cclng = allocate_integer_array( current_maxccls ); 1086 1087 current_max_ccl_tbl_size = INITIAL_MAX_CCL_TBL_SIZE; 1088 ccltbl = allocate_Character_array( current_max_ccl_tbl_size ); --- 17 unchanged lines hidden (view full) --- 1106 dfaacc = allocate_dfaacc_union( current_max_dfas ); 1107 1108 nultrans = (int *) 0; 1109 } 1110 1111 1112void usage() 1113 { |
943 fprintf( stderr, 944"%s [-bcdfhilnpstvwBFILTV78+ -C[aefFmr] -Pprefix -Sskeleton] [file ...]\n", | 1114 FILE *f = stdout; 1115 1116 fprintf( f, 1117_( "%s [-bcdfhilnpstvwBFILTV78+? -C[aefFmr] -ooutput -Pprefix -Sskeleton]\n" ), |
945 program_name ); | 1118 program_name ); |
1119 fprintf( f, _( "\t[--help --version] [file ...]\n" ) ); |
|
946 | 1120 |
947 fprintf( stderr, 948 "\t-b generate backing-up information to lex.backup\n" ); 949 fprintf( stderr, "\t-c do-nothing POSIX option\n" ); 950 fprintf( stderr, "\t-d turn on debug mode in generated scanner\n" ); 951 fprintf( stderr, "\t-f generate fast, large scanner\n" ); 952 fprintf( stderr, "\t-h produce this help message\n" ); 953 fprintf( stderr, "\t-i generate case-insensitive scanner\n" ); 954 fprintf( stderr, "\t-l maximal compatibility with original lex\n" ); 955 fprintf( stderr, "\t-n do-nothing POSIX option\n" ); 956 fprintf( stderr, "\t-p generate performance report to stderr\n" ); 957 fprintf( stderr, 958 "\t-s suppress default rule to ECHO unmatched text\n" ); 959 fprintf( stderr, 960 "\t-t write generated scanner on stdout instead of lex.yy.c\n" ); 961 fprintf( stderr, 962 "\t-v write summary of scanner statistics to stderr\n" ); 963 fprintf( stderr, "\t-w do not generate warnings\n" ); 964 fprintf( stderr, "\t-B generate batch scanner (opposite of -I)\n" ); 965 fprintf( stderr, 966 "\t-F use alternative fast scanner representation\n" ); 967 fprintf( stderr, 968 "\t-I generate interactive scanner (opposite of -B)\n" ); 969 fprintf( stderr, "\t-L suppress #line directives in scanner\n" ); 970 fprintf( stderr, "\t-T %s should run in trace mode\n", program_name ); 971 fprintf( stderr, "\t-V report %s version\n", program_name ); 972 fprintf( stderr, "\t-7 generate 7-bit scanner\n" ); 973 fprintf( stderr, "\t-8 generate 8-bit scanner\n" ); 974 fprintf( stderr, "\t-+ generate C++ scanner class\n" ); 975 fprintf( stderr, 976 "\t-C specify degree of table compression (default is -Cem):\n" ); 977 fprintf( stderr, 978 "\t\t-Ca trade off larger tables for better memory alignment\n" ); 979 fprintf( stderr, "\t\t-Ce construct equivalence classes\n" ); 980 fprintf( stderr, 981 "\t\t-Cf do not compress scanner tables; use -f representation\n" ); 982 fprintf( stderr, 983 "\t\t-CF do not compress scanner tables; use -F representation\n" ); 984 fprintf( stderr, "\t\t-Cm construct meta-equivalence classes\n" ); 985 fprintf( stderr, 986 "\t\t-Cr use read() instead of stdio for scanner input\n" ); 987 fprintf( stderr, "\t-P specify scanner prefix other than \"yy\"\n" ); 988 fprintf( stderr, "\t-S specify skeleton file\n" ); | 1121 fprintf( f, _( "\t-b generate backing-up information to %s\n" ), 1122 backing_name ); 1123 fprintf( f, _( "\t-c do-nothing POSIX option\n" ) ); 1124 fprintf( f, _( "\t-d turn on debug mode in generated scanner\n" ) ); 1125 fprintf( f, _( "\t-f generate fast, large scanner\n" ) ); 1126 fprintf( f, _( "\t-h produce this help message\n" ) ); 1127 fprintf( f, _( "\t-i generate case-insensitive scanner\n" ) ); 1128 fprintf( f, _( "\t-l maximal compatibility with original lex\n" ) ); 1129 fprintf( f, _( "\t-n do-nothing POSIX option\n" ) ); 1130 fprintf( f, _( "\t-p generate performance report to stderr\n" ) ); 1131 fprintf( f, 1132 _( "\t-s suppress default rule to ECHO unmatched text\n" ) ); 1133 1134 if ( ! did_outfilename ) 1135 { 1136 sprintf( outfile_path, outfile_template, 1137 prefix, C_plus_plus ? "cc" : "c" ); 1138 outfilename = outfile_path; 1139 } 1140 1141 fprintf( f, 1142 _( "\t-t write generated scanner on stdout instead of %s\n" ), 1143 outfilename ); 1144 1145 fprintf( f, 1146 _( "\t-v write summary of scanner statistics to f\n" ) ); 1147 fprintf( f, _( "\t-w do not generate warnings\n" ) ); 1148 fprintf( f, _( "\t-B generate batch scanner (opposite of -I)\n" ) ); 1149 fprintf( f, 1150 _( "\t-F use alternative fast scanner representation\n" ) ); 1151 fprintf( f, 1152 _( "\t-I generate interactive scanner (opposite of -B)\n" ) ); 1153 fprintf( f, _( "\t-L suppress #line directives in scanner\n" ) ); 1154 fprintf( f, _( "\t-T %s should run in trace mode\n" ), program_name ); 1155 fprintf( f, _( "\t-V report %s version\n" ), program_name ); 1156 fprintf( f, _( "\t-7 generate 7-bit scanner\n" ) ); 1157 fprintf( f, _( "\t-8 generate 8-bit scanner\n" ) ); 1158 fprintf( f, _( "\t-+ generate C++ scanner class\n" ) ); 1159 fprintf( f, _( "\t-? produce this help message\n" ) ); 1160 fprintf( f, 1161_( "\t-C specify degree of table compression (default is -Cem):\n" ) ); 1162 fprintf( f, 1163_( "\t\t-Ca trade off larger tables for better memory alignment\n" ) ); 1164 fprintf( f, _( "\t\t-Ce construct equivalence classes\n" ) ); 1165 fprintf( f, 1166_( "\t\t-Cf do not compress scanner tables; use -f representation\n" ) ); 1167 fprintf( f, 1168_( "\t\t-CF do not compress scanner tables; use -F representation\n" ) ); 1169 fprintf( f, _( "\t\t-Cm construct meta-equivalence classes\n" ) ); 1170 fprintf( f, 1171 _( "\t\t-Cr use read() instead of stdio for scanner input\n" ) ); 1172 fprintf( f, _( "\t-o specify output filename\n" ) ); 1173 fprintf( f, _( "\t-P specify scanner prefix other than \"yy\"\n" ) ); 1174 fprintf( f, _( "\t-S specify skeleton file\n" ) ); 1175 fprintf( f, _( "\t--help produce this help message\n" ) ); 1176 fprintf( f, _( "\t--version report %s version\n" ), program_name ); |
989 } | 1177 } |