Rui Ueyama | 794366a | 2017-02-14 04:47:05 +0000 | [diff] [blame] | 1 | //===- ScriptLexer.h --------------------------------------------*- C++ -*-===// |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 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 | |
Rui Ueyama | 794366a | 2017-02-14 04:47:05 +0000 | [diff] [blame] | 10 | #ifndef LLD_ELF_SCRIPT_LEXER_H |
| 11 | #define LLD_ELF_SCRIPT_LEXER_H |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 12 | |
Rui Ueyama | 3f85170 | 2017-10-02 21:00:41 +0000 | [diff] [blame] | 13 | #include "lld/Common/LLVM.h" |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 14 | #include "llvm/ADT/StringRef.h" |
Eugene Leviant | 03ff016 | 2016-11-21 15:49:56 +0000 | [diff] [blame] | 15 | #include "llvm/Support/MemoryBuffer.h" |
Benjamin Kramer | bd52120 | 2016-06-03 16:57:13 +0000 | [diff] [blame] | 16 | #include <utility> |
Adhemerval Zanella | b92a34e | 2016-04-06 21:33:18 +0000 | [diff] [blame] | 17 | #include <vector> |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 18 | |
| 19 | namespace lld { |
| 20 | namespace elf { |
| 21 | |
Rui Ueyama | 794366a | 2017-02-14 04:47:05 +0000 | [diff] [blame] | 22 | class ScriptLexer { |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 23 | public: |
Rui Ueyama | 794366a | 2017-02-14 04:47:05 +0000 | [diff] [blame] | 24 | explicit ScriptLexer(MemoryBufferRef MB); |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 25 | |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 26 | void setError(const Twine &Msg); |
Eugene Leviant | 03ff016 | 2016-11-21 15:49:56 +0000 | [diff] [blame] | 27 | void tokenize(MemoryBufferRef MB); |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 28 | static StringRef skipSpace(StringRef S); |
| 29 | bool atEOF(); |
| 30 | StringRef next(); |
Rui Ueyama | f5fce48 | 2017-03-09 19:23:00 +0000 | [diff] [blame] | 31 | StringRef peek(); |
Justin Bogner | 5424e7c | 2016-10-17 06:21:13 +0000 | [diff] [blame] | 32 | void skip(); |
Rui Ueyama | 83043f2 | 2016-10-17 16:01:53 +0000 | [diff] [blame] | 33 | bool consume(StringRef Tok); |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 34 | void expect(StringRef Expect); |
Rui Ueyama | f5fce48 | 2017-03-09 19:23:00 +0000 | [diff] [blame] | 35 | bool consumeLabel(StringRef Tok); |
Rui Ueyama | b5f1c3e | 2016-12-01 04:36:49 +0000 | [diff] [blame] | 36 | std::string getCurrentLocation(); |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 37 | |
Eugene Leviant | 03ff016 | 2016-11-21 15:49:56 +0000 | [diff] [blame] | 38 | std::vector<MemoryBufferRef> MBs; |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 39 | std::vector<StringRef> Tokens; |
Rui Ueyama | 731a66a | 2017-02-15 19:58:17 +0000 | [diff] [blame] | 40 | bool InExpr = false; |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 41 | size_t Pos = 0; |
Eugene Leviant | 03ff016 | 2016-11-21 15:49:56 +0000 | [diff] [blame] | 42 | |
| 43 | private: |
Rui Ueyama | 731a66a | 2017-02-15 19:58:17 +0000 | [diff] [blame] | 44 | void maybeSplitExpr(); |
Rui Ueyama | b5f1c3e | 2016-12-01 04:36:49 +0000 | [diff] [blame] | 45 | StringRef getLine(); |
| 46 | size_t getLineNumber(); |
| 47 | size_t getColumnNumber(); |
| 48 | |
Rui Ueyama | 10091b0 | 2016-12-01 04:36:54 +0000 | [diff] [blame] | 49 | MemoryBufferRef getCurrentMB(); |
Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | } // namespace elf |
| 53 | } // namespace lld |
| 54 | |
| 55 | #endif |