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