| Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 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" |
| 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 | |
| 22 | class ScriptParserBase { |
| 23 | public: |
| Eugene Leviant | 03ff016 | 2016-11-21 15:49:56 +0000 | [diff] [blame] | 24 | explicit ScriptParserBase(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(); |
| 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); |
| Eugene Leviant | ed30ce7 | 2016-11-28 09:58:04 +0000 | [diff] [blame^] | 35 | std::string currentLocation(); |
| Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 36 | |
| Eugene Leviant | 03ff016 | 2016-11-21 15:49:56 +0000 | [diff] [blame] | 37 | std::vector<MemoryBufferRef> MBs; |
| Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 38 | std::vector<StringRef> Tokens; |
| 39 | size_t Pos = 0; |
| 40 | bool Error = false; |
| Eugene Leviant | 03ff016 | 2016-11-21 15:49:56 +0000 | [diff] [blame] | 41 | |
| 42 | private: |
| 43 | MemoryBufferRef currentBuffer(); |
| Adhemerval Zanella | e77b5bf | 2016-04-06 20:59:11 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | } // namespace elf |
| 47 | } // namespace lld |
| 48 | |
| 49 | #endif |