2017-02-14 12:47:05 +08:00
|
|
|
//===- ScriptLexer.h --------------------------------------------*- C++ -*-===//
|
2016-04-07 04:59:11 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-04-07 04:59:11 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
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();
|
2018-08-28 16:39:21 +08:00
|
|
|
StringRef peek2();
|
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
|