Skip to content

Commit

Permalink
Merge branch 'master' into fix/objectionary#2930/simplify-phi-grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Mar 12, 2024
2 parents e64f050 + d1249b2 commit 633908b
Show file tree
Hide file tree
Showing 57 changed files with 333 additions and 174 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: teatimeguest/setup-texlive-action@v3.0.2
- uses: teatimeguest/setup-texlive-action@v3.1.0
with:
update-all-packages: true
packages: scheme-basic geometry xcolor naive-ebnf microtype etoolbox
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: teatimeguest/setup-texlive-action@v3.0.2
- uses: teatimeguest/setup-texlive-action@v3.1.0
with:
update-all-packages: true
packages: scheme-basic geometry xcolor naive-ebnf microtype etoolbox
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ebnf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- run: |
sudo apt-get update
sudo apt-get -y install ghostscript imagemagick texlive-extra-utils pdf2svg inkscape
- uses: teatimeguest/setup-texlive-action@v3.0.2
- uses: teatimeguest/setup-texlive-action@v3.1.0
with:
update-all-packages: true
packages: scheme-basic geometry xcolor naive-ebnf microtype etoolbox
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
markdown-lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b32f140b0c872d58512e0a66172253c302617b90
- uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694
- uses: articulate/actions-markdownlint@v1
2 changes: 1 addition & 1 deletion .github/workflows/simian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- run: |
wget --quiet http://public.yegor256.com/simian.jar -O /tmp/simian.jar
- run: |
java -jar /tmp/simian.jar -threshold=25 -excludes=**/gen -excludes=**/it **/*.java
java -jar /tmp/simian.jar -threshold=16 -excludes=**/gen -excludes=**/it **/*.java
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- uses: teatimeguest/setup-texlive-action@v3.0.2
- uses: teatimeguest/setup-texlive-action@v3.1.0
with:
update-all-packages: true
packages: scheme-basic geometry xcolor naive-ebnf microtype etoolbox
Expand Down
8 changes: 0 additions & 8 deletions eo-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ SOFTWARE.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>slow</excludedGroups>
<argLine>@{argLine} -Xss${stack-size}</argLine>
<systemPropertyVariables>
<runtime.path>${project.basedir}/../eo-runtime</runtime.path>
Expand Down Expand Up @@ -490,13 +489,6 @@ SOFTWARE.
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>nothing-to-exclude</excludedGroups>
</configuration>
</plugin>
<plugin>
<groupId>com.github.volodya-lombrozo</groupId>
<artifactId>jtcop-maven-plugin</artifactId>
Expand Down
12 changes: 6 additions & 6 deletions eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ public final class AssembleMojo extends SafeMojo {

/**
* Pull again even if the .eo file is already present?
* @checkstyle MemberNameCheck (7 lines)
* @since 0.10.0
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(property = "eo.overWrite", required = true, defaultValue = "false")
private boolean overWrite;

/**
* Track optimization steps into intermediate XML files?
*
* @checkstyle MemberNameCheck (7 lines)
* @since 0.24.0
* @checkstyle MemberNameCheck (7 lines)
*/
@SuppressWarnings("PMD.LongVariable")
@Parameter(property = "eo.trackOptimizationSteps", required = true, defaultValue = "false")
Expand All @@ -139,25 +139,25 @@ public final class AssembleMojo extends SafeMojo {

/**
* Skip artifact with the version 0.0.0.
* @checkstyle MemberNameCheck (7 lines)
* @since 0.9.0
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(property = "eo.skipZeroVersions", required = true, defaultValue = "true")
private boolean skipZeroVersions;

/**
* Shall we discover JAR artifacts for .EO sources?
* @checkstyle MemberNameCheck (7 lines)
* @since 0.12.0
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(property = "eo.discoverSelf", required = true, defaultValue = "false")
private boolean discoverSelf;

/**
* Fail resolution process on conflicting dependencies.
*
* @checkstyle MemberNameCheck (7 lines)
* @since 1.0
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(property = "eo.ignoreVersionConflicts", required = true, defaultValue = "false")
@SuppressWarnings("PMD.LongVariable")
Expand Down Expand Up @@ -196,9 +196,9 @@ public final class AssembleMojo extends SafeMojo {
/**
* If set to TRUE, the exception on exit will be printed in details
* to the log.
* @since 0.29.0
* @checkstyle MemberNameCheck (7 lines)
* @checkstyle VisibilityModifierCheck (10 lines)
* @since 0.29.0
*/
@Parameter(property = "eo.unrollExitError")
@SuppressWarnings("PMD.ImmutableField")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
/**
* Compile binaries.
*
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
* @since 0.1
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
@Mojo(
name = "binarize",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
/**
* Parse rust inserts.
*
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
* @since 0.1
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
@SuppressWarnings("PMD.LongVariable")
public final class BinarizeParse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public final class DemandMojo extends SafeMojo {

/**
* List of object names to add.
* @checkstyle MemberNameCheck (7 lines)
* @since 0.17.0
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(required = true)
private List<String> objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public final class OptimizeMojo extends SafeMojo {
/**
* Track optimization steps into intermediate XML files?
*
* @checkstyle MemberNameCheck (7 lines)
* @since 0.24.0
* @checkstyle MemberNameCheck (7 lines)
*/
@SuppressWarnings("PMD.LongVariable")
@Parameter(property = "eo.trackOptimizationSteps", required = true, defaultValue = "false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
* Take binary files from where ResolveMojo placed them and
* copy to target/classes.
*
* @since 0.11
* @see <a href="https://news.eolang.org/2022-10-19-placed-catalog.html">Place catalog</a>
* @since 0.11
*/
@Mojo(
name = "place",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public final class PullMojo extends SafeMojo {

/**
* Pull again even if the .eo file is already present?
* @checkstyle MemberNameCheck (7 lines)
* @since 0.10.0
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(property = "eo.overWrite", required = true, defaultValue = "false")
private boolean overWrite;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,26 @@ public final class ResolveMojo extends SafeMojo {
/**
* Skip artifact with the version 0.0.0.
*
* @checkstyle MemberNameCheck (7 lines)
* @since 0.9.0
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(property = "eo.skipZeroVersions", required = true, defaultValue = "true")
private boolean skipZeroVersions;

/**
* Shall we discover JAR artifacts for .EO sources?
*
* @checkstyle MemberNameCheck (7 lines)
* @since 0.12.0
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(property = "eo.discoverSelf", required = true, defaultValue = "false")
private boolean discoverSelf;

/**
* Fail resolution process on conflicting dependencies.
*
* @checkstyle MemberNameCheck (7 lines)
* @since 1.0
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(property = "eo.ignoreVersionConflicts", required = true, defaultValue = "false")
@SuppressWarnings("PMD.LongVariable")
Expand Down
8 changes: 4 additions & 4 deletions eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ abstract class SafeMojo extends AbstractMojo {
/**
* The path to a text file where paths of all added
* .class (and maybe others) files are placed.
* @since 0.11.0
* @checkstyle MemberNameCheck (7 lines)
* @checkstyle VisibilityModifierCheck (10 lines)
* @since 0.11.0
*/
@Parameter(
property = "eo.placed",
Expand All @@ -144,9 +144,9 @@ abstract class SafeMojo extends AbstractMojo {

/**
* The path to a text file where paths of generated java files per EO program.
* @since 0.11.0
* @checkstyle MemberNameCheck (7 lines)
* @checkstyle VisibilityModifierCheck (10 lines)
* @since 0.11.0
*/
@Parameter(
property = "eo.transpiled",
Expand All @@ -157,8 +157,8 @@ abstract class SafeMojo extends AbstractMojo {

/**
* Mojo execution timeout in seconds.
* @checkstyle VisibilityModifierCheck (10 lines)
* @since 0.28.12
* @checkstyle VisibilityModifierCheck (10 lines)
*/
@Parameter(property = "eo.timeout")
protected Integer timeout = Integer.MAX_VALUE;
Expand All @@ -174,9 +174,9 @@ abstract class SafeMojo extends AbstractMojo {
/**
* If set to TRUE, the exception on exit will be printed in details
* to the log.
* @since 0.29.0
* @checkstyle MemberNameCheck (7 lines)
* @checkstyle VisibilityModifierCheck (10 lines)
* @since 0.29.0
*/
@Parameter(property = "eo.unrollExitError")
protected boolean unrollExitError = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public final class ShakeMojo extends SafeMojo {
/**
* Track optimization steps into intermediate XML files?
*
* @checkstyle MemberNameCheck (7 lines)
* @since 0.24.0
* @checkstyle MemberNameCheck (7 lines)
*/
@SuppressWarnings("PMD.LongVariable")
@Parameter(property = "eo.trackOptimizationSteps", required = true, defaultValue = "false")
Expand Down
68 changes: 67 additions & 1 deletion eo-maven-plugin/src/main/java/org/eolang/maven/UnphiMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
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.IterableEnvelope;
import org.cactoos.iterable.Joined;
import org.cactoos.iterable.Mapped;
import org.cactoos.list.ListOf;
import org.cactoos.number.SumOf;
import org.cactoos.set.SetOf;
import org.cactoos.text.TextOf;
import org.eolang.maven.util.HmBase;
import org.eolang.maven.util.Home;
import org.eolang.maven.util.Walk;
import org.eolang.parser.PhiSyntax;
import org.xembly.Directive;
import org.xembly.Directives;

/**
* Read PHI files and parse them to the XMIR.
Expand Down Expand Up @@ -75,10 +81,19 @@ public final class UnphiMojo extends SafeMojo {
)
private File unphiOutputDir;

/**
* Extra metas to add to unphied XMIR.
* @checkstyle MemberNameCheck (10 lines)
*/
@SuppressWarnings("PMD.ImmutableField")
@Parameter(property = "eo.unphiMetas")
private Set<String> unphiMetas = new SetOf<>();

@Override
public void exec() {
final List<Path> errors = new ListOf<>();
final Home home = new HmBase(this.unphiOutputDir);
final Iterable<Directive> metas = new UnphiMojo.Metas(this.unphiMetas);
final int count = new SumOf(
new Threads<>(
Runtime.getRuntime().availableProcessors(),
Expand All @@ -93,7 +108,8 @@ public void exec() {
);
final XML parsed = new PhiSyntax(
phi.getFileName().toString().replace(".phi", ""),
new TextOf(phi)
new TextOf(phi),
metas
).parsed();
home.save(parsed.toString(), xmir);
Logger.info(
Expand Down Expand Up @@ -121,4 +137,54 @@ public void exec() {
);
}
}

/**
* Accumulates all metas that should be attached to unphied XMIR.
* +package meta is prohibited since it's converted to special object
* with "位 -> Package" binding.
* @since 0.36.0
*/
private static class Metas extends IterableEnvelope<Directive> {
/**
* Package meta.
*/
private static final String PACKAGE = "package";

/**
* Ctor.
* @param metas Metas to append
*/
Metas(final Iterable<String> metas) {
super(
new Joined<>(
new Mapped<>(
meta -> {
final String[] pair = meta.split(" ", 2);
final String head = pair[0].substring(1);
if (head.equals(UnphiMojo.Metas.PACKAGE)) {
throw new IllegalStateException(
"+package meta is prohibited for attaching to unphied XMIR"
);
}
final Directives dirs = new Directives()
.xpath("/program/metas")
.add("meta")
.add("head").set(head).up()
.add("tail");
if (pair.length > 1) {
dirs.set(pair[1].trim()).up();
for (final String part : pair[1].trim().split(" ")) {
dirs.add("part").set(part).up();
}
} else {
dirs.up();
}
return dirs.up();
},
metas
)
)
);
}
}
}

0 comments on commit 633908b

Please sign in to comment.