-
Notifications
You must be signed in to change notification settings - Fork 177
bug(#4559): auto phi formation correctly parsed with application precedences #4560
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
base: master
Are you sure you want to change the base?
Changes from 15 commits
06c4813
9bdb52f
da64738
554385c
d2f2257
2ebe627
32c2eec
18aeaaf
96763d6
eb1c1eb
d36d73f
e2a0396
ece0c48
7bedfad
82cd9ba
d9bea33
4ae096f
ac2de15
0971a90
82f1cb7
a67b94b
cfc1e13
f384915
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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). | ||
| */ | ||
|
|
@@ -1210,10 +1217,21 @@ 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)); | ||
|
||
| } while (matcher.find()); | ||
| } else if (application.startsWith("Q.")) { | ||
| abase = application.replace("Q.", "Φ."); | ||
| } else { | ||
h1alexbel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| abase = String.format("ξ.ρ.%s", application); | ||
h1alexbel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| this.startAbstract(ctx) | ||
| .enter().prop("name", new AutoName(ctx, "p").asString()) | ||
| .start(ctx) | ||
| .prop("base", String.format("ξ.ρ.%s", application)) | ||
| .prop("base", abase) | ||
| .prop("name", "φ"); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # 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[2][@name='x' and @base='∅' and not(@as)] and o[3][@name='φ' and @base='Φ.a.bca.eaa.boom']/o[1][@base='Φ.org.eolang.number']] | ||
| input: | | ||
| [] > foo | ||
| start > @ | ||
| Q.a.bca.eaa.boom 42 >> [x] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # 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='.j']/o[@base='.i']/o[@base='Φ.org.eolang.txt.text']/o[@base='ξ.ρ.args']] | ||
| - //o[@base='.i' and not(@name)]/o[2][@base='Φ.org.foo.b'] | ||
| input: | | ||
| [args] > main | ||
| foo > app | ||
| ((Q.org.eolang.txt.text args).i Q.org.foo.b).j >> [y] |
| 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! |
Uh oh!
There was an error while loading. Please reload this page.