diff options
| author | Yong He <yonghe@outlook.com> | 2022-06-13 12:20:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-13 12:20:35 -0700 |
| commit | c90c6ab750ab05dd6d337e4f857958b8f3d00153 (patch) | |
| tree | 569085637c5d3de33d7aaec8ab8c0e84be49bfd0 /source/slang/slang-mangled-lexer.cpp | |
| parent | 68d9d87f9385a8c7c29443dcfcbf70434dc889bd (diff) | |
Language Server improvements. (#2269)
* Language Server improvements.
- Improve parser robustness around `attribute_syntax`.
- Exclude instance members in a static query.
- Coloring accessors
- Improved signature help cursor range check.
* Add expected test result.
* Language server: support configuring predefined macros.
* Fix constructor highlighting.
* Improving performance by supporting incremental text change notifications.
* Fix UTF16 positions and highlighting of constructor calls.
* Add completion suggestions for HLSL semantics.
* Fix tests.
* Fix: don't skip static variables in a static query.
* Include literal init expr value in hover text.
* Fix scenarios where completion failed to trigger.
* Fixing language server protocol field initializations.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-mangled-lexer.cpp')
| -rw-r--r-- | source/slang/slang-mangled-lexer.cpp | 72 |
1 files changed, 60 insertions, 12 deletions
diff --git a/source/slang/slang-mangled-lexer.cpp b/source/slang/slang-mangled-lexer.cpp index 32a8fa741..4920cfce3 100644 --- a/source/slang/slang-mangled-lexer.cpp +++ b/source/slang/slang-mangled-lexer.cpp @@ -158,8 +158,14 @@ UnownedStringSlice MangledLexer::readSimpleName() } } -UnownedStringSlice MangledLexer::readRawStringSegment() +String MangledLexer::readRawStringSegment() { + bool escapeMode = false; + if (peekChar() == 'R') + { + escapeMode = true; + nextChar(); + } // Read the length part UInt count = readCount(); if (count > UInt(m_end - m_cursor)) @@ -170,9 +176,52 @@ UnownedStringSlice MangledLexer::readRawStringSegment() auto result = UnownedStringSlice(m_cursor, m_cursor + count); m_cursor += count; + if (escapeMode) + return unescapeString(result); return result; } +String MangledLexer::unescapeString(UnownedStringSlice str) +{ + StringBuilder sb; + Index cursor = 0; + while (cursor < str.getLength()) + { + auto ch = str[cursor]; + auto nextCh = 0; + if (cursor + 1 < str.getLength()) + { + nextCh = str[cursor + 1]; + } + if (ch == '_' && nextCh == 'u') + { + sb.appendChar('_'); + cursor += 2; + } + else if (ch == '_') + { + cursor++; + Int charValue = 0; + while (cursor < str.getLength()) + { + auto current = str[cursor]; + if (current == 'x') + break; + charValue = charValue * 16 + CharUtil::getHexDigitValue(current); + cursor++; + } + sb.appendChar((char)charValue); + cursor++; + } + else + { + sb.appendChar(ch); + cursor++; + } + } + return sb.ProduceString(); +} + UInt MangledLexer::readParamCount() { _expect("p"); @@ -183,25 +232,24 @@ UInt MangledLexer::readParamCount() /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! MangledNameParser !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ -/* static */SlangResult MangledNameParser::parseModuleName(const UnownedStringSlice& in, UnownedStringSlice& outModuleName) +/* static */SlangResult MangledNameParser::parseModuleName(const UnownedStringSlice& in, String& outModuleName) { MangledLexer lexer(in); - { switch (lexer.peekChar()) { - case 'T': - case 'G': - case 'V': - { - lexer.nextChar(); - break; - } - default: break; + case 'T': + case 'G': + case 'V': + { + lexer.nextChar(); + break; + } + default: break; } } - UnownedStringSlice name = lexer.readRawStringSegment(); + auto name = lexer.readRawStringSegment(); if (name.getLength() == 0) { return SLANG_FAIL; |
