1//===- LLLexer.h - Lexer for LLVM 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 represents the Lexer for .ll files. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LIB_ASMPARSER_LLLEXER_H 15#define LIB_ASMPARSER_LLLEXER_H 16 17#include "LLToken.h" 18#include "llvm/ADT/APSInt.h" 19#include "llvm/ADT/APFloat.h"
| 1//===- LLLexer.h - Lexer for LLVM 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 represents the Lexer for .ll files. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LIB_ASMPARSER_LLLEXER_H 15#define LIB_ASMPARSER_LLLEXER_H 16 17#include "LLToken.h" 18#include "llvm/ADT/APSInt.h" 19#include "llvm/ADT/APFloat.h"
|
| 20#include "llvm/Support/SourceMgr.h"
|
20#include <string> 21 22namespace llvm { 23 class MemoryBuffer; 24 class Type;
| 21#include <string> 22 23namespace llvm { 24 class MemoryBuffer; 25 class Type;
|
25 class ParseError;
| 26 class SMDiagnostic;
|
26 27 class LLLexer { 28 const char *CurPtr; 29 MemoryBuffer *CurBuf;
| 27 28 class LLLexer { 29 const char *CurPtr; 30 MemoryBuffer *CurBuf;
|
30 ParseError &ErrorInfo;
| 31 SMDiagnostic &ErrorInfo; 32 SourceMgr &SM;
|
31 32 // Information about the current token. 33 const char *TokStart; 34 lltok::Kind CurKind; 35 std::string StrVal; 36 unsigned UIntVal; 37 const Type *TyVal; 38 APFloat APFloatVal; 39 APSInt APSIntVal; 40 41 std::string TheError; 42 public:
| 33 34 // Information about the current token. 35 const char *TokStart; 36 lltok::Kind CurKind; 37 std::string StrVal; 38 unsigned UIntVal; 39 const Type *TyVal; 40 APFloat APFloatVal; 41 APSInt APSIntVal; 42 43 std::string TheError; 44 public:
|
43 explicit LLLexer(MemoryBuffer *StartBuf, ParseError &);
| 45 explicit LLLexer(MemoryBuffer *StartBuf, SourceMgr &SM, SMDiagnostic &);
|
44 ~LLLexer() {} 45 46 lltok::Kind Lex() { 47 return CurKind = LexToken(); 48 } 49
| 46 ~LLLexer() {} 47 48 lltok::Kind Lex() { 49 return CurKind = LexToken(); 50 } 51
|
50 typedef const char* LocTy; 51 LocTy getLoc() const { return TokStart; }
| 52 typedef SMLoc LocTy; 53 LocTy getLoc() const { return SMLoc::getFromPointer(TokStart); }
|
52 lltok::Kind getKind() const { return CurKind; } 53 const std::string getStrVal() const { return StrVal; } 54 const Type *getTyVal() const { return TyVal; } 55 unsigned getUIntVal() const { return UIntVal; } 56 const APSInt &getAPSIntVal() const { return APSIntVal; } 57 const APFloat &getAPFloatVal() const { return APFloatVal; } 58 59 60 bool Error(LocTy L, const std::string &Msg) const;
| 54 lltok::Kind getKind() const { return CurKind; } 55 const std::string getStrVal() const { return StrVal; } 56 const Type *getTyVal() const { return TyVal; } 57 unsigned getUIntVal() const { return UIntVal; } 58 const APSInt &getAPSIntVal() const { return APSIntVal; } 59 const APFloat &getAPFloatVal() const { return APFloatVal; } 60 61 62 bool Error(LocTy L, const std::string &Msg) const;
|
61 bool Error(const std::string &Msg) const { return Error(CurPtr, Msg); }
| 63 bool Error(const std::string &Msg) const { return Error(getLoc(), Msg); }
|
62 std::string getFilename() const; 63 64 private: 65 lltok::Kind LexToken(); 66 67 int getNextChar(); 68 void SkipLineComment(); 69 lltok::Kind LexIdentifier();
--- 15 unchanged lines hidden --- | 64 std::string getFilename() const; 65 66 private: 67 lltok::Kind LexToken(); 68 69 int getNextChar(); 70 void SkipLineComment(); 71 lltok::Kind LexIdentifier();
--- 15 unchanged lines hidden --- |