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

fix(#3073): removed explicit copying from EO #3077

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
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,6 @@ SOFTWARE.
<xsl:value-of select="eo:specials(@base, false())"/>
</xsl:otherwise>
</xsl:choose>
<!-- Copy -->
<xsl:if test="@copy">
<xsl:text>()</xsl:text>
</xsl:if>
<!-- Nested objects -->
<xsl:if test="count(o)&gt;0">
<xsl:text>(</xsl:text>
Expand All @@ -313,10 +309,6 @@ SOFTWARE.
<xsl:with-param name="package" select="$package"/>
</xsl:apply-templates>
<xsl:value-of select="eo:specials(@base, true())"/>
<!-- Copy -->
<xsl:if test="@copy">
<xsl:text>()</xsl:text>
</xsl:if>
<!-- Nested objects -->
<xsl:if test="count(o)&gt;1">
<xsl:text>(</xsl:text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,6 @@ SOFTWARE.
<xsl:with-param name="indent" select="$indent"/>
<xsl:with-param name="rho" select="$rho"/>
</xsl:apply-templates>
<xsl:apply-templates select=".[@copy]" mode="copy">
<xsl:with-param name="name" select="$name"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:apply-templates>
<xsl:apply-templates select="." mode="located">
<xsl:with-param name="name" select="$name"/>
<xsl:with-param name="indent" select="$indent"/>
Expand Down Expand Up @@ -434,22 +430,6 @@ SOFTWARE.
<xsl:with-param name="skip" select="1"/>
<xsl:with-param name="rho" select="$rho"/>
</xsl:apply-templates>
<xsl:apply-templates select=".[@copy]" mode="copy">
<xsl:with-param name="name" select="$name"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:apply-templates>
</xsl:template>
<!-- Empty application -->
<xsl:template match="o[@copy]" mode="copy">
<xsl:param name="indent"/>
<xsl:param name="name"/>
<xsl:value-of select="$indent"/>
<xsl:value-of select="eo:tabs(1)"/>
<xsl:value-of select="$name"/>
<xsl:text> = new PhCopy(</xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>);</xsl:text>
<xsl:value-of select="eo:eol(0)"/>
</xsl:template>
<!-- Location of object -->
<xsl:template match="*" mode="located">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ eo: |
[z] > main
# This is the default 64+ symbols comment in front of named abstract object.
[] > x
seq' > y
seq > y
phi: |
{
main ↦ ⟦
z ↦ ∅,
x ↦ ⟦⟧,
y ↦ Φ.org.eolang.seq()
y ↦ Φ.org.eolang.seq
}
32 changes: 14 additions & 18 deletions eo-parser/src/main/antlr4/org/eolang/parser/Eo.g4
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ master
;

// Just an object reference without name
just: beginner
| finisherCopied
just: beginnerOrFinisher
| versioned
;

Expand Down Expand Up @@ -160,7 +159,8 @@ happlicationHeadExtended
// Simple statements that can be used as head of application
applicable
: STAR
| (NAME | AT) COPY?
| NAME
| PHI
;

// Horizontal application tail
Expand All @@ -182,8 +182,7 @@ happlicationTailReversedFirst
// Argument of horizontal application
// Does not contain elements in vertical notation
happlicationArg
: beginner
| finisherCopied
: beginnerOrFinisher
| hmethod
| scope
;
Expand Down Expand Up @@ -391,15 +390,13 @@ hmethodExtendedVersioned

// Head of horizontal method
hmethodHead
: beginner
| finisherCopied
: beginnerOrFinisher
| scope
;

// Extended head of horizontal method
hmethodHeadExtended
: beginner
| finisherCopied
: beginnerOrFinisher
| scope
;

Expand Down Expand Up @@ -454,7 +451,7 @@ vmethodHeadVapplication

// Tail of method
methodTail
: DOT finisherCopied
: DOT finisher
;

// Versioned tail of method
Expand All @@ -475,14 +472,15 @@ beginner
// Can start or finish the statement
finisher
: NAME
| AT
| PHI
| RHO
| SIGMA
;

// Finisher with optional COPY
finisherCopied
: finisher COPY?
// Beginner or finisher
beginnerOrFinisher
: beginner
| finisher
;

// Name with optional version
Expand All @@ -503,7 +501,7 @@ oname

// Suffix
suffix
: SPACE ARROW SPACE (AT | NAME)
: SPACE ARROW SPACE (PHI | NAME)
;

// Simple scope
Expand Down Expand Up @@ -554,8 +552,6 @@ SLASH
COLON
: ':'
;
COPY: '\''
;
ARROW
: '>'
;
Expand Down Expand Up @@ -585,7 +581,7 @@ LB : '('
;
RB : ')'
;
AT : '@'
PHI : '@'
;
RHO : '^'
;
Expand Down
19 changes: 7 additions & 12 deletions eo-parser/src/main/java/org/eolang/parser/XeEoListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,17 +496,14 @@ public void enterApplicable(final EoParser.ApplicableContext ctx) {
this.objects.prop("star");
} else if (ctx.NAME() != null) {
base = ctx.NAME().getText();
} else if (ctx.AT() != null) {
} else if (ctx.PHI() != null) {
base = "@";
} else {
base = "";
}
if (!base.isEmpty()) {
this.objects.prop("base", base);
}
if (ctx.COPY() != null) {
this.objects.prop("copy");
}
this.objects.leave();
}

Expand Down Expand Up @@ -1068,7 +1065,7 @@ public void enterFinisher(final EoParser.FinisherContext ctx) {
final String base;
if (ctx.NAME() != null) {
base = ctx.NAME().getText();
} else if (ctx.AT() != null) {
} else if (ctx.PHI() != null) {
base = "@";
} else if (ctx.RHO() != null) {
base = "^";
Expand All @@ -1088,15 +1085,13 @@ public void exitFinisher(final EoParser.FinisherContext ctx) {
}

@Override
public void enterFinisherCopied(final EoParser.FinisherCopiedContext ctx) {
public void enterBeginnerOrFinisher(final EoParser.BeginnerOrFinisherContext ctx) {
// Nothing here
}

@Override
public void exitFinisherCopied(final EoParser.FinisherCopiedContext ctx) {
if (ctx.COPY() != null) {
this.objects.enter().prop("copy").leave();
}
public void exitBeginnerOrFinisher(final EoParser.BeginnerOrFinisherContext ctx) {
// Nothing here
}

@Override
Expand Down Expand Up @@ -1135,8 +1130,8 @@ public void exitOname(final EoParser.OnameContext ctx) {
@SuppressWarnings("PMD.ConfusingTernary")
public void enterSuffix(final EoParser.SuffixContext ctx) {
this.objects.enter();
if (ctx.AT() != null) {
this.objects.prop("name", ctx.AT().getText());
if (ctx.PHI() != null) {
this.objects.prop("name", ctx.PHI().getText());
} else if (ctx.NAME() != null) {
this.objects.prop("name", ctx.NAME().getText());
}
Expand Down
1 change: 0 additions & 1 deletion eo-parser/src/main/resources/XMIR.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ SOFTWARE.
<xs:attribute name="abstract" type="empty"/>
<xs:attribute name="method" type="empty"/>
<xs:attribute name="const" type="empty"/>
<xs:attribute name="copy" type="empty"/>
</xs:complexType>
<xs:complexType name="program">
<xs:sequence>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,8 @@ SOFTWARE.
</xsl:for-each>
<xsl:text>]</xsl:text>
</xsl:template>
<!-- TAIL: SUFFIX, NAME, CONST, COPY, ATOM -->
<!-- TAIL: SUFFIX, NAME, CONST, ATOM -->
<xsl:template match="o" mode="tail">
<xsl:if test="@copy">
<xsl:text>'</xsl:text>
</xsl:if>
<xsl:if test="@as">
<xsl:text>:</xsl:text>
<xsl:value-of select="@as"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,8 @@ SOFTWARE.
</xsl:for-each>
<xsl:text>]</xsl:text>
</xsl:template>
<!-- TAIL: SUFFIX, NAME, CONST, COPY, ATOM -->
<!-- TAIL: SUFFIX, NAME, CONST, ATOM -->
<xsl:template match="o" mode="tail">
<xsl:if test="@copy">
<xsl:text>'</xsl:text>
</xsl:if>
<xsl:if test="@as">
<xsl:text>:</xsl:text>
<xsl:value-of select="@as"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
xsls: []
tests:
- /program/errors[count(error)=0]
- /program/license[text()!='']
- /program/metas[count(meta)=4]
- /program/metas/meta[head='foo' and tail='']
Expand Down Expand Up @@ -43,7 +44,7 @@ eo: |
z
f
12:foo
((t' r 8.54 "yes" "\t").print 88 0x1f):hey
((t r 8.54 "yes" "\t").print 88 0x1f):hey
TRUE:vtx
false:fle > a!
[]
Expand All @@ -58,8 +59,8 @@ eo: |
q
.w
.e:qwerty > qwe
f'
z'
f
z
(z 5):0
z:1
a.
Expand Down Expand Up @@ -93,21 +94,21 @@ eo: |
t.o
.two "hello!"
.three > a1
.four (a b c') > a2
.four (a b c) > a2
.five > a3

test
me
(now (f (f (f (f 1)))).f):i

# This is the default 64+ symbols comment in front of abstract object
# This is the default 64+ symbols comment in front of abstract object.
[] > ooo
# This is one
# This is the default 64+ symbols comment in front of abstract object
# This is the default 64+ symbols comment in front of abstract object.
[] > o-1 /?

# This is two
# This is the default 64+ symbols comment in front of abstract object
# This is the default 64+ symbols comment in front of abstract object.
[] > o2

-2.4E3 > x
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
line: 6
line: 1
eo: |
# This is the default 64+ symbols comment in front of abstract object
[args] > app
Expand Down
10 changes: 0 additions & 10 deletions eo-runtime/src/test/eo/org/eolang/runtime-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,6 @@
64
a.free

# Test.
[] > copy-object-with-dot
# Book.
[] > book
"qwerty" > title
book.title' > copy-title
eq. > @
copy-title
"qwerty"

# Test.
[] > parent-in-vertical-notation
(memory 5).alloc > m
Expand Down
Loading