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 Module *ParseAssemblyString(const char * AsmString, Module * M);// throw (ParseException) 00032 00033 //===------------------------------------------------------------------------=== 00034 // Helper Classes 00035 //===------------------------------------------------------------------------=== 00036 00037 // ParseException - For when an exceptional event is generated by the parser. 00038 // This class lets you print out the exception message 00039 // 00040 class ParseException { 00041 public: 00042 ParseException(const std::string &filename, const std::string &message, 00043 int LineNo = -1, int ColNo = -1); 00044 00045 ParseException(const ParseException &E); 00046 00047 // getMessage - Return the message passed in at construction time plus extra 00048 // information extracted from the options used to parse with... 00049 // 00050 const std::string getMessage() const; 00051 00052 inline const std::string &getRawMessage() const { // Just the raw message... 00053 return Message; 00054 } 00055 00056 inline const std::string &getFilename() const { 00057 return Filename; 00058 } 00059 00060 // getErrorLocation - Return the line and column number of the error in the 00061 // input source file. The source filename can be derived from the 00062 // ParserOptions in effect. If positional information is not applicable, 00063 // these will return a value of -1. 00064 // 00065 inline const void getErrorLocation(int &Line, int &Column) const { 00066 Line = LineNo; Column = ColumnNo; 00067 } 00068 00069 private : 00070 std::string Filename; 00071 std::string Message; 00072 int LineNo, ColumnNo; // -1 if not relevant 00073 00074 ParseException &operator=(const ParseException &E); // objects by reference 00075 }; 00076 00077 } // End llvm namespace 00078 00079 #endif