diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/PhiMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/PhiMojo.java index 2bcd2c4b22..8cd137166f 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/PhiMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/PhiMojo.java @@ -46,7 +46,6 @@ import org.cactoos.text.TextOf; import org.eolang.maven.footprint.Saved; import org.eolang.maven.util.Walk; -import org.eolang.parser.Schema; import org.eolang.parser.StUnhex; import org.eolang.parser.TrParsing; @@ -156,7 +155,6 @@ private int translate(final Path xmir, final Xsline xsline, final int position, position, total, xmir, xmir.toFile().length() ); final XML xml = new XMLDocument(new TextOf(xmir).asString()); - new Schema(xml).check(); final Path relative = Paths.get( this.phiInputDir.toPath().relativize(xmir).toString().replace( String.format(".%s", AssembleMojo.XMIR), 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 839131c4f9..dc44d6c33c 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 @@ -40,10 +40,7 @@ import org.eolang.maven.util.HmBase; import org.eolang.maven.util.Home; import org.eolang.maven.util.Walk; -import org.eolang.parser.Schema; -import org.eolang.parser.xmir.Xmir; -import org.eolang.parser.xmir.XmirReversed; -import org.eolang.parser.xmir.XmirSwap; +import org.eolang.parser.Xmir; /** * Print XMIR to EO. @@ -101,15 +98,13 @@ void exec() throws IOException { .replace(".xmir", ".eo") ); 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 - ); + final String program; + if (this.printReversed) { + program = new Xmir(xml).toReversed(); + } else { + program = new Xmir(xml).toEO(); + } + home.save(program, relative); Logger.info( this, "Printed: %[file]s (%[size]s) => %[file]s (%[size]s)", diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptTrain.java b/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptTrain.java index 0ef625563e..91493c413c 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptTrain.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptTrain.java @@ -54,7 +54,6 @@ public final class OptTrain implements Optimization { static final Train DEFAULT_TRAIN = new TrFast( new TrLambda( new TrClasspath<>( - new TrDefault<>(), "/org/eolang/parser/optimize/globals-to-abstracts.xsl", "/org/eolang/parser/optimize/remove-refs.xsl", "/org/eolang/parser/optimize/abstracts-float-up.xsl", @@ -62,7 +61,8 @@ public final class OptTrain implements Optimization { "/org/eolang/parser/add-refs.xsl", "/org/eolang/parser/optimize/fix-missed-names.xsl", "/org/eolang/parser/add-refs.xsl", - "/org/eolang/parser/set-locators.xsl" + "/org/eolang/parser/set-locators.xsl", + "/org/eolang/parser/blank-xsd-schema.xsl" ).back(), StEoLogged::new ), diff --git a/eo-maven-plugin/src/main/resources/log4j.properties b/eo-maven-plugin/src/main/resources/log4j.properties index 9703a96e4b..e5bf95aa94 100644 --- a/eo-maven-plugin/src/main/resources/log4j.properties +++ b/eo-maven-plugin/src/main/resources/log4j.properties @@ -30,5 +30,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.xmir.XmirTest=INFO +log4j.logger.org.eolang.parser.XmirTest=INFO log4j.logger.org.eolang.maven.SodgMojo=TRACE diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/ShakeMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/ShakeMojoTest.java index 93a08707c3..e0849773cc 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/ShakeMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/ShakeMojoTest.java @@ -71,14 +71,14 @@ void shakesSuccessfully(@Mktmp final Path temp) throws IOException { .execute(new FakeMaven.Shake()) .result(); MatcherAssert.assertThat( - "After successful operation of the ShakeMojo, a xml should appear.", + "After successful operation of the ShakeMojo, an XML should appear", res, Matchers.hasKey( String.format("target/%s/foo/x/main/01-remove-refs.xml", ShakeMojo.STEPS) ) ); MatcherAssert.assertThat( - "After successful operation of the ShakeMojo, a xmir should appear.", + "After successful operation of the ShakeMojo, an XMIR should appear", res, Matchers.hasKey( String.format(this.key, ShakeMojo.DIR, AssembleMojo.XMIR) diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/SodgMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/SodgMojoTest.java index f7c34934bb..21e89241b8 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/SodgMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/SodgMojoTest.java @@ -33,6 +33,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Collection; import java.util.LinkedList; import java.util.List; @@ -69,6 +70,11 @@ void convertsSimpleObjectToGraph(@Mktmp final Path temp) throws Exception { new Farea(temp).together( f -> { f.clean(); + f.files().file("XMIR.xsd").save( + Paths.get(System.getProperty("user.dir")).resolve( + "../eo-parser/src/main/resources/XMIR.xsd" + ) + ); f.files().file("src/main/eo/foo.eo").write( "# This unit test is supposed to check the functionality of the corresponding object.\n[] > foo\n".getBytes() ); diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/as-type-optimization.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/as-type-optimization.yaml index 61de511df0..7b0cab0067 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/as-type-optimization.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/as-type-optimization.yaml @@ -31,6 +31,7 @@ xsls: - /org/eolang/parser/add-refs.xsl - /org/eolang/parser/add-default-package.xsl - /org/eolang/parser/optimize/constant-folding.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - //o[@base='org.eolang.bool' and o[@base='org.eolang.bytes' and text()='01-']] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/bindings-to-java.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/bindings-to-java.yaml index ae5e91b42a..526a75ecff 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/bindings-to-java.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/bindings-to-java.yaml @@ -26,6 +26,7 @@ xsls: - /org/eolang/maven/pre/attrs.xsl - /org/eolang/maven/pre/data.xsl - /org/eolang/maven/pre/to-java.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - //java/text()[contains(., 'new PhWith(ret, 0')] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/converts-to-java-with-arrays-and-scopes.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/converts-to-java-with-arrays-and-scopes.yaml index f262acef89..2672e7fcfe 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/converts-to-java-with-arrays-and-scopes.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/converts-to-java-with-arrays-and-scopes.yaml @@ -48,6 +48,7 @@ xsls: - /org/eolang/maven/pre/attrs.xsl - /org/eolang/maven/pre/data.xsl - /org/eolang/maven/pre/to-java.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] eo: | diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/data-as-bytes.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/data-as-bytes.yaml index 27f1ce1e2c..c9b67d5dfc 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/data-as-bytes.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/data-as-bytes.yaml @@ -27,6 +27,7 @@ xsls: - /org/eolang/maven/pre/attrs.xsl - /org/eolang/maven/pre/data.xsl - /org/eolang/maven/pre/to-java.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - //java[contains(text(), '.take("org").take("eolang").take("true")')] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/embedded-class.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/embedded-class.yaml index d987f919d4..979e0b13e4 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/embedded-class.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/embedded-class.yaml @@ -33,6 +33,7 @@ xsls: - /org/eolang/maven/pre/attrs.xsl - /org/eolang/maven/pre/data.xsl - /org/eolang/maven/pre/to-java.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - //java[contains(text(), 'PhMethod(new PhMethod(rho, "ρ"), "ρ")')] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/locators-to-java.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/locators-to-java.yaml index 4e53f02d96..b42784b1d9 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/locators-to-java.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/locators-to-java.yaml @@ -29,6 +29,7 @@ xsls: - /org/eolang/maven/pre/attrs.xsl - /org/eolang/maven/pre/data.xsl - /org/eolang/maven/pre/to-java.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - //java[contains(text(), 'new PhLocated(ret, 3, 2, "Φ.foo.φ")')] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/long-class-name.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/long-class-name.yaml index a8bb04cecf..7b7bd159f0 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/long-class-name.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/long-class-name.yaml @@ -27,6 +27,7 @@ xsls: - /org/eolang/maven/pre/attrs.xsl - /org/eolang/maven/pre/data.xsl - /org/eolang/maven/pre/to-java.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - //java[contains(text(), 'public final class EOtest$EOblah0$EOblah1$EO89_58 extends PhDefault')] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/set-package.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/set-package.yaml index 31a1f16d24..9f49cb0f05 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/set-package.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/set-package.yaml @@ -23,6 +23,7 @@ xsls: - /org/eolang/maven/pre/classes.xsl - /org/eolang/maven/pre/package.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - //class[@name='bar' and @package='foo.long-name'] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/synthetic-attributes-with-to-java.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/synthetic-attributes-with-to-java.yaml index 5cb781ac6a..8a66e1f444 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/synthetic-attributes-with-to-java.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/synthetic-attributes-with-to-java.yaml @@ -48,6 +48,7 @@ xsls: - /org/eolang/maven/pre/attrs.xsl - /org/eolang/maven/pre/data.xsl - /org/eolang/maven/pre/to-java.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] eo: | diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/test-object-to-java.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/test-object-to-java.yaml index 2f7f9dbdd5..c308548107 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/test-object-to-java.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/test-object-to-java.yaml @@ -26,6 +26,7 @@ xsls: - /org/eolang/maven/pre/attrs.xsl - /org/eolang/maven/pre/data.xsl - /org/eolang/maven/pre/to-java.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - //java[contains(text(), ' @Test')] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tests-moving-inside.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tests-moving-inside.yaml index fbd2207bef..b45654a72c 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tests-moving-inside.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tests-moving-inside.yaml @@ -28,6 +28,7 @@ xsls: - /org/eolang/maven/pre/align-test-classes.xsl - /org/eolang/maven/pre/remove-high-level-inner-classes.xsl - /org/eolang/maven/pre/rename-tests-inners.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - /program/objects[count(class)=1] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tests-test.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tests-test.yaml index e86ee0b64c..fc9fedbf7d 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tests-test.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tests-test.yaml @@ -33,6 +33,7 @@ xsls: - /org/eolang/maven/pre/attrs.xsl - /org/eolang/maven/pre/data.xsl - /org/eolang/maven/pre/to-java.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - //java[contains(text(), '@Test')] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tuple-to-java.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tuple-to-java.yaml index ab34ee9a77..de9184d1c6 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tuple-to-java.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/tuple-to-java.yaml @@ -30,6 +30,7 @@ xsls: - /org/eolang/maven/pre/attrs.xsl - /org/eolang/maven/pre/data.xsl - /org/eolang/maven/pre/to-java.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - //java[contains(text(), 'Phi ret = Phi.Φ.take("org").take("eolang").take("tuple");')] diff --git a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/underscore-to-java.yaml b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/underscore-to-java.yaml index 6ff9e62e63..c21d367ec2 100644 --- a/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/underscore-to-java.yaml +++ b/eo-maven-plugin/src/test/resources/org/eolang/maven/packs/underscore-to-java.yaml @@ -26,6 +26,7 @@ xsls: - /org/eolang/maven/pre/attrs.xsl - /org/eolang/maven/pre/data.xsl - /org/eolang/maven/pre/to-java.xsl + - /org/eolang/parser/blank-xsd-schema.xsl tests: - /program[not(errors)] - //java[contains(text(), 'public final class EOfoo__underscore extends PhDefault')] diff --git a/eo-parser/src/main/java/org/eolang/parser/BytesToHex.java b/eo-parser/src/main/java/org/eolang/parser/BytesToHex.java index 1a12e78d86..49a1645a31 100644 --- a/eo-parser/src/main/java/org/eolang/parser/BytesToHex.java +++ b/eo-parser/src/main/java/org/eolang/parser/BytesToHex.java @@ -32,7 +32,7 @@ * * @since 0.44 */ -public final class BytesToHex implements Supplier { +final class BytesToHex implements Supplier { /** * The bytes. @@ -43,7 +43,7 @@ public final class BytesToHex implements Supplier { * Ctor. * @param bts Bytes */ - public BytesToHex(final byte[] bts) { + BytesToHex(final byte[] bts) { this.bytes = Arrays.copyOf(bts, bts.length); } diff --git a/eo-parser/src/main/java/org/eolang/parser/CheckPack.java b/eo-parser/src/main/java/org/eolang/parser/CheckPack.java index 2640411e73..03dc7775b8 100644 --- a/eo-parser/src/main/java/org/eolang/parser/CheckPack.java +++ b/eo-parser/src/main/java/org/eolang/parser/CheckPack.java @@ -24,6 +24,7 @@ package org.eolang.parser; import com.jcabi.log.Logger; +import com.jcabi.xml.StrictXML; import com.jcabi.xml.XML; import com.yegor256.xsline.Shift; import com.yegor256.xsline.StClasspath; @@ -78,11 +79,15 @@ public Collection failures() throws IOException { train = train.with(new StClasspath(xsl)); } } - final XML out = new Xsline(train).pass( - new EoSyntax( - "scenario", - new InputOf(String.format("%s\n", src)) - ).parsed() + final XML out = new StrictXML( + new Xsline(train).pass( + new StrictXML( + new EoSyntax( + "scenario", + new InputOf(String.format("%s\n", src)) + ).parsed() + ) + ) ); Logger.debug(this, "Output XML:\n%s", out); final Collection failures = new LinkedList<>(); diff --git a/eo-parser/src/main/java/org/eolang/parser/SourceText.java b/eo-parser/src/main/java/org/eolang/parser/DrListing.java similarity index 78% rename from eo-parser/src/main/java/org/eolang/parser/SourceText.java rename to eo-parser/src/main/java/org/eolang/parser/DrListing.java index 03bfe9bf03..fa7eb6ae38 100644 --- a/eo-parser/src/main/java/org/eolang/parser/SourceText.java +++ b/eo-parser/src/main/java/org/eolang/parser/DrListing.java @@ -23,14 +23,19 @@ */ package org.eolang.parser; +import java.util.Iterator; import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.misc.Interval; +import org.xembly.Directive; +import org.xembly.Directives; /** * Source text of parser context. + * * @since 0.34.0 */ -public final class SourceText { +final class DrListing implements Iterable { + /** * Context. */ @@ -40,17 +45,22 @@ public final class SourceText { * Ctor. * @param ctx Context */ - public SourceText(final ParserRuleContext ctx) { + DrListing(final ParserRuleContext ctx) { this.context = ctx; } @Override - public String toString() { - return this.context.getStart().getInputStream().getText( + public Iterator iterator() { + final String text = this.context.getStart().getInputStream().getText( new Interval( this.context.getStart().getStartIndex(), this.context.getStop().getStopIndex() ) ); + return new Directives() + .xpath("/program") + .strict(1).add("listing") + .set(text) + .iterator(); } } diff --git a/eo-parser/src/main/java/org/eolang/parser/DrProgram.java b/eo-parser/src/main/java/org/eolang/parser/DrProgram.java new file mode 100644 index 0000000000..72e44b2a61 --- /dev/null +++ b/eo-parser/src/main/java/org/eolang/parser/DrProgram.java @@ -0,0 +1,129 @@ +/* + * 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. + */ +package org.eolang.parser; + +import com.jcabi.manifests.Manifests; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Iterator; +import org.xembly.Directive; +import org.xembly.Directives; + +/** + * The {@code program} element in XML as Xembly {@link Directives}. + * + * @since 0.44.0 + */ +final class DrProgram implements Iterable { + + /** + * Name of the program. + */ + private final String name; + + /** + * Ctor. + * @param nme Name of the program + */ + DrProgram(final String nme) { + this.name = nme; + } + + @Override + public Iterator iterator() { + final String when = ZonedDateTime.now(ZoneOffset.UTC).format( + DateTimeFormatter.ISO_INSTANT + ); + return new Directives() + .comment( + String.join( + "\n ", + "", + "This is XMIR, a dialect of XML, which is used to represent a parsed", + "EO program. For more information about the XMIR format, please visit", + "https://news.eolang.org/2022-11-25-xmir-guide.html.", + "", + String.format( + "The file was auto-generated by the parser %s (%s) at %s.", + Manifests.read("EO-Version"), + Manifests.read("EO-Revision"), + when + ), + "Do not edit it manually. The source code of the parser is available", + "on GitHub, at https://github.com/objectionary/eo (bug reports are welcome).", + "" + ) + ) + .add("program") + .attr( + "noNamespaceSchemaLocation xsi http://www.w3.org/2001/XMLSchema-instance", + DrProgram.schema() + ) + .attr("name", this.name) + .attr("version", Manifests.read("EO-Version")) + .attr("revision", Manifests.read("EO-Revision")) + .attr("dob", Manifests.read("EO-Dob")) + .attr("time", when) + .iterator(); + } + + /** + * Find the location of XSD schema. + * + *

In production, the XSD is located online at the eolang.org + * website, were we deploy it on every release cycle (see the {@code .rultor.yml} + * file. However, during testing cycle, we must use the local file, + * allowing its most recent changes to be visible to the code. However, + * we don't know exactly where from the tests are being executed + * (what is the current directory). Because of this, we try to find the + * file using a number of options.

+ * + * @return The location of the XSD schema file/URL + */ + private static String schema() { + String schema = String.format( + "https://www.eolang.org/xsd/XMIR-%s.xsd", + Manifests.read("EO-Version") + ); + final String[] opts = { + "XMIR.xsd", + "src/main/resources/XMIR.xsd", + "../eo-parser/src/main/resources/XMIR.xsd", + }; + for (final String opt : opts) { + final Path path = Paths.get(opt).toAbsolutePath(); + if (path.toFile().exists()) { + schema = String.format( + "file:///%s", + path.toString().replace("\\", "/") + ); + break; + } + } + return schema; + } +} diff --git a/eo-parser/src/main/java/org/eolang/parser/EoIndentLexer.java b/eo-parser/src/main/java/org/eolang/parser/EoIndentLexer.java index 784db021cf..d0e2743700 100644 --- a/eo-parser/src/main/java/org/eolang/parser/EoIndentLexer.java +++ b/eo-parser/src/main/java/org/eolang/parser/EoIndentLexer.java @@ -40,7 +40,7 @@ * * @since 1.0 */ -public final class EoIndentLexer extends EoLexer { +final class EoIndentLexer extends EoLexer { /** * Generated tokes. */ @@ -61,7 +61,7 @@ public final class EoIndentLexer extends EoLexer { * @param txt Source code. * @throws IOException If fails. */ - public EoIndentLexer(final Text txt) throws IOException { + EoIndentLexer(final Text txt) throws IOException { this(CharStreams.fromStream(new InputStreamOf(txt))); } diff --git a/eo-parser/src/main/java/org/eolang/parser/EoSyntax.java b/eo-parser/src/main/java/org/eolang/parser/EoSyntax.java index 1b51b4ecde..ba1212d233 100644 --- a/eo-parser/src/main/java/org/eolang/parser/EoSyntax.java +++ b/eo-parser/src/main/java/org/eolang/parser/EoSyntax.java @@ -111,7 +111,6 @@ public XML parsed() throws IOException { new Directives(xel).append(spy) ).domQuietly() ); - new Schema(dom).check(); if (spy.size() == 0) { Logger.debug( this, diff --git a/eo-parser/src/main/java/org/eolang/parser/ParsingErrors.java b/eo-parser/src/main/java/org/eolang/parser/ParsingErrors.java index 7a0db365b9..00d7c2d4d7 100644 --- a/eo-parser/src/main/java/org/eolang/parser/ParsingErrors.java +++ b/eo-parser/src/main/java/org/eolang/parser/ParsingErrors.java @@ -42,6 +42,7 @@ */ final class ParsingErrors extends BaseErrorListener implements ANTLRErrorListener, Iterable { + /** * Errors accumulated. */ @@ -103,6 +104,7 @@ public Iterator iterator() { .addIf("errors") .strict(1) .add("error") + .attr("check", "eo-parser") .attr("line", error.line()) .attr("severity", "critical") .set(error.getMessage()), diff --git a/eo-parser/src/main/java/org/eolang/parser/PhiSyntax.java b/eo-parser/src/main/java/org/eolang/parser/PhiSyntax.java index c62b372bac..2c8203cf10 100644 --- a/eo-parser/src/main/java/org/eolang/parser/PhiSyntax.java +++ b/eo-parser/src/main/java/org/eolang/parser/PhiSyntax.java @@ -101,7 +101,6 @@ public XML parsed() throws IOException { new Directives(xel).append(spy).append(this.extra) ).domQuietly() ); - new Schema(dom).check(); if (spy.size() == 0) { Logger.debug(this, "Input of PHI calculus compiled, no errors"); } else { diff --git a/eo-parser/src/main/java/org/eolang/parser/Schema.java b/eo-parser/src/main/java/org/eolang/parser/Schema.java deleted file mode 100644 index c68ad60593..0000000000 --- a/eo-parser/src/main/java/org/eolang/parser/Schema.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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. - */ -package org.eolang.parser; - -import com.jcabi.log.Logger; -import com.jcabi.xml.XML; -import com.jcabi.xml.XSDDocument; -import java.util.Collection; -import javax.xml.transform.dom.DOMSource; -import org.cactoos.io.ResourceOf; -import org.cactoos.text.TextOf; -import org.cactoos.text.UncheckedText; -import org.xml.sax.SAXParseException; - -/** - * The schema for XMIR. - * - * @since 0.6 - */ -public final class Schema { - - /** - * The XML. - */ - private final XML xmir; - - /** - * Ctor. - * @param xml The XMIR - */ - public Schema(final XML xml) { - this.xmir = xml; - } - - /** - * Check and crash if mistakes. - */ - public void check() { - final Collection violations = new XSDDocument( - new UncheckedText( - new TextOf(new ResourceOf("XMIR.xsd")) - ).asString() - ).validate(new DOMSource(this.xmir.node())); - if (!violations.isEmpty()) { - Logger.error(this, "XML with XSD failures:%n%s", this.xmir); - for (final SAXParseException violation : violations) { - Logger.error( - this, "XSD failure at #%d:%d %s", - violation.getLineNumber(), - violation.getColumnNumber(), - violation.getLocalizedMessage() - ); - } - throw new IllegalStateException( - String.format( - "There are %d XSD violation(s), see the log", - violations.size() - ) - ); - } - } - -} diff --git a/eo-parser/src/main/java/org/eolang/parser/StEoLogged.java b/eo-parser/src/main/java/org/eolang/parser/StEoLogged.java index f1e42aa30d..fd9c3ed38f 100644 --- a/eo-parser/src/main/java/org/eolang/parser/StEoLogged.java +++ b/eo-parser/src/main/java/org/eolang/parser/StEoLogged.java @@ -27,7 +27,6 @@ import com.jcabi.xml.XML; import com.yegor256.xsline.Shift; import java.util.function.Consumer; -import org.eolang.parser.xmir.Xmir; /** * Shift that logs the EO representation of the XML before throwing an exception. @@ -78,8 +77,8 @@ public XML apply(final int position, final XML xml) { } catch (final RuntimeException ex) { this.logger.accept( String.format( - "Eo representation of the parsed xml: %n%s", - new Xmir.Default(xml).toEO() + "EO representation of the parsed XML: %n%s", + new Xmir(xml).toEO() ) ); throw new IllegalStateException( diff --git a/eo-parser/src/main/java/org/eolang/parser/TrParsing.java b/eo-parser/src/main/java/org/eolang/parser/TrParsing.java index 215c1aa470..6231d5b392 100644 --- a/eo-parser/src/main/java/org/eolang/parser/TrParsing.java +++ b/eo-parser/src/main/java/org/eolang/parser/TrParsing.java @@ -84,7 +84,8 @@ public TrParsing() { "/org/eolang/parser/add-default-package.xsl", "/org/eolang/parser/explicit-data.xsl", "/org/eolang/parser/const-to-dataized.xsl", - "/org/eolang/parser/set-locators.xsl" + "/org/eolang/parser/set-locators.xsl", + "/org/eolang/parser/clean-up.xsl" ).back() ), TrParsing.class, diff --git a/eo-parser/src/main/java/org/eolang/parser/XeEoListener.java b/eo-parser/src/main/java/org/eolang/parser/XeEoListener.java index d13c10bf27..a18a6e8209 100644 --- a/eo-parser/src/main/java/org/eolang/parser/XeEoListener.java +++ b/eo-parser/src/main/java/org/eolang/parser/XeEoListener.java @@ -23,12 +23,8 @@ */ package org.eolang.parser; -import com.jcabi.manifests.Manifests; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; import java.util.Iterator; import java.util.List; import java.util.function.Supplier; @@ -40,7 +36,6 @@ import org.apache.commons.text.StringEscapeUtils; import org.cactoos.iterable.Mapped; import org.cactoos.text.Joined; -import org.eolang.parser.xmir.XmirInfo; import org.xembly.Directive; import org.xembly.Directives; @@ -64,11 +59,6 @@ "PMD.GodClass" }) public final class XeEoListener implements EoListener, Iterable { - /** - * Info about xmir. - */ - private static final XmirInfo INFO = new XmirInfo(); - /** * Meta for testing. */ @@ -114,19 +104,9 @@ public XeEoListener(final String name) { @Override public void enterProgram(final EoParser.ProgramContext ctx) { this.dirs - .comment(XeEoListener.INFO) - .add("program") - .attr("name", this.name) - .attr("version", Manifests.read("EO-Version")) - .attr("revision", Manifests.read("EO-Revision")) - .attr("dob", Manifests.read("EO-Dob")) - .attr( - "time", - ZonedDateTime.now(ZoneOffset.UTC).format( - DateTimeFormatter.ISO_INSTANT - ) - ) - .add("listing").set(new SourceText(ctx)).up(); + .append(new DrProgram(this.name)) + .append(new DrListing(ctx)) + .xpath("/program").strict(1); } @Override 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 f4ce6de734..73bbfb5635 100644 --- a/eo-parser/src/main/java/org/eolang/parser/XePhiListener.java +++ b/eo-parser/src/main/java/org/eolang/parser/XePhiListener.java @@ -23,12 +23,8 @@ */ package org.eolang.parser; -import com.jcabi.manifests.Manifests; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; import java.util.ArrayDeque; import java.util.Collection; import java.util.Deque; @@ -40,7 +36,6 @@ import org.antlr.v4.runtime.tree.TerminalNode; import org.apache.commons.text.StringEscapeUtils; import org.cactoos.list.ListOf; -import org.eolang.parser.xmir.XmirInfo; import org.xembly.Directive; import org.xembly.Directives; @@ -61,11 +56,6 @@ "PMD.GodClass" }) public final class XePhiListener implements PhiListener, Iterable { - /** - * Info about xmir. - */ - private static final XmirInfo INFO = new XmirInfo(); - /** * Package lambda. */ @@ -124,17 +114,9 @@ public XePhiListener(final String nme) { public void enterProgram(final PhiParser.ProgramContext ctx) { this.objs.add(new Objects.ObjXembly()); this.dirs - .comment(XePhiListener.INFO) - .add("program") - .attr("name", this.name) - .attr("version", Manifests.read("EO-Version")) - .attr("revision", Manifests.read("EO-Revision")) - .attr("dob", Manifests.read("EO-Dob")) - .attr( - "time", - ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT) - ) - .add("listing").set(new SourceText(ctx)).up(); + .append(new DrProgram(this.name)) + .append(new DrListing(ctx)) + .xpath("/program").strict(1); if (ctx.object() == null || ctx.object().formation() == null) { this.objects().start(); } diff --git a/eo-parser/src/main/java/org/eolang/parser/xmir/Xmir.java b/eo-parser/src/main/java/org/eolang/parser/Xmir.java similarity index 55% rename from eo-parser/src/main/java/org/eolang/parser/xmir/Xmir.java rename to eo-parser/src/main/java/org/eolang/parser/Xmir.java index 93b9898d95..c4fae225dd 100644 --- a/eo-parser/src/main/java/org/eolang/parser/xmir/Xmir.java +++ b/eo-parser/src/main/java/org/eolang/parser/Xmir.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package org.eolang.parser.xmir; +package org.eolang.parser; import com.jcabi.log.Logger; import com.jcabi.xml.XML; @@ -31,39 +31,33 @@ import com.yegor256.xsline.StLambda; import com.yegor256.xsline.TrDefault; import com.yegor256.xsline.TrLambda; +import com.yegor256.xsline.TrLogged; import com.yegor256.xsline.Train; import com.yegor256.xsline.Xsline; -import org.eolang.parser.StUnhex; /** * Prints XMIR to EO. + * + *

Default Xmir that prints EO with straight vertical methods.

+ * + *

This class will help you turn XMIR (XML document) into EOLANG + * plain text source code. It's as simple as this:

+ * + *
 String eo = new Xmir.Default(xml).toEO();
+ * + *

Here, the {@code xml} is a {@code String} or an instance + * of {@code XML} from the jcabi-xml package.

+ * + * @link xml.jcabi.com * @since 0.35.0 */ -public interface Xmir { - /** - * Converts XMIR to EO. - * @return EO representation as {@code String} - */ - String toEO(); +public final class Xmir { /** - * Default Xmir that prints EO with straight vertical methods. - * - * This class will help you turn XMIR (XML document) into EOLANG - * plain text source code. It's as simple as this: - * - *
 String eo = new Xmir.Default(xml).toEO();
- * - * Here, the {@code xml} is a {@code String} or an instance - * of {@code XML} from the jcabi-xml package. - * @link xml.jcabi.com - * @since 0.35.5 + * Train of transformations. */ - final class Default implements Xmir { - /** - * Train of transformations. - */ - private static final Train TRAIN = new TrLambda( + private static final Train TRAIN = new TrLogged( + new TrLambda( new TrDefault<>( new StClasspath("/org/eolang/parser/explicit-data.xsl"), new StUnhex(), @@ -80,52 +74,49 @@ final class Default implements Xmir { } ) ) - ); - - /** - * Default xmir-to-eo XSL transformation. - */ - private static final String TO_EO = "/org/eolang/parser/xmir-to-eo.xsl"; + ) + ); - /** - * The XML. - */ - private final XML xml; + /** + * The XML. + */ + private final XML xml; - /** - * Result to-EO transformation. - */ - private final String xsl; + /** + * Ctor. + * @param src The source + */ + public Xmir(final XML src) { + this.xml = src; + } - /** - * Ctor. - * @param src The source - */ - public Default(final XML src) { - this(src, Xmir.Default.TO_EO); - } + /** + * Converts XMIR to EO. + * @return EO representation as {@code String} + */ + public String toEO() { + return this.via("/org/eolang/parser/xmir-to-eo.xsl"); + } - /** - * Ctor. - * @param src The source - * @param classpath To-EO transformation classpath - */ - public Default(final XML src, final String classpath) { - this.xml = src; - this.xsl = classpath; - } + /** + * Converts XMIR to EO, in reverse notation. + * @return EO representation as {@code String} + */ + public String toReversed() { + return this.via("/org/eolang/parser/xmir-to-eo-reversed.xsl"); + } - @Override - public String toEO() { - return new Xsline( - Xmir.Default.TRAIN - .with( - new StClasspath(this.xsl) - ) + /** + * Converts XMIR to EO, via provided XSL. + * @param xsl The XSL + * @return EO representation as {@code String} + */ + private String via(final String xsl) { + return new Xsline( + Xmir.TRAIN.with( + new StClasspath(xsl) ) - .pass(this.xml) - .xpath("eo/text()") - .get(0); - } + ).pass(this.xml).xpath("eo/text()").get(0); } + } diff --git a/eo-parser/src/main/java/org/eolang/parser/xmir/XmirEnvelope.java b/eo-parser/src/main/java/org/eolang/parser/xmir/XmirEnvelope.java deleted file mode 100644 index 1851f0d13a..0000000000 --- a/eo-parser/src/main/java/org/eolang/parser/xmir/XmirEnvelope.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. - */ -package org.eolang.parser.xmir; - -/** - * Envelope for {@link Xmir}. - * @since 0.35.0 - */ -class XmirEnvelope implements Xmir { - /** - * Original XMIR. - */ - private final Xmir origin; - - /** - * Ctor. - * @param xmir Original XMIR - */ - XmirEnvelope(final Xmir xmir) { - this.origin = xmir; - } - - @Override - public String toEO() { - return this.origin.toEO(); - } -} diff --git a/eo-parser/src/main/java/org/eolang/parser/xmir/XmirInfo.java b/eo-parser/src/main/java/org/eolang/parser/xmir/XmirInfo.java deleted file mode 100644 index 7ef1ebca91..0000000000 --- a/eo-parser/src/main/java/org/eolang/parser/xmir/XmirInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ -package org.eolang.parser.xmir; - -/** - * Info about XMIR. - * @since 0.34.0 - */ -public final class XmirInfo { - /** - * Info about xmir. - */ - private static final String INFO = String.join( - "", - "This is XMIR - a dialect of XML, which is used to present a parsed EO program. ", - "For more information please visit https://news.eolang.org/2022-11-25-xmir-guide.html" - ); - - @Override - public String toString() { - return XmirInfo.INFO; - } -} 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 deleted file mode 100644 index 1ec918c39e..0000000000 --- a/eo-parser/src/main/java/org/eolang/parser/xmir/XmirReversed.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - */ -package org.eolang.parser.xmir; - -import com.jcabi.xml.XML; - -/** - * Converts to EO with reversed methods. - * @since 0.35.0 - */ -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"; - - /** - * Ctor. - * @param xml The source xml - */ - public XmirReversed(final XML xml) { - 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 deleted file mode 100644 index 9d93a7ef2e..0000000000 --- a/eo-parser/src/main/java/org/eolang/parser/xmir/package-info.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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. - */ - -/** - * 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/org/eolang/parser/blank-xsd-schema.xsl b/eo-parser/src/main/resources/org/eolang/parser/blank-xsd-schema.xsl new file mode 100644 index 0000000000..ed1de30218 --- /dev/null +++ b/eo-parser/src/main/resources/org/eolang/parser/blank-xsd-schema.xsl @@ -0,0 +1,40 @@ + + + + + + + + https://www.eolang.org/xsd/XMIR-anything.xsd + + + + + + + + diff --git a/eo-parser/src/main/resources/org/eolang/parser/clean-up.xsl b/eo-parser/src/main/resources/org/eolang/parser/clean-up.xsl new file mode 100644 index 0000000000..3a8816e421 --- /dev/null +++ b/eo-parser/src/main/resources/org/eolang/parser/clean-up.xsl @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + diff --git a/eo-parser/src/main/java/org/eolang/parser/xmir/XmirSwap.java b/eo-parser/src/test/java/org/eolang/parser/CheckPackTest.java similarity index 63% rename from eo-parser/src/main/java/org/eolang/parser/xmir/XmirSwap.java rename to eo-parser/src/test/java/org/eolang/parser/CheckPackTest.java index f35d82c0d8..fc0cc1daf4 100644 --- a/eo-parser/src/main/java/org/eolang/parser/xmir/XmirSwap.java +++ b/eo-parser/src/test/java/org/eolang/parser/CheckPackTest.java @@ -21,30 +21,35 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package org.eolang.parser.xmir; +package org.eolang.parser; + +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; /** - * Xmir swap. Depends on given condition behaves like one of given Xmirs. - * @since 0.35.0 + * Test case for {@link CheckPack}. + * + * @since 0.1 */ -public final class XmirSwap extends XmirEnvelope { - /** - * Ctor. - * @param condition Take first Xmir or not. - * @param first First Xmir. - * @param second Second Xmir. - */ - public XmirSwap(final boolean condition, final Xmir first, final Xmir second) { - super( - () -> { - final Xmir xmir; - if (condition) { - xmir = first; - } else { - xmir = second; - } - return xmir.toEO(); - } +final class CheckPackTest { + + @Test + void parsesAndChecksSimpleCode() throws Exception { + MatcherAssert.assertThat( + "doesn't fail on basic example", + new CheckPack( + String.join( + "\n", + "xsls: []", + "tests: []", + "eo: |", + " # test.", + " [] > foo" + ) + ).failures(), + Matchers.emptyIterable() ); } + } diff --git a/eo-parser/src/test/java/org/eolang/parser/DrProgramTest.java b/eo-parser/src/test/java/org/eolang/parser/DrProgramTest.java new file mode 100644 index 0000000000..653e94e57c --- /dev/null +++ b/eo-parser/src/test/java/org/eolang/parser/DrProgramTest.java @@ -0,0 +1,99 @@ +/* + * 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. + */ +package org.eolang.parser; + +import com.jcabi.matchers.XhtmlMatchers; +import com.jcabi.xml.XML; +import com.jcabi.xml.XMLDocument; +import java.nio.file.Paths; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; +import org.xembly.Directives; +import org.xembly.Xembler; + +/** + * Test case for {@link DrProgram}. + * + * @since 0.1 + */ +final class DrProgramTest { + + @Test + void buildsProgramElement() throws Exception { + MatcherAssert.assertThat( + "XMIR program element is built", + XhtmlMatchers.xhtml( + new Xembler(new DrProgram("foo")).xml() + ), + XhtmlMatchers.hasXPaths( + "/program[@name='foo']", + "/program[@dob and @time and @version and @revision]" + ) + ); + } + + @Test + @DisabledOnOs(OS.WINDOWS) + void setsSchemaLocation() throws Exception { + final XML xml = new XMLDocument(new Xembler(new DrProgram("foo")).xml()); + MatcherAssert.assertThat( + "XSD location is set", + xml.toString(), + Matchers.containsString( + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + ) + ); + final String url = xml.xpath("/program/@xsi:noNamespaceSchemaLocation").get(0); + MatcherAssert.assertThat( + "URL of XSD is set to file", + url, + Matchers.startsWith("file:///") + ); + final String path = url.substring("file:///".length()); + MatcherAssert.assertThat( + "XSD file exists", + Paths.get(path).toFile().exists(), + Matchers.is(true) + ); + } + + @Test + void validatesAgainstSchema() { + MatcherAssert.assertThat( + "XMIR document validates correctly", + new XMLDocument( + new Xembler( + new Directives().append(new DrProgram("foo")) + .add("listing").set("hello, world!").up() + .add("objects").add("o").attr("name", "bar") + ).domQuietly() + ).validate(), + Matchers.emptyIterable() + ); + } + +} diff --git a/eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java b/eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java index 43d78b3c52..286e439d27 100644 --- a/eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java @@ -24,6 +24,7 @@ package org.eolang.parser; import com.jcabi.matchers.XhtmlMatchers; +import com.jcabi.xml.StrictXML; import com.jcabi.xml.XML; import com.jcabi.xml.XMLDocument; import java.io.IOException; @@ -250,10 +251,12 @@ void checksTypoPacks(final String yml) throws IOException { final Yaml yaml = new Yaml(); final Map map = yaml.load(yml); Assumptions.assumeTrue(map.get("skip") == null); - final XML xml = new EoSyntax( - "typo", - new InputOf(String.format("%s\n", map.get("eo"))) - ).parsed(); + final XML xml = new StrictXML( + new EoSyntax( + "typo", + new InputOf(String.format("%s\n", map.get("eo"))) + ).parsed() + ); MatcherAssert.assertThat( EoIndentLexerTest.TO_ADD_MESSAGE, XhtmlMatchers.xhtml(xml.toString()), diff --git a/eo-parser/src/test/java/org/eolang/parser/PhiSyntaxTest.java b/eo-parser/src/test/java/org/eolang/parser/PhiSyntaxTest.java index 905f9dbd93..c9b52751fe 100644 --- a/eo-parser/src/test/java/org/eolang/parser/PhiSyntaxTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/PhiSyntaxTest.java @@ -24,6 +24,7 @@ package org.eolang.parser; import com.jcabi.matchers.XhtmlMatchers; +import com.jcabi.xml.StrictXML; import com.jcabi.xml.XML; import java.io.IOException; import org.eolang.jucs.ClasspathSource; @@ -97,7 +98,7 @@ void addsMetaForPackage() throws IOException { @ParameterizedTest @ClasspathSource(value = "org/eolang/parser/phi-syntax/", glob = "**.phi") void checksValidExpressions(final String phi) throws IOException { - final XML xml = new PhiSyntax(phi).parsed(); + final XML xml = new StrictXML(new PhiSyntax(phi).parsed()); MatcherAssert.assertThat( "syntax is valid, can be parsed without errors", XhtmlMatchers.xhtml(xml.toString()), @@ -108,7 +109,7 @@ void checksValidExpressions(final String phi) throws IOException { @ParameterizedTest @ClasspathSource(value = "org/eolang/parser/phi-typos/", glob = "**.phi") void checksBrokenExressions(final String phi) throws IOException { - final XML xml = new PhiSyntax(phi).parsed(); + final XML xml = new StrictXML(new PhiSyntax(phi).parsed()); MatcherAssert.assertThat( "syntax is broken, can't be parsed without errors", XhtmlMatchers.xhtml(xml.toString()), diff --git a/eo-parser/src/test/java/org/eolang/parser/StEoLoggedTest.java b/eo-parser/src/test/java/org/eolang/parser/StEoLoggedTest.java index d590a8e47c..b9f0af7d07 100644 --- a/eo-parser/src/test/java/org/eolang/parser/StEoLoggedTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/StEoLoggedTest.java @@ -35,6 +35,9 @@ import org.hamcrest.Matchers; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.xembly.Directives; +import org.xembly.ImpossibleModificationException; +import org.xembly.Xembler; /** * Test case for {@link StEoLogged}. @@ -57,7 +60,7 @@ void hasTheSameUid() { } @Test - void delegatesWithoutException() { + void delegatesWithoutException() throws ImpossibleModificationException { final FakeLog log = new FakeLog(); MatcherAssert.assertThat( "We expect that shift will successfully generate output xml", @@ -91,14 +94,7 @@ void printsMessageWithEoIfExceptionIsThrown() { log.all() ), log.last(), - Matchers.containsString( - String.join( - "\n", - "[] > main", - " true > x", - " false > y" - ) - ) + Matchers.containsString("[] > bar") ); } @@ -114,19 +110,15 @@ void printsMessageWithEoIfExceptionIsThrown() { * * @return XML */ - private static XML example() { + private static XML example() throws ImpossibleModificationException { return new XMLDocument( - String.join( - "\n", - "", - " ", - " ", - " ", - " ", - " ", - " ", - "" - ) + new Xembler( + new Directives().append(new DrProgram("foo")) + .add("objects") + .add("o") + .attr("abstract", "") + .attr("name", "bar") + ).xml() ); } diff --git a/eo-parser/src/test/java/org/eolang/parser/TrParsingTest.java b/eo-parser/src/test/java/org/eolang/parser/TrParsingTest.java index 4455e2525b..530ef56cdf 100644 --- a/eo-parser/src/test/java/org/eolang/parser/TrParsingTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/TrParsingTest.java @@ -36,6 +36,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; +import org.xembly.Xembler; /** * Test case for {@link TrParsing}. @@ -139,4 +140,17 @@ void createsXaxStoryWithXslStylesheets(final String yaml) { Matchers.is(true) ); } + + @Test + void setsBlankSchema() { + MatcherAssert.assertThat( + "Removes XSD schema from XMIR", + new Xsline( + new TrClasspath<>("/org/eolang/parser/blank-xsd-schema.xsl").back() + ).pass(new XMLDocument(new Xembler(new DrProgram("foo")).xmlQuietly())), + XhtmlMatchers.hasXPath( + "/program[@xsi:noNamespaceSchemaLocation='https://www.eolang.org/xsd/XMIR-anything.xsd']" + ) + ); + } } diff --git a/eo-parser/src/test/java/org/eolang/parser/xmir/XmirTest.java b/eo-parser/src/test/java/org/eolang/parser/XmirTest.java similarity index 53% rename from eo-parser/src/test/java/org/eolang/parser/xmir/XmirTest.java rename to eo-parser/src/test/java/org/eolang/parser/XmirTest.java index d4cf9b580a..65216cad8b 100644 --- a/eo-parser/src/test/java/org/eolang/parser/xmir/XmirTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/XmirTest.java @@ -21,47 +21,34 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package org.eolang.parser.xmir; +package org.eolang.parser; -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.params.ParameterizedTest; import org.yaml.snakeyaml.Yaml; /** - * Test case for {@link Xmir} and {@link XmirReversed}. + * Test case for {@link Xmir}. * * @since 0.5 - * @checkstyle AbbreviationAsWordInNameCheck (500 lines) */ final class XmirTest { + @ParameterizedTest @ClasspathSource(value = "org/eolang/parser/samples/", glob = "**.yaml") void printsStraight(final String pack) throws IOException { final Map map = new Yaml().load(pack); - final String key = "straight"; - final String eolang = this.eolang((String) map.get("origin"), Xmir.Default::new); - 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) + "Result EO should be equal to original EO", + this.asXmir((String) map.get("origin")).toEO(), + Matchers.equalTo(map.get("straight")) ); } @@ -69,43 +56,26 @@ void printsStraight(final String pack) throws IOException { @ClasspathSource(value = "org/eolang/parser/samples/", glob = "**.yaml") void printsReversed(final String pack) throws IOException { final Map map = new Yaml().load(pack); - final String key = "reversed"; - final String eolang = this.eolang((String) map.get("origin"), XmirReversed::new); 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) + "Result EO should be equal to original EO in reverse notation", + this.asXmir((String) map.get("origin")).toReversed(), + Matchers.equalTo(map.get("reversed")) ); } /** - * Parse EO from given pack, converts XMIR to EO. - * @param original Original EOLANG - * @param xmir Xmir constructor - * @return Eolang from XMIR + * Convert EO to XMIR. + * @param program Program in EOLANG + * @return XMIR */ - private String eolang( - final String original, - final Function xmir - ) throws IOException { - Logger.debug(this, "Original EOLANG:%n%s", original); - final XML first = new EoSyntax("test", new InputOf(original)).parsed(); + private Xmir asXmir(final String program) throws IOException { + final XML xml = new EoSyntax("test", new InputOf(program)).parsed(); MatcherAssert.assertThat( "Original EO should be parsed without errors", - first, + xml, 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); - return eolang; + return new Xmir(xml); } + } diff --git a/eo-parser/src/test/java/org/eolang/parser/XslBenchmarkIT.java b/eo-parser/src/test/java/org/eolang/parser/XslBenchmarkIT.java index 22e4f91ba4..85e4a57312 100644 --- a/eo-parser/src/test/java/org/eolang/parser/XslBenchmarkIT.java +++ b/eo-parser/src/test/java/org/eolang/parser/XslBenchmarkIT.java @@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit; import org.cactoos.io.ResourceOf; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.openjdk.jmh.Main; import org.openjdk.jmh.annotations.Benchmark; @@ -53,6 +54,7 @@ @Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @State(Scope.Benchmark) +@Disabled @SuppressWarnings({ "JTCOP.RuleAllTestsHaveProductionClass", "PMD.JUnitTestClassShouldBeFinal", 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 deleted file mode 100644 index 9d93a7ef2e..0000000000 --- a/eo-parser/src/test/java/org/eolang/parser/xmir/package-info.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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. - */ - -/** - * 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/META-INF/MANIFEST.MF b/eo-parser/src/test/resources/META-INF/MANIFEST.MF index 3ce6ec92ab..9f3562c435 100644 --- a/eo-parser/src/test/resources/META-INF/MANIFEST.MF +++ b/eo-parser/src/test/resources/META-INF/MANIFEST.MF @@ -1,3 +1,3 @@ -EO-Version: 0.0-SNAPSHOT +EO-Version: 0.0.0 EO-Revision: 1234567 EO-Dob: 2023-03-19T00:00:00 diff --git a/eo-parser/src/test/resources/log4j.properties b/eo-parser/src/test/resources/log4j.properties index 263eb6d9a7..d0d27ce5d5 100644 --- a/eo-parser/src/test/resources/log4j.properties +++ b/eo-parser/src/test/resources/log4j.properties @@ -27,6 +27,8 @@ log4j.appender.CONSOLE.layout=com.jcabi.log.MulticolorLayout log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss} [%color{%p}] %c: %m%n log4j.logger.com.jcabi.log=WARN +log4j.logger.com.yegor256.xsline=WARN +log4j.logger.com.yegor256.xsline.StSchema=DEBUG log4j.logger.org.eolang=WARN -log4j.logger.org.eolang.parser.xmir.XmirTest=WARN +log4j.logger.org.eolang.parser.XmirTest=WARN log4j.logger.org.eolang.parser.CheckPack=INFO diff --git a/eo-parser/src/test/resources/org/eolang/parser/packs/float-up-same-attrs.yaml b/eo-parser/src/test/resources/org/eolang/parser/packs/float-up-same-attrs.yaml index cd91b092fd..f4b5d8a325 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/packs/float-up-same-attrs.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/packs/float-up-same-attrs.yaml @@ -25,9 +25,9 @@ xsls: - /org/eolang/parser/optimize/abstracts-float-up.xsl - /org/eolang/parser/optimize/remove-levels.xsl - /org/eolang/parser/add-refs.xsl + - /org/eolang/parser/clean-up.xsl tests: - /program[count(.//o[@base='build' and not(@ref)])=2] - - /program/objects[count(o[@original-name='build'])=2] eo: | # This is the default 64+ symbols comment in front of abstract object. [] > hello diff --git a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/float-abstracts.yaml b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/float-abstracts.yaml index 6d5ea26e12..bff4c3fe6f 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/float-abstracts.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/float-abstracts.yaml @@ -25,6 +25,7 @@ xsls: - /org/eolang/parser/optimize/abstracts-float-up.xsl - /org/eolang/parser/optimize/remove-levels.xsl - /org/eolang/parser/add-refs.xsl + - /org/eolang/parser/clean-up.xsl tests: - /program/objects[count(o)=9] - /program[not(errors)] @@ -33,7 +34,7 @@ tests: - //o[@base='first$t2$native'] - //o[@name='first' and not(@ancestors)] - //o[@name='first']/o[@base='test'] - - //o[@name='first$t2$second' and @ancestors='1' and @parent='first'] + - //o[@name='first$t2$second'] - //o[@name='first$t2$second$third'] - //o[@name='first$t2$second$third']/o[@base='stdout']/o[@base='a'] - //o[@line and @name='aa'] diff --git a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/float-and-keep-names.yaml b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/float-and-keep-names.yaml index c356eec962..3404635f54 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/float-and-keep-names.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/float-and-keep-names.yaml @@ -26,6 +26,7 @@ xsls: - /org/eolang/parser/optimize/remove-levels.xsl - /org/eolang/parser/add-refs.xsl - /org/eolang/parser/optimize/fix-missed-names.xsl + - /org/eolang/parser/clean-up.xsl tests: - //o[@base='first$second' and @line='6'] eo: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/floating-sets-parent-names.yaml b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/floating-sets-parent-names.yaml index 36135ac1f6..544a1484ae 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/floating-sets-parent-names.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/floating-sets-parent-names.yaml @@ -23,9 +23,10 @@ xsls: - /org/eolang/parser/add-refs.xsl - /org/eolang/parser/optimize/abstracts-float-up.xsl + - /org/eolang/parser/clean-up.xsl tests: - /program[not(errors)] - - //o[@name='a$m$t2$a0' and @parent='a$m'] + - //o[@name='a$m$t2$a0'] eo: | # This is the default 64+ symbols comment in front of abstract object. [] > a diff --git a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/not-redundant-levels.yaml b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/not-redundant-levels.yaml index e30a192e39..8496d1cc72 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/not-redundant-levels.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/not-redundant-levels.yaml @@ -23,6 +23,7 @@ xsls: - /org/eolang/parser/optimize/abstracts-float-up.xsl - /org/eolang/parser/optimize/remove-levels.xsl + - /org/eolang/parser/clean-up.xsl tests: - /program[not(errors)] # 'first' object diff --git a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arguments-and-abstract-parents.yaml b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arguments-and-abstract-parents.yaml index 02bf1a5f9f..d38ba7ae34 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arguments-and-abstract-parents.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arguments-and-abstract-parents.yaml @@ -23,6 +23,7 @@ xsls: - /org/eolang/parser/optimize/abstracts-float-up.xsl - /org/eolang/parser/optimize/remove-levels.xsl + - /org/eolang/parser/clean-up.xsl tests: - /program[not(errors)] # 'main' object diff --git a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arguments-and-siblings.yaml b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arguments-and-siblings.yaml index 303d0b91a6..34a8dccba8 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arguments-and-siblings.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arguments-and-siblings.yaml @@ -23,6 +23,7 @@ xsls: - /org/eolang/parser/optimize/abstracts-float-up.xsl - /org/eolang/parser/optimize/remove-levels.xsl + - /org/eolang/parser/clean-up.xsl tests: - /program[not(errors)] # 'main' object diff --git a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arrays.yaml b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arrays.yaml index 114a08006d..e60bc11c3d 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arrays.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-arrays.yaml @@ -24,6 +24,7 @@ xsls: - /org/eolang/parser/wrap-method-calls.xsl - /org/eolang/parser/optimize/abstracts-float-up.xsl - /org/eolang/parser/optimize/remove-levels.xsl + - /org/eolang/parser/clean-up.xsl tests: - /program[not(errors)] # 'main' object diff --git a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-siblings.yaml b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-siblings.yaml index a1027e8494..62e46be65f 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-siblings.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels-with-siblings.yaml @@ -23,6 +23,7 @@ xsls: - /org/eolang/parser/optimize/abstracts-float-up.xsl - /org/eolang/parser/optimize/remove-levels.xsl + - /org/eolang/parser/clean-up.xsl tests: - /program[not(errors)] # 'main' object diff --git a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels.yaml b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels.yaml index 155ecf6270..9dac830767 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/packs/optimize/redundant-levels.yaml @@ -23,6 +23,7 @@ xsls: - /org/eolang/parser/optimize/abstracts-float-up.xsl - /org/eolang/parser/optimize/remove-levels.xsl + - /org/eolang/parser/clean-up.xsl tests: - /program[not(errors)] # 'another' object diff --git a/pom.xml b/pom.xml index 0e51481122..c1fb05a7f2 100644 --- a/pom.xml +++ b/pom.xml @@ -109,7 +109,7 @@ SOFTWARE. com.jcabi.incubator xembly - 0.31.1 + 0.32.1 xml-apis @@ -137,7 +137,7 @@ SOFTWARE. com.yegor256 xsline - 0.21.1 + 0.22.1 org.junit @@ -194,7 +194,7 @@ SOFTWARE. com.jcabi jcabi-xml - 0.30.1 + 0.31.0 com.jcabi