]>
git.saurik.com Git - bison.git/blob - src/main.c
1 /* Top level entry point of bison,
2 Copyright 1984, 1986, 1989, 1992, 1995, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 This file is part of Bison, the GNU Compiler Compiler.
7 Bison is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 Bison is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Bison; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
24 #include "bitset_stats.h"
39 #include "conflicts.h"
40 #include "print_graph.h"
41 #include "muscle_tab.h"
43 /* The name this program was run with, for messages. */
49 main (int argc
, char *argv
[])
51 program_name
= argv
[0];
52 setlocale (LC_ALL
, "");
53 bindtextdomain (PACKAGE
, LOCALEDIR
);
58 time_report
= trace_flag
& trace_time
;
60 timevar_start (TV_TOTAL
);
62 if (trace_flag
& trace_bitsets
)
63 bitset_stats_enable ();
67 /* Read the input. Copy some parts of it to FGUARD, FACTION, FTABLE
68 and FATTRS. In file reader.c. The other parts are recorded in
69 the grammar; see gram.h. */
71 timevar_push (TV_READER
);
73 timevar_pop (TV_READER
);
75 if (complain_message_count
)
78 /* Find useless nonterminals and productions and reduce the grammar. */
79 timevar_push (TV_REDUCE
);
81 timevar_pop (TV_REDUCE
);
83 /* Record other info about the grammar. In files derives and
85 timevar_push (TV_SETS
);
88 timevar_pop (TV_SETS
);
90 /* Convert to nondeterministic finite state machine. In file LR0.
91 See state.h for more info. */
92 timevar_push (TV_LR0
);
96 /* make it deterministic. In file lalr. */
97 timevar_push (TV_LALR
);
99 timevar_pop (TV_LALR
);
101 /* Find and record any conflicts: places where one token of
102 lookahead is not enough to disambiguate the parsing. In file
103 conflicts. Also resolve s/r conflicts based on precedence
105 timevar_push (TV_CONFLICTS
);
108 timevar_pop (TV_CONFLICTS
);
110 /* Output file names. */
111 compute_output_file_names ();
113 /* Output the detailed report on the grammar. */
116 timevar_push (TV_REPORT
);
118 timevar_pop (TV_REPORT
);
121 /* Stop if there were errors, to avoid trashing previous output
123 if (complain_message_count
)
126 /* Output the VCG graph. */
129 timevar_push (TV_GRAPH
);
131 timevar_pop (TV_GRAPH
);
134 /* Output the tables and the parser to ftable. In file output. */
135 timevar_push (TV_PARSER
);
137 timevar_pop (TV_PARSER
);
139 timevar_push (TV_FREE
);
147 /* The scanner memory cannot be released right after parsing, as it
148 contains things such as user actions, prologue, epilogue etc. */
151 /* If using alloca.c, flush the alloca'ed memory for the benefit of
152 people running Bison as a library in IDEs. */
156 timevar_pop (TV_FREE
);
158 if (trace_flag
& trace_bitsets
)
159 bitset_stats_dump (stderr
);
161 /* Stop timing and print the times. */
162 timevar_stop (TV_TOTAL
);
163 timevar_print (stderr
);
165 return complain_message_count
? EXIT_FAILURE
: EXIT_SUCCESS
;