|
65 | 65 | "and" @allow_blank_line_before
|
66 | 66 | )
|
67 | 67 | (value_definition
|
68 |
| - (and_operator) @allow_blank_line_before |
| 68 | + (let_and_operator) @allow_blank_line_before |
69 | 69 | )
|
70 | 70 |
|
71 | 71 | ; Append line breaks. If there is a comment following, we don't add anything,
|
|
155 | 155 | "if"
|
156 | 156 | "in"
|
157 | 157 | "include"
|
158 |
| - (infix_operator) |
| 158 | + ; Infix operators |
| 159 | + (pow_operator) |
| 160 | + (mult_operator) |
| 161 | + (add_operator) |
| 162 | + (concat_operator) |
| 163 | + (rel_operator) |
| 164 | + (and_operator) |
| 165 | + (or_operator) |
| 166 | + (assign_operator) |
159 | 167 | "inherit"
|
160 | 168 | "initializer"
|
161 | 169 | (item_attribute)
|
|
186 | 194 | "*"
|
187 | 195 | "="
|
188 | 196 | "|"
|
189 |
| - "||" |
190 | 197 | "->"
|
191 | 198 | "<-"
|
192 | 199 | "{"
|
|
212 | 219 | "downto"
|
213 | 220 | "else"
|
214 | 221 | "in"
|
215 |
| - (infix_operator) ; This one can, but we want a space before anyway. |
| 222 | + ; Infix operators can come after an open parenthesis, but we want a space before anyway |
| 223 | + (pow_operator) |
| 224 | + (mult_operator) |
| 225 | + (add_operator) |
| 226 | + (concat_operator) |
| 227 | + (rel_operator) |
| 228 | + (and_operator) |
| 229 | + (or_operator) |
| 230 | + (assign_operator) |
216 | 231 | "nonrec"
|
217 | 232 | "of"
|
218 | 233 | "rec"
|
|
234 | 249 | ; during their definition, in which case no space must be appended.
|
235 | 250 | ; space must be appended otherwise
|
236 | 251 | (
|
237 |
| - (and_operator) @append_space |
| 252 | + (let_and_operator) @append_space |
238 | 253 | .
|
239 | 254 | ")"* @do_nothing
|
240 | 255 | )
|
|
394 | 409 | .
|
395 | 410 | "=" @prepend_space
|
396 | 411 | )
|
397 |
| -( |
398 |
| - "("* @do_nothing |
399 |
| - . |
400 |
| - "||" @prepend_space |
401 |
| -) |
402 | 412 | (
|
403 | 413 | "("* @do_nothing
|
404 | 414 | .
|
|
800 | 810 | )
|
801 | 811 |
|
802 | 812 | (value_definition
|
803 |
| - (and_operator) @prepend_spaced_softline |
| 813 | + (let_and_operator) @prepend_spaced_softline |
804 | 814 | )
|
805 | 815 |
|
806 | 816 | ; There is a large class of terms which should be separated from "=" by a soft line break.
|
|
1374 | 1384 |
|
1375 | 1385 | ; As above, infix expressions are nested grammar elements, so we must identify the
|
1376 | 1386 | ; top-level one: it is the one that is not preceded by an infix operator.
|
1377 |
| -; We only consider the common logic operators, as not to mess with arithmetic expressions |
| 1387 | +; We only consider logic operators, as not to mess with arithmetic expressions |
1378 | 1388 | (
|
1379 |
| - (infix_operator |
1380 |
| - [ |
1381 |
| - "||" |
1382 |
| - "&&" |
1383 |
| - ] |
1384 |
| - )? @do_nothing |
| 1389 | + [ |
| 1390 | + (and_operator) |
| 1391 | + (or_operator) |
| 1392 | + ]? @do_nothing |
1385 | 1393 | .
|
1386 | 1394 | (infix_expression) @begin_scope @end_scope
|
1387 | 1395 | (#scope_id! "infix_expression")
|
1388 | 1396 | )
|
1389 | 1397 | (infix_expression
|
1390 |
| - (infix_operator |
1391 |
| - [ |
1392 |
| - "||" |
1393 |
| - "&&" |
1394 |
| - ] |
1395 |
| - ) @prepend_spaced_scoped_softline |
| 1398 | + [ |
| 1399 | + (and_operator) |
| 1400 | + (or_operator) |
| 1401 | + ] @prepend_spaced_scoped_softline |
1396 | 1402 | (#scope_id! "infix_expression")
|
1397 | 1403 | )
|
1398 | 1404 |
|
1399 |
| -; Put softline and indented blocks after infix operators |
1400 |
| -; that have no particular treatment (e.g. "@@") |
| 1405 | +; Put softline and indented blocks after all other infix operators |
1401 | 1406 | (infix_expression
|
1402 |
| - (infix_operator |
1403 |
| - [ |
1404 |
| - "||" |
1405 |
| - "&&" |
1406 |
| - ]? @do_nothing |
1407 |
| - ) @append_spaced_softline @append_indent_start |
| 1407 | + [ |
| 1408 | + (pow_operator) |
| 1409 | + (mult_operator) |
| 1410 | + (add_operator) |
| 1411 | + (concat_operator) |
| 1412 | + (rel_operator) |
| 1413 | + (assign_operator) |
| 1414 | + ] @append_spaced_softline @append_indent_start |
1408 | 1415 | .
|
1409 | 1416 | (_) @append_indent_end
|
1410 | 1417 | )
|
|
0 commit comments