Skip to content

Commit

Permalink
Merge pull request #2877 from objectionary/2873
Browse files Browse the repository at this point in the history
disable comments for anonymous abstract objects at XMIR-to-EO generation
  • Loading branch information
yegor256 authored Feb 15, 2024
2 parents 1f66aa8 + 40ca4ab commit b7423b0
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ void printsSuccessfully(@TempDir final Path temp) throws Exception {

@ParameterizedTest
@ClasspathSource(value = "org/eolang/maven/print/samples/", glob = "**.yaml")
void printsInStraitNotation(final String pack, @TempDir final Path temp) throws Exception {
void printsInStraightNotation(final String pack, @TempDir final Path temp) throws Exception {
final Map<String, Object> yaml = new Yaml().load(pack);
MatcherAssert.assertThat(
"PrintMojo should print EO in strait notation, but it didn't",
"PrintMojo should print EO in straight notation, but it didn't",
PrintMojoTest.printed(yaml, temp, false).asString(),
Matchers.equalTo((String) yaml.get("strait"))
Matchers.equalTo((String) yaml.get("straight"))
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
origin: |
EA-EA-EA-EA > xs
"hello" > ys
TRUE > b1
FALSE > b2
strait: |
straight: |
EA-EA-EA-EA > xs
"hello" > ys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ origin: |
input-of
args.at not-a-number
strait: |
straight: |
+package sandbox
# This is the default 64+ symbols comment in front of named abstract object.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
origin: |
-- > empty
strait: |
straight: |
-- > empty
reversed: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ origin: |
QQ.io.stdout > @
QQ.txt.sprintf ""
strait: |
straight: |
# This is the default 64+ symbols comment in front of named abstract object.
[] > app
QQ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ origin: |
n
"hello, 大家!"
strait: |
straight: |
# This is the license part
# of the program
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ origin: |
+alias stdout org.eolang.io.stdout
+alias sprintf org.eolang.txt.sprintf
+architect [email protected]
# This is the default 64+ symbols comment in front of named abstract object.
[] > base
memory 0 > x
Expand All @@ -26,12 +26,12 @@ origin: |
self
v
strait: |
straight: |
+package sandbox
+alias stdout org.eolang.io.stdout
+alias sprintf org.eolang.txt.sprintf
+architect [email protected]
# This is the default 64+ symbols comment in front of named abstract object.
[] > base
memory > x
Expand Down Expand Up @@ -63,7 +63,7 @@ reversed: |
+alias stdout org.eolang.io.stdout
+alias sprintf org.eolang.txt.sprintf
+architect [email protected]
# This is the default 64+ symbols comment in front of named abstract object.
[] > base
memory > x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ origin: |
[] > foo
2.18 > e
strait: |
straight: |
3.14 > pi
# This is the default 64+ symbols comment in front of named abstract object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ origin: |
it's me
"""
strait: |
straight: |
# This is the default 64+ symbols comment in front of named abstract object.
[] > app
QQ
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
origin: |
* 1 "Hello" x > array
strait: |
straight: |
* > array
1
"Hello"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ origin: |
"result is %d\n"
-1.times 228
strait: |
straight: |
# This is the default 64+ symbols comment in front of named abstract object.
[] > app
QQ
Expand Down
2 changes: 1 addition & 1 deletion eo-parser/src/main/java/org/eolang/parser/xmir/Xmir.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public interface Xmir {
String toEO();

/**
* Default Xmir that prints EO with strait vertical methods.
* 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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ SOFTWARE.
<!-- ABSTRACT OR ATOM -->
<xsl:template match="o[not(@data) and not(@base)]" mode="head">
<xsl:param name="indent"/>
<xsl:value-of select="$comment"/>
<xsl:value-of select="$indent"/>
<xsl:if test="@name">
<xsl:value-of select="$comment"/>
<xsl:value-of select="$indent"/>
</xsl:if>
<xsl:text>[</xsl:text>
<xsl:for-each select="o[eo:attr(.)]">
<xsl:if test="position()&gt;1">
Expand Down
8 changes: 5 additions & 3 deletions eo-parser/src/main/resources/org/eolang/parser/xmir-to-eo.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" id="xmir-to-eo" version="2.0">
<!--
This one maps XMIR to EO original syntax in strait notation.
This one maps XMIR to EO original syntax in straight notation.
It's used in Xmir.java class.
-->
<xsl:import href="/org/eolang/parser/_funcs.xsl"/>
Expand Down Expand Up @@ -124,8 +124,10 @@ SOFTWARE.
<!-- ABSTRACT OR ATOM -->
<xsl:template match="o[not(@data) and not(@base)]" mode="head">
<xsl:param name="indent"/>
<xsl:value-of select="$comment"/>
<xsl:value-of select="$indent"/>
<xsl:if test="@name">
<xsl:value-of select="$comment"/>
<xsl:value-of select="$indent"/>
</xsl:if>
<xsl:text>[</xsl:text>
<xsl:for-each select="o[eo:attr(.)]">
<xsl:if test="position()&gt;1">
Expand Down
8 changes: 4 additions & 4 deletions eo-parser/src/test/java/org/eolang/parser/xmir/XmirTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
final class XmirTest {
@ParameterizedTest
@ClasspathSource(value = "org/eolang/parser/samples/", glob = "**.yaml")
void printsStrait(final String pack) throws IOException {
void printsStraight(final String pack) throws IOException {
final Map<String, Object> map = new Yaml().load(pack);
final String key = "strait";
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",
Expand Down Expand Up @@ -103,9 +103,9 @@ private String eolang(
first,
Matchers.not(XhtmlMatchers.hasXPath("//errors/error"))
);
Logger.debug(this, "First:%n%s", first);
Logger.info(this, "First:%n%s", first);
final String eolang = xmir.apply(first).toEO();
Logger.debug(this, "EOLANG:%n%s", eolang);
Logger.info(this, "EOLANG:%n%s", eolang);
return eolang;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
origin: |
EA-EA-EA-EA > xs
"hello" > ys
TRUE > b1
FALSE > b2
strait: |
straight: |
EA-EA-EA-EA > xs
"hello" > ys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ origin: |
input-of
args.at not-a-number
strait: |
straight: |
+package sandbox
# This is the default 64+ symbols comment in front of named abstract object.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
origin: |
-- > empty
strait: |
straight: |
-- > empty
reversed: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ origin: |
QQ.io.stdout > @
QQ.txt.sprintf ""
strait: |
straight: |
# This is the default 64+ symbols comment in front of named abstract object.
[] > app
QQ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ origin: |
n
"hello, 大家!"
strait: |
straight: |
# This is the license part
# of the program
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ origin: |
+alias stdout org.eolang.io.stdout
+alias sprintf org.eolang.txt.sprintf
+architect [email protected]
# This is the default 64+ symbols comment in front of named abstract object.
[] > base
memory 0 > x
Expand All @@ -26,12 +26,12 @@ origin: |
self
v
strait: |
straight: |
+package sandbox
+alias stdout org.eolang.io.stdout
+alias sprintf org.eolang.txt.sprintf
+architect [email protected]
# This is the default 64+ symbols comment in front of named abstract object.
[] > base
memory > x
Expand Down Expand Up @@ -63,7 +63,7 @@ reversed: |
+alias stdout org.eolang.io.stdout
+alias sprintf org.eolang.txt.sprintf
+architect [email protected]
# This is the default 64+ symbols comment in front of named abstract object.
[] > base
memory > x
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
origin: |
# This is the default 64+ symbols comment in front of named abstract object.
[] > foo
test
[]
"hello, world!" > @
straight: |
# This is the default 64+ symbols comment in front of named abstract object.
[] > foo
test
[]
"hello, world!" > @
reversed: |
# This is the default 64+ symbols comment in front of named abstract object.
[] > foo
test
[]
"hello, world!" > @
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ origin: |
[] > foo
2.18 > e
strait: |
straight: |
3.14 > pi
# This is the default 64+ symbols comment in front of named abstract object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ origin: |
it's me
"""
strait: |
straight: |
# This is the default 64+ symbols comment in front of named abstract object.
[] > app
QQ
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
origin: |
* 1 "Hello" x > array
strait: |
straight: |
* > array
1
"Hello"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ origin: |
"result is %d\n"
-1.times 228
strait: |
straight: |
# This is the default 64+ symbols comment in front of named abstract object.
[] > app
QQ
Expand Down

0 comments on commit b7423b0

Please sign in to comment.