rrevenantt / antlr4rust

ANTLR4 parser generator runtime for Rust programming laguage
Other
398 stars 70 forks source link

Listenable trait is not fully implemented for labeled contexts #61

Open yuriry opened 1 year ago

yuriry commented 1 year ago

exit() method from Listenable trait is not implemented for labeled contexts. As a result, fn exit_or(&mut self, _ctx: &OrContext<'a>) not being called when walking the generated tree :(

boolExpr:
  ...
  | boolExpr '||'  boolExpr                                  #or
  ...

Screenshot from 2022-10-19 20-06-24

See also impl<'input, 'a> Listenable<dyn LabelsListener<'input> + 'a> for AddContext<'input>

rrevenantt commented 1 year ago

It appears to be harder to fix than it looks. For now as a workaround you can enable visitor generation(-visitor argument), it seems to also generate correct Listenable implementation with it.

yuriry commented 1 year ago

Thank you so much! -visitor argument fixes the problem and exit_or is now being called.