src
main.cc
Go to the documentation of this file.
1 #include "src/util/c99_stdint.h"
2 #include <string>
3 
4 #include "src/codegen/output.h"
5 #include "src/conf/msg.h"
6 #include "src/conf/opt.h"
7 #include "src/conf/warn.h"
8 #include "src/globals.h"
9 #include "src/parse/input.h"
10 #include "src/parse/parser.h"
11 #include "src/parse/scanner.h"
12 
13 namespace re2c
14 {
15 
16 bool bUsedYYBitmap = false;
17 bool bWroteGetState = false;
18 bool bWroteCondCheck = false;
19 uint32_t last_fill_index = 0;
20 std::string yySetupRule = "";
21 
22 } // end namespace re2c
23 
24 using namespace re2c;
25 
26 int main(int, char *argv[])
27 {
28  switch (parse_opts (argv, opts))
29  {
30  case OK: break;
31  case EXIT_OK: return 0;
32  case EXIT_FAIL: return 1;
33  }
34 
35  // set up the source stream
37  if (!input.open ())
38  {
39  error ("cannot open source file: %s", opts.source_file);
40  return 1;
41  }
42 
43  // set up the output streams
45  if (!output.source.open ())
46  {
47  error ("cannot open output file: %s", opts.output_file);
48  return 1;
49  }
50  if (opts->tFlag && !output.header.open ())
51  {
52  error ("cannot open header file: %s", opts->header_file);
53  return 1;
54  }
55 
56  Scanner scanner (input, output.source);
57  parse (scanner, output);
58 
59  return warn.error () ? 1 : 0;
60 }
bool bWroteGetState
Definition: main.cc:17
bool open()
Definition: input.cc:10
bool tFlag
Definition: opt.h:118
void error(const char *fmt,...)
Definition: msg.cc:10
void parse(Scanner &, Output &)
Warn warn
Definition: warn.cc:11
const char * output_file
Definition: opt.h:154
OutputFile source
Definition: output.h:136
bool bWroteCondCheck
Definition: main.cc:18
const char * header_file
Definition: opt.h:118
std::string yySetupRule
Definition: main.cc:20
bool bUsedYYBitmap
Definition: main.cc:16
HeaderFile header
Definition: output.h:137
Definition: opt.h:209
bool open()
Definition: output.cc:65
Opt opts
Definition: opt.cc:7
uint32_t last_fill_index
Definition: main.cc:19
int main(int, char *argv[])
Definition: main.cc:26
bool error() const
Definition: warn.cc:34
Definition: bitmap.cc:10
parse_opts_t parse_opts(char **argv, Opt &opts)
const char * source_file
Definition: opt.h:153