summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-14 14:58:24 -0700
committerGitHub <noreply@github.com>2024-03-14 14:58:24 -0700
commitc7d7a965c14318c07bd5b8ec60b960c2e95dfebd (patch)
treea8ba4c59576863fd6e3bc869f34fa3a431a818dc /source/slang
parentf5f0740be8102b4d719575d97b00dbd21b54ffbe (diff)
Support `#include` with angle brackets. (#3773)
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-preprocessor.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/source/slang/slang-preprocessor.cpp b/source/slang/slang-preprocessor.cpp
index 9586088a1..b0986f64c 100644
--- a/source/slang/slang-preprocessor.cpp
+++ b/source/slang/slang-preprocessor.cpp
@@ -2994,10 +2994,25 @@ static void HandleIncludeDirective(PreprocessorDirectiveContext* context)
AdvanceRawToken(context);
Token pathToken;
- if(!Expect(context, TokenType::StringLiteral, Diagnostics::expectedTokenInPreprocessorDirective, &pathToken))
- return;
-
- String path = getFileNameTokenValue(pathToken);
+ String path;
+ if (PeekRawTokenType(context) == TokenType::OpLess)
+ {
+ StringBuilder pathSB;
+ Expect(context, TokenType::OpLess, Diagnostics::expectedTokenInPreprocessorDirective, &pathToken);
+ while (PeekRawTokenType(context) != TokenType::OpGreater &&
+ PeekRawTokenType(context) != TokenType::EndOfFile)
+ {
+ pathSB << AdvanceRawToken(context).getContent();
+ }
+ if (!Expect(context, TokenType::OpGreater, Diagnostics::expectedTokenInPreprocessorDirective))
+ return;
+ path = pathSB.produceString();
+ }
+ else
+ {
+ Expect(context, TokenType::StringLiteral, Diagnostics::expectedTokenInPreprocessorDirective, &pathToken);
+ path = getFileNameTokenValue(pathToken);
+ }
auto directiveLoc = GetDirectiveLoc(context);