Skip to content
Draft
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
06c4813
test(eo-parser): add test case for auto phi formation with applicatio…
h1alexbel Sep 17, 2025
9bdb52f
test: update test cases to reflect new auto phi formation behavior wi…
h1alexbel Sep 17, 2025
da64738
refactor(XeEoListener): rename APPLICATION_PRECEDENCE to A_PRECEDENCE…
h1alexbel Sep 17, 2025
554385c
bug(#4559): add new transpile pack for auto phi formation with applic…
h1alexbel Sep 17, 2025
d2f2257
bug(#4559): add new transpile pack for auto phi formation with applic…
h1alexbel Sep 17, 2025
2ebe627
bug(#4559): last application
h1alexbel Sep 17, 2025
32c2eec
bug(#4559): add auto-phi-with-application-precendence.yaml test resou…
h1alexbel Sep 19, 2025
18aeaaf
bug(#4559): refine XSL template to exclude positioned objects from au…
h1alexbel Sep 19, 2025
96763d6
bug(#4559): typo
h1alexbel Sep 19, 2025
eb1c1eb
bug(#4559): test case
h1alexbel Sep 22, 2025
d36d73f
bug(#4559): handle fully qualified names in auto-phi formation by str…
h1alexbel Sep 22, 2025
e2a0396
chore(#4559): remove empty line from test resource file
h1alexbel Sep 22, 2025
ece0c48
empty commit to restart pipelines
h1alexbel Sep 22, 2025
7bedfad
bug(#4559): add test case for auto phi formation from FQN precedence …
h1alexbel Sep 24, 2025
82cd9ba
bug(#4559): simplify Q-prefixed application handling by replacing Q w…
h1alexbel Sep 24, 2025
d9bea33
empty commit to restart pipelines
h1alexbel Sep 24, 2025
4ae096f
bug(#4559): auto-phi formation from application with \rho
h1alexbel Sep 25, 2025
ac2de15
bug(#4559): extend identifier pattern to support Unicode letters and …
h1alexbel Sep 25, 2025
0971a90
bug(#4559): redundant loop
h1alexbel Sep 25, 2025
82f1cb7
bug(#4559): typo
h1alexbel Sep 25, 2025
a67b94b
bug(#4559): add support for QQ prefix in EO applications to map to Φ.…
h1alexbel Sep 25, 2025
cfc1e13
bug(#4559): add test case for auto phi formation from nested application
h1alexbel Sep 25, 2025
f384915
bug(#4559): skip auto-phi formation test due to parsing issues with n…
h1alexbel Sep 25, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
# yamllint disable rule:line-length
out: []
file: org/eolang/snippets/foo.eo
args: ["org.eolang.snippets.foo"]
eo: |
+alias org.eolang.io.stdout
+alias org.eolang.txt.text
+alias org.eolang.structs.list
+package org.eolang.snippets

[] > foo
"abcdefghijk" > origin
origin > @
[cont-list] > custom-map
mapped. > @
cont-list
(text orgn).contains x >> [x]
origin > orgn!

[] +> test-custom-map
eq. > @
list (* true true)
foo.custom-map (list (* "abc" "ghi"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
# yamllint disable rule:line-length
sheets:
- /org/eolang/maven/transpile/set-locators.xsl
- /org/eolang/maven/transpile/set-original-names.xsl
- /org/eolang/maven/transpile/classes.xsl
- /org/eolang/maven/transpile/tests.xsl
- /org/eolang/maven/transpile/attrs.xsl
- /org/eolang/maven/transpile/data.xsl
- /org/eolang/maven/transpile/to-java.xsl
asserts:
- /object[not(errors)]
- //java[contains(text(), 'Φ.custom-map.ap🌵46.φ')]
- //java[contains(text(), 'Φ.custom-map.ap🌵46.φ.ρ.ρ.α0')]
- //java[contains(text(), 'Phi rrbb = Phi.Φ.take("org").take("eolang").take("text");')]
- //java[contains(text(), 'rrbb1 = new PhMethod(rrbb1, "orgn");')]
- //java[contains(text(), 'Phi rrb = new PhMethod(rrbb, "what");')]
- //java[contains(text(), 'Phi rrb1 = Phi.Φ.take("org").take("eolang").take("b");')]
- //java[contains(text(), 'Phi rr = new PhMethod(rrb, "ttt");')]
input: |
[cont-list] > custom-map
mapped. > @
cont-list
((text orgn).what b).ttt >> [y]
origin > orgn!
18 changes: 17 additions & 1 deletion eo-parser/src/main/java/org/eolang/parser/XeEoListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.Token;
Expand All @@ -35,6 +37,11 @@
"PMD.GodClass"
})
final class XeEoListener implements EoListener, Iterable<Directive> {
/**
* Last application.
*/
private static final Pattern LAST_APPLICATION = Pattern.compile("\\)\\.([a-zA-Z_]\\w*)$");

/**
* Xembly directives we are building (mutable).
*/
Expand Down Expand Up @@ -1210,10 +1217,19 @@ private String alphaAttr(final ParserRuleContext ctx, final String msg) {
* @param application Application base
*/
private void startAutoPhiFormation(final ParserRuleContext ctx, final String application) {
final Matcher matcher = XeEoListener.LAST_APPLICATION.matcher(application);
String abase;
if (matcher.find()) {
do {
abase = String.format(".%s", matcher.group(1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h1alexbel what if the base would be something like this: ^.x.^.y.^.z? You'll reduce it to z and append $.^. in front of it?

Copy link
Member Author

@h1alexbel h1alexbel Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxonfjvipon we won't reduce it, but will append the base "as is" to the ξ.ρ., so it looks like this: ξ.ρ.ρ.x.ρ.y.ρ.z. Should we remove first ρ. part from the start in this case, so the final one will look like ξ.ρ.x.ρ.y.ρ.z?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h1alexbel all this stuff with appending $.^ is not correct by default, we have a corresponding XSL transformation which does all of this if it's necessary. The main part of parsing this block is to properly create formation with auto name and with @ attribute and save everything else unchanged and leave it to the further processing

Copy link
Member Author

@h1alexbel h1alexbel Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxonfjvipon sometimes we need add redundant ξ.ρ in auto Phi formations to correctly processed by auto-phi-formation-restruct.xsl, especially on this line:

<!-- Remove redundant ξ.X for void attributes, located inside the auto-phi formation -->
<xsl:template match="o[starts-with(@base,'ξ.') and not(@pos) and ancestor::o[contains(@name,'ap🌵')][descendant::o[@base='∅' and @name=substring-after(current()/@base,'ξ.')]]]"/>

Once we solve this puzzle, we can get rid of this sheet and appending ξ.ρ to the application base. WDYT? Am I missing something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h1alexbel I think all of this stuff is over engineered and we're shooting to our leg by introducing such crutches. I strongly believe all of this auto naming processing can be done in XeListener without any regexp and further XSL processing, because you have two entry points for each AST element: enter and exit. It should be implemented much simpler in general

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h1alexbel Let's resolve that puzzle first so we create right XML in XeListener for auto named formation with phi without further XSL processing and ap prefixes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's resolve that puzzle first so we create right XML in XeListener for auto named formation with phi without further XSL processing and ap prefixes

@maxonfjvipon in this PR, right? Or we can merge this one, and resolve #4557 in parallel?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h1alexbel let's resolve #4557 first

} while (matcher.find());
} else {
abase = String.format("ξ.ρ.%s", application);
}
this.startAbstract(ctx)
.enter().prop("name", new AutoName(ctx, "p").asString())
.start(ctx)
.prop("base", String.format("ξ.ρ.%s", application))
.prop("base", abase)
.prop("name", "φ");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@
</xsl:copy>
</xsl:template>
<!-- Remove redundant ξ.X for void attributes, located inside the auto-phi formation -->
<xsl:template match="o[starts-with(@base,'ξ.') and ancestor::o[contains(@name,'ap🌵')][descendant::o[@base='∅' and @name=substring-after(current()/@base,'ξ.')]]]"/>
<xsl:template match="o[starts-with(@base,'ξ.') and not(@pos) and ancestor::o[contains(@name,'ap🌵')][descendant::o[@base='∅' and @name=substring-after(current()/@base,'ξ.')]]]"/>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
# yamllint disable rule:line-length
sheets: []
asserts:
- /object[not(errors)]
- //o[not(@base) and @name='ap🌵34' and o[@name='φ' and @base='.ttt']/o[@base='.what']/o[@base='Φ.org.eolang.text']/o[@base='ξ.ρ.orgn']]
- //o[not(@base) and @name='ap🌵54' and o[@name='φ' and @base='.g']/o[@base='.e']/o[@base='.c']]
- //o[not(@base) and @name='ap🌵86' and o[@name='φ' and @base='.contains']/o[@base='Φ.org.eolang.text']/o[@base='ξ.ρ.orgn']]
- //o[not(@base) and @name='ap🌵86' and o[@name='φ' and @base='.contains']/o[@base='ξ.x']]
input: |
[cont-list] > custom-map
foo > boom
((text orgn).what b).ttt >> [y]
bar > dummy
(((a b).c d).e f).g >> [v]
mapped. > @
cont-list
(text orgn).contains x >> [x]
origin > orgn!
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
sheets: []
asserts:
- /object[not(errors)]
- //o[not(@base) and @name='a🌵34' and o[2][@name='i' and @base='∅'] and o[3][@name='φ']]
- //o[@base='Φ.org.eolang.foo' and o[@base='ξ.a🌵34']]
- //o[not(@base) and @name='ap🌵34' and o[2][@name='i' and @base='∅'] and o[3][@name='φ']]
- //o[@base='Φ.org.eolang.foo' and o[@base='ξ.ap🌵34']]
input: |
[] > main
foo > @
Expand Down
Loading