summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-parser.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-12-15 16:30:09 -0800
committerGitHub <noreply@github.com>2023-12-15 16:30:09 -0800
commitf8b3027d0be0b890152a6a649822741cd3a3b6b6 (patch)
tree7180b8063f0b99be4b4ee31288214b59ccc461ff /source/slang/slang-parser.cpp
parent21d17abb0e511806b7c93effc58f37169d837766 (diff)
Add language server support for vfx files. (#3414)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-parser.cpp')
-rw-r--r--source/slang/slang-parser.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index 1fd8bffcc..7be03a313 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -3046,6 +3046,22 @@ namespace Slang
link = &semantic->next;
}
+ // If we see a '<', ignore the remaining.
+ if (AdvanceIf(parser, TokenType::OpLess))
+ {
+ for (;;)
+ {
+ auto token = parser->tokenReader.peekToken();
+ if (token.type == TokenType::EndOfFile)
+ break;
+ else if (token.type == TokenType::OpGreater)
+ break;
+ else
+ parser->tokenReader.advanceToken();
+ }
+ parser->ReadToken(TokenType::OpGreater);
+ }
+
// If we see another `:`, then that means there
// is yet another semantic to be processed.
// Otherwise we assume we are at the end of the list.
@@ -3482,6 +3498,54 @@ namespace Slang
return decl;
}
+ static NodeBase* parseIgnoredBlockDecl(Parser* parser, void*)
+ {
+ parser->ReadToken(TokenType::LBrace);
+ int remaingingBraceToClose = 1;
+ for (;;)
+ {
+ auto token = parser->ReadToken();
+ if (token.type == TokenType::RBrace)
+ {
+ remaingingBraceToClose--;
+ if (remaingingBraceToClose == 0)
+ break;
+ }
+ else if (token.type == TokenType::LBrace)
+ {
+ remaingingBraceToClose++;
+ }
+ else if (token.type == TokenType::EndOfFile)
+ {
+ break;
+ }
+ }
+ auto decl = parser->astBuilder->create<EmptyDecl>();
+ parser->FillPosition(decl);
+ return decl;
+ }
+
+ static NodeBase* parseTransparentBlockDecl(Parser* parser, void*)
+ {
+ if (parser->currentScope && parser->currentScope->containerDecl)
+ {
+ parseDeclBody(parser, parser->currentScope->containerDecl);
+ return nullptr;
+ }
+ else
+ {
+ SLANG_UNEXPECTED("parseTransparentBlock should be called with a valid scope.");
+ }
+ }
+
+ static NodeBase* parseFileDecl(Parser* parser, void*)
+ {
+ auto fileDecl = parser->astBuilder->create<FileDecl>();
+ parser->FillPosition(fileDecl);
+ parseDeclBody(parser, fileDecl);
+ return fileDecl;
+ }
+
static NodeBase* parseConstructorDecl(Parser* parser, void* /*userData*/)
{
ConstructorDecl* decl = parser->astBuilder->create<ConstructorDecl>();
@@ -7782,6 +7846,10 @@ namespace Slang
_makeParseDecl("__generic_value_param", parseGlobalGenericValueParamDecl ),
_makeParseDecl("namespace", parseNamespaceDecl ),
_makeParseDecl("using", parseUsingDecl ),
+ _makeParseDecl("__ignored_block", parseIgnoredBlockDecl ),
+ _makeParseDecl("__transparent_block", parseTransparentBlockDecl),
+ _makeParseDecl("__file_decl", parseFileDecl),
+
// !!!!!!!!!!!!!!!!!!!!!! Modifer !!!!!!!!!!!!!!!!!!!!!!