1 //===-- llvm/MC/MCAsmParser.h - Abstract Asm Parser Interface ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_MC_MCASMPARSER_H
11 #define LLVM_MC_MCASMPARSER_H
13 #include "llvm/System/DataTypes.h"
18 class MCAsmParserExtension;
27 /// MCAsmParser - Generic assembler parser interface, for use by target specific
31 typedef bool (MCAsmParserExtension::*DirectiveHandler)(StringRef, SMLoc);
34 MCAsmParser(const MCAsmParser &); // DO NOT IMPLEMENT
35 void operator=(const MCAsmParser &); // DO NOT IMPLEMENT
36 protected: // Can only create subclasses.
40 virtual ~MCAsmParser();
42 virtual void AddDirectiveHandler(MCAsmParserExtension *Object,
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
57 virtual void Warning(SMLoc L, const Twine &Msg) = 0;
59 /// Error - Emit an error at the location \arg L, with the message \arg
62 /// \return The return value is always true, as an idiomatic convenience to
64 virtual bool Error(SMLoc L, const Twine &Msg) = 0;
66 /// Lex - Get the next AsmToken in the stream, possibly handling file
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 /// ParseIdentifier - Parse an identifier or string (as a quoted identifier)
77 /// and set \arg Res to the identifier contents.
78 virtual bool ParseIdentifier(StringRef &Res) = 0;
80 /// ParseExpression - Parse an arbitrary expression.
82 /// @param Res - The value of the expression. The result is undefined
84 /// @result - False on success.
85 virtual bool ParseExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
86 bool ParseExpression(const MCExpr *&Res);
88 /// ParseParenExpression - Parse an arbitrary expression, assuming that an
89 /// initial '(' has already been consumed.
91 /// @param Res - The value of the expression. The result is undefined
93 /// @result - False on success.
94 virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
96 /// ParseAbsoluteExpression - Parse an expression which must evaluate to an
99 /// @param Res - The value of the absolute expression. The result is undefined
101 /// @result - False on success.
102 virtual bool ParseAbsoluteExpression(int64_t &Res) = 0;
105 } // End llvm namespace