Skip to content

Commit

Permalink
fix(objectionary#2729): syntax pack + multithread printing
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Dec 26, 2023
1 parent 248b57b commit a8d62b4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
40 changes: 25 additions & 15 deletions eo-maven-plugin/src/main/java/org/eolang/maven/PrintMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.cactoos.experimental.Threads;
import org.cactoos.iterable.Mapped;
import org.cactoos.number.SumOf;
import org.cactoos.text.TextOf;
import org.eolang.maven.util.HmBase;
import org.eolang.maven.util.Home;
Expand Down Expand Up @@ -72,23 +74,31 @@ public final class PrintMojo extends SafeMojo {

@Override
void exec() throws IOException {
final Collection<Path> sources = new Walk(this.printSourcesDir.toPath());
final Home home = new HmBase(this.printOutputDir);
for (final Path source : sources) {
final Path relative = Paths.get(
this.printSourcesDir.toPath().relativize(source).toString()
.replace(".xmir", ".eo")
);
home.save(new XMIR(new TextOf(source)).toEO(), relative);
Logger.info(
this,
"Printed: %s => %s", source, this.printOutputDir.toPath().resolve(relative)
);
}
if (sources.isEmpty()) {
final int total = new SumOf(
new Threads<>(
Runtime.getRuntime().availableProcessors(),
new Mapped<>(
source -> () -> {
final Path relative = Paths.get(
this.printSourcesDir.toPath().relativize(source).toString()
.replace(".xmir", ".eo")
);
home.save(new XMIR(new TextOf(source)).toEO(), relative);
Logger.info(
this,
"Printed: %s => %s", source, this.printOutputDir.toPath().resolve(relative)
);
return 1;
},
new Walk(this.printSourcesDir.toPath())
)
)
).intValue();
if (total == 0) {
Logger.info(this, "No XMIR sources found");
} else {
Logger.info(this, "Printed %d XMIR sources into EO", sources.size());
Logger.info(this, "Printed %d XMIR sources into EO", total);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# @todo #2729:60min Enable the test when it's possible. Current syntax is not supported now. In our
# EBNF such is understood as vertical application with 3 arguments. But all arguments in
# application must be either all bound or not. But it should not be like that with reversed
# application. Need to extend the grammar and make sure the test works. Don't forget to remove the
# puzzle.
skip: true
xsls: []
tests:
- /program/errors[count(*)=0]
eo: |
if. > condition
TRUE
"TRUE":0
"FALSE":1

0 comments on commit a8d62b4

Please sign in to comment.