Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing ref processing in the bytes.eo #3498

Merged
merged 6 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions .github/workflows/telegram.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,33 @@ jobs:
- uses: djdefi/cloc-action@7
with:
options: --json --report-file=cloc.json
- run: sudo apt-get update && sudo apt-get install --yes jq
- run: sudo apt-get update && sudo apt-get install --yes jq bc
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- run: gem install hoc
- run: |
git fetch --tag
(
printf 'Good news, we have just published the %dth release ' \
printf 'Good news, we have just published the %d-th release ' \
"$(git tag | wc -l | xargs)"
printf 'of [EO-to-Java compiler](https://github.com/objectionary/eo): '
printf '[%s](https://github.com/objectionary/eo/releases/tag/%s). ' \
"${{github.ref_name}}" "${{github.ref_name}}"
printf 'At the moment, there are %d lines-of code ' \
"$(jq '.SUM.code' <cloc.json)"
printf 'and %d [hits-of-code](https://www.yegor256.com/2014/11/14/hits-of-code.html) ' \
"$(hoc .)"
printf 'in the [repository](https://github.com/objectionary/eo) '
printf '(%d Git commits total). ' \
printf 'At the moment, there are %dK lines-of code ' \
"$(echo "$(jq '.SUM.code' <cloc.json)" / 1000 | bc)"
printf 'and %dK [hits-of-code](https://www.yegor256.com/2014/11/14/hits-of-code.html) ' \
"$(echo "$(hoc .)" / 1000 | bc)"
printf 'in the [repository](https://github.com/objectionary/eo) on GitHub '
printf '(%d commits total). ' \
"$(git rev-list --count master)"
printf 'There are %d objects and %d atoms in the runtime. ' \
printf 'Currently, there are %d objects and %d atoms ' \
"$(find eo-runtime/src/main/eo -name '*.eo' | wc -l)" \
"$(find eo-runtime/src/main/java/EOorg -name 'EO*.java' | wc -l)"
printf 'You are welcome to give it a try!'
printf 'in the [eo-runtime](https://github.com/objectionary/eo/tree/master/eo-runtime) module. '
printf 'There are %d open issues in [our backlog](https://github.com/objectionary/eo/issues), ' \
"$(curl --silent 'https://api.github.com/repos/objectionary/eo/issues?state=open&per_page=100' | jq length)"
printf 'please, help us fix them (take those with the "help wanted" badge first).'
) > message.md
- uses: appleboy/telegram-action@master
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import org.eolang.maven.rust.Names;
import org.eolang.maven.rust.RustNode;
import org.eolang.maven.tojos.ForeignTojo;
import org.eolang.parser.ParsingTrain;
import org.eolang.parser.TrParsing;

/**
* Parse rust inserts.
Expand All @@ -67,7 +67,7 @@ public final class BinarizeParse {
* appropriate XSL transformation.
*/
private static final Train<Shift> TRAIN = new TrBulk<>(
new TrClasspath<>(new ParsingTrain().empty()),
new TrClasspath<>(new TrParsing().empty()),
Arrays.asList("/org/eolang/maven/add_rust/add_rust.xsl")
).back().back();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.eolang.maven.optimization.Optimization;
import org.eolang.maven.tojos.ForeignTojo;
import org.eolang.maven.tojos.TojoHash;
import org.eolang.parser.ParsingTrain;
import org.eolang.parser.TrParsing;

/**
* Optimize XML files.
Expand Down Expand Up @@ -143,7 +143,7 @@ private int optimized(final ForeignTojo tojo, final Optimization optimization)
*/
private Optimization optimization() {
final Optimization opt;
final Train<Shift> train = this.measured(new ParsingTrain());
final Train<Shift> train = this.measured(new TrParsing());
if (this.trackOptimizationSteps) {
opt = new OptSpy(
train,
Expand Down
7 changes: 3 additions & 4 deletions eo-maven-plugin/src/main/java/org/eolang/maven/PhiMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.jcabi.xml.XMLDocument;
import com.yegor256.xsline.Shift;
import com.yegor256.xsline.TrClasspath;
import com.yegor256.xsline.TrDefault;
import com.yegor256.xsline.TrJoined;
import com.yegor256.xsline.Train;
import com.yegor256.xsline.Xsline;
Expand All @@ -48,8 +47,8 @@
import org.cactoos.text.TextOf;
import org.eolang.maven.footprint.Saved;
import org.eolang.maven.util.Walk;
import org.eolang.parser.ParsingTrain;
import org.eolang.parser.Schema;
import org.eolang.parser.TrParsing;

/**
* Read XMIR files and translate them to the phi-calculus expression.
Expand Down Expand Up @@ -219,9 +218,9 @@ private int translate(final Path xmir, final Xsline xsline, final int position,
private Train<Shift> train() {
final Train<Shift> train;
if (this.phiOptimize) {
train = new ParsingTrain();
train = new TrParsing();
} else {
train = new TrDefault<>();
train = new com.yegor256.xsline.TrDefault<>();
}
final List<String> dependent = new ListOf<>(
"/org/eolang/parser/critical-errors/duplicate-names.xsl",
Expand Down
13 changes: 8 additions & 5 deletions eo-maven-plugin/src/main/java/org/eolang/maven/UnphiMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.eolang.maven.util.Home;
import org.eolang.maven.util.Walk;
import org.eolang.parser.PhiSyntax;
import org.eolang.parser.TrStepped;
import org.xembly.Directive;
import org.xembly.Directives;

Expand All @@ -65,11 +66,13 @@ public final class UnphiMojo extends SafeMojo {
/**
* Unphi transformations.
*/
private static final Train<Shift> TRANSFORMATIONS = new TrClasspath<>(
"/org/eolang/maven/unphi/wrap-bytes.xsl",
"/org/eolang/parser/wrap-method-calls.xsl",
"/org/eolang/maven/unphi/atoms-with-bound-attrs.xsl"
).back();
private static final Train<Shift> TRANSFORMATIONS = new TrStepped(
new TrClasspath<>(
"/org/eolang/maven/unphi/wrap-bytes.xsl",
"/org/eolang/parser/wrap-method-calls.xsl",
"/org/eolang/maven/unphi/atoms-with-bound-attrs.xsl"
).back()
);

/**
* The directory where to take phi files for parsing from.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ void optimizesSimpleObject(@Mktmp final Path temp) throws Exception {
f.files().file("target/eo/2-optimize/foo.xmir").exists(),
Matchers.is(true)
);
f.files().show();
}
);
}
Expand Down
31 changes: 30 additions & 1 deletion eo-maven-plugin/src/test/java/org/eolang/maven/PhiMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,40 @@ void convertsSimpleObjectToPhi(@Mktmp final Path temp,
f.files().file("target/eo/phi/foo.phi").exists(),
Matchers.is(true)
);
f.files().show();
}
);
}

@Test
void convertsObjectWithSystemType(@Mktmp final Path temp) throws Exception {
new Farea(temp).together(
f -> {
f.clean();
f.files().file("src/main/eo/org/eolang/bytes.eo").write(
String.join(
"\n",
"+package org.eolang",
"",
"# In this program, we define a 'system' object, similar",
"# to how it is defined in org.eolang package, trying to",
"# reproduce the error.",
"[] > bytes",
" $.eq 01- > yes",
""
).getBytes()
);
f.build().plugins().appendItself();
f.exec("eo:register", "eo:parse", "eo:optimize");
f.exec("eo:xmir-to-phi");
}
);
MatcherAssert.assertThat(
"the .phi file is generated",
temp.resolve("target/eo/phi/org/eolang/bytes.phi").toFile().exists(),
Matchers.is(true)
);
}

@Test
void createsFiles(@Mktmp final Path temp) throws Exception {
MatcherAssert.assertThat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ void printsSimpleObject(@Mktmp final Path temp) throws Exception {
f.files().file("target/generated-sources/eo/foo.eo").exists(),
Matchers.is(true)
);
f.files().show();
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,11 @@ void convertsSimpleObjectToGraph(@Mktmp final Path temp) throws Exception {
.execution()
.goals("register", "parse", "optimize", "shake", "sodg");
f.exec("compile");
f.files().show();
MatcherAssert.assertThat(
"the .sodg file is generated",
f.files().file("target/eo/sodg/foo.sodg").exists(),
Matchers.is(true)
);
f.files().show();
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,15 @@ void checksUnphiPacks(final String pack, @Mktmp final Path temp) throws Exceptio
void convertsToXmirAndBack(final String pack, @Mktmp final Path temp) throws Exception {
final Map<String, Object> map = new Yaml().load(pack);
if (map.get("skip") != null) {
Assumptions.abort(
String.format("%s is not ready", pack)
);
Assumptions.abort(String.format("%s is not ready", pack));
}
final String phi = map.get("phi").toString();
final String main = "target/phi/main.phi";
final Path path = Paths.get(main);
new HmBase(temp).save(phi, path);
final long saved = temp.resolve(path).toFile().lastModified();
final FakeMaven maven = new FakeMaven(temp).execute(UnphiMojo.class);
final FakeMaven maven = new FakeMaven(temp)
.execute(UnphiMojo.class);
maven.foreignTojos().add("name")
.withXmir(temp.resolve(String.format("target/%s/main.xmir", ParseMojo.DIR)));
final Path result = maven
Expand All @@ -189,10 +188,8 @@ void convertsToXmirAndBack(final String pack, @Mktmp final Path temp) throws Exc
);
MatcherAssert.assertThat(
"Origin phi should equal to phi got from \"unphied\" xmir, but it isn't",
phi,
Matchers.equalTo(
new TextOf(result).asString()
)
new TextOf(result).asString(),
Matchers.equalTo(phi)
);
}

Expand Down
2 changes: 1 addition & 1 deletion eo-parser/src/main/java/org/eolang/parser/CheckPack.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Collection<String> failures() throws IOException {
final Map<String, Object> map = yaml.load(this.script);
final String src = map.get("eo").toString();
final Iterable<String> xsls = (Iterable<String>) map.get("xsls");
Train<Shift> train = new ParsingTrain();
Train<Shift> train = new TrParsing();
if (xsls != null) {
if (!map.containsKey("defaults")) {
train = train.empty();
Expand Down
Loading
Loading