Skip to content

Action code blocks and side effects #334

Answered by kevinmehall
knewt asked this question in Q&A
Discussion options

You must be logged in to vote

On a parse error that exhausts all alternatives, rust-peg will restart the parse in an error tracing mode to collect the expected set to report in the error message (this is not enabled in the initial parse because it's slow, and not needed in the likely case of a successful parse). All the action code blocks before reaching the error will be re-run. If a conditional action code block returns a different Ok/Err status forcing the parser onto a different path than the first parse, the implementation may panic. Yes, the prior partial parse tree will be dropped before re-parsing.

The other case that isn't technically running it multiple times but where you should be careful of side effects i…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@knewt
Comment options

@kevinmehall
Comment options

@knewt
Comment options

Answer selected by knewt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants