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.
45 // When false (default), an identifier ending in ':' is a label token.
46 // When true, the ':' is treated as a separate token.
47 bool IgnoreColonInIdentifiers;
50 explicit LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &,
54 return CurKind = LexToken();
58 LocTy getLoc() const { return SMLoc::getFromPointer(TokStart); }
59 lltok::Kind getKind() const { return CurKind; }
60 const std::string &getStrVal() const { return StrVal; }
61 Type *getTyVal() const { return TyVal; }
62 unsigned getUIntVal() const { return UIntVal; }
63 const APSInt &getAPSIntVal() const { return APSIntVal; }
64 const APFloat &getAPFloatVal() const { return APFloatVal; }
66 void setIgnoreColonInIdentifiers(bool val) {
67 IgnoreColonInIdentifiers = val;
70 bool Error(LocTy ErrorLoc, const Twine &Msg) const;
71 bool Error(const Twine &Msg) const { return Error(getLoc(), Msg); }
73 void Warning(LocTy WarningLoc, const Twine &Msg) const;
74 void Warning(const Twine &Msg) const { return Warning(getLoc(), Msg); }
77 lltok::Kind LexToken();
80 void SkipLineComment();
81 lltok::Kind ReadString(lltok::Kind kind);
84 lltok::Kind LexIdentifier();
85 lltok::Kind LexDigitOrNegative();
86 lltok::Kind LexPositive();
88 lltok::Kind LexDollar();
89 lltok::Kind LexExclaim();
90 lltok::Kind LexPercent();
91 lltok::Kind LexUIntID(lltok::Kind Token);
92 lltok::Kind LexVar(lltok::Kind Var, lltok::Kind VarID);
93 lltok::Kind LexQuote();
95 lltok::Kind LexHash();
96 lltok::Kind LexCaret();
98 uint64_t atoull(const char *Buffer, const char *End);
99 uint64_t HexIntToVal(const char *Buffer, const char *End);
100 void HexToIntPair(const char *Buffer, const char *End, uint64_t Pair[2]);
101 void FP80HexToIntPair(const char *Buffer, const char *End, uint64_t Pair[2]);
103 } // end namespace llvm