[PATCH] D41577: Simplify script lexer.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 26 02:07:47 PST 2017
ruiu created this revision.
ruiu added a reviewer: grimar.
Herald added a subscriber: emaste.
Simplify script lexer.
https://reviews.llvm.org/D41577
Files:
lld/ELF/ScriptLexer.cpp
lld/ELF/ScriptParser.cpp
Index: lld/ELF/ScriptParser.cpp
===================================================================
--- lld/ELF/ScriptParser.cpp
+++ lld/ELF/ScriptParser.cpp
@@ -707,8 +707,6 @@
if (consume(">"))
Cmd->MemoryRegionName = next();
- else if (peek().startswith(">"))
- Cmd->MemoryRegionName = next().drop_front();
Cmd->Phdrs = readOutputSectionPhdrs();
Index: lld/ELF/ScriptLexer.cpp
===================================================================
--- lld/ELF/ScriptLexer.cpp
+++ lld/ELF/ScriptLexer.cpp
@@ -115,11 +115,19 @@
continue;
}
+ // ">foo" is parsed to ">" and "foo", but ">>" is parsed to ">>".
+ if (S.startswith("<<") || S.startswith("<=") || S.startswith(">>") ||
+ S.startswith(">=")) {
+ Vec.push_back(S.substr(0, 2));
+ S = S.substr(2);
+ continue;
+ }
+
// Unquoted token. This is more relaxed than tokens in C-like language,
// so that you can write "file-name.cpp" as one bare token, for example.
size_t Pos = S.find_first_not_of(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- "0123456789_.$/\\~=+[]*?-!<>^:");
+ "0123456789_.$/\\~=+[]*?-!^:");
// A character that cannot start a word (which is usually a
// punctuation) forms a single character token.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41577.128154.patch
Type: text/x-patch
Size: 1300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171226/a7997577/attachment.bin>
More information about the llvm-commits
mailing list