Skip to content

Commit

Permalink
fix(#2769): remove bidning with VTX name
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Jan 12, 2024
1 parent 0711edd commit 3cb3852
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
@@ -0,0 +1,4 @@
tests:
- /program/objects[count(o)=1]/o[@name='app']
phi:
"{ ν ↦ ⟦ Δ ⤍ 01- ⟧, app ↦ ⟦ ν ↦ ⟦ Δ ⤍ 00- ⟧, args ↦ ∅, φ ↦ Φ.org.eolang.io.stdout (α0 ↦ Φ.org.eolang.string (α0 ↦ Φ.org.eolang.bytes (Δ ⤍ 48-65-6C-6C-6F-2C-20-77-6F-72-6C-64-21-0A))) ⟧ }"
@@ -0,0 +1,4 @@
tests:
- /program/objects[count(o)=1]/o[@name='x']
phi:
"{ν ↦ ⟦Δ ⤍ 01-⟧, x ↦ ⟦z ↦ ξ.y⟧}"
12 changes: 12 additions & 0 deletions eo-parser/src/main/java/org/eolang/parser/Objects.java
Expand Up @@ -89,6 +89,12 @@ interface Objects extends Iterable<Directive> {
*/
Objects leave();

/**
* Remove current object.
* @return Self.
*/
Objects remove();

/**
* Xembly object tree.
* @since 0.1
Expand Down Expand Up @@ -147,6 +153,12 @@ public Objects leave() {
return this;
}

@Override
public Objects remove() {
this.dirs.remove();
return this;
}

@Override
public Iterator<Directive> iterator() {
return this.dirs.iterator();
Expand Down
17 changes: 14 additions & 3 deletions eo-parser/src/main/java/org/eolang/parser/XePhiListener.java
Expand Up @@ -201,9 +201,20 @@ public void enterBinding(final PhiParser.BindingContext ctx) {

@Override
public void exitBinding(final PhiParser.BindingContext ctx) {
if ((ctx.alphaBinding() != null || ctx.emptyBinding() != null)
&& this.objs.size() > this.packages.size()) {
this.objects().leave();
if (this.objs.size() > this.packages.size()) {
if (ctx.alphaBinding() != null) {
if (ctx.alphaBinding().attribute().VTX() != null) {
this.objects().remove();
} else {
this.objects().leave();
}
} else if (ctx.emptyBinding() != null) {
if (ctx.emptyBinding().attribute().VTX() != null) {
this.objects().remove();
} else {
this.objects().leave();
}
}
}
}

Expand Down

0 comments on commit 3cb3852

Please sign in to comment.