LLVM API Documentation
00001 //===-- llvm/Assembly/Parser.h - Parser for VM assembly files ---*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // These classes are implemented by the lib/AsmParser library. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_ASSEMBLY_PARSER_H 00015 #define LLVM_ASSEMBLY_PARSER_H 00016 00017 #include <string> 00018 00019 namespace llvm { 00020 00021 class Module; 00022 class ParseException; 00023 00024 00025 // The useful interface defined by this file... Parse an ascii file, and return 00026 // the internal representation in a nice slice'n'dice'able representation. Note 00027 // that this does not verify that the generated LLVM is valid, so you should run 00028 // the verifier after parsing the file to check that it's ok. 00029 // 00030 Module *ParseAssemblyFile(const std::string &Filename);// throw (ParseException) 00031 00032 //===------------------------------------------------------------------------=== 00033 // Helper Classes 00034 //===------------------------------------------------------------------------=== 00035 00036 // ParseException - For when an exceptional event is generated by the parser. 00037 // This class lets you print out the exception message 00038 // 00039 struct ParseException { 00040 ParseException(const std::string &filename, const std::string &message, 00041 int LineNo = -1, int ColNo = -1); 00042 00043 ParseException(const ParseException &E); 00044 00045 // getMessage - Return the message passed in at construction time plus extra 00046 // information extracted from the options used to parse with... 00047 // 00048 const std::string getMessage() const; 00049 00050 inline const std::string &getRawMessage() const { // Just the raw message... 00051 return Message; 00052 } 00053 00054 inline const std::string &getFilename() const { 00055 return Filename; 00056 } 00057 00058 // getErrorLocation - Return the line and column number of the error in the 00059 // input source file. The source filename can be derived from the 00060 // ParserOptions in effect. If positional information is not applicable, 00061 // these will return a value of -1. 00062 // 00063 inline const void getErrorLocation(int &Line, int &Column) const { 00064 Line = LineNo; Column = ColumnNo; 00065 } 00066 00067 private : 00068 std::string Filename; 00069 std::string Message; 00070 int LineNo, ColumnNo; // -1 if not relevant 00071 00072 ParseException &operator=(const ParseException &E); // objects by reference 00073 }; 00074 00075 } // End llvm namespace 00076 00077 #endif