comparison lld/ELF/ScriptLexer.h @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children 0572611fdcc8
comparison
equal deleted inserted replaced
147:c2174574ed3a 150:1d019706d866
1 //===- ScriptLexer.h --------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLD_ELF_SCRIPT_LEXER_H
10 #define LLD_ELF_SCRIPT_LEXER_H
11
12 #include "lld/Common/LLVM.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/MemoryBuffer.h"
15 #include <utility>
16 #include <vector>
17
18 namespace lld {
19 namespace elf {
20
21 class ScriptLexer {
22 public:
23 explicit ScriptLexer(MemoryBufferRef mb);
24
25 void setError(const Twine &msg);
26 void tokenize(MemoryBufferRef mb);
27 static StringRef skipSpace(StringRef s);
28 bool atEOF();
29 StringRef next();
30 StringRef peek();
31 StringRef peek2();
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
43 private:
44 void maybeSplitExpr();
45 StringRef getLine();
46 size_t getLineNumber();
47 size_t getColumnNumber();
48
49 MemoryBufferRef getCurrentMB();
50 };
51
52 } // namespace elf
53 } // namespace lld
54
55 #endif