diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/UnphiMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/UnphiMojoTest.java index cb4ac420a9..60b352e1fb 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/UnphiMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/UnphiMojoTest.java @@ -44,6 +44,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; import org.yaml.snakeyaml.Yaml; /** @@ -144,8 +145,12 @@ void convertsToXmirAndBack(final String pack, @TempDir final Path temp) throws E ); } - @Test - void convertsValidXmirAndParsableEO(@TempDir final Path temp) throws IOException { + @ParameterizedTest + @CsvSource({"true", "false"}) + void convertsValidXmirAndParsableEO( + final boolean reversed, + @TempDir final Path temp + ) throws Exception { final Map map = new FakeMaven(temp) .withProgram( "[args] > app", @@ -154,6 +159,7 @@ void convertsValidXmirAndParsableEO(@TempDir final Path temp) throws IOException ) .with("printSourcesDir", temp.resolve("target/1-parse").toFile()) .with("printOutputDir", temp.resolve("target/generated-sources").toFile()) + .with("printReversed", reversed) .execute(ParseMojo.class) .execute(OptimizeMojo.class) .execute(PhiMojo.class) diff --git a/eo-parser/src/main/antlr4/org/eolang/parser/Eo.g4 b/eo-parser/src/main/antlr4/org/eolang/parser/Eo.g4 index 8003ab04c9..e8e29a1298 100644 --- a/eo-parser/src/main/antlr4/org/eolang/parser/Eo.g4 +++ b/eo-parser/src/main/antlr4/org/eolang/parser/Eo.g4 @@ -181,10 +181,8 @@ vapplication // Vertical application head vapplicationHead : applicable - | hmethodExtended - | hmethodExtendedVersioned - | vmethod - | vmethodVersioned + | hmethodOptional + | vmethodOptional | versioned ; @@ -193,6 +191,11 @@ vapplicationHeadNamed : vapplicationHead oname? ; +// Vertical application head with binding +vapplicationHeadAs + : vapplicationHead as + ; + // Vertical application arguments vapplicationArgs : EOL @@ -245,11 +248,6 @@ vapplicationArgHapplicationUnbinded : happlicationExtended oname? ; -// Vertical application head with binding -vapplicationHeadAs - : (applicable | hmethodOptional | versioned) as - ; - // Vertical anonym object as argument of vertical application vapplicationArgVanonymUnbinded : attributes oname? formatees? diff --git a/eo-parser/src/main/java/org/eolang/parser/xmir/XmirReversed.java b/eo-parser/src/main/java/org/eolang/parser/xmir/XmirReversed.java index 398986e7bd..8b015d3575 100644 --- a/eo-parser/src/main/java/org/eolang/parser/xmir/XmirReversed.java +++ b/eo-parser/src/main/java/org/eolang/parser/xmir/XmirReversed.java @@ -33,7 +33,7 @@ public final class XmirReversed extends XmirEnvelope { /** * XSL transformation that converts XMIR to EO with reversed methods. */ - private static final String REVERSED = "/org/eolang/parser/xmir-to-eo.xsl"; + private static final String REVERSED = "/org/eolang/parser/xmir-to-eo-reversed.xsl"; /** * Ctor. diff --git a/eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo-reversed.xsl b/eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo-reversed.xsl new file mode 100644 index 0000000000..ae15cf74f6 --- /dev/null +++ b/eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo-reversed.xsl @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + # + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + + + * + + + + + + + + + [ + + + + + + + ] + + + + + ' + + + : + + + + > + + + ! + + + / + + + + + + + + + + """ + + + + + + + + """ + + + + + + + + -- + + + + + + + + + Invalid data attribute: + + + + + + + + + + + diff --git a/eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo.xsl b/eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo.xsl index 14985e5217..d9946bc563 100644 --- a/eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo.xsl +++ b/eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo.xsl @@ -24,8 +24,8 @@ SOFTWARE. --> @@ -71,27 +71,43 @@ SOFTWARE. - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - . - * diff --git a/eo-parser/src/test/java/org/eolang/parser/xmir/XmirTest.java b/eo-parser/src/test/java/org/eolang/parser/xmir/XmirTest.java index 792ef55af1..e62b785812 100644 --- a/eo-parser/src/test/java/org/eolang/parser/xmir/XmirTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/xmir/XmirTest.java @@ -34,7 +34,6 @@ import org.eolang.parser.EoSyntax; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.yaml.snakeyaml.Yaml; @@ -45,18 +44,7 @@ * @checkstyle AbbreviationAsWordInNameCheck (500 lines) */ final class XmirTest { - /** - * Convert EO to xmir and back and compare. - * @param pack EO pack. - * @throws Exception If fails. - * @todo #2758:30min Implement printing from XMIR to EO in strait notation - * (where method starts on the next line). It should be done via XSL which - * should be used in {@link Xmir.Default} object. The next disabled test - * shows that such implementation does not work now: - * {@link XmirTest#printsStrait(String)} - */ @ParameterizedTest - @Disabled @ClasspathSource(value = "org/eolang/parser/samples/", glob = "**.yaml") void printsStrait(final String pack) throws IOException { final Map map = new Yaml().load(pack); diff --git a/eo-parser/src/test/resources/org/eolang/parser/packs/syntax/vertical-methods-in-application.yaml b/eo-parser/src/test/resources/org/eolang/parser/packs/syntax/vertical-methods-in-application.yaml index e190e14382..bfc879e346 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/packs/syntax/vertical-methods-in-application.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/packs/syntax/vertical-methods-in-application.yaml @@ -10,4 +10,18 @@ eo: | .b:0 c .d - .e:1 \ No newline at end of file + .e:1 + Q + .org + .eolang + .io + .stdout > third + Q + .org + .eolang + .string:0 + Q + .org + .eolang + .bytes + 00-42-23 \ No newline at end of file diff --git a/eo-parser/src/test/resources/org/eolang/parser/samples/dataless.yaml b/eo-parser/src/test/resources/org/eolang/parser/samples/dataless.yaml index f17a4a0efb..28d4056a9a 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/samples/dataless.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/samples/dataless.yaml @@ -16,7 +16,7 @@ strait: | [args] > main QQ .io - stdout > @ + .stdout > @ args .at args diff --git a/eo-parser/src/test/resources/org/eolang/parser/samples/idiomatic.yaml b/eo-parser/src/test/resources/org/eolang/parser/samples/idiomatic.yaml index 2f31eddaf3..f3d719e93f 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/samples/idiomatic.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/samples/idiomatic.yaml @@ -48,7 +48,9 @@ strait: | """ 4.55 > x! * - "Hello, \u0434\u0440\u0443\u0433" + """ + Hello, \u0434\u0440\u0443\u0433 + """ 2.18 TRUE .plus @@ -57,7 +59,7 @@ strait: | .plus """ hello, \u5927\u5BB6! - """" + """ .if > @ reversed: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/samples/inheritance.yaml b/eo-parser/src/test/resources/org/eolang/parser/samples/inheritance.yaml index f5438b7c64..01e1205d2f 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/samples/inheritance.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/samples/inheritance.yaml @@ -13,6 +13,7 @@ origin: | self.f > @ self v + [] > derived base > @ [self v] > f @@ -27,7 +28,8 @@ strait: | +architect yegor256@gmail.com [] > base - memory 0 > x + memory > x + 0 [self v] > f x .write > @ @@ -37,13 +39,14 @@ strait: | .f > @ self v + [] > derived base > @ [self v] > f self .g > @ self - v + v reversed: | +package sandbox diff --git a/eo-parser/src/test/resources/org/eolang/parser/samples/just-float.yaml b/eo-parser/src/test/resources/org/eolang/parser/samples/just-float.yaml index 81412db4bb..75883a90bd 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/samples/just-float.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/samples/just-float.yaml @@ -5,6 +5,7 @@ origin: | strait: | 3.14 > pi + [] > foo 2.18 > e diff --git a/eo-parser/src/test/resources/org/eolang/parser/samples/times.yaml b/eo-parser/src/test/resources/org/eolang/parser/samples/times.yaml index 31af6075ed..f4ec32c721 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/samples/times.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/samples/times.yaml @@ -12,13 +12,13 @@ strait: | .stdout > @ QQ .txt - .sprintf + .sprintf """ result is %d\n """ - -1 - .times - 228 + -1 + .times + 228 reversed: | [] > app