aboutsummaryrefslogtreecommitdiffhomepage
path: root/ptx_parser/src/lib.rs
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2024-09-03 18:11:09 +0200
committerAndrzej Janik <[email protected]>2024-09-03 18:11:09 +0200
commit3f31069e1bcd68bee2c0761dc2e817b9fc65579d (patch)
tree5dc05f3401071c44652b8b4797682bd06532e8c1 /ptx_parser/src/lib.rs
parent6a7c871b252ee3b9d9ec49000ac779487d8ee8b8 (diff)
downloadZLUDA-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.rs26
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>> {