Initial checkin of simple&fast SSA based GCSE algorithm
[oota-llvm.git] / include / llvm / Assembly / Parser.h
1 //===-- llvm/assembly/Parser.h - Parser for VM assembly files ----*- C++ -*--=//
2 //
3 //  These classes are implemented by the lib/AssemblyParser library.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef LLVM_ASSEMBLY_PARSER_H
8 #define LLVM_ASSEMBLY_PARSER_H
9
10 #include <string>
11
12 class Module;
13 class ParseException;
14
15
16 // The useful interface defined by this file... Parse an ascii file, and return
17 // the internal representation in a nice slice'n'dice'able representation.
18 //
19 Module *ParseAssemblyFile(const std::string &Filename);// throw (ParseException)
20
21 //===------------------------------------------------------------------------===
22 //                              Helper Classes
23 //===------------------------------------------------------------------------===
24
25 // ParseException - For when an exceptional event is generated by the parser.
26 // This class lets you print out the exception message
27 //
28 class ParseException {
29 public:
30   ParseException(const std::string &filename, const std::string &message, 
31                  int LineNo = -1, int ColNo = -1);
32
33   ParseException(const ParseException &E);
34
35   // getMessage - Return the message passed in at construction time plus extra 
36   // information extracted from the options used to parse with...
37   //
38   const std::string getMessage() const;
39
40   inline const std::string &getRawMessage() const {   // Just the raw message...
41     return Message;
42   }
43
44   inline const std::string &getFilename() const {
45     return Filename;
46   }
47
48   // getErrorLocation - Return the line and column number of the error in the
49   // input source file.  The source filename can be derived from the 
50   // ParserOptions in effect.  If positional information is not applicable, 
51   // these will return a value of -1.
52   //
53   inline const void getErrorLocation(int &Line, int &Column) const {
54     Line = LineNo; Column = ColumnNo;
55   }
56
57 private :
58   std::string Filename;
59   std::string Message;
60   int LineNo, ColumnNo;                               // -1 if not relevant
61
62   ParseException &operator=(const ParseException &E); // objects by reference
63 };
64
65 #endif