-
|
I'm working on a custom language and have a question about the best approach for handling nested indentation in formatters. My use case: I have a grammar with nested block structures: This produces syntax like : The Challenge: I need the items inside the 'subBlock' to be double indented(8 spaces with 4-space tabs)- one level for being inside the outer block and another level for being inside subBlock. Like this My current solution: I'm using a custom formatting object with explicit tab counts: My questions:
The current solution works but I want to make sure I'm following the best practices. Any guidance would be appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi, is there a reason not to move the complete |
Beta Was this translation helpful? Give feedback.
I would recommend to do this as well. I never expected adopters to have multiple levels of indentation in one AST node (it's an anti-pattern, there are multiple reasons for that), so it's reflected as an implementation detail in the formatter.