Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Committing to a conversion #10

Open
CAD97 opened this issue Nov 10, 2018 · 1 comment
Open

Committing to a conversion #10

CAD97 opened this issue Nov 10, 2018 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers mentored Has a comment describing the likely direction to take

Comments

@CAD97
Copy link
Collaborator

CAD97 commented Nov 10, 2018

In order to aid the creation of correct ASTs, it's sometimes useful to know when things go wrong when you don't expect. I propose adding a #[pest_ast(commit)] or similar, after which conversions in the sequence which would otherwise cause a Err(NoMatch) to propagate, instead cause a panic detailing where the error is.

@CAD97 CAD97 added enhancement New feature or request good first issue Good for newcomers labels Nov 10, 2018
@CAD97
Copy link
Collaborator Author

CAD97 commented Nov 10, 2018

This is probably a bit more involved than I'd wish, as it adds state to the conversion where it didn't exist before. However, here's a rough outline of what needs to change to support this:

Best guess: replace the FromPest::from_pest(inner)? with FromPest::from_pest(inner).map_err(|e| if commit { panic!(..) } else { e })?, and add code to manage the commit variable. We can rely on optimizing it out if it's never set.

// TODO: Should this be panicking instead?
// panic!(
// concat!(
// "in ",
// stringify!(#name),
// ".",
// stringify!(#member),
// ", expected `",
// stringify!(#rule),
// "` but found `{:?}`"
// ),
// pair.as_rule(),
// )

@CAD97 CAD97 added the mentored Has a comment describing the likely direction to take label Nov 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers mentored Has a comment describing the likely direction to take
Projects
None yet
Development

No branches or pull requests

1 participant