diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/PrintMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/PrintMojo.java index be5148fdb8..be2bde2a98 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/PrintMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/PrintMojo.java @@ -24,6 +24,8 @@ package org.eolang.maven; import com.jcabi.log.Logger; +import com.jcabi.xml.XML; +import com.jcabi.xml.XMLDocument; import java.io.File; import java.io.IOException; import java.nio.file.Path; @@ -38,8 +40,10 @@ import org.eolang.maven.util.HmBase; import org.eolang.maven.util.Home; import org.eolang.maven.util.Walk; -import org.eolang.parser.XMIR; +import org.eolang.parser.Schema; import org.eolang.parser.xmir.Xmir; +import org.eolang.parser.xmir.XmirReversed; +import org.eolang.parser.xmir.XmirSwap; /** * Print XMIR to EO. @@ -73,6 +77,13 @@ public final class PrintMojo extends SafeMojo { ) private File printOutputDir; + @Parameter( + property = "eo.printReversed", + required = true, + defaultValue = "false" + ) + private boolean printReversed = false; + @Override void exec() throws IOException { final Home home = new HmBase(this.printOutputDir); @@ -85,7 +96,16 @@ void exec() throws IOException { this.printSourcesDir.toPath().relativize(source).toString() .replace(".xmir", ".eo") ); - home.save(new Xmir(new TextOf(source)).toEO(), relative); + final XML xml = new XMLDocument(new TextOf(source).asString()); + new Schema(xml).check(); + home.save( + new XmirSwap( + this.printReversed, + new XmirReversed(xml), + new Xmir.Default(xml) + ).toEO(), + relative + ); Logger.info( this, "Printed: %s => %s", source, this.printOutputDir.toPath().resolve(relative) diff --git a/eo-maven-plugin/src/main/resources/log4j.properties b/eo-maven-plugin/src/main/resources/log4j.properties index 6398d644fc..8f38ea9bfb 100644 --- a/eo-maven-plugin/src/main/resources/log4j.properties +++ b/eo-maven-plugin/src/main/resources/log4j.properties @@ -8,5 +8,5 @@ log4j.logger.org.eolang=INFO log4j.logger.com.yegor256.xsline=INFO log4j.logger.org.eolang.parser.EoSyntax=INFO log4j.logger.org.eolang.parser.Scenario=INFO -log4j.logger.org.eolang.parser.XMIRTest=INFO +log4j.logger.org.eolang.parser.xmir.XmirTest=INFO log4j.logger.org.eolang.maven.SodgMojo=TRACE diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/PrintMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/PrintMojoTest.java index d47a5080b1..414a2937bc 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/PrintMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/PrintMojoTest.java @@ -40,6 +40,11 @@ /** * Test cases for {@link PrintMojo}. * @since 0.33.0 + * @todo #2758:30min To test that PrintMojo prints EO in different notations depends + * on given flag. When {@link org.eolang.parser.xmir.XmirReversed} and + * {@link org.eolang.parser.xmir.Xmir.Default} work correctly and prints xmirs in + * corresponding notations we need to check that PrintMojo uses them correctly + * depends on given flag {@link PrintMojo#printReversed}. */ final class PrintMojoTest { @Test diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/print/inner/a.xmir b/eo-maven-plugin/src/test/resources/org/eolang/maven/print/inner/a.xmir index c4fd813877..a0582321e7 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/print/inner/a.xmir +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/print/inner/a.xmir @@ -1,4 +1,19 @@ - + + [d] > a + cage d > this-d + [] > new + ^ > @ + [] > foo + this-d.plus 1 > @ + diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/print/inner/b.xmir b/eo-maven-plugin/src/test/resources/org/eolang/maven/print/inner/b.xmir index 4bef0ad2fd..f5153606cc 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/print/inner/b.xmir +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/print/inner/b.xmir @@ -1,4 +1,19 @@ - + + [a] > a + cage a > this-a + [] > new + ^ > @ + [] > foo + this-a.foo.plus 2 > @ + diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/print/main.xmir b/eo-maven-plugin/src/test/resources/org/eolang/maven/print/main.xmir index 8205107e6d..94edb187dc 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/print/main.xmir +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/print/main.xmir @@ -1,4 +1,12 @@ - + [] > main [args...] > main b.new (a.new 42) 21 @@ -19,7 +27,7 @@ 00 00 00 00 00 00 00 2A - 00 00 00 00 00 00 00 0C + 00 00 00 00 00 00 00 0C diff --git a/eo-parser/src/main/java/org/eolang/parser/xmir/Xmir.java b/eo-parser/src/main/java/org/eolang/parser/xmir/Xmir.java index b80cacee96..5a374ec254 100644 --- a/eo-parser/src/main/java/org/eolang/parser/xmir/Xmir.java +++ b/eo-parser/src/main/java/org/eolang/parser/xmir/Xmir.java @@ -24,18 +24,15 @@ package org.eolang.parser.xmir; import com.jcabi.xml.XML; -import com.jcabi.xml.XMLDocument; -import com.yegor256.xsline.TrClasspath; +import com.yegor256.xsline.Shift; +import com.yegor256.xsline.StClasspath; import com.yegor256.xsline.TrDefault; -import com.yegor256.xsline.TrJoined; +import com.yegor256.xsline.Train; import com.yegor256.xsline.Xsline; -import org.cactoos.Text; -import org.cactoos.scalar.Unchecked; import org.eolang.parser.StUnhex; /** * Prints XMIR to EO. - * * @since 0.35.0 */ public interface Xmir { @@ -60,9 +57,13 @@ public interface Xmir { */ final class Default implements Xmir { /** - * Wrap method calls XSL. + * Train of transformations. */ - private static final String WRAP = "/org/eolang/parser/wrap-method-calls.xsl"; + private static final Train TRAIN = new TrDefault<>( + new StClasspath("/org/eolang/parser/explicit-data.xsl"), + new StUnhex(), + new StClasspath("/org/eolang/parser/wrap-method-calls.xsl") + ); /** * Default xmir-to-eo XSL transformation. @@ -70,83 +71,41 @@ final class Default implements Xmir { private static final String TO_EO = "/org/eolang/parser/xmir-to-eo.xsl"; /** - * The XML content. - */ - private final Unchecked content; - - /** - * XSL transformation sheets. - */ - private final String[] sheets; - - /** - * Ctor. - * @param src The source + * The XML. */ - public Default(final String src) { - this(new XMLDocument(src)); - } + private final XML xml; /** - * Ctor. - * @param src The source + * Result to-EO transformation. */ - public Default(final Text src) { - this(new Unchecked<>(src::asString), Xmir.Default.TO_EO); - } - - /** - * Ctor. - * @param src The source - * @param xsl To-EO transformation - */ - public Default(final Text src, final String xsl) { - this(new Unchecked<>(src::asString), xsl); - } - - /** - * Ctor. - * @param src The source - */ - public Default(final XML src, final String xsl) { - this(new Unchecked<>(src::toString), xsl); - } + private final String xsl; /** * Ctor. * @param src The source */ public Default(final XML src) { - this(new Unchecked<>(src::toString), Xmir.Default.TO_EO); - } - - /** - * Ctor. - * @param src The source - * @param xsl To-EO transformation - */ - Default(final Unchecked src, final String xsl) { - this(src, new String[] { Xmir.Default.WRAP, xsl }); + this(src, Xmir.Default.TO_EO); } /** * Ctor. * @param src The source + * @param classpath To-EO transformation classpath */ - private Default(final Unchecked src, final String[] sheets) { - this.content = src; - this.sheets = sheets; + public Default(final XML src, final String classpath) { + this.xml = src; + this.xsl = classpath; } @Override public String toEO() { return new Xsline( - new TrJoined<>( - new TrDefault<>(new StUnhex()), - new TrClasspath<>(this.sheets).back() + Xmir.Default.TRAIN.with( + new StClasspath(this.xsl) ) ) - .pass(new XMLDocument(this.content.value())) + .pass(this.xml) .xpath("eo/text()") .get(0); } 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 b0e60081bb..398986e7bd 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 @@ -24,7 +24,6 @@ package org.eolang.parser.xmir; import com.jcabi.xml.XML; -import org.cactoos.scalar.Unchecked; /** * Converts to EO with reversed methods. @@ -34,21 +33,13 @@ 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-reversed.xsl"; + private static final String REVERSED = "/org/eolang/parser/xmir-to-eo.xsl"; /** * Ctor. * @param xml The source xml */ public XmirReversed(final XML xml) { - this(new Unchecked<>(xml::toString)); - } - - /** - * Ctor. - * @param src The source - */ - private XmirReversed(final Unchecked src) { - super(new Xmir.Default(src, XmirReversed.REVERSED)); + super(new Xmir.Default(xml, XmirReversed.REVERSED)); } } diff --git a/eo-parser/src/main/java/org/eolang/parser/xmir/package-info.java b/eo-parser/src/main/java/org/eolang/parser/xmir/package-info.java new file mode 100644 index 0000000000..ec389a6c0d --- /dev/null +++ b/eo-parser/src/main/java/org/eolang/parser/xmir/package-info.java @@ -0,0 +1,34 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2023 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. + */ + +/** + * EO parser. + * + * @author Yegor Bugayenko (yegor256@gmail.com) + * @version $Id$ + * @since 0.1 + * @see Project site www.eolang.org + * @see GitHub project + */ +package org.eolang.parser.xmir; diff --git a/eo-parser/src/main/resources/XMIR.xsd b/eo-parser/src/main/resources/XMIR.xsd index 2032196dc3..7f9e34ffdf 100644 --- a/eo-parser/src/main/resources/XMIR.xsd +++ b/eo-parser/src/main/resources/XMIR.xsd @@ -37,7 +37,17 @@ SOFTWARE. - + + + + + + + + + + + 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 0ab3075432..14985e5217 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. --> @@ -68,10 +68,6 @@ SOFTWARE. - - - - @@ -80,7 +76,9 @@ SOFTWARE. - + + + @@ -94,6 +92,10 @@ SOFTWARE. . + + + * + @@ -131,24 +133,39 @@ SOFTWARE. - + + - + """ - - + + + + + + """ - + + + + + -- + + + + + + - - - - - + + Invalid data attribute: + + diff --git a/eo-parser/src/test/java/org/eolang/parser/XMIRTest.java b/eo-parser/src/test/java/org/eolang/parser/XMIRTest.java deleted file mode 100644 index 09acb8fad8..0000000000 --- a/eo-parser/src/test/java/org/eolang/parser/XMIRTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016-2023 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. - */ -package org.eolang.parser; - -import com.jcabi.log.Logger; -import com.jcabi.xml.ClasspathSources; -import com.jcabi.xml.XML; -import com.jcabi.xml.XSLDocument; -import com.yegor256.xsline.TrClasspath; -import com.yegor256.xsline.Xsline; -import java.io.IOException; -import org.cactoos.io.InputOf; -import org.eolang.jucs.ClasspathSource; -import org.eolang.parser.xmir.Xmir; -import org.hamcrest.MatcherAssert; -import org.hamcrest.Matchers; -import org.junit.jupiter.params.ParameterizedTest; - -/** - * Test case for {@link Xmir}. - * - * @since 0.5 - * @checkstyle AbbreviationAsWordInNameCheck (500 lines) - */ -final class XMIRTest { - - /** - * Convert EO to xmir and back and compare. - * @param src EO source. - * @throws Exception If fails. - * @todo #2750:30min Empty bytes in EO ("--") are not converted successfully. The test - * `org/eolang/parser/xmir-samples-wrong/empty-bytes.eo` fails. Transformation `xmir-to-eo.xsl` - * need to be fixed. Don't forget to move `empty-bytes.eo` test from - * `org/eolang/parser/xmir-samples-wrong` to `org/eolang/parser/xmir-samples` after fixing - * `xmir-to-eo.xsl`. - */ - @ParameterizedTest - @ClasspathSource(value = "org/eolang/parser/xmir-samples/", glob = "**.eo") - void printsToEO(final String src) throws Exception { - Logger.debug(this, "Original EOLANG:%n%s", src); - final XML first = XMIRTest.clean(XMIRTest.parse(src)); - Logger.debug(this, "First:%n%s", first); - final String eolang = new Xmir(first).toEO(); - Logger.debug(this, "EOLANG:%n%s", eolang); - final XML second = XMIRTest.clean(XMIRTest.parse(eolang)); - Logger.debug(this, "Second:%n%s", second); - final String ignore = "data=\"\\S+\""; - MatcherAssert.assertThat( - first - .toString() - .replaceAll(ignore, ""), - Matchers.equalTo( - second - .toString() - .replaceAll(ignore, "") - ) - ); - } - - /** - * Parse EO code to XMIR. - * @param source The source - * @return XMIR - * @throws IOException If fails - */ - private static XML parse(final String source) throws IOException { - return new Xsline( - new TrClasspath<>( - "/org/eolang/parser/wrap-method-calls.xsl", - "/org/eolang/parser/explicit-data.xsl" - ).back() - ).pass( - new EoSyntax("test", new InputOf(source)).parsed() - ); - } - - /** - * Take the clean version of XML, without the noise. - * @param xmir The original - * @return Clean one - */ - private static XML clean(final XML xmir) { - return new XSLDocument( - XMIRTest.class.getResourceAsStream("strip-xmir.xsl") - ).with(new ClasspathSources()).transform(xmir); - } - -} 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 new file mode 100644 index 0000000000..04f055755a --- /dev/null +++ b/eo-parser/src/test/java/org/eolang/parser/xmir/XmirTest.java @@ -0,0 +1,108 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2023 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. + */ +package org.eolang.parser.xmir; + +import com.jcabi.log.Logger; +import com.jcabi.matchers.XhtmlMatchers; +import com.jcabi.xml.XML; +import java.io.IOException; +import java.util.Map; +import java.util.function.Function; +import org.cactoos.io.InputOf; +import org.eolang.jucs.ClasspathSource; +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; + +/** + * Test case for {@link Xmir} and {@link XmirReversed}. + * + * @since 0.5 + * @checkstyle AbbreviationAsWordInNameCheck (500 lines) + */ +final class XmirTest { + /** + * Convert EO to xmir and back and compare. + * @param pack EO pack. + * @throws Exception If fails. + * c 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/xmir/samples/", glob = "**.yaml") + void printsStrait(final String pack) throws IOException { + this.parseAndCompare(pack, "strait", Xmir.Default::new); + } + + @ParameterizedTest + @ClasspathSource(value = "org/eolang/parser/xmir/samples/", glob = "**.yaml") + void printsReversed(final String pack) throws IOException { + this.parseAndCompare(pack, "reversed", XmirReversed::new); + } + + /** + * Parse EO from given pack, converts XMIR to EO and compare with result EO. + * @param pack Yaml pack + * @param key Key to get result EO from pack + * @param xmir Xmir constructor + */ + private void parseAndCompare( + final String pack, + final String key, + final Function xmir + ) throws IOException { + final Map map = new Yaml().load(pack); + final String original = (String) map.get("origin"); + Logger.debug(this, "Original EOLANG:%n%s", original); + final XML first = new EoSyntax("test", new InputOf(original)).parsed(); + MatcherAssert.assertThat( + "Original EO should be parsed without errors", + first, + Matchers.not(XhtmlMatchers.hasXPath("//errors/error")) + ); + Logger.debug(this, "First:%n%s", first); + final String eolang = xmir.apply(first).toEO(); + Logger.debug(this, "EOLANG:%n%s", eolang); + MatcherAssert.assertThat( + "Result EO should be parsed without errors", + new EoSyntax("test", new InputOf(eolang)).parsed(), + Matchers.not(XhtmlMatchers.hasXPath("//errors/error")) + ); + MatcherAssert.assertThat( + String.format( + "Result EO should be equal to original EO in %s notation", + key + ), + map.get(key), + Matchers.equalTo(eolang) + ); + } +} diff --git a/eo-parser/src/test/java/org/eolang/parser/xmir/package-info.java b/eo-parser/src/test/java/org/eolang/parser/xmir/package-info.java new file mode 100644 index 0000000000..ec389a6c0d --- /dev/null +++ b/eo-parser/src/test/java/org/eolang/parser/xmir/package-info.java @@ -0,0 +1,34 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2023 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. + */ + +/** + * EO parser. + * + * @author Yegor Bugayenko (yegor256@gmail.com) + * @version $Id$ + * @since 0.1 + * @see Project site www.eolang.org + * @see GitHub project + */ +package org.eolang.parser.xmir; diff --git a/eo-parser/src/test/resources/log4j.properties b/eo-parser/src/test/resources/log4j.properties index ed8c3259a1..9d0927ec14 100644 --- a/eo-parser/src/test/resources/log4j.properties +++ b/eo-parser/src/test/resources/log4j.properties @@ -6,4 +6,4 @@ log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss} [%color{%p}] %c: %m log4j.logger.com.jcabi.log=WARN log4j.logger.org.eolang=INFO -log4j.logger.org.eolang.parser.XMIRTest=INFO +log4j.logger.org.eolang.parser.xmir.XmirTest=INFO diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples-wrong/empty-bytes.eo b/eo-parser/src/test/resources/org/eolang/parser/xmir-samples-wrong/empty-bytes.eo deleted file mode 100644 index fb1dd8d6b5..0000000000 --- a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples-wrong/empty-bytes.eo +++ /dev/null @@ -1 +0,0 @@ --- > empty diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/bytes.eo b/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/bytes.eo deleted file mode 100644 index 0390ce06e8..0000000000 --- a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/bytes.eo +++ /dev/null @@ -1,9 +0,0 @@ -EA-EA-EA-EA > xs - -""" -hello -""" > ys - -TRUE > b1 - -FALSE > b2 \ No newline at end of file diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/dataless.eo b/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/dataless.eo deleted file mode 100644 index 9e23e0a617..0000000000 --- a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/dataless.eo +++ /dev/null @@ -1,10 +0,0 @@ -+package sandbox - -[args] > main - QQ.io.stdout > @ - args.at - args.length.neg - nan.plus negative-infinity > not-a-number - text-of - input-of - args.at not-a-number diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/empty-string.eo b/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/empty-string.eo deleted file mode 100644 index 1c5d604fb9..0000000000 --- a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/empty-string.eo +++ /dev/null @@ -1,3 +0,0 @@ -[] > app - QQ.io.stdout > @ - QQ.txt.sprintf "" diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/idiomatic.eo b/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/idiomatic.eo deleted file mode 100644 index edbc24214a..0000000000 --- a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/idiomatic.eo +++ /dev/null @@ -1,27 +0,0 @@ -# This is the license part -# of the program - -+meta1 -+meta2 short -+meta2 long tail - -3.1415 > pi - -[x x2 x3...] > idiomatic - 5 > iTest_me - [] > rr /int - if. > @ - plus. - this - minus. - n:hello - "家" - 4.55 > x! - * - "Hello, друг" - 2.18 - TRUE - bar - plus. - n - "hello, 大家!" diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/inheritance.eo b/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/inheritance.eo deleted file mode 100644 index 18d5262f35..0000000000 --- a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/inheritance.eo +++ /dev/null @@ -1,20 +0,0 @@ -+package sandbox -+alias stdout org.eolang.io.stdout -+alias sprintf org.eolang.txt.sprintf -+architect yegor256@gmail.com - -[] > base - memory 0 > x - [self v] > f - x.write > @ - v - [self v] > g - self.f > @ - self - v -[] > derived - base > @ - [self v] > f - self.g > @ - self - v diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/just-float.eo b/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/just-float.eo deleted file mode 100644 index 9d1b9c6913..0000000000 --- a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/just-float.eo +++ /dev/null @@ -1,3 +0,0 @@ -3.14 > pi -[] > foo - 2.18 > e diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/times.eo b/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/times.eo deleted file mode 100644 index a16d6d5d93..0000000000 --- a/eo-parser/src/test/resources/org/eolang/parser/xmir-samples/times.eo +++ /dev/null @@ -1,4 +0,0 @@ -[] > app - QQ.io.stdout > @ - QQ.txt.sprintf "result is %d\n" - -1.times 228 diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/bytes.yaml b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/bytes.yaml new file mode 100644 index 0000000000..5a58108b4c --- /dev/null +++ b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/bytes.yaml @@ -0,0 +1,32 @@ +origin: | + EA-EA-EA-EA > xs + + """ + hello + """ > ys + + TRUE > b1 + + FALSE > b2 + +strait: | + EA-EA-EA-EA > xs + + """ + hello + """ > ys + + TRUE > b1 + + FALSE > b2 + +reversed: | + EA-EA-EA-EA > xs + + """ + hello + """ > ys + + TRUE > b1 + + FALSE > b2 diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/dataless.yaml b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/dataless.yaml new file mode 100644 index 0000000000..f17a4a0efb --- /dev/null +++ b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/dataless.yaml @@ -0,0 +1,53 @@ +origin: | + +package sandbox + + [args] > main + QQ.io.stdout > @ + args.at + args.length.neg + nan.plus negative-infinity > not-a-number + text-of + input-of + args.at not-a-number + +strait: | + +package sandbox + + [args] > main + QQ + .io + stdout > @ + args + .at + args + .length + .neg + nan + .plus > not-a-number + negative-infinity + text-of + input-of + args + .at + not-a-number + +reversed: | + +package sandbox + + [args] > main + stdout. > @ + io. + QQ + at. + args + neg. + length. + args + plus. > not-a-number + nan + negative-infinity + text-of + input-of + at. + args + not-a-number diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/empty-bytes.yaml b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/empty-bytes.yaml new file mode 100644 index 0000000000..b65828c795 --- /dev/null +++ b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/empty-bytes.yaml @@ -0,0 +1,8 @@ +origin: | + -- > empty + +strait: | + -- > empty + +reversed: | + -- > empty diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/empty-string.yaml b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/empty-string.yaml new file mode 100644 index 0000000000..8fcc59b094 --- /dev/null +++ b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/empty-string.yaml @@ -0,0 +1,26 @@ +origin: | + [] > app + QQ.io.stdout > @ + QQ.txt.sprintf "" + +strait: | + [] > app + QQ + .io + .stdout > @ + QQ + .txt + .sprintf + """ + """ + +reversed: | + [] > app + stdout. > @ + io. + QQ + sprintf. + txt. + QQ + """ + """ diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/idiomatic.yaml b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/idiomatic.yaml new file mode 100644 index 0000000000..2f31eddaf3 --- /dev/null +++ b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/idiomatic.yaml @@ -0,0 +1,96 @@ +origin: | + # This is the license part + # of the program + + +meta1 + +meta2 short + +meta2 long tail + + 3.1415 > pi + + [x x2 x3] > idiomatic + 5 > iTest_me + [] > rr /int + if. > @ + plus. + this + minus. + n + "家" + 4.55 > x! + * + "Hello, друг" + 2.18 + TRUE + bar + plus. + n + "hello, 大家!" + +strait: | + # This is the license part + # of the program + + +meta1 + +meta2 short + +meta2 long tail + + 3.1415 > pi + + [x x2 x3] > idiomatic + 5 > iTest_me + [] > rr /int + this + n + .minus + """ + \u5BB6 + """ + 4.55 > x! + * + "Hello, \u0434\u0440\u0443\u0433" + 2.18 + TRUE + .plus + bar + n + .plus + """ + hello, \u5927\u5BB6! + """" + .if > @ + +reversed: | + # This is the license part + # of the program + + +meta1 + +meta2 short + +meta2 long tail + + 3.1415 > pi + + [x x2 x3] > idiomatic + 5 > iTest_me + [] > rr /int + if. > @ + plus. + this + minus. + n + """ + \u5BB6 + """ + 4.55 > x! + * + """ + Hello, \u0434\u0440\u0443\u0433 + """ + 2.18 + TRUE + bar + plus. + n + """ + hello, \u5927\u5BB6! + """ diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/inheritance.yaml b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/inheritance.yaml new file mode 100644 index 0000000000..f5438b7c64 --- /dev/null +++ b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/inheritance.yaml @@ -0,0 +1,73 @@ +origin: | + +package sandbox + +alias stdout org.eolang.io.stdout + +alias sprintf org.eolang.txt.sprintf + +architect yegor256@gmail.com + + [] > base + memory 0 > x + [self v] > f + x.write > @ + v + [self v] > g + self.f > @ + self + v + [] > derived + base > @ + [self v] > f + self.g > @ + self + v + +strait: | + +package sandbox + +alias stdout org.eolang.io.stdout + +alias sprintf org.eolang.txt.sprintf + +architect yegor256@gmail.com + + [] > base + memory 0 > x + [self v] > f + x + .write > @ + v + [self v] > g + self + .f > @ + self + v + [] > derived + base > @ + [self v] > f + self + .g > @ + self + v + +reversed: | + +package sandbox + +alias stdout org.eolang.io.stdout + +alias sprintf org.eolang.txt.sprintf + +architect yegor256@gmail.com + + [] > base + memory > x + 0 + [self v] > f + write. > @ + x + v + [self v] > g + f. > @ + self + self + v + + [] > derived + base > @ + [self v] > f + g. > @ + self + self + v diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/just-float.yaml b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/just-float.yaml new file mode 100644 index 0000000000..81412db4bb --- /dev/null +++ b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/just-float.yaml @@ -0,0 +1,15 @@ +origin: | + 3.14 > pi + [] > foo + 2.18 > e + +strait: | + 3.14 > pi + [] > foo + 2.18 > e + +reversed: | + 3.14 > pi + + [] > foo + 2.18 > e diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/stars-tuples.yaml b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/stars-tuples.yaml new file mode 100644 index 0000000000..e04e13cf4a --- /dev/null +++ b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/stars-tuples.yaml @@ -0,0 +1,18 @@ +origin: | + * 1 "Hello" x > array + +strait: | + * > array + 1 + """ + Hello + """ + x + +reversed: | + * > array + 1 + """ + Hello + """ + x diff --git a/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/times.yaml b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/times.yaml new file mode 100644 index 0000000000..31af6075ed --- /dev/null +++ b/eo-parser/src/test/resources/org/eolang/parser/xmir/samples/times.yaml @@ -0,0 +1,36 @@ +origin: | + [] > app + QQ.io.stdout > @ + QQ.txt.sprintf + "result is %d\n" + -1.times 228 + +strait: | + [] > app + QQ + .io + .stdout > @ + QQ + .txt + .sprintf + """ + result is %d\n + """ + -1 + .times + 228 + +reversed: | + [] > app + stdout. > @ + io. + QQ + sprintf. + txt. + QQ + """ + result is %d\n + """ + times. + -1 + 228