> core of the problem .. no dedicated slot

Yes and no - it's relatively easy to add a "comment slot" to every node (like 
the upstream AST has a magic comment field that is used sometimes and how `nph` 
has 3 - pre/mid/post-comment) - what's hard is knowing which node a particular 
comment belongs to while parsing - for this, there is no consistent rule that's 
possible to apply, partially because the grammar itself is somewhat random for 
different nodes, both when parsing comments but also when parsing the nodes 
themselves - ie `optInd` vs `flexComment` vs indAndComment` vs "mandatory vs 
optional comma" vs "mandatory vs optional indent" and so on - many composed 
nodes (like identdefs but also `procty` etc) differ in where indent and 
comments are allowed "inside" the node (before and after the `:` \- before and 
after the `=` etc).

When we also take into account concepts, generics, post and do expressions, 
they all show significant departures from each other in terms of rules for 
whitespace and comment, so the proper "attaching" of comment to nodes becomes 
problematic in and of itself, even if a proper space for them existed in the 
AST.

Reply via email to