The abstract Visitor (& subsequently the concrete one) generated from the TSqlLexer.g4 and TSqlParser.g4 at https://github.com/antlr/grammars-v4/blob/master/sql/tsql/ has a lot of Visit methods corresponding to each grammar rule. For my project, I only need a subset of these Visit methods but even these are numerous. As I start to put my implementation specific code into the Visit methods of my concrete Visitor, I have a fear that the Visitor is going to have hundreds of lines of code and get unruly. How do I stop this from happening ? Can I "group" related Visit methods to different classes ? E.g the Visitor has a rule called 'expression' and there are recursively defined sub rules like 'function expression', 'bracketed expressions' etc. Can I have a separate class handle all 'expression' visit methods with my implementation ? Am I overthinking this ? This appears to be a common problem encountered while visiting trees and I am hoping that developers more experienced than me have already solved this using other patterns/mechanisms. Any pointers appreciated And a big shout out to the amazing guys/gals who developed ANTLR and the .g4 files.
Aucun commentaire:
Enregistrer un commentaire