rrevenantt/antlr4rust

Generating Listenable::exit

Closed this issue · 1 comments

There doesn't seem to be any code generated for the exit method of listeners. E.g. it generates

impl<'input,'a> Listenable<dyn GroundedListener<'input> + 'a> for RulesContext<'input>{
	fn enter(&self,listener: &mut (dyn GroundedListener<'input> + 'a)) {
		listener.enter_every_rule(self);
		listener.enter_rules(self);
	}
}  

when I expect

impl<'input,'a> Listenable<dyn GroundedListener<'input> + 'a> for RulesContext<'input>{
	fn enter(&self,listener: &mut (dyn GroundedListener<'input> + 'a)) {
		listener.enter_every_rule(self);
		listener.enter_rules(self);
	}
	fn exit(&self,listener: &mut (dyn GroundedListener<'input> + 'a)) {
		listener.exit_rules(self);
		listener.exit_every_rule(self);
	}
}

This results in the walker not being able to perform post-order traversal. Am I missing something to generate these methods?

You don't miss anything, that a bug, looks like it incorrectly handles the case when only listener is generated. For now you should be able to work around it by generating visitor as well(add -visitor to ANTLR execution parameters)