[PATCH] D41577: Simplify script lexer.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 26 02:14:15 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL321453: Simplify script lexer. (authored by ruiu, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41577?vs=128154&id=128155#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41577

Files:
  lld/trunk/ELF/ScriptLexer.cpp
  lld/trunk/ELF/ScriptParser.cpp


Index: lld/trunk/ELF/ScriptParser.cpp
===================================================================
--- lld/trunk/ELF/ScriptParser.cpp
+++ lld/trunk/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/trunk/ELF/ScriptLexer.cpp
===================================================================
--- lld/trunk/ELF/ScriptLexer.cpp
+++ lld/trunk/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.128155.patch
Type: text/x-patch
Size: 1336 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171226/99cd183f/attachment.bin>


More information about the llvm-commits mailing list