MC/AsmParser: Move .lsym parsing to Darwin specific parser.
[oota-llvm.git] / include / llvm / MC / MCParser / MCAsmParser.h
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
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;
26
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);
32
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();
38
39 public:
40   virtual ~MCAsmParser();
41
42   virtual void AddDirectiveHandler(MCAsmParserExtension *Object,
43                                    StringRef Directive,
44                                    DirectiveHandler Handler) = 0;
45
46   virtual SourceMgr &getSourceManager() = 0;
47
48   virtual MCAsmLexer &getLexer() = 0;
49
50   virtual MCContext &getContext() = 0;
51
52   /// getStreamer - Return the output streamer for the assembler.
53   virtual MCStreamer &getStreamer() = 0;
54
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;
58
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;
65
66   /// Lex - Get the next AsmToken in the stream, possibly handling file
67   /// inclusion first.
68   virtual const AsmToken &Lex() = 0;
69
70   /// getTok - Get the current AsmToken from the stream.
71   const AsmToken &getTok();
72
73   /// \brief Report an error at the current lexer location.
74   bool TokError(const char *Msg);
75
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;
79
80   /// ParseExpression - Parse an arbitrary expression.
81   ///
82   /// @param Res - The value of the expression. The result is undefined
83   /// on error.
84   /// @result - False on success.
85   virtual bool ParseExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
86   bool ParseExpression(const MCExpr *&Res);
87
88   /// ParseParenExpression - Parse an arbitrary expression, assuming that an
89   /// initial '(' has already been consumed.
90   ///
91   /// @param Res - The value of the expression. The result is undefined
92   /// on error.
93   /// @result - False on success.
94   virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
95
96   /// ParseAbsoluteExpression - Parse an expression which must evaluate to an
97   /// absolute value.
98   ///
99   /// @param Res - The value of the absolute expression. The result is undefined
100   /// on error.
101   /// @result - False on success.
102   virtual bool ParseAbsoluteExpression(int64_t &Res) = 0;
103 };
104
105 } // End llvm namespace
106
107 #endif