MCAsmParser.h revision 81ea00f45d59953d34a1db4973dd72d14080ab15
1//===-- llvm/MC/MCAsmParser.h - Abstract Asm Parser Interface ---*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef LLVM_MC_MCASMPARSER_H 11#define LLVM_MC_MCASMPARSER_H 12 13#include "llvm/System/DataTypes.h" 14 15namespace llvm { 16class AsmToken; 17class MCAsmLexer; 18class MCAsmParserExtension; 19class MCContext; 20class MCExpr; 21class MCStreamer; 22class SMLoc; 23class StringRef; 24class Twine; 25 26/// MCAsmParser - Generic assembler parser interface, for use by target specific 27/// assembly parsers. 28class MCAsmParser { 29public: 30 typedef bool (MCAsmParserExtension::*DirectiveHandler)(StringRef, SMLoc); 31 32private: 33 MCAsmParser(const MCAsmParser &); // DO NOT IMPLEMENT 34 void operator=(const MCAsmParser &); // DO NOT IMPLEMENT 35protected: // Can only create subclasses. 36 MCAsmParser(); 37 38public: 39 virtual ~MCAsmParser(); 40 41 virtual void AddDirectiveHandler(MCAsmParserExtension *Object, 42 StringRef Directive, 43 DirectiveHandler Handler) = 0; 44 45 virtual MCAsmLexer &getLexer() = 0; 46 47 virtual MCContext &getContext() = 0; 48 49 /// getStreamer - Return the output streamer for the assembler. 50 virtual MCStreamer &getStreamer() = 0; 51 52 /// Warning - Emit a warning at the location \arg L, with the message \arg 53 /// Msg. 54 virtual void Warning(SMLoc L, const Twine &Msg) = 0; 55 56 /// Error - Emit an error at the location \arg L, with the message \arg 57 /// Msg. 58 /// 59 /// \return The return value is always true, as an idiomatic convenience to 60 /// clients. 61 virtual bool Error(SMLoc L, const Twine &Msg) = 0; 62 63 /// Lex - Get the next AsmToken in the stream, possibly handling file 64 /// inclusion first. 65 virtual const AsmToken &Lex() = 0; 66 67 /// getTok - Get the current AsmToken from the stream. 68 const AsmToken &getTok(); 69 70 /// \brief Report an error at the current lexer location. 71 bool TokError(const char *Msg); 72 73 /// ParseExpression - Parse an arbitrary expression. 74 /// 75 /// @param Res - The value of the expression. The result is undefined 76 /// on error. 77 /// @result - False on success. 78 virtual bool ParseExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0; 79 bool ParseExpression(const MCExpr *&Res); 80 81 /// ParseParenExpression - Parse an arbitrary expression, assuming that an 82 /// initial '(' has already been consumed. 83 /// 84 /// @param Res - The value of the expression. The result is undefined 85 /// on error. 86 /// @result - False on success. 87 virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0; 88 89 /// ParseAbsoluteExpression - Parse an expression which must evaluate to an 90 /// absolute value. 91 /// 92 /// @param Res - The value of the absolute expression. The result is undefined 93 /// on error. 94 /// @result - False on success. 95 virtual bool ParseAbsoluteExpression(int64_t &Res) = 0; 96}; 97 98} // End llvm namespace 99 100#endif 101