diff options
Diffstat (limited to 'lld/ELF/ScriptLexer.cpp')
| -rw-r--r-- | lld/ELF/ScriptLexer.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lld/ELF/ScriptLexer.cpp b/lld/ELF/ScriptLexer.cpp index fa77df59583..86720de3527 100644 --- a/lld/ELF/ScriptLexer.cpp +++ b/lld/ELF/ScriptLexer.cpp @@ -124,7 +124,7 @@ void ScriptLexer::tokenize(MemoryBufferRef MB) { // 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. @@ -169,7 +169,7 @@ bool ScriptLexer::atEOF() { return Error || Tokens.size() == Pos; } // Split a given string as an expression. // This function returns "3", "*" and "5" for "3*5" for example. static std::vector<StringRef> tokenizeExpr(StringRef S) { - StringRef Ops = "+-*/"; // List of operators + StringRef Ops = "+-*/:"; // List of operators // Quoted strings are literal strings, so we don't want to split it. if (S.startswith("\"")) @@ -229,14 +229,11 @@ StringRef ScriptLexer::next() { return Tokens[Pos++]; } -StringRef ScriptLexer::peek(unsigned N) { - StringRef Tok; - for (unsigned I = 0; I <= N; ++I) { - Tok = next(); - if (Error) - return ""; - } - Pos = Pos - N - 1; +StringRef ScriptLexer::peek() { + StringRef Tok = next(); + if (Error) + return ""; + Pos = Pos - 1; return Tok; } @@ -248,6 +245,18 @@ bool ScriptLexer::consume(StringRef Tok) { return false; } +// Consumes Tok followed by ":". Space is allowed between Tok and ":". +bool ScriptLexer::consumeLabel(StringRef Tok) { + if (consume((Tok + ":").str())) + return true; + if (Tokens.size() >= Pos + 2 && Tokens[Pos] == Tok && + Tokens[Pos + 1] == ":") { + Pos += 2; + return true; + } + return false; +} + void ScriptLexer::skip() { (void)next(); } void ScriptLexer::expect(StringRef Expect) { |

