create an MCStreamer and provide it to AsmParser.
[oota-llvm.git] / tools / llvm-mc / AsmParser.h
1 //===- AsmParser.h - Parser for Assembly Files ------------------*- 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 // This class declares the parser for assembly files.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ASMPARSER_H
15 #define ASMPARSER_H
16
17 #include "AsmLexer.h"
18
19 namespace llvm {
20 class MCInst;
21 class MCStreamer;
22   
23 class AsmParser {
24   AsmLexer Lexer;
25   MCStreamer &Out;
26   
27   struct X86Operand;
28   
29 public:
30   AsmParser(SourceMgr &SM, MCStreamer &OutStr) : Lexer(SM), Out(OutStr) {}
31   ~AsmParser() {}
32   
33   bool Run();
34   
35 private:
36   bool ParseStatement();
37   
38   bool Error(SMLoc L, const char *Msg);
39   bool TokError(const char *Msg);
40   
41   void EatToEndOfStatement();
42   
43   bool ParseExpression(int64_t &Res);
44   bool ParsePrimaryExpr(int64_t &Res);
45   bool ParseBinOpRHS(unsigned Precedence, int64_t &Res);
46   bool ParseParenExpr(int64_t &Res);
47   
48   // X86 specific.
49   bool ParseX86InstOperands(MCInst &Inst);
50   bool ParseX86Operand(X86Operand &Op);
51   bool ParseX86MemOperand(X86Operand &Op);
52 };
53
54 } // end namespace llvm
55
56 #endif