libparse.cc 596 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "parse/asm-parse.hh"

// Export parsed file name.
char *filename = 0;

// Define exported parse functions.
namespace parse
{

  // Display the results of intermediate steps.
  int trace_scan_p = 0;
  int trace_parse_p = 0;

  // Parse a MIPS asm file, return the corresponding abstract syntax.
  ::inst::Program*
  parse (const std::string &fname)
  {
    yy::Parser parser = yy::Parser (trace_parse_p, yy::Location ());

    yy::program_builder.reset ();

    scan_open (fname);
    parser.parse ();
    scan_close ();

    return ::yy::program_builder.get();
  }

} // namespace parse