Chris Lattner | 8e3a8e0 | 2007-11-18 08:46:26 +0000 | [diff] [blame] | 1 | //===- LLLexer.h - Lexer for LLVM Assembly Files ----------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Chris Lattner | 8e3a8e0 | 2007-11-18 08:46:26 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This class represents the Lexer for .ll files. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LIB_ASMPARSER_LLLEXER_H |
| 15 | #define LIB_ASMPARSER_LLLEXER_H |
| 16 | |
| 17 | #include <vector> |
| 18 | #include <string> |
| 19 | #include <iosfwd> |
| 20 | |
| 21 | namespace llvm { |
| 22 | class MemoryBuffer; |
| 23 | |
| 24 | class LLLexer { |
| 25 | const char *CurPtr; |
| 26 | unsigned CurLineNo; |
| 27 | MemoryBuffer *CurBuf; |
| 28 | |
| 29 | const char *TokStart; |
| 30 | |
| 31 | std::string TheError; |
| 32 | public: |
Dan Gohman | 950a4c4 | 2008-03-25 22:06:05 +0000 | [diff] [blame] | 33 | explicit LLLexer(MemoryBuffer *StartBuf); |
Chris Lattner | 8e3a8e0 | 2007-11-18 08:46:26 +0000 | [diff] [blame] | 34 | ~LLLexer() {} |
| 35 | |
| 36 | const char *getTokStart() const { return TokStart; } |
| 37 | unsigned getTokLength() const { return CurPtr-TokStart; } |
| 38 | unsigned getLineNo() const { return CurLineNo; } |
| 39 | std::string getFilename() const; |
| 40 | int LexToken(); |
| 41 | |
| 42 | const std::string getError() const { return TheError; } |
| 43 | |
| 44 | private: |
| 45 | int getNextChar(); |
| 46 | void SkipLineComment(); |
| 47 | int LexIdentifier(); |
| 48 | int LexDigitOrNegative(); |
| 49 | int LexPositive(); |
| 50 | int LexAt(); |
| 51 | int LexPercent(); |
| 52 | int LexQuote(); |
| 53 | int Lex0x(); |
| 54 | }; |
| 55 | } // end namespace llvm |
| 56 | |
| 57 | #endif |