add support for parsing and emitting .section directives. We can now parse
[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 MCContext;
21 class MCInst;
22 class MCStreamer;
23   
24 class AsmParser {
25   AsmLexer Lexer;
26   MCContext &Ctx;
27   MCStreamer &Out;
28   
29   struct X86Operand;
30   
31 public:
32   AsmParser(SourceMgr &SM, MCContext &ctx, MCStreamer &OutStr)
33     : Lexer(SM), Ctx(ctx), Out(OutStr) {}
34   ~AsmParser() {}
35   
36   bool Run();
37   
38 private:
39   bool ParseStatement();
40   
41   bool Error(SMLoc L, const char *Msg);
42   bool TokError(const char *Msg);
43   
44   void EatToEndOfStatement();
45   
46   bool ParseExpression(int64_t &Res);
47   bool ParsePrimaryExpr(int64_t &Res);
48   bool ParseBinOpRHS(unsigned Precedence, int64_t &Res);
49   bool ParseParenExpr(int64_t &Res);
50   
51   // X86 specific.
52   bool ParseX86InstOperands(MCInst &Inst);
53   bool ParseX86Operand(X86Operand &Op);
54   bool ParseX86MemOperand(X86Operand &Op);
55   
56   // Directive Parsing.
57   bool ParseDirectiveSection();
58   
59 };
60
61 } // end namespace llvm
62
63 #endif