MCAsmParserExtension.h revision 4e82bbb745160f19d76b9b5de5b93ebe224e1acf
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  SourceMgr &getSourceManager() { return getParser().getSourceManager(); }
45  MCStreamer &getStreamer() { return getParser().getStreamer(); }
46  void Warning(SMLoc L, const Twine &Msg) {
47    return getParser().Warning(L, Msg);
48  }
49  bool Error(SMLoc L, const Twine &Msg) {
50    return getParser().Error(L, Msg);
51  }
52
53  const AsmToken &Lex() { return getParser().Lex(); }
54
55  const AsmToken &getTok() { return getParser().getTok(); }
56
57  bool TokError(const char *Msg) {
58    return getParser().TokError(Msg);
59  }
60
61  /// @}
62};
63
64} // End llvm namespace
65
66#endif
67