diff --git a/eo-maven-plugin/src/main/resources/org/eolang/maven/transpile/to-java.xsl b/eo-maven-plugin/src/main/resources/org/eolang/maven/transpile/to-java.xsl index 6621656f0a..c81d9adcfa 100644 --- a/eo-maven-plugin/src/main/resources/org/eolang/maven/transpile/to-java.xsl +++ b/eo-maven-plugin/src/main/resources/org/eolang/maven/transpile/to-java.xsl @@ -519,6 +519,12 @@ SOFTWARE. + + + Dispatching alpha attributes is not supported in EO yet, found: + + + 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 c280f48e76..2aced34b3a 100644 --- a/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 +++ b/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 @@ -64,6 +64,11 @@ tauBinding | attribute voids ARROW formation ; +applicationTauBinding + : fullAttribute ARROW object + | fullAttribute voids ARROW formation + ; + voids : LB (void? | void (COMMA void)+) RB ; @@ -77,6 +82,10 @@ attribute : PHI | RHO | LABEL + ; + +fullAttribute + : attribute | ALPHA ; @@ -101,8 +110,8 @@ application ; applicationBindings - : tauBinding? - | tauBinding (COMMA tauBinding)* + : applicationTauBinding? + | applicationTauBinding (COMMA applicationTauBinding)* ; applicationObjects @@ -114,7 +123,7 @@ justObject : object ; -dispatch: DOT attribute +dispatch: DOT fullAttribute ; applicationsOrDispatches diff --git a/eo-parser/src/main/java/org/eolang/parser/TrFull.java b/eo-parser/src/main/java/org/eolang/parser/TrFull.java index 85a28eec4c..c4ab891db7 100644 --- a/eo-parser/src/main/java/org/eolang/parser/TrFull.java +++ b/eo-parser/src/main/java/org/eolang/parser/TrFull.java @@ -27,7 +27,6 @@ import com.yegor256.xsline.TrDefault; import com.yegor256.xsline.TrEnvelope; import com.yegor256.xsline.TrFast; -import com.yegor256.xsline.TrLambda; import com.yegor256.xsline.TrLogged; import com.yegor256.xsline.Train; import java.util.logging.Level; @@ -52,13 +51,10 @@ public TrFull(final Train train) { super( new TrStepped( new TrFast( - new TrLambda( - new TrLogged( - train, - TrFull.class, - Level.FINEST - ), - StEoLogged::new + new TrLogged( + train, + TrFull.class, + Level.FINEST ), TrFull.class, 500L 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 b0fa4920ef..214b67bf23 100644 --- a/eo-parser/src/main/java/org/eolang/parser/XePhiListener.java +++ b/eo-parser/src/main/java/org/eolang/parser/XePhiListener.java @@ -231,6 +231,16 @@ public void exitTauBinding(final PhiParser.TauBindingContext ctx) { this.exitObjectBinding(); } + @Override + public void enterApplicationTauBinding(final PhiParser.ApplicationTauBindingContext ctx) { + this.startObject(ctx); + } + + @Override + public void exitApplicationTauBinding(final PhiParser.ApplicationTauBindingContext ctx) { + this.exitObjectBinding(); + } + @Override public void enterVoids(final PhiParser.VoidsContext ctx) { // Nothing here @@ -267,7 +277,7 @@ public void enterAttribute(final PhiParser.AttributeContext ctx) { attr = "@"; } else if (ctx.RHO() != null) { attr = "^"; - } else if (ctx.LABEL() != null || ctx.ALPHA() != null) { + } else if (ctx.LABEL() != null) { attr = ctx.getText(); } else { attr = ""; @@ -280,6 +290,18 @@ public void exitAttribute(final PhiParser.AttributeContext ctx) { // Nothing here } + @Override + public void enterFullAttribute(final PhiParser.FullAttributeContext ctx) { + if (ctx.attribute() == null) { + this.attributes.push(ctx.getText()); + } + } + + @Override + public void exitFullAttribute(final PhiParser.FullAttributeContext ctx) { + // Nothing here + } + @Override public void enterEmptyBinding(final PhiParser.EmptyBindingContext ctx) { this.addVoidAttribute(ctx); diff --git a/eo-parser/src/main/java/org/eolang/parser/Xmir.java b/eo-parser/src/main/java/org/eolang/parser/Xmir.java index 933d47b72f..c2d5755dd6 100644 --- a/eo-parser/src/main/java/org/eolang/parser/Xmir.java +++ b/eo-parser/src/main/java/org/eolang/parser/Xmir.java @@ -223,7 +223,7 @@ public String toSaltyPhi() { * @return XMIR in other representation as {@link String}. */ private String converted(final Train train, final String xsl, final String xpath) { - return this.converted(new TrJoined<>(train.with(new StClasspath(xsl))), xpath); + return this.converted(train.with(new StClasspath(xsl)), xpath); } /** diff --git a/eo-parser/src/main/resources/org/eolang/parser/print/to-eo-reversed.xsl b/eo-parser/src/main/resources/org/eolang/parser/print/to-eo-reversed.xsl index 2631b0f0b1..8bcc76910b 100644 --- a/eo-parser/src/main/resources/org/eolang/parser/print/to-eo-reversed.xsl +++ b/eo-parser/src/main/resources/org/eolang/parser/print/to-eo-reversed.xsl @@ -94,6 +94,12 @@ SOFTWARE. + + + Dispatching alpha attributes is not supported in EO yet, found: + + + . diff --git a/eo-parser/src/main/resources/org/eolang/parser/print/to-eo.xsl b/eo-parser/src/main/resources/org/eolang/parser/print/to-eo.xsl index 8f02cefa20..e5866e5739 100644 --- a/eo-parser/src/main/resources/org/eolang/parser/print/to-eo.xsl +++ b/eo-parser/src/main/resources/org/eolang/parser/print/to-eo.xsl @@ -79,6 +79,12 @@ SOFTWARE. + + + Dispatching alpha attributes is not supported in EO yet, found: + + + diff --git a/eo-parser/src/test/java/org/eolang/parser/XmirTest.java b/eo-parser/src/test/java/org/eolang/parser/XmirTest.java index aba3804a8f..c450535716 100644 --- a/eo-parser/src/test/java/org/eolang/parser/XmirTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/XmirTest.java @@ -25,6 +25,7 @@ import com.jcabi.matchers.XhtmlMatchers; import com.jcabi.xml.XML; +import com.jcabi.xml.XMLDocument; import java.io.IOException; import org.cactoos.io.InputOf; import org.eolang.jucs.ClasspathSource; @@ -33,7 +34,11 @@ import org.eolang.xax.Xtory; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.xembly.Directives; +import org.xembly.Xembler; /** * Test case for {@link Xmir}. @@ -42,6 +47,25 @@ */ final class XmirTest { + @Test + void failsOnDispatchingAlphaAttributes() { + Assertions.assertThrows( + IllegalArgumentException.class, + new Xmir( + new XMLDocument( + new Xembler( + new Directives(new DrProgram("foo")) + .add("objects") + .add("o").attr("name", "foo") + .add("o").attr("base", ".α0").attr("name", "self") + .add("o").attr("base", "$") + ).xmlQuietly() + ) + )::toEO, + "XMIR with alpha dispatch should fail on converting to EO" + ); + } + @ParameterizedTest @ClasspathSource(value = "org/eolang/parser/print-packs/yaml", glob = "**.yaml") void printsToEoStraight(final String pack) throws IOException { 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 2b88bae4e3..83f1c2e5e0 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 @@ -10,9 +10,10 @@ error-on-purpose ↦ ⊥, the-атрибут ↦ Φ.ρ, hi-大家 ↦ ⟦ ⟧, - α0 ↦ Φ () () (), - α65536 ↦ Φ.r, - k ↦ ⟦ λ ⤍ Function_Name_i64, α0 ↦ ⟦ λ ⤍ FunctionName, Δ ⤍ 42- ⟧ ⟧, + triple ↦ Φ () () (), + sss ↦ Φ.r, + alpha-dispatch ↦ ξ.x.α0.α1.y, + k ↦ ⟦ λ ⤍ Function_Name_i64, first ↦ ⟦ λ ⤍ FunctionName, Δ ⤍ 42- ⟧ ⟧, terminator-application ↦ ⊥ (t ↦ ξ.t), terminator-dispatch ↦ ⊥.t, string ↦ "Hello", diff --git a/eo-parser/src/test/resources/org/eolang/parser/phi-syntax/alpha-twice.phi b/eo-parser/src/test/resources/org/eolang/parser/phi-syntax/alpha-twice.phi deleted file mode 100644 index e2d54990db..0000000000 --- a/eo-parser/src/test/resources/org/eolang/parser/phi-syntax/alpha-twice.phi +++ /dev/null @@ -1 +0,0 @@ -{⟦ k ↦ ⟦ α2 ↦ ξ.k, α2 ↦ ξ.t ⟧ ⟧} diff --git a/eo-parser/src/test/resources/org/eolang/parser/phi-typos/alpha-in-formation.phi b/eo-parser/src/test/resources/org/eolang/parser/phi-typos/alpha-in-formation.phi new file mode 100644 index 0000000000..5de4f7c430 --- /dev/null +++ b/eo-parser/src/test/resources/org/eolang/parser/phi-typos/alpha-in-formation.phi @@ -0,0 +1 @@ +{⟦ α0 ↦ ξ.t ⟧}