Rename ScriptParser.{cpp,h} -> ScriptLexer.{cpp,h}.
These files contain a lexer, so the new names are better.
The parser is in LinkerScript.{cpp,h}.
llvm-svn: 295022
diff --git a/lld/ELF/CMakeLists.txt b/lld/ELF/CMakeLists.txt
index 0d1e5b2..02888b8 100644
--- a/lld/ELF/CMakeLists.txt
+++ b/lld/ELF/CMakeLists.txt
@@ -22,7 +22,7 @@
Mips.cpp
OutputSections.cpp
Relocations.cpp
- ScriptParser.cpp
+ ScriptLexer.cpp
Strings.cpp
SymbolTable.cpp
Symbols.cpp
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index a0b8530..1405fa5 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -17,7 +17,7 @@
#include "InputSection.h"
#include "Memory.h"
#include "OutputSections.h"
-#include "ScriptParser.h"
+#include "ScriptLexer.h"
#include "Strings.h"
#include "SymbolTable.h"
#include "Symbols.h"
@@ -1016,12 +1016,12 @@
return 0;
}
-class elf::ScriptParser final : public ScriptParserBase {
+class elf::ScriptParser final : public ScriptLexer {
typedef void (ScriptParser::*Handler)();
public:
ScriptParser(MemoryBufferRef MB)
- : ScriptParserBase(MB),
+ : ScriptLexer(MB),
IsUnderSysroot(isUnderSysroot(MB.getBufferIdentifier())) {}
void readLinkerScript();
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptLexer.cpp
similarity index 84%
rename from lld/ELF/ScriptParser.cpp
rename to lld/ELF/ScriptLexer.cpp
index 474895f..6398a52 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptLexer.cpp
@@ -1,4 +1,4 @@
-//===- ScriptParser.cpp ---------------------------------------------------===//
+//===- ScriptLexer.cpp ----------------------------------------------------===//
//
// The LLVM Linker
//
@@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
-#include "ScriptParser.h"
+#include "ScriptLexer.h"
#include "Error.h"
#include "llvm/ADT/Twine.h"
@@ -21,7 +21,7 @@
using namespace lld::elf;
// Returns a whole line containing the current token.
-StringRef ScriptParserBase::getLine() {
+StringRef ScriptLexer::getLine() {
StringRef S = getCurrentMB().getBuffer();
StringRef Tok = Tokens[Pos - 1];
@@ -32,29 +32,29 @@
}
// Returns 1-based line number of the current token.
-size_t ScriptParserBase::getLineNumber() {
+size_t ScriptLexer::getLineNumber() {
StringRef S = getCurrentMB().getBuffer();
StringRef Tok = Tokens[Pos - 1];
return S.substr(0, Tok.data() - S.data()).count('\n') + 1;
}
// Returns 0-based column number of the current token.
-size_t ScriptParserBase::getColumnNumber() {
+size_t ScriptLexer::getColumnNumber() {
StringRef Tok = Tokens[Pos - 1];
return Tok.data() - getLine().data();
}
-std::string ScriptParserBase::getCurrentLocation() {
+std::string ScriptLexer::getCurrentLocation() {
std::string Filename = getCurrentMB().getBufferIdentifier();
if (!Pos)
return Filename;
return (Filename + ":" + Twine(getLineNumber())).str();
}
-ScriptParserBase::ScriptParserBase(MemoryBufferRef MB) { tokenize(MB); }
+ScriptLexer::ScriptLexer(MemoryBufferRef MB) { tokenize(MB); }
// We don't want to record cascading errors. Keep only the first one.
-void ScriptParserBase::setError(const Twine &Msg) {
+void ScriptLexer::setError(const Twine &Msg) {
if (Error)
return;
Error = true;
@@ -71,7 +71,7 @@
}
// Split S into linker script tokens.
-void ScriptParserBase::tokenize(MemoryBufferRef MB) {
+void ScriptLexer::tokenize(MemoryBufferRef MB) {
std::vector<StringRef> Vec;
MBs.push_back(MB);
StringRef S = MB.getBuffer();
@@ -118,7 +118,7 @@
}
// Skip leading whitespace characters or comments.
-StringRef ScriptParserBase::skipSpace(StringRef S) {
+StringRef ScriptLexer::skipSpace(StringRef S) {
for (;;) {
if (S.startswith("/*")) {
size_t E = S.find("*/", 2);
@@ -144,9 +144,9 @@
}
// An erroneous token is handled as if it were the last token before EOF.
-bool ScriptParserBase::atEOF() { return Error || Tokens.size() == Pos; }
+bool ScriptLexer::atEOF() { return Error || Tokens.size() == Pos; }
-StringRef ScriptParserBase::next() {
+StringRef ScriptLexer::next() {
if (Error)
return "";
if (atEOF()) {
@@ -156,7 +156,7 @@
return Tokens[Pos++];
}
-StringRef ScriptParserBase::peek(unsigned N) {
+StringRef ScriptLexer::peek(unsigned N) {
StringRef Tok;
for (unsigned I = 0; I <= N; ++I) {
Tok = next();
@@ -167,7 +167,7 @@
return Tok;
}
-bool ScriptParserBase::consume(StringRef Tok) {
+bool ScriptLexer::consume(StringRef Tok) {
if (peek() == Tok) {
skip();
return true;
@@ -175,9 +175,9 @@
return false;
}
-void ScriptParserBase::skip() { (void)next(); }
+void ScriptLexer::skip() { (void)next(); }
-void ScriptParserBase::expect(StringRef Expect) {
+void ScriptLexer::expect(StringRef Expect) {
if (Error)
return;
StringRef Tok = next();
@@ -190,7 +190,7 @@
return S.bytes_begin() <= T.bytes_begin() && T.bytes_end() <= S.bytes_end();
}
-MemoryBufferRef ScriptParserBase::getCurrentMB() {
+MemoryBufferRef ScriptLexer::getCurrentMB() {
// Find input buffer containing the current token.
assert(!MBs.empty());
if (!Pos)
diff --git a/lld/ELF/ScriptParser.h b/lld/ELF/ScriptLexer.h
similarity index 83%
rename from lld/ELF/ScriptParser.h
rename to lld/ELF/ScriptLexer.h
index 42ae267..2ebf862 100644
--- a/lld/ELF/ScriptParser.h
+++ b/lld/ELF/ScriptLexer.h
@@ -1,4 +1,4 @@
-//===- ScriptParser.h -------------------------------------------*- C++ -*-===//
+//===- ScriptLexer.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Linker
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_ELF_SCRIPT_PARSER_H
-#define LLD_ELF_SCRIPT_PARSER_H
+#ifndef LLD_ELF_SCRIPT_LEXER_H
+#define LLD_ELF_SCRIPT_LEXER_H
#include "lld/Core/LLVM.h"
#include "llvm/ADT/StringRef.h"
@@ -19,9 +19,9 @@
namespace lld {
namespace elf {
-class ScriptParserBase {
+class ScriptLexer {
public:
- explicit ScriptParserBase(MemoryBufferRef MB);
+ explicit ScriptLexer(MemoryBufferRef MB);
void setError(const Twine &Msg);
void tokenize(MemoryBufferRef MB);