@@ -86,10 +86,25 @@ module.exports = grammar({
86
86
$ . _cmd_layout_start_if ,
87
87
$ . _cmd_layout_start_let ,
88
88
$ . _cmd_layout_start_quote ,
89
+ // This variant is used in a `choice` with the others, and serves only to create a terminal node for explicit
90
+ // braces.
91
+ // If the scanner emitted the same symbol for virtual and explicit braces, we would either get an anonymous node
92
+ // ranging over the brace, or a terminal brace node even for virtual starts if we were to alias the symbol to '{'
93
+ // unconditionally.
94
+ // So we use separate symbols and alias only this one.
95
+ // The same reasoning applies to `_cond_layout_end_explicit`.
96
+ // The terminal could be ensured in different ways – adding an `optional('{')` after the start symbol, using
97
+ // `seq($._cmd_layout_start_explicit, '{')` instead of including the brace in the scanner range, or branching the
98
+ // entire layout on the start token to unconditionally use `_cmd_brace_close` instead of
99
+ // `_cond_layout_end_explicit`.
100
+ // However, these solutions are all very expensive, adding between 500 and 1000kB to the shared object size, and up
101
+ // to a second in generation time.
102
+ $ . _cmd_layout_start_explicit ,
89
103
90
104
// Emitted when a new line's indent mandates ending the current layout (depending on the layout sort), or when a
91
105
// special inline layout-ending token is encountered, like an `in`.
92
106
$ . _cond_layout_end ,
107
+ $ . _cond_layout_end_explicit ,
93
108
94
109
// Instruct the scanner to push or pop a brace context.
95
110
$ . _cmd_brace_open ,
0 commit comments