Fredrik Ekre
5d57cd93a5
Replace `=` and `\in` with `in` in generators
...
At least we can reuse all the code from for loops pretty easily.
2 years ago
Fredrik Ekre
b9b80002f9
Replace `=` and `\in` with `in` in for loop specifications
...
There is a lot of code for handling this. Partly because we need to
handle both regular loops, and cartesian loops.
2 years ago
Fredrik Ekre
6f8c7c7152
Fix an edgecase in operator chains with newlines hidden inside
...
This also removes the limitation of no newline children in a operator
call chain and fixes a bug with trailing comments inside a chain.
2 years ago
Fredrik Ekre
4d54e37fcd
Fix edgecases in spaces in operator call chains
...
This patch fixes a bug where, in an operator call chain, whitespace was
borrows from the next child, but the call chain continued after.
2 years ago
Fredrik Ekre
a181b65baa
Fix <: and >: without LHS
...
This patch fixes formatting of <: and >: when used without LHS. This is
again an inconsistency compared to other operators.
2 years ago
Fredrik Ekre
a0b7eb2c2c
Add utility function to extract children::Vector in a type stable way.
2 years ago
Fredrik Ekre
b2b3e905ed
Fix spaces around assignment with non-trivia operators.
2 years ago
Fredrik Ekre
04a20b7c30
Fix spaces around operators when nesting calls
...
The next leaf node might not be a direct grand child when nesting
operators. This patches introduces a function `replace_first_leaf` that
replaces the correct leaf.
2 years ago
Fredrik Ekre
d7ea5f69a7
Fix float formatting with tight-binding +/-
...
A leading `+`/`-` is part of the float literal if there is no space in
between (in which case it becomes a call). This patch fixes the regexes
to handle this for float parsing.
2 years ago
Fredrik Ekre
7c48019613
Fix whitespace around :: when LHS is missing
...
`::` can be used without a LHS in e.g. function definitions like
`f(::Int) = ...`.
2 years ago
Fredrik Ekre
7b7cfc5dc3
Fix formatting of for-loops with Unicode \in.
2 years ago
Fredrik Ekre
d6887109e3
Prune spaces around `:`, `^`, and `::`.
2 years ago
Fredrik Ekre
1bb9480718
Filter out K":" and K"^" from space_around_operators
...
It is a bit weird to not be consistent and put spaces around all
operators, but most people would agree that using no spaces for `:` and
`^` look better.
2 years ago
Fredrik Ekre
d076ca8546
Format files with Runic :^)
2 years ago
Fredrik Ekre
00987199c3
Whitespace around <: and >:
2 years ago
Fredrik Ekre
8e13c29a50
Fix spaces around assignment in for-loop specifications
...
`for`-loop nodes are of kind K"=" even when using `in`. This patch fixes
the predicate for `spaces_around_assignments` to include K"in" as an
option. Note that when using `in` spaces are required, but the pass
is still useful to remove spaces when there are more than one.
2 years ago
Fredrik Ekre
a0ba874830
Fix infix_op_call predicat
2 years ago
Fredrik Ekre
0db3c5484a
Fix spaces in comparison chains
2 years ago
Fredrik Ekre
c489dfcaa5
Format spaces around assignment
...
This patch generalizes the `spaces_around_operators` pass to
`spaces_around_x` and uses it for both operators and assignment.
The new `spaces_around_assignments` matches a lot of things:
- regular assignment (`a=b` -> `a = b`, `a+=b` -> `a += b`,
`a=+b` -> `a = + b`)
- dotted assignment (`a.=b` -> `a .= b`, `a.+=b` -> `a .+= b`,
`a.=+b` -> `a .= + b`)
- keywords in function definitions and at callsites
(`f(x=1) = x` -> f(x = 1)`, `g(x=1)` -> `g(x = 1)`).
- named tuples (`(x=1, y=2)` -> `(x = 1, y = 2)`)
- etc...
2 years ago
Fredrik Ekre
40ccafd579
Format spaces around operators
...
This adds a pass which adds a single space between operators, for
example `a+b` -> `a + b` and `a==b` -> `a == b`. Note that comparison
chains are still left untouched (`a == b == c`) and is a todo.
2 years ago
Fredrik Ekre
f6e55f62e8
Format floating point literals.
2 years ago
Fredrik Ekre
df9c263ec8
Extract rewriters into separate functions.
2 years ago