MCAsmParser.h revision c6ef277a0b8f43af22d86aea9d5053749cacfbbb
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 MCValue;
22class SMLoc;
23class Twine;
24
25/// MCAsmParser - Generic assembler parser interface, for use by target specific
26/// assembly parsers.
27class MCAsmParser {
28  MCAsmParser(const MCAsmParser &);   // DO NOT IMPLEMENT
29  void operator=(const MCAsmParser &);  // DO NOT IMPLEMENT
30protected: // Can only create subclasses.
31  MCAsmParser();
32
33public:
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  /// getTok - Get the current AsmToken from the stream.
59  const AsmToken &getTok();
60
61  /// ParseExpression - Parse an arbitrary expression.
62  ///
63  /// @param Res - The value of the expression. The result is undefined
64  /// on error.
65  /// @result - False on success.
66  virtual bool ParseExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
67  bool ParseExpression(const MCExpr *&Res);
68
69  /// ParseParenExpression - Parse an arbitrary expression, assuming that an
70  /// initial '(' has already been consumed.
71  ///
72  /// @param Res - The value of the expression. The result is undefined
73  /// on error.
74  /// @result - False on success.
75  virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
76
77  /// ParseAbsoluteExpression - Parse an expression which must evaluate to an
78  /// absolute value.
79  ///
80  /// @param Res - The value of the absolute expression. The result is undefined
81  /// on error.
82  /// @result - False on success.
83  virtual bool ParseAbsoluteExpression(int64_t &Res) = 0;
84};
85
86} // End llvm namespace
87
88#endif
89