delph-in / pydelphin

Python libraries for DELPH-IN
https://pydelphin.readthedocs.io/
MIT License
77 stars 27 forks source link

format function for LineComment and BlockComment #356

Closed olzama closed 1 year ago

olzama commented 1 year ago

If I understand right, the format method is not currently implemented for all Events, in particular it is not implemented for LineComment and BlockComment? This would be useful in scenarios when someone is automatically updating part of a large TDL file and wants to copy large parts of it without modifying them (while modifying other parts).

goodmami commented 1 year ago

Yes, that's because the LineComment and BlockComment events are paired with simple strings and not delphin.tdl classes, like delphin.tdl.TypeDefinition for TypeDefinition events. I think we could make delphin.tdl.LineComment and delphin.tdl.BlockComment classes as subtypes of str, which would allow tdl.format() to print them appropriately.