Currently (from my experimentation) rust-peg will not parse mutable parameters in the header for a rule it seems to mistake mut for the parameter name, thus expecting a colon to follow it instead of the actual parameter name. This would allow for more powerful use cases where parameters can be used to create some amount of context or side effects for rules.
The following code won't compile, but I believe it should:
parser!(
grammar space_counter() for str {
rule run(mut space_count: i32) -> i32 = // mut parameter here is what fails
needs_mutable_borrw(&mut space_count) {space_count}
rule needs_mutable_borrw(n_spaces: &mut i32) -> String = v:" " {
n_spaces += 1;
return v;
}
}
);
This might be outside the scope of rust-peg, but I believe it would be a helpful feature especially given that this is default rust behavior.
Currently (from my experimentation) rust-peg will not parse mutable parameters in the header for a rule it seems to mistake
mutfor the parameter name, thus expecting a colon to follow it instead of the actual parameter name. This would allow for more powerful use cases where parameters can be used to create some amount of context or side effects for rules.The following code won't compile, but I believe it should:
This might be outside the scope of rust-peg, but I believe it would be a helpful feature especially given that this is default rust behavior.