Add a hack to unbreak MSVC builds. str(n)casecmp are POSIX functions and aren't avail...
[oota-llvm.git] / tools / llvm-mc / AsmLexer.h
1 //===- AsmLexer.h - Lexer 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 lexer for assembly files.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ASMLEXER_H
15 #define ASMLEXER_H
16
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/MC/MCAsmLexer.h"
19 #include "llvm/Support/DataTypes.h"
20 #include <string>
21 #include <cassert>
22
23 namespace llvm {
24 class MemoryBuffer;
25 class SourceMgr;
26 class SMLoc;
27
28 /// AsmLexer - Lexer class for assembly files.
29 class AsmLexer : public MCAsmLexer {
30   SourceMgr &SrcMgr;
31   
32   const char *CurPtr;
33   const MemoryBuffer *CurBuf;
34   
35   const char *TokStart;
36
37   /// This is the current buffer index we're lexing from as managed by the
38   /// SourceMgr object.
39   int CurBuffer;
40   
41   void operator=(const AsmLexer&); // DO NOT IMPLEMENT
42   AsmLexer(const AsmLexer&);       // DO NOT IMPLEMENT
43
44 protected:
45   /// LexToken - Read the next token and return its code.
46   virtual AsmToken LexToken();
47
48 public:
49   AsmLexer(SourceMgr &SrcMgr);
50   ~AsmLexer();
51   
52   SMLoc getLoc() const;
53   
54   StringRef LexUntilEndOfStatement();
55   
56
57   /// EnterIncludeFile - Enter the specified file. This returns true on failure.
58   bool EnterIncludeFile(const std::string &Filename);
59   
60   void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
61   
62 private:
63   int getNextChar();
64   AsmToken ReturnError(const char *Loc, const std::string &Msg);
65
66   AsmToken LexIdentifier();
67   AsmToken LexPercent();
68   AsmToken LexSlash();
69   AsmToken LexLineComment();
70   AsmToken LexDigit();
71   AsmToken LexQuote();
72 };
73   
74 } // end namespace llvm
75
76 #endif