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 /// ParseExpression - Parse an arbitrary expression.
78 /// @param Res - The value of the expression. The result is undefined
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.
87 /// @param Res - The value of the expression. The result is undefined
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
95 /// @param Res - The value of the absolute expression. The result is undefined
97 /// @result - False on success.
98 virtual bool ParseAbsoluteExpression(int64_t &Res
) = 0;
101 } // End llvm namespace