LLLexer.h revision 8e3a8e0452695643d04c21e15c94b802aef81bae
1//===- LLLexer.h - Lexer for LLVM Assembly Files ----------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file was developed by Chris Lattner and is distributed under 6// the University of Illinois Open Source License. See LICENSE.TXT for details. 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 21namespace 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: 33 LLLexer(MemoryBuffer *StartBuf); 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 58