Skip to content

Commit

Permalink
fix(#3649): prettier braces print in phi
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Dec 12, 2024
1 parent 2790ee7 commit d55089c
Show file tree
Hide file tree
Showing 30 changed files with 281 additions and 341 deletions.
8 changes: 3 additions & 5 deletions eo-parser/src/main/resources/org/eolang/parser/phi/to-phi.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,9 @@ SOFTWARE.
<xsl:copy-of select="./errors"/>
<phi>
<xsl:text>{</xsl:text>
<xsl:variable name="tabs" select="2"/>
<xsl:value-of select="eo:eol(1)"/>
<xsl:value-of select="$lb"/>
<xsl:value-of select="eo:eol(2)"/>
<xsl:variable name="tabs" select="1"/>
<xsl:value-of select="eo:eol(1)"/>
<xsl:variable name="has-package" select="metas/meta/head[text()='package']"/>
<xsl:variable name="package" select="metas/meta[head[text()='package']]/tail[1]"/>
<xsl:variable name="parts" select="tokenize($package,'\.')"/>
Expand Down Expand Up @@ -310,9 +309,8 @@ SOFTWARE.
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="eo:eol(1)"/>
<xsl:value-of select="$rb"/>
<xsl:value-of select="eo:eol(0)"/>
<xsl:value-of select="$rb"/>
<xsl:text>}</xsl:text>
</phi>
</program>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ input: |
as-phi $
$.greater-than 0
with-sugar: |-
{
prints-itself ↦ ⟦
φ ↦ Φ̇.assert-that(Φ̇.as-phi(ξ).length, ξ.greater-than(0))
{⟦
prints-itself ↦ ⟦
φ ↦ Φ̇.assert-that(Φ̇.as-phi(ξ).length, ξ.greater-than(0))
}
}
no-sugar: |-
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,16 @@ input: |
# No comments.
[] > inner /bytes
with-sugar: |-
{
main ↦ ⟦
λ ⤍ Lmain
⟧,
outer ↦ ⟦
inner ↦ ⟦
λ ⤍ Louter_inner
{⟦
main ↦ ⟦
λ ⤍ Lmain
⟧,
outer ↦ ⟦
inner ↦ ⟦
λ ⤍ Louter_inner
}
}
no-sugar: |-
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ input: |
[] >>
01- > b
with-sugar: |-
{
object ↦ ⟦
first ↦ Φ̇.x(ξ.auto-named-attr-at-4-6),
auto-named-attr-at-4-6 ↦ ⟦
b ↦ Φ̇.bytes(⟦ Δ ⤍ 01- ⟧)
{⟦
object ↦ ⟦
first ↦ Φ̇.x(ξ.auto-named-attr-at-4-6),
auto-named-attr-at-4-6 ↦ ⟦
b ↦ Φ̇.bytes(⟦ Δ ⤍ 01- ⟧)
}
}
no-sugar: |-
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@ input: |
5:five
"hello":3
with-sugar: |-
{
xyz ↦ Φ̇.x(
attr ↦ Φ̇.y,
abs ↦ ⟦
z ↦ ∅,
φ ↦ Φ̇.w
⟧,
five ↦ 5,
α3 ↦ "hello"
)
}
{⟦
xyz ↦ Φ̇.x(
attr ↦ Φ̇.y,
abs ↦ ⟦
z ↦ ∅,
φ ↦ Φ̇.w
⟧,
five ↦ 5,
α3 ↦ "hello"
)
⟧}
no-sugar: |-
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,38 +85,36 @@ input: |
00-.as-bytes.eq false
with-sugar: |-
{
org ↦ ⟦
eolang ↦ ⟦
compares-two-bools ↦ ⟦
φ ↦ Φ̇.true.eq(Φ̇.true)
⟧,
true-as-bool ↦ ⟦
φ ↦ Φ̇.true.as-bool
⟧,
compares-two-different-types ↦ ⟦
φ ↦ Φ̇.true.eq(42).not
⟧,
compares-bool-to-bytes ↦ ⟦
φ ↦ Φ̇.true.eq(Φ̇.bytes(⟦ Δ ⤍ 01- ⟧)).and(
Φ̇.false.eq(Φ̇.bytes(⟦ Δ ⤍ 00- ⟧))
)
⟧,
compares-bool-to-string ↦ ⟦
φ ↦ Φ̇.true.eq("\u0001").and(Φ̇.false.eq("\u0000"))
⟧,
compares-bool-to-bytes-reverse ↦ ⟦
φ ↦ Φ̇.bytes(⟦ Δ ⤍ 01- ⟧).as-bytes.eq(Φ̇.true).and(
Φ̇.bytes(⟦ Δ ⤍ 00- ⟧).as-bytes.eq(Φ̇.false)
)
⟧,
λ ⤍ Package
{⟦
org ↦ ⟦
eolang ↦ ⟦
compares-two-bools ↦ ⟦
φ ↦ Φ̇.true.eq(Φ̇.true)
⟧,
true-as-bool ↦ ⟦
φ ↦ Φ̇.true.as-bool
⟧,
compares-two-different-types ↦ ⟦
φ ↦ Φ̇.true.eq(42).not
⟧,
compares-bool-to-bytes ↦ ⟦
φ ↦ Φ̇.true.eq(Φ̇.bytes(⟦ Δ ⤍ 01- ⟧)).and(
Φ̇.false.eq(Φ̇.bytes(⟦ Δ ⤍ 00- ⟧))
)
⟧,
compares-bool-to-string ↦ ⟦
φ ↦ Φ̇.true.eq("\u0001").and(Φ̇.false.eq("\u0000"))
⟧,
compares-bool-to-bytes-reverse ↦ ⟦
φ ↦ Φ̇.bytes(⟦ Δ ⤍ 01- ⟧).as-bytes.eq(Φ̇.true).and(
Φ̇.bytes(⟦ Δ ⤍ 00- ⟧).as-bytes.eq(Φ̇.false)
)
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
}
no-sugar: |-
{
Expand Down
124 changes: 61 additions & 63 deletions eo-parser/src/test/resources/org/eolang/parser/phi-packs/bytes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,73 +83,71 @@ input: |
# as a new sequence.
[b] > concat /bytes
with-sugar: |-
{
org ↦ ⟦
eolang ↦ ⟦
bytes ↦ ⟦
data ↦ ∅,
eq ↦ ⟦
λ ⤍ Lorg_eolang_bytes_eq,
x ↦ ∅
⟧,
size ↦ ⟦
λ ⤍ Lorg_eolang_bytes_size
⟧,
slice ↦ ⟦
λ ⤍ Lorg_eolang_bytes_slice,
start ↦ ∅,
len ↦ ∅
⟧,
as-string ↦ ⟦
λ ⤍ Lorg_eolang_bytes_as_string
⟧,
as-int ↦ ⟦
λ ⤍ Lorg_eolang_bytes_as_int
⟧,
as-float ↦ ⟦
λ ⤍ Lorg_eolang_bytes_as_float
⟧,
and ↦ ⟦
λ ⤍ Lorg_eolang_bytes_and,
b ↦ ∅
⟧,
or ↦ ⟦
λ ⤍ Lorg_eolang_bytes_or,
b ↦ ∅
⟧,
xor ↦ ⟦
λ ⤍ Lorg_eolang_bytes_xor,
b ↦ ∅
⟧,
not ↦ ⟦
λ ⤍ Lorg_eolang_bytes_not
⟧,
left ↦ ⟦
x ↦ ∅,
φ ↦ ξ.ρ.right(ξ.x.neg)
⟧,
right ↦ ⟦
λ ⤍ Lorg_eolang_bytes_right,
x ↦ ∅
⟧,
as-bool ↦ ⟦
φ ↦ ξ.ρ.eq(Φ̇.bytes(⟦ Δ ⤍ 01- ⟧))
⟧,
as-bytes ↦ ⟦
φ ↦ ξ.ρ
⟧,
concat ↦ ⟦
λ ⤍ Lorg_eolang_bytes_concat,
b ↦ ∅
{⟦
org ↦ ⟦
eolang ↦ ⟦
bytes ↦ ⟦
data ↦ ∅,
eq ↦ ⟦
λ ⤍ Lorg_eolang_bytes_eq,
x ↦ ∅
⟧,
λ ⤍ Package
size ↦ ⟦
λ ⤍ Lorg_eolang_bytes_size
⟧,
slice ↦ ⟦
λ ⤍ Lorg_eolang_bytes_slice,
start ↦ ∅,
len ↦ ∅
⟧,
as-string ↦ ⟦
λ ⤍ Lorg_eolang_bytes_as_string
⟧,
as-int ↦ ⟦
λ ⤍ Lorg_eolang_bytes_as_int
⟧,
as-float ↦ ⟦
λ ⤍ Lorg_eolang_bytes_as_float
⟧,
and ↦ ⟦
λ ⤍ Lorg_eolang_bytes_and,
b ↦ ∅
⟧,
or ↦ ⟦
λ ⤍ Lorg_eolang_bytes_or,
b ↦ ∅
⟧,
xor ↦ ⟦
λ ⤍ Lorg_eolang_bytes_xor,
b ↦ ∅
⟧,
not ↦ ⟦
λ ⤍ Lorg_eolang_bytes_not
⟧,
left ↦ ⟦
x ↦ ∅,
φ ↦ ξ.ρ.right(ξ.x.neg)
⟧,
right ↦ ⟦
λ ⤍ Lorg_eolang_bytes_right,
x ↦ ∅
⟧,
as-bool ↦ ⟦
φ ↦ ξ.ρ.eq(Φ̇.bytes(⟦ Δ ⤍ 01- ⟧))
⟧,
as-bytes ↦ ⟦
φ ↦ ξ.ρ
⟧,
concat ↦ ⟦
λ ⤍ Lorg_eolang_bytes_concat,
b ↦ ∅
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
}
no-sugar: |-
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@ input: |
[y] > main
x y > z
with-sugar: |-
{
foo ↦ ⟦
bar ↦ ⟦
main ↦ ⟦
y ↦ ∅,
z ↦ Φ.com.yegor256.x(ξ.y)
⟧,
λ ⤍ Package
{⟦
foo ↦ ⟦
bar ↦ ⟦
main ↦ ⟦
y ↦ ∅,
z ↦ Φ.com.yegor256.x(ξ.y)
⟧,
λ ⤍ Package
⟧,
λ ⤍ Package
}
}
no-sugar: |-
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ input: |
5.plus 5 > ten
"Hello".concat "world" > greetings
with-sugar: |-
{
ten ↦ 5.plus(5),
greetings ↦ "Hello".concat("world")
}
{⟦
ten ↦ 5.plus(5),
greetings ↦ "Hello".concat("world")
⟧}
no-sugar: |-
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
---
input: -- > empty
with-sugar: |-
{
empty ↦ Φ̇.bytes(⟦ Δ ⤍ -- ⟧)
}
{⟦
empty ↦ Φ̇.bytes(⟦ Δ ⤍ -- ⟧)
⟧}
no-sugar: |-
{
Expand Down
Loading

0 comments on commit d55089c

Please sign in to comment.