I'm trying to build a Formatter, but can't figure out Indents.
When I simply try to build blocks, giving every single one Indent: NONE, it still formats to 8 spaces.
I suppose, that it has something to do with ASTree.
The tree in screenshoot has WhiteSpace character to those 8 spaces, before it is NewLine WhiteSpace and Colon, after is "Get" token... but bnf grammar is little different, new line is actually a separate token, including an IndentToken, this has size 0 and is not visible there, there screen of parsed Tokens before AST:
I'm not sure, why those 2 tokens are not in resulting AST, but I suspect, they are the reason for wrong indentation.
Simplified grammar for it looks like:
varDeclaration ::= VAR IDENTIFIER setgetDecl
setgetDecl ::= COLON NEW_LINE INDENT getDecl DEDENT
getDecl ::= GET COLON stmtOrSuite
Does anyone have an idea what I might be doing wrong, so formatter is this broken?
Or is it even ok, for a grammar to check newLines & indents like this?