diff --git a/eo-maven-plugin/src/main/resources/org/eolang/maven/phi/to-phi.xsl b/eo-maven-plugin/src/main/resources/org/eolang/maven/phi/to-phi.xsl index bf7a653cc6..f56ddf6963 100644 --- a/eo-maven-plugin/src/main/resources/org/eolang/maven/phi/to-phi.xsl +++ b/eo-maven-plugin/src/main/resources/org/eolang/maven/phi/to-phi.xsl @@ -27,6 +27,9 @@ SOFTWARE. + + + @@ -70,6 +73,9 @@ SOFTWARE. + + + @@ -133,17 +139,126 @@ SOFTWARE. , - + + + - + + + + + + + + + + + + + + + + + + + + + + + + || + + + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -207,6 +322,7 @@ SOFTWARE. + @@ -244,60 +360,120 @@ SOFTWARE. - - - - + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + ( - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + ) - - - - - + + + + + + + + + + + + + + + + + + + + ( - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + ) @@ -305,10 +481,6 @@ SOFTWARE. ( - - - 0 - @@ -316,7 +488,6 @@ SOFTWARE. - ) @@ -347,13 +518,6 @@ SOFTWARE. - - - - - - - @@ -364,6 +528,7 @@ SOFTWARE. . + @@ -374,22 +539,27 @@ SOFTWARE. - - - - + + + + + + + + + + + - - - - - - - - - + + + + + + + diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/PhiMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/PhiMojoTest.java index fa4bb11614..25fc0bd0b1 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/PhiMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/PhiMojoTest.java @@ -40,7 +40,6 @@ import org.hamcrest.Matchers; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assumptions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; @@ -77,18 +76,12 @@ void convertsSimpleObjectToPhi(@Mktmp final Path temp, @RandomProgram final Stri ); MatcherAssert.assertThat( "the .phi file is generated", - new String( - Files.readAllBytes( - temp.resolve("target/eo/phi/foo.phi") - ), - StandardCharsets.UTF_8 - ), - Matchers.containsString("α0 ↦ \"Hello, world!\\n\"") + Files.readString(temp.resolve("target/eo/phi/foo.phi")), + Matchers.containsString("(\"Hello, world!\\n\")") ); } @Test - @Disabled void convertsSimpleXmirToPhi(@Mktmp final Path temp) throws Exception { new Farea(temp).together( f -> { @@ -97,9 +90,9 @@ void convertsSimpleXmirToPhi(@Mktmp final Path temp) throws Exception { String.join( " ", "", - "", + "", "", - "01 02 03", + "01-02-03", "" ).getBytes() ); @@ -113,13 +106,8 @@ void convertsSimpleXmirToPhi(@Mktmp final Path temp) throws Exception { ); MatcherAssert.assertThat( "the .phi file is generated", - new String( - Files.readAllBytes( - temp.resolve("target/eo/phi/foo.phi") - ), - StandardCharsets.UTF_8 - ), - Matchers.containsString("α0 ↦ ⟦ Δ ⤍ 01-02-03 ⟧") + Files.readString(temp.resolve("target/eo/phi/foo.phi")), + Matchers.containsString("(⟦ Δ ⤍ 01-02-03 ⟧)") ); } @@ -164,16 +152,10 @@ void convertsObjectWithSystemType(@Mktmp final Path temp) throws Exception { ); MatcherAssert.assertThat( "the .phi file is generated", - new String( - Files.readAllBytes( - temp.resolve("target/eo/phi/org/eolang/bytes.phi") - ), - StandardCharsets.UTF_8 - ), + Files.readString(temp.resolve("target/eo/phi/org/eolang/bytes.phi")), Matchers.allOf( - Matchers.containsString("α0 ↦ Φ.org.eolang.bytes("), - Matchers.containsString("α0 ↦ ⟦ Δ ⤍ 01-02-03 ⟧"), - Matchers.containsString("yes ↦ ξ.eq(") + Matchers.containsString("yes ↦ ξ.eq("), + Matchers.containsString("Φ.org.eolang.bytes(⟦ Δ ⤍ 01-02-03 ⟧)") ) ); } diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/as-phi.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/as-phi.yaml index 6627119ef8..7ed4601aff 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/as-phi.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/as-phi.yaml @@ -32,12 +32,7 @@ phi: |- ⟦ prints-itself ↦ ⟦ φ ↦ Φ.org.eolang.assert-that( - α0 ↦ Φ.org.eolang.as-phi( - α0 ↦ ξ - ).length, - α1 ↦ ξ.greater-than( - α0 ↦ 0 - ) + Φ.org.eolang.as-phi(ξ).length, ξ.greater-than(0) ) ⟧ ⟧ diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/auto-named.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/auto-named.yaml index 3e530190f0..b0ea995e64 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/auto-named.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/auto-named.yaml @@ -30,13 +30,9 @@ phi: |- { ⟦ object ↦ ⟦ - first ↦ Φ.org.eolang.x( - α0 ↦ ξ.auto-named-attr-at-4-6 - ), + first ↦ Φ.org.eolang.x(ξ.auto-named-attr-at-4-6), auto-named-attr-at-4-6 ↦ ⟦ - b ↦ Φ.org.eolang.bytes( - α0 ↦ ⟦ Δ ⤍ 01- ⟧ - ) + b ↦ Φ.org.eolang.bytes(⟦ Δ ⤍ 01- ⟧) ⟧ ⟧ ⟧ diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/bool-tests.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/bool-tests.yaml index 9d979ff3d1..2861d82ea0 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/bool-tests.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/bool-tests.yaml @@ -90,51 +90,25 @@ phi: |- org ↦ ⟦ eolang ↦ ⟦ compares-two-bools ↦ ⟦ - φ ↦ Φ.org.eolang.true.eq( - α0 ↦ Φ.org.eolang.true - ) + φ ↦ Φ.org.eolang.true.eq(Φ.org.eolang.true) ⟧, true-as-bool ↦ ⟦ φ ↦ Φ.org.eolang.true.as-bool ⟧, compares-two-different-types ↦ ⟦ - φ ↦ Φ.org.eolang.true.eq( - α0 ↦ 42 - ).not + φ ↦ Φ.org.eolang.true.eq(42).not ⟧, compares-bool-to-bytes ↦ ⟦ - φ ↦ Φ.org.eolang.true.eq( - α0 ↦ Φ.org.eolang.bytes( - α0 ↦ ⟦ Δ ⤍ 01- ⟧ - ) - ).and( - α0 ↦ Φ.org.eolang.false.eq( - α0 ↦ Φ.org.eolang.bytes( - α0 ↦ ⟦ Δ ⤍ 00- ⟧ - ) - ) + φ ↦ Φ.org.eolang.true.eq(Φ.org.eolang.bytes(⟦ Δ ⤍ 01- ⟧)).and( + Φ.org.eolang.false.eq(Φ.org.eolang.bytes(⟦ Δ ⤍ 00- ⟧)) ) ⟧, compares-bool-to-string ↦ ⟦ - φ ↦ Φ.org.eolang.true.eq( - α0 ↦ "\u0001" - ).and( - α0 ↦ Φ.org.eolang.false.eq( - α0 ↦ "\u0000" - ) - ) + φ ↦ Φ.org.eolang.true.eq("\u0001").and(Φ.org.eolang.false.eq("\u0000")) ⟧, compares-bool-to-bytes-reverse ↦ ⟦ - φ ↦ Φ.org.eolang.bytes( - α0 ↦ ⟦ Δ ⤍ 01- ⟧ - ).as-bytes.eq( - α0 ↦ Φ.org.eolang.true - ).and( - α0 ↦ Φ.org.eolang.bytes( - α0 ↦ ⟦ Δ ⤍ 00- ⟧ - ).as-bytes.eq( - α0 ↦ Φ.org.eolang.false - ) + φ ↦ Φ.org.eolang.bytes(⟦ Δ ⤍ 01- ⟧).as-bytes.eq(Φ.org.eolang.true).and( + Φ.org.eolang.bytes(⟦ Δ ⤍ 00- ⟧).as-bytes.eq(Φ.org.eolang.false) ) ⟧, λ ⤍ Package diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/bytes.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/bytes.yaml index b49023497a..7ea68ddc3c 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/bytes.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/bytes.yaml @@ -28,7 +28,7 @@ eo: | +version 0.0.0 # This is the default 64+ symbols comment in front of named abstract object. - [] > bytes + [data] > bytes # This is the default 64+ symbols comment in front of named abstract object. [x] > eq /bool @@ -88,7 +88,7 @@ phi: |- org ↦ ⟦ eolang ↦ ⟦ bytes ↦ ⟦ - Δ ⤍ ∅, + data ↦ ∅, eq ↦ ⟦ λ ⤍ Lorg_eolang_bytes_eq, x ↦ ∅ @@ -127,20 +127,14 @@ phi: |- ⟧, left ↦ ⟦ x ↦ ∅, - φ ↦ ξ.ρ.right( - α0 ↦ ξ.x.neg - ) + φ ↦ ξ.ρ.right(ξ.x.neg) ⟧, right ↦ ⟦ λ ⤍ Lorg_eolang_bytes_right, x ↦ ∅ ⟧, as-bool ↦ ⟦ - φ ↦ ξ.ρ.eq( - α0 ↦ Φ.org.eolang.bytes( - α0 ↦ ⟦ Δ ⤍ 01- ⟧ - ) - ) + φ ↦ ξ.ρ.eq(Φ.org.eolang.bytes(⟦ Δ ⤍ 01- ⟧)) ⟧, as-bytes ↦ ⟦ φ ↦ ξ.ρ diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/custom-alias.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/custom-alias.yaml index 70d407568c..3e7c8f01c1 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/custom-alias.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/custom-alias.yaml @@ -34,9 +34,7 @@ phi: |- bar ↦ ⟦ main ↦ ⟦ y ↦ ∅, - z ↦ Φ.com.yegor256.x( - α0 ↦ ξ.y - ) + z ↦ Φ.com.yegor256.x(ξ.y) ⟧, λ ⤍ Package ⟧, diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/data-dispatch.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/data-dispatch.yaml index addf325678..22996bccdb 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/data-dispatch.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/data-dispatch.yaml @@ -26,11 +26,7 @@ eo: | phi: |- { ⟦ - ten ↦ 5.plus( - α0 ↦ 5 - ), - greetings ↦ "Hello".concat( - α0 ↦ "world" - ) + ten ↦ 5.plus(5), + greetings ↦ "Hello".concat("world") ⟧ } diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/empty-bytes.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/empty-bytes.yaml index c2f2897640..5c2e54c4a6 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/empty-bytes.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/empty-bytes.yaml @@ -24,8 +24,6 @@ eo: -- > empty phi: |- { ⟦ - empty ↦ Φ.org.eolang.bytes( - α0 ↦ ⟦ Δ ⤍ -- ⟧ - ) + empty ↦ Φ.org.eolang.bytes(⟦ Δ ⤍ -- ⟧) ⟧ } diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/fibonaci.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/fibonaci.yaml index 0a0ea7d912..f9f8ae0a84 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/fibonaci.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/fibonaci.yaml @@ -42,21 +42,8 @@ phi: |- example ↦ ⟦ fibonacci ↦ ⟦ n ↦ ∅, - φ ↦ ξ.n.lt( - α0 ↦ 2 - ).if( - α0 ↦ ξ.n, - α1 ↦ ξ.ρ.fibonacci( - α0 ↦ ξ.n.minus( - α0 ↦ 1 - ) - ).plus( - α0 ↦ ξ.ρ.fibonacci( - α0 ↦ ξ.n.minus( - α0 ↦ 2 - ) - ) - ) + φ ↦ ξ.n.lt(2).if( + ξ.n, ξ.ρ.fibonacci(ξ.n.minus(1)).plus(ξ.ρ.fibonacci(ξ.n.minus(2))) ) ⟧, λ ⤍ Package diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/iterates-over-counter.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/iterates-over-counter.yaml index 15aae9810f..a7f10ae8b4 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/iterates-over-counter.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/iterates-over-counter.yaml @@ -39,28 +39,14 @@ phi: |- { ⟦ iterates-over-simple-counter ↦ ⟦ - x ↦ Φ.org.eolang.memory( - α0 ↦ 0 - ), - φ ↦ ξ.x.write( - α0 ↦ 5 - ).eq( - α0 ↦ 5 - ).and( - α0 ↦ ξ.x.as-int.lt( - α0 ↦ 10 - ).while( - α0 ↦ ⟦ + x ↦ Φ.org.eolang.memory(0), + φ ↦ ξ.x.write(5).eq(5).and( + ξ.x.as-int.lt(10).while( + ⟦ i ↦ ∅, - φ ↦ ξ.ρ.x.write( - α0 ↦ ξ.ρ.x.as-int.plus( - α0 ↦ 1 - ) - ) + φ ↦ ξ.ρ.x.write(ξ.ρ.x.as-int.plus(1)) ⟧ - ).eq( - α0 ↦ 11 - ) + ).eq(11) ) ⟧ ⟧ diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/jeo-part.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/jeo-part.yaml index 79154e63be..d17a3ae464 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/jeo-part.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/jeo-part.yaml @@ -39,8 +39,7 @@ phi: |- access ↦ 32, supername ↦ "java/lang/Object", interfaces ↦ Φ.org.eolang.tuple( - α0 ↦ Φ.org.eolang.tuple.empty, - α1 ↦ "org/eolang/benchmark/F" + Φ.org.eolang.tuple.empty, "org/eolang/benchmark/F" ) ⟧, λ ⤍ Package diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/nested.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/nested.yaml index 51186ac1f6..13da714340 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/nested.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/nested.yaml @@ -42,9 +42,7 @@ phi: |- y ↦ ⟦ d ↦ ξ.ρ.ρ.a, z ↦ ⟦ - five ↦ ξ.ρ.ρ.ρ.ρ.main( - α0 ↦ 5 - ), + five ↦ ξ.ρ.ρ.ρ.ρ.main(5), b ↦ ξ.ρ.ρ.ρ.a, e ↦ ξ.ρ.d ⟧ diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/one-byte.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/one-byte.yaml index 6b34438f4a..b9a2ae3889 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/one-byte.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/one-byte.yaml @@ -24,8 +24,6 @@ eo: A2- > bts phi: |- { ⟦ - bts ↦ Φ.org.eolang.bytes( - α0 ↦ ⟦ Δ ⤍ A2- ⟧ - ) + bts ↦ Φ.org.eolang.bytes(⟦ Δ ⤍ A2- ⟧) ⟧ } diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/with-anonym-abstract.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/with-anonym-abstract.yaml index 48bda2ec8c..1b622be29d 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/with-anonym-abstract.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/phi/yaml/with-anonym-abstract.yaml @@ -31,9 +31,7 @@ phi: |- test ↦ ⟦ s ↦ ⟦ x ↦ ξ.ρ - ⟧.plus( - α0 ↦ Φ.org.eolang.int - ) + ⟧.plus(Φ.org.eolang.int) ⟧ ⟧ } diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/inline-application.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/inline-application.yaml new file mode 100644 index 0000000000..050677324a --- /dev/null +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/unphi/inline-application.yaml @@ -0,0 +1,42 @@ +# The MIT License (MIT) +# +# Copyright (c) 2016-2024 Objectionary.com +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +--- +tests: + - //o[@base='.foo' and @name='xyz']/o[1][@base='Q'] + - //o[@base='.foo' and @name='xyz']/o[@as='0' and @base='org.eolang.string']/o[@base='org.eolang.bytes' and text()='48-65-6C-6C-6F'] + - //o[@base='.foo' and @name='xyz']/o[@as='1' and @base='org.eolang.string']/o[@base='org.eolang.bytes' and text()='77-6F-72-6C-64'] + - //o[@base='.foo' and @name='xyz']/o[@as='2' and @base='.plus']/o[1][@base='org.eolang.number' and not(@as)]/o[@base='org.eolang.bytes' and text()='40-45-00-00-00-00-00-00'] + - //o[@base='.foo' and @name='xyz']/o[@as='2' and @base='.plus']/o[@base='org.eolang.number' and @as='0']/o[@base='org.eolang.bytes' and text()='40-41-80-00-00-00-00-00'] + - //o[@base='.foo' and @name='xyz']/o[@as='3' and @base='.some']/o[1][@base='org.eolang.number' and not(@as)]/o[@base='org.eolang.bytes' and text()='40-3F-19-99-99-99-99-9A'] + - //o[@base='.foo' and @name='xyz']/o[@as='3' and @base='.some']/o[@base='.y' and @as='0']/o[1][@base='Q'] + - //o[@base='.foo' and @name='xyz']/o[@as='3' and @base='.some']/o[@base='.y' and @as='0']/o[@base='org.eolang.number' and @as='0']/o[@base='org.eolang.bytes' and text()='40-26-00-00-00-00-00-00'] +phi: |- + { + ⟦ + xyz ↦ Φ.foo( + "Hello", + "world", + 42.plus(35), + 31.1.some(Φ.y(11)) + ) + ⟧ + } diff --git a/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 b/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 index f84938cca5..fb02971615 100644 --- a/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 +++ b/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 @@ -86,14 +86,23 @@ FUNCTION ; application - : LB applicationBinding RB + : LB (applicationBindings | applicationObjects) RB ; -applicationBinding +applicationBindings : tauBinding? | tauBinding (COMMA tauBinding)* ; +applicationObjects + : justObject? + | justObject (COMMA justObject)+ + ; + +justObject + : object + ; + dispatch: DOT attribute ; diff --git a/eo-parser/src/main/java/org/eolang/parser/XePhiListener.java b/eo-parser/src/main/java/org/eolang/parser/XePhiListener.java index 9bc7feaa72..80018579a7 100644 --- a/eo-parser/src/main/java/org/eolang/parser/XePhiListener.java +++ b/eo-parser/src/main/java/org/eolang/parser/XePhiListener.java @@ -76,6 +76,11 @@ public final class XePhiListener implements PhiListener, Iterable { */ private final Stack properties; + /** + * Stack of alphas. + */ + private final Stack alphas; + /** * Objects. */ @@ -106,6 +111,7 @@ public XePhiListener(final String nme) { this.objs = new ArrayDeque<>(); this.attributes = new Stack<>(); this.properties = new Stack<>(); + this.alphas = new Stack<>(); this.packages = new ListOf<>(); this.start = System.nanoTime(); } @@ -300,15 +306,39 @@ public void exitApplication(final PhiParser.ApplicationContext ctx) { } @Override - public void enterApplicationBinding(final PhiParser.ApplicationBindingContext ctx) { + public void enterApplicationBindings(final PhiParser.ApplicationBindingsContext ctx) { // Nothing here } @Override - public void exitApplicationBinding(final PhiParser.ApplicationBindingContext ctx) { + public void exitApplicationBindings(final PhiParser.ApplicationBindingsContext ctx) { // Nothing here } + @Override + public void enterApplicationObjects(final PhiParser.ApplicationObjectsContext ctx) { + this.alphas.push(0); + } + + @Override + public void exitApplicationObjects(final PhiParser.ApplicationObjectsContext ctx) { + this.alphas.pop(); + } + + @Override + public void enterJustObject(final PhiParser.JustObjectContext ctx) { + this.enterObjectBinding(); + final int index = this.alphas.peek(); + this.alphas.pop(); + this.alphas.push(index + 1); + this.attributes.push(String.valueOf(index)); + } + + @Override + public void exitJustObject(final PhiParser.JustObjectContext ctx) { + this.exitObjectBinding(); + } + @Override @SuppressWarnings("PMD.ConfusingTernary") public void enterDispatch(final PhiParser.DispatchContext ctx) { diff --git a/eo-parser/src/test/resources/org/eolang/parser/phi-syntax/all-the-basics.phi b/eo-parser/src/test/resources/org/eolang/parser/phi-syntax/all-the-basics.phi index 2c8fb519de..34bb1cc4f6 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/phi-syntax/all-the-basics.phi +++ b/eo-parser/src/test/resources/org/eolang/parser/phi-syntax/all-the-basics.phi @@ -24,5 +24,8 @@ int-application ↦ 42(z ↦ ξ.f), float-dot ↦ 52.1.print, float-application ↦ 52.1(z ↦ ξ.f), - minus ↦ -0 + minus ↦ -0, + inline-application ↦ Φ.x( + "Hello", 42, Φ.y("world", 11.plus(12)), 42.5 + ) ⟧}