73111cab457bc0b05c5160707105d397150f1125
[oota-llvm.git] / include / llvm / MC / 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 MCContext;
19 class MCExpr;
20 class MCStreamer;
21 class MCValue;
22 class SMLoc;
23 class Twine;
24
25 /// MCAsmParser - Generic assembler parser interface, for use by target specific
26 /// assembly parsers.
27 class MCAsmParser {
28   MCAsmParser(const MCAsmParser &);   // DO NOT IMPLEMENT
29   void operator=(const MCAsmParser &);  // DO NOT IMPLEMENT
30 protected: // Can only create subclasses.
31   MCAsmParser();
32  
33 public:
34   virtual ~MCAsmParser();
35
36   virtual MCAsmLexer &getLexer() = 0;
37
38   virtual MCContext &getContext() = 0;
39
40   /// getSteamer - Return the output streamer for the assembler.
41   virtual MCStreamer &getStreamer() = 0;
42
43   /// Warning - Emit a warning at the location \arg L, with the message \arg
44   /// Msg.
45   virtual void Warning(SMLoc L, const Twine &Msg) = 0;
46
47   /// Warning - Emit an error at the location \arg L, with the message \arg
48   /// Msg.
49   ///
50   /// \return The return value is always true, as an idiomatic convenience to
51   /// clients.
52   virtual bool Error(SMLoc L, const Twine &Msg) = 0;
53
54   /// Lex - Get the next AsmToken in the stream, possibly handling file
55   /// inclusion first.
56   virtual const AsmToken &Lex() = 0;
57   
58   /// ParseExpression - Parse an arbitrary expression.
59   ///
60   /// @param Res - The value of the expression. The result is undefined
61   /// on error.
62   /// @result - False on success.
63   virtual bool ParseExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
64   bool ParseExpression(const MCExpr *&Res);
65   
66   /// ParseParenExpression - Parse an arbitrary expression, assuming that an
67   /// initial '(' has already been consumed.
68   ///
69   /// @param Res - The value of the expression. The result is undefined
70   /// on error.
71   /// @result - False on success.
72   virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
73
74   /// ParseAbsoluteExpression - Parse an expression which must evaluate to an
75   /// absolute value.
76   ///
77   /// @param Res - The value of the absolute expression. The result is undefined
78   /// on error.
79   /// @result - False on success.
80   virtual bool ParseAbsoluteExpression(int64_t &Res) = 0;
81 };
82
83 } // End llvm namespace
84
85 #endif