mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-31 12:37:45 +00:00
feat: get if else right
This commit is contained in:
parent
361670e855
commit
c4f01f25de
3 changed files with 161 additions and 3 deletions
|
@ -41,11 +41,11 @@ pub fn rule(
|
||||||
steps.push_back(crate::builder::Step::FormatWider(
|
steps.push_back(crate::builder::Step::FormatWider(
|
||||||
child.element,
|
child.element,
|
||||||
));
|
));
|
||||||
|
steps.push_back(crate::builder::Step::Dedent);
|
||||||
if branch != "else" {
|
if branch != "else" {
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
steps.push_back(crate::builder::Step::Pad);
|
steps.push_back(crate::builder::Step::Pad);
|
||||||
}
|
}
|
||||||
steps.push_back(crate::builder::Step::Dedent);
|
|
||||||
}
|
}
|
||||||
crate::config::Layout::Wide => {
|
crate::config::Layout::Wide => {
|
||||||
steps.push_back(crate::builder::Step::Format(child.element));
|
steps.push_back(crate::builder::Step::Format(child.element));
|
||||||
|
|
|
@ -1,4 +1,70 @@
|
||||||
[
|
[
|
||||||
(if a then b else c)
|
(if a then b else c)
|
||||||
(if /**/ a /**/ then /**/ b /**/ else /**/ c)
|
(if /**/ a /**/ then /**/ b /**/ else /**/ c)
|
||||||
|
(if
|
||||||
|
(if
|
||||||
|
(if
|
||||||
|
(if a then b else c)
|
||||||
|
then
|
||||||
|
(if a then b else c)
|
||||||
|
else
|
||||||
|
(if a then b else c))
|
||||||
|
then
|
||||||
|
(if
|
||||||
|
(if a then b else c)
|
||||||
|
then
|
||||||
|
(if a then b else c)
|
||||||
|
else
|
||||||
|
(if a then b else c))
|
||||||
|
else
|
||||||
|
(if
|
||||||
|
(if a then b else c)
|
||||||
|
then
|
||||||
|
(if a then b else c)
|
||||||
|
else
|
||||||
|
(if a then b else c)))
|
||||||
|
then
|
||||||
|
(if
|
||||||
|
(if
|
||||||
|
(if a then b else c)
|
||||||
|
then
|
||||||
|
(if a then b else c)
|
||||||
|
else
|
||||||
|
(if a then b else c))
|
||||||
|
then
|
||||||
|
(if
|
||||||
|
(if a then b else c)
|
||||||
|
then
|
||||||
|
(if a then b else c)
|
||||||
|
else
|
||||||
|
(if a then b else c))
|
||||||
|
else
|
||||||
|
(if
|
||||||
|
(if a then b else c)
|
||||||
|
then
|
||||||
|
(if a then b else c)
|
||||||
|
else
|
||||||
|
(if a then b else c)))
|
||||||
|
else
|
||||||
|
(if
|
||||||
|
(if
|
||||||
|
(if a then b else c)
|
||||||
|
then
|
||||||
|
(if a then b else c)
|
||||||
|
else
|
||||||
|
(if a then b else c))
|
||||||
|
then
|
||||||
|
(if
|
||||||
|
(if a then b else c)
|
||||||
|
then
|
||||||
|
(if a then b else c)
|
||||||
|
else
|
||||||
|
(if a then b else c))
|
||||||
|
else
|
||||||
|
(if
|
||||||
|
(if a then b else c)
|
||||||
|
then
|
||||||
|
(if a then b else c)
|
||||||
|
else
|
||||||
|
(if a then b else c))))
|
||||||
]
|
]
|
||||||
|
|
|
@ -4,13 +4,105 @@
|
||||||
if
|
if
|
||||||
/**/
|
/**/
|
||||||
a
|
a
|
||||||
/**/
|
/**/
|
||||||
then
|
then
|
||||||
/**/
|
/**/
|
||||||
b
|
b
|
||||||
/**/
|
/**/
|
||||||
else
|
else
|
||||||
/**/
|
/**/
|
||||||
c
|
c
|
||||||
)
|
)
|
||||||
|
(
|
||||||
|
if
|
||||||
|
(
|
||||||
|
if
|
||||||
|
(
|
||||||
|
if
|
||||||
|
( if a then b else c )
|
||||||
|
then
|
||||||
|
( if a then b else c )
|
||||||
|
else
|
||||||
|
( if a then b else c )
|
||||||
|
)
|
||||||
|
then
|
||||||
|
(
|
||||||
|
if
|
||||||
|
( if a then b else c )
|
||||||
|
then
|
||||||
|
( if a then b else c )
|
||||||
|
else
|
||||||
|
( if a then b else c )
|
||||||
|
)
|
||||||
|
else
|
||||||
|
(
|
||||||
|
if
|
||||||
|
( if a then b else c )
|
||||||
|
then
|
||||||
|
( if a then b else c )
|
||||||
|
else
|
||||||
|
( if a then b else c )
|
||||||
|
)
|
||||||
|
)
|
||||||
|
then
|
||||||
|
(
|
||||||
|
if
|
||||||
|
(
|
||||||
|
if
|
||||||
|
( if a then b else c )
|
||||||
|
then
|
||||||
|
( if a then b else c )
|
||||||
|
else
|
||||||
|
( if a then b else c )
|
||||||
|
)
|
||||||
|
then
|
||||||
|
(
|
||||||
|
if
|
||||||
|
( if a then b else c )
|
||||||
|
then
|
||||||
|
( if a then b else c )
|
||||||
|
else
|
||||||
|
( if a then b else c )
|
||||||
|
)
|
||||||
|
else
|
||||||
|
(
|
||||||
|
if
|
||||||
|
( if a then b else c )
|
||||||
|
then
|
||||||
|
( if a then b else c )
|
||||||
|
else
|
||||||
|
( if a then b else c )
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
(
|
||||||
|
if
|
||||||
|
(
|
||||||
|
if
|
||||||
|
( if a then b else c )
|
||||||
|
then
|
||||||
|
( if a then b else c )
|
||||||
|
else
|
||||||
|
( if a then b else c )
|
||||||
|
)
|
||||||
|
then
|
||||||
|
(
|
||||||
|
if
|
||||||
|
( if a then b else c )
|
||||||
|
then
|
||||||
|
( if a then b else c )
|
||||||
|
else
|
||||||
|
( if a then b else c )
|
||||||
|
)
|
||||||
|
else
|
||||||
|
(
|
||||||
|
if
|
||||||
|
( if a then b else c )
|
||||||
|
then
|
||||||
|
( if a then b else c )
|
||||||
|
else
|
||||||
|
( if a then b else c )
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue