2017-02-14 12:47:05 +08:00
|
|
|
//===- ScriptLexer.h --------------------------------------------*- C++ -*-===//
|
2016-04-07 04:59:11 +08:00
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-02-14 12:47:05 +08:00
|
|
|
#ifndef LLD_ELF_SCRIPT_LEXER_H
|
|
|
|
#define LLD_ELF_SCRIPT_LEXER_H
|
2016-04-07 04:59:11 +08:00
|
|
|
|
2017-10-03 05:00:41 +08:00
|
|
|
#include "lld/Common/LLVM.h"
|
2016-04-07 04:59:11 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2016-11-21 23:49:56 +08:00
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
2016-06-04 00:57:13 +08:00
|
|
|
#include <utility>
|
2016-04-07 05:33:18 +08:00
|
|
|
#include <vector>
|
2016-04-07 04:59:11 +08:00
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace elf {
|
|
|
|
|
2017-02-14 12:47:05 +08:00
|
|
|
class ScriptLexer {
|
2016-04-07 04:59:11 +08:00
|
|
|
public:
|
2017-02-14 12:47:05 +08:00
|
|
|
explicit ScriptLexer(MemoryBufferRef MB);
|
2016-04-07 04:59:11 +08:00
|
|
|
|
|
|
|
void setError(const Twine &Msg);
|
2016-11-21 23:49:56 +08:00
|
|
|
void tokenize(MemoryBufferRef MB);
|
2016-04-07 04:59:11 +08:00
|
|
|
static StringRef skipSpace(StringRef S);
|
|
|
|
bool atEOF();
|
|
|
|
StringRef next();
|
2017-03-10 03:23:00 +08:00
|
|
|
StringRef peek();
|
2016-10-17 14:21:13 +08:00
|
|
|
void skip();
|
2016-10-18 00:01:53 +08:00
|
|
|
bool consume(StringRef Tok);
|
2016-04-07 04:59:11 +08:00
|
|
|
void expect(StringRef Expect);
|
2017-03-10 03:23:00 +08:00
|
|
|
bool consumeLabel(StringRef Tok);
|
2016-12-01 12:36:49 +08:00
|
|
|
std::string getCurrentLocation();
|
2016-04-07 04:59:11 +08:00
|
|
|
|
2016-11-21 23:49:56 +08:00
|
|
|
std::vector<MemoryBufferRef> MBs;
|
2016-04-07 04:59:11 +08:00
|
|
|
std::vector<StringRef> Tokens;
|
2017-02-16 03:58:17 +08:00
|
|
|
bool InExpr = false;
|
2016-04-07 04:59:11 +08:00
|
|
|
size_t Pos = 0;
|
2016-11-21 23:49:56 +08:00
|
|
|
|
|
|
|
private:
|
2017-02-16 03:58:17 +08:00
|
|
|
void maybeSplitExpr();
|
2016-12-01 12:36:49 +08:00
|
|
|
StringRef getLine();
|
|
|
|
size_t getLineNumber();
|
|
|
|
size_t getColumnNumber();
|
|
|
|
|
2016-12-01 12:36:54 +08:00
|
|
|
MemoryBufferRef getCurrentMB();
|
2016-04-07 04:59:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace elf
|
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|