aboutsummaryrefslogtreecommitdiffhomepage
path: root/ptx/src/ptx.lalrpop
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2021-12-14 00:02:23 +0100
committerAndrzej Janik <[email protected]>2021-12-14 00:02:23 +0100
commit971951bc9e696fbf895978b864a45b2ddb56ba5b (patch)
treed680b4a162192361fa05d76e259f11915e63ad7f /ptx/src/ptx.lalrpop
parent0ca14d740fcf76579d17f5b573f3f003f04592bc (diff)
downloadZLUDA-971951bc9e696fbf895978b864a45b2ddb56ba5b.tar.gz
ZLUDA-971951bc9e696fbf895978b864a45b2ddb56ba5b.zip
Improve reporting of recovered unrecognized statement/directive
Diffstat (limited to 'ptx/src/ptx.lalrpop')
-rw-r--r--ptx/src/ptx.lalrpop21
1 files changed, 9 insertions, 12 deletions
diff --git a/ptx/src/ptx.lalrpop b/ptx/src/ptx.lalrpop
index f6fd9cd..e3a4022 100644
--- a/ptx/src/ptx.lalrpop
+++ b/ptx/src/ptx.lalrpop
@@ -394,9 +394,11 @@ Directive: Option<ast::Directive<'input, ast::ParsedArgParams<'input>>> = {
let (linking, var) = v;
Some(ast::Directive::Variable(linking, var))
},
- ! => {
- let err = <>;
- errors.push(err.error);
+ @L ! @R => {
+ let (start, _, end)= (<>);
+ errors.push(ParseError::User { error:
+ ast::PtxError::UnrecognizedDirective { start, end }
+ });
None
}
};
@@ -527,15 +529,10 @@ Statement: Option<ast::Statement<ast::ParsedArgParams<'input>>> = {
PragmaStatement => None,
"{" <s:Statement*> "}" => Some(ast::Statement::Block(without_none(s))),
@L ! ";" @R => {
- let (start, mut err, _, end) = (<>);
- // TODO: report this error more generally, perhaps in user error?
- err.error = match err.error {
- ParseError::UnrecognizedToken { token: (_, token, _), expected } => {
- ParseError::UnrecognizedToken { token: (start, token, end), expected }
- }
- e => e
- };
- errors.push(err.error);
+ let (start, _, _, end) = (<>);
+ errors.push(ParseError::User { error:
+ ast::PtxError::UnrecognizedStatement { start, end }
+ });
None
}
};