For PR351:
[oota-llvm.git] / include / llvm / Assembly / Parser.h
1 //===-- llvm/Assembly/Parser.h - Parser for VM assembly files ---*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 //  These classes are implemented by the lib/AsmParser library.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ASSEMBLY_PARSER_H
15 #define LLVM_ASSEMBLY_PARSER_H
16
17 #include <string>
18
19 namespace llvm {
20
21 class Module;
22 class ParseException;
23
24
25 // The useful interface defined by this file... Parse an ascii file, and return
26 // the internal representation in a nice slice'n'dice'able representation.  Note
27 // that this does not verify that the generated LLVM is valid, so you should run
28 // the verifier after parsing the file to check that it's ok.
29 //
30 Module *ParseAssemblyFile(const std::string &Filename);// throw (ParseException)
31
32 //===------------------------------------------------------------------------===
33 //                              Helper Classes
34 //===------------------------------------------------------------------------===
35
36 // ParseException - For when an exceptional event is generated by the parser.
37 // This class lets you print out the exception message
38 //
39 struct ParseException {
40   ParseException(const std::string &filename, const std::string &message, 
41                  int LineNo = -1, int ColNo = -1);
42
43   ParseException(const ParseException &E);
44
45   // getMessage - Return the message passed in at construction time plus extra 
46   // information extracted from the options used to parse with...
47   //
48   const std::string getMessage() const;
49
50   inline const std::string &getRawMessage() const {   // Just the raw message...
51     return Message;
52   }
53
54   inline const std::string &getFilename() const {
55     return Filename;
56   }
57
58   // getErrorLocation - Return the line and column number of the error in the
59   // input source file.  The source filename can be derived from the 
60   // ParserOptions in effect.  If positional information is not applicable, 
61   // these will return a value of -1.
62   //
63   inline const void getErrorLocation(int &Line, int &Column) const {
64     Line = LineNo; Column = ColumnNo;
65   }
66
67 private :
68   std::string Filename;
69   std::string Message;
70   int LineNo, ColumnNo;                               // -1 if not relevant
71
72   ParseException &operator=(const ParseException &E); // objects by reference
73 };
74
75 } // End llvm namespace
76
77 #endif