]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/ELF/ScriptLexer.h
MFV r323530,r323533,r323534: 7431 ZFS Channel Programs, and followups
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / ELF / ScriptLexer.h
1 //===- ScriptLexer.h --------------------------------------------*- C++ -*-===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLD_ELF_SCRIPT_LEXER_H
11 #define LLD_ELF_SCRIPT_LEXER_H
12
13 #include "lld/Core/LLVM.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/Support/MemoryBuffer.h"
16 #include <utility>
17 #include <vector>
18
19 namespace lld {
20 namespace elf {
21
22 class ScriptLexer {
23 public:
24   explicit ScriptLexer(MemoryBufferRef MB);
25
26   void setError(const Twine &Msg);
27   void tokenize(MemoryBufferRef MB);
28   static StringRef skipSpace(StringRef S);
29   bool atEOF();
30   StringRef next();
31   StringRef peek();
32   void skip();
33   bool consume(StringRef Tok);
34   void expect(StringRef Expect);
35   bool consumeLabel(StringRef Tok);
36   std::string getCurrentLocation();
37
38   std::vector<MemoryBufferRef> MBs;
39   std::vector<StringRef> Tokens;
40   bool InExpr = false;
41   size_t Pos = 0;
42   bool Error = false;
43
44 private:
45   void maybeSplitExpr();
46   StringRef getLine();
47   size_t getLineNumber();
48   size_t getColumnNumber();
49
50   MemoryBufferRef getCurrentMB();
51 };
52
53 } // namespace elf
54 } // namespace lld
55
56 #endif