]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/ELF/ScriptParser.h
Update lld to trunk r290819 and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / ELF / ScriptParser.h
1 //===- ScriptParser.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_PARSER_H
11 #define LLD_ELF_SCRIPT_PARSER_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 ScriptParserBase {
23 public:
24   explicit ScriptParserBase(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   std::string getCurrentLocation();
36
37   std::vector<MemoryBufferRef> MBs;
38   std::vector<StringRef> Tokens;
39   size_t Pos = 0;
40   bool Error = false;
41
42 private:
43   StringRef getLine();
44   size_t getLineNumber();
45   size_t getColumnNumber();
46
47   MemoryBufferRef getCurrentMB();
48 };
49
50 } // namespace elf
51 } // namespace lld
52
53 #endif