1 //===- LLLexer.h - Lexer for LLVM Assembly Files ----------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class represents the Lexer for .ll files.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_ASMPARSER_LLLEXER_H
15 #define LLVM_LIB_ASMPARSER_LLLEXER_H
18 #include "llvm/ADT/APFloat.h"
19 #include "llvm/ADT/APSInt.h"
20 #include "llvm/Support/SourceMgr.h"
32 SMDiagnostic &ErrorInfo;
36 // Information about the current token.
46 explicit LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &,
51 return CurKind = LexToken();
55 LocTy getLoc() const { return SMLoc::getFromPointer(TokStart); }
56 lltok::Kind getKind() const { return CurKind; }
57 const std::string &getStrVal() const { return StrVal; }
58 Type *getTyVal() const { return TyVal; }
59 unsigned getUIntVal() const { return UIntVal; }
60 const APSInt &getAPSIntVal() const { return APSIntVal; }
61 const APFloat &getAPFloatVal() const { return APFloatVal; }
64 bool Error(LocTy L, const Twine &Msg) const;
65 bool Error(const Twine &Msg) const { return Error(getLoc(), Msg); }
67 void Warning(LocTy WarningLoc, const Twine &Msg) const;
68 void Warning(const Twine &Msg) const { return Warning(getLoc(), Msg); }
71 lltok::Kind LexToken();
74 void SkipLineComment();
75 lltok::Kind ReadString(lltok::Kind kind);
78 lltok::Kind LexIdentifier();
79 lltok::Kind LexDigitOrNegative();
80 lltok::Kind LexPositive();
82 lltok::Kind LexDollar();
83 lltok::Kind LexExclaim();
84 lltok::Kind LexPercent();
85 lltok::Kind LexQuote();
87 lltok::Kind LexHash();
89 uint64_t atoull(const char *Buffer, const char *End);
90 uint64_t HexIntToVal(const char *Buffer, const char *End);
91 void HexToIntPair(const char *Buffer, const char *End, uint64_t Pair[2]);
92 void FP80HexToIntPair(const char *Buff, const char *End, uint64_t Pair[2]);
94 } // end namespace llvm