MCAsmParser: Add getSourceManager().
[llvm.git] / include / llvm / MC / MCParser / MCAsmParser.h
blobda9b6f228d93a7b572cfb7691558f30cff7abc8d
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 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_MC_MCASMPARSER_H
11 #define LLVM_MC_MCASMPARSER_H
13 #include "llvm/System/DataTypes.h"
15 namespace llvm {
16 class AsmToken;
17 class MCAsmLexer;
18 class MCAsmParserExtension;
19 class MCContext;
20 class MCExpr;
21 class MCStreamer;
22 class SMLoc;
23 class SourceMgr;
24 class StringRef;
25 class Twine;
27 /// MCAsmParser - Generic assembler parser interface, for use by target specific
28 /// assembly parsers.
29 class MCAsmParser {
30 public:
31 typedef bool (MCAsmParserExtension::*DirectiveHandler)(StringRef, SMLoc);
33 private:
34 MCAsmParser(const MCAsmParser &); // DO NOT IMPLEMENT
35 void operator=(const MCAsmParser &); // DO NOT IMPLEMENT
36 protected: // Can only create subclasses.
37 MCAsmParser();
39 public:
40 virtual ~MCAsmParser();
42 virtual void AddDirectiveHandler(MCAsmParserExtension *Object,
43 StringRef Directive,
44 DirectiveHandler Handler) = 0;
46 virtual SourceMgr &getSourceManager() = 0;
48 virtual MCAsmLexer &getLexer() = 0;
50 virtual MCContext &getContext() = 0;
52 /// getStreamer - Return the output streamer for the assembler.
53 virtual MCStreamer &getStreamer() = 0;
55 /// Warning - Emit a warning at the location \arg L, with the message \arg
56 /// Msg.
57 virtual void Warning(SMLoc L, const Twine &Msg) = 0;
59 /// Error - Emit an error at the location \arg L, with the message \arg
60 /// Msg.
61 ///
62 /// \return The return value is always true, as an idiomatic convenience to
63 /// clients.
64 virtual bool Error(SMLoc L, const Twine &Msg) = 0;
66 /// Lex - Get the next AsmToken in the stream, possibly handling file
67 /// inclusion first.
68 virtual const AsmToken &Lex() = 0;
70 /// getTok - Get the current AsmToken from the stream.
71 const AsmToken &getTok();
73 /// \brief Report an error at the current lexer location.
74 bool TokError(const char *Msg);
76 /// ParseExpression - Parse an arbitrary expression.
77 ///
78 /// @param Res - The value of the expression. The result is undefined
79 /// on error.
80 /// @result - False on success.
81 virtual bool ParseExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
82 bool ParseExpression(const MCExpr *&Res);
84 /// ParseParenExpression - Parse an arbitrary expression, assuming that an
85 /// initial '(' has already been consumed.
86 ///
87 /// @param Res - The value of the expression. The result is undefined
88 /// on error.
89 /// @result - False on success.
90 virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
92 /// ParseAbsoluteExpression - Parse an expression which must evaluate to an
93 /// absolute value.
94 ///
95 /// @param Res - The value of the absolute expression. The result is undefined
96 /// on error.
97 /// @result - False on success.
98 virtual bool ParseAbsoluteExpression(int64_t &Res) = 0;
101 } // End llvm namespace
103 #endif