From f3ecf978a07b02681a4d70a9d83991e6661bf753 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 29 Aug 2023 20:58:44 +0800 Subject: Correct parsing spirv with no rhs operands (#3161) * Correct parsing spirv with no rhs operands * Guard against eof --- source/slang/slang-parser.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'source/slang/slang-parser.cpp') diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index 57a21a90a..7e6d7d308 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -6411,8 +6411,27 @@ namespace Slang // At this point we can also parse bitwise or expressions // while(!(parser->LookAheadToken(TokenType::RBrace) - || parser->LookAheadToken(TokenType::Semicolon))) + || parser->LookAheadToken(TokenType::Semicolon) + || parser->LookAheadToken(TokenType::EndOfFile)) + || resultTypeOperand + || resultOperand) { + // Insert the LHS result-type operand + if(ret.operands.getCount() == opInfo->resultTypeIndex && resultTypeOperand) + { + ret.operands.add(*resultTypeOperand); + resultTypeOperand.reset(); + continue; + } + + // Insert the LHS result operand + if(ret.operands.getCount() == opInfo->resultIdIndex && resultOperand) + { + ret.operands.add(*resultOperand); + resultOperand.reset(); + continue; + } + if(ret.operands.getCount() == opInfo->maxOperandCount) { parser->diagnose( @@ -6423,14 +6442,6 @@ namespace Slang ); } - // Insert the LHS result-type operand - if(ret.operands.getCount() == opInfo->resultTypeIndex && resultTypeOperand) - ret.operands.add(*resultTypeOperand); - - // Insert the LHS result operand - if(ret.operands.getCount() == opInfo->resultIdIndex && resultOperand) - ret.operands.add(*resultOperand); - if(auto operand = parseSPIRVAsmOperand(parser)) { while(AdvanceIf(parser, TokenType::OpBitOr)) -- cgit v1.2.3