int main(int argc, char **argv) { int i; #ifdef NEED_ARGV_FIXUP argv_fixup( &argc, &argv ); #endif flexinit( argc, argv ); readin(); ntod(); for ( i = 1; i <= num_rules; ++i ) if ( ! rule_useful[i] && i != default_rule ) line_warning( _( "rule cannot be matched" ), rule_linenum[i] ); if ( spprdflt && ! reject && rule_useful[default_rule] ) line_warning( _( "-s option given but default rule can be matched" ), rule_linenum[default_rule] ); /* 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 ); return 0; /* keep compilers/lint happy */ }
int flex_main (int argc, char *argv[]) { int i, exit_status, child_status; /* Set a longjmp target. Yes, I know it's a hack, but it gets worse: The * return value of setjmp, if non-zero, is the desired exit code PLUS ONE. * For example, if you want 'main' to return with code '2', then call * longjmp() with an argument of 3. This is because it is invalid to * specify a value of 0 to longjmp. FLEX_EXIT(n) should be used instead of * exit(n); */ exit_status = setjmp (flex_main_jmp_buf); if (exit_status){ if (stdout && !_stdout_closed && !ferror(stdout)){ fflush(stdout); fclose(stdout); } while (wait(&child_status) > 0){ if (!WIFEXITED (child_status) || WEXITSTATUS (child_status) != 0){ /* report an error of a child */ if( exit_status <= 1 ) exit_status = 2; } } return exit_status - 1; } flexinit (argc, argv); readin (); skelout (); /* %% [1.5] DFA */ ntod (); for (i = 1; i <= num_rules; ++i) if (!rule_useful[i] && i != default_rule) line_warning (_("rule cannot be matched"), rule_linenum[i]); if (spprdflt && !reject && rule_useful[default_rule]) line_warning (_ ("-s option given but default rule can be matched"), rule_linenum[default_rule]); /* 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); return 0; /* keep compilers/lint happy */ }
void traditional_print_type (FILE * f, char * text) { int i; #ifdef CFUNCTIONS_DEBUG if (trad_debug) printf ("traditional print type `%s': \n", text); #endif for (i = 0; i < n_arg; i++) { /* Need to do this due to problem with `[]'. */ unsigned len = c_word (args[i]->name->name); #ifdef CFUNCTIONS_DEBUG if (trad_debug) printf ("comparing with %s\n", args[i]->name->name); #endif if (strncmp ((char *) args[i]->name->name, text, len) == 0) { arg_fprint (f, args[i]); return; } } if (warns.implicit_int) line_warning ("implicit int argument `%s'", text); fprintf (f, "int /* default */ %s", text); }
void check_trailing_context (int *nfa_states, int num_states, int *accset, int nacc) { int i, j; for (i = 1; i <= num_states; ++i) { int ns = nfa_states[i]; int type = state_type[ns]; int ar = assoc_rule[ns]; if (type == STATE_NORMAL || rule_type[ar] != RULE_VARIABLE) { /* do nothing */ } else if (type == STATE_TRAILING_CONTEXT) { /* Potential trouble. Scan set of accepting numbers * for the one marking the end of the "head". We * assume that this looping will be fairly cheap * since it's rare that an accepting number set * is large. */ for (j = 1; j <= nacc; ++j) if (accset[j] & YY_TRAILING_HEAD_MASK) { line_warning (_ ("dangerous trailing context"), rule_linenum[ar]); return; } } } }