Closed fangism closed 3 years ago
$ verible-verilog-format --show_token_partition_tree ~/testing/verilog/formatting/export.sv
Full token partition tree:
{ ([<auto>], policy: always-expand) @{}
{ ([<auto>], policy: always-expand) @{0}, (origin: "module m;
... endmodule")
{ ([module m ;], policy: fit-else-expand, (origin: "module m;")) }
{ (>>[<auto>], policy: tabular-alignment) @{0,1}, (origin: "export "DPI...ounter_get;")
{ (>>[export "DPI-C"], policy: fit-else-expand) }
{ (>>[function mhpmcounter_get], policy: fit-else-expand, (origin: "function mhpmcounter_get")) }
{ (>>[;], policy: uninitialized) }
}
{ ([endmodule], policy: always-expand, (origin: "endmodule")) }
}
}
This is a token partitioning problem.
Particularly strange is the fact that the entire export declaration node was marked for tabular-alignment.
b/169255663
The tabular-alignment designation came from NodeEnum::kModuleItemList
because module-items can contain alignable sections, but is not necessarily alignable in its entirety. When the export node got hoisted/flattened, it inadvertently turned a non-alignment partition into an align-handled one.
We need to prevent that in tree_unwrapper.cc during partition reshaping.
The function that needs updating is ReshapeTokenPartition.
Test case
Actual output
Expected or suggested output
Original form looked better.