MCAsmParserExtension.h revision 53131982d6290e3a865f400174778deaac452ff3
1//===-- llvm/MC/MCAsmParserExtension.h - Asm Parser Hooks -------*- 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_MCASMPARSEREXTENSION_H
11#define LLVM_MC_MCASMPARSEREXTENSION_H
12
13#include "llvm/MC/MCParser/MCAsmParser.h"
14#include "llvm/Support/SMLoc.h"
15
16namespace llvm {
17
18/// \brief Generic interface for extending the MCAsmParser,
19/// which is implemented by target and object file assembly parser
20/// implementations.
21class MCAsmParserExtension {
22  MCAsmParserExtension(const MCAsmParserExtension &);   // DO NOT IMPLEMENT
23  void operator=(const MCAsmParserExtension &);  // DO NOT IMPLEMENT
24
25  MCAsmParser *Parser;
26
27protected:
28  MCAsmParserExtension();
29
30public:
31  virtual ~MCAsmParserExtension();
32
33  /// \brief Initialize the extension for parsing using the given \arg
34  /// Parser. The extension should use the AsmParser interfaces to register its
35  /// parsing routines.
36  virtual void Initialize(MCAsmParser &Parser);
37
38  /// @name MCAsmParser Proxy Interfaces
39  /// @{
40
41  MCContext &getContext() { return getParser().getContext(); }
42  MCAsmLexer &getLexer() { return getParser().getLexer(); }
43  MCAsmParser &getParser() { return *Parser; }
44  MCStreamer &getStreamer() { return getParser().getStreamer(); }
45  void Warning(SMLoc L, const Twine &Msg) {
46    return getParser().Warning(L, Msg);
47  }
48  bool Error(SMLoc L, const Twine &Msg) {
49    return getParser().Error(L, Msg);
50  }
51
52  const AsmToken &Lex() { return getParser().Lex(); }
53
54  const AsmToken &getTok() { return getParser().getTok(); }
55
56  bool TokError(const char *Msg) {
57    return getParser().TokError(Msg);
58  }
59
60  /// @}
61};
62
63} // End llvm namespace
64
65#endif
66