diff options
author | Andrzej Janik <[email protected]> | 2024-09-03 18:11:09 +0200 |
---|---|---|
committer | Andrzej Janik <[email protected]> | 2024-09-03 18:11:09 +0200 |
commit | 3f31069e1bcd68bee2c0761dc2e817b9fc65579d (patch) | |
tree | 5dc05f3401071c44652b8b4797682bd06532e8c1 /ptx_parser/src/lib.rs | |
parent | 6a7c871b252ee3b9d9ec49000ac779487d8ee8b8 (diff) | |
download | ZLUDA-3f31069e1bcd68bee2c0761dc2e817b9fc65579d.tar.gz ZLUDA-3f31069e1bcd68bee2c0761dc2e817b9fc65579d.zip |
Allow ftz and saturated conversions
Diffstat (limited to 'ptx_parser/src/lib.rs')
-rw-r--r-- | ptx_parser/src/lib.rs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/ptx_parser/src/lib.rs b/ptx_parser/src/lib.rs index 357304b..b81d826 100644 --- a/ptx_parser/src/lib.rs +++ b/ptx_parser/src/lib.rs @@ -289,7 +289,12 @@ pub fn parse_module_unchecked<'input>(text: &'input str) -> Option<ast::Module<' state, input: &input[..], }; - module.parse(parser).ok() + let parsing_result = module.parse(parser).ok(); + if !errors.is_empty() { + None + } else { + parsing_result + } } pub fn parse_module_checked<'input>( @@ -314,19 +319,24 @@ pub fn parse_module_checked<'input>( if !errors.is_empty() { return Err(errors); } - let parse_error = { + let parse_result = { let state = PtxParserState::new(&mut errors); let parser = PtxParser { state, input: &tokens[..], }; - match module.parse(parser) { - Ok(ast) => return Ok(ast), - Err(err) => PtxError::Parser(err.into_inner()), - } + module + .parse(parser) + .map_err(|err| PtxError::Parser(err.into_inner())) }; - errors.push(parse_error); - Err(errors) + match parse_result { + Ok(result) if errors.is_empty() => Ok(result), + Ok(_) => Err(errors), + Err(err) => { + errors.push(err); + Err(errors) + } + } } fn module<'a, 'input>(stream: &mut PtxParser<'a, 'input>) -> PResult<ast::Module<'input>> { |