Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Apr 13, 2024
2 parents ec05fe3 + 18bdbcf commit af896ac
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 41 deletions.
2 changes: 1 addition & 1 deletion eo-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ SOFTWARE.
<limit>
<counter>CLASS</counter>
<value>MISSEDCOUNT</value>
<maximum>6</maximum>
<maximum>8</maximum>
</limit>
</limits>
</rule>
Expand Down
23 changes: 21 additions & 2 deletions eo-parser/src/main/antlr4/org/eolang/parser/Eo.g4
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ vapplicationArgUnbound
vapplicationArgUnboundCurrent
: vapplicationArgHapplicationUnbound // horizontal application
| vapplicationArgHanonymUnbound // horizontal anonym object
| onlyphi // unnamed abstract object with only @-bound attribute
| justNamed // just an object reference
| methodNamed // method
;
Expand Down Expand Up @@ -336,6 +337,19 @@ hanonym
: attributes hanonymInner+
;

// Unnamed abstract object with only @-bound attribute
// x.y.z > [i] -> [i] (x.y.z > @)
// x y z > [i] -> [i] (x y z > @)
// [a] (b > c) > [i] -> [i] ([a] (b > c) > @)
// x > [i] -> [i] (x > @)
onlyphi
: (hmethod | happlication | hanonym | just) onlyphiTail
;

// Tail of the unnamed abstract object with only @-bound attribute
onlyphiTail: spacedArrow attributes
;

// Inner object of horizontal anonym object
// Does not contan elements in vertical notation
hanonymInner
Expand Down Expand Up @@ -424,11 +438,12 @@ vmethodOptional
// 2. vertical application
// 3. just an object reference
// 4. vertical formation
// 5. unnamed abstract object with only @-bound attribute
// Ends on the next line
vmethodHead
: vmethodHead methodTailOptional vmethodHeadApplicationTail
| vmethodHeadVapplication
| justNamed EOL
| (justNamed | onlyphi) EOL
| formationNamedOrNameless
;

Expand Down Expand Up @@ -501,7 +516,11 @@ oname

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

spacedArrow
: SPACE ARROW SPACE
;

// Simple scope
Expand Down
36 changes: 33 additions & 3 deletions eo-parser/src/main/java/org/eolang/parser/XeEoListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,26 @@ public void exitHanonym(final EoParser.HanonymContext ctx) {
// Nothing here
}

@Override
public void enterOnlyphi(final EoParser.OnlyphiContext ctx) {
this.startAbstract(ctx).enter();
}

@Override
public void exitOnlyphi(final EoParser.OnlyphiContext ctx) {
// Nothing here
}

@Override
public void enterOnlyphiTail(final EoParser.OnlyphiTailContext ctx) {
this.objects.enter().prop("name", "@").leave().leave();
}

@Override
public void exitOnlyphiTail(final EoParser.OnlyphiTailContext ctx) {
// Nothing here
}

@Override
public void enterHanonymInner(final EoParser.HanonymInnerContext ctx) {
this.objects.enter();
Expand Down Expand Up @@ -974,12 +994,12 @@ public void exitVmethodHead(final EoParser.VmethodHeadContext ctx) {

@Override
public void enterMethodTailOptional(final EoParser.MethodTailOptionalContext ctx) {
// Nothing here
// Nothing here
}

@Override
public void exitMethodTailOptional(final EoParser.MethodTailOptionalContext ctx) {
// Nothing here
// Nothing here
}

@Override
Expand Down Expand Up @@ -1142,6 +1162,16 @@ public void exitSuffix(final EoParser.SuffixContext ctx) {
this.objects.leave();
}

@Override
public void enterSpacedArrow(final EoParser.SpacedArrowContext ctx) {
// Nothing here
}

@Override
public void exitSpacedArrow(final EoParser.SpacedArrowContext ctx) {
// Nothing here
}

@Override
public void enterScope(final EoParser.ScopeContext ctx) {
// Nothing here
Expand Down Expand Up @@ -1314,7 +1344,7 @@ private Objects startObject(final ParserRuleContext ctx) {
* Start abstract object.
*
* @param ctx Context
* @return Xembly objects after creating abstract object
* @return Xembly objects after creating abstract object
*/
private Objects startAbstract(final ParserRuleContext ctx) {
return this.startObject(ctx).prop("abstract").leave();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
xsls: []
tests:
- //o[@base='a']/o[@abstract and not(@name) and o[@name='@' and @base='.b'] and o[not(@base) and @name='i']]
- //o[@base='a']/o[@abstract and not(@name) and o[@name='@' and @base='a' and o[@base='b']]]
- //o[@base='a']/o[@abstract and not(@name) and o[@abstract and @name='@' and o[@base='a' and @name='b']] and o[@name='c']]
- //o[@base='a']/o[@abstract and not(@name) and o[@base='d' and @name='@']]
- //o[@abstract and o[@base='z' and @name='@']]/following-sibling::o[@base='.x' and @method]
eo: |
a > x
a.b > [i]
a b > []
[o] (a > b) > [c]
d > []
z > []
.x
3 changes: 1 addition & 2 deletions eo-runtime/src/test/eo/org/eolang/cage-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
[] > stores-abstract-object-into-cage
new. > c
cage
[]
112 > @
112 > []
c.eq 112 > @

# Test.
Expand Down
3 changes: 1 addition & 2 deletions eo-runtime/src/test/eo/org/eolang/goto-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
seq > @
*
go.to
[g2]
g1.forward 42 > @
g1.forward 42 > [g2]
7
42
20 changes: 7 additions & 13 deletions eo-runtime/src/test/eo/org/eolang/memory-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,8 @@
and. > @
eq.
try
[]
m.write 2556 > @
[e]
e > @
m.write 2556 > []
e > [e]
TRUE
2556
m.free
Expand All @@ -146,10 +144,8 @@
and. > @
eq.
try
[]
m.write 82.22 > @
[e]
e > @
m.write 82.22 > []
e > []
TRUE
82.22
m.free
Expand All @@ -160,10 +156,8 @@
and. > @
eq.
try
[]
m.write "Prot" > @
[e]
e > @
m.write "Prot" > []
e > []
TRUE
"Proto"
m.free
Expand All @@ -188,5 +182,5 @@
m.free
try
m
[e] (QQ.io.stdout e > @)
QQ.io.stdout e > [e]
FALSE
24 changes: 8 additions & 16 deletions eo-runtime/src/test/eo/org/eolang/try-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@
"some string"
7
5
[e]
QQ.io.stdout e > @
[]
FALSE > @
QQ.io.stdout e > [e]
FALSE > []

# Test.
[] > two-nested-try-blocks
Expand All @@ -61,8 +59,7 @@
"some string"
7
5
[e]
error e > @
error e > [e]
TRUE
[e]
QQ.io.stdout e > @
Expand All @@ -72,10 +69,8 @@
[] > try-without-error-block
eq. > @
try
[]
30.plus 2 > @
[e]
e > @
30.plus 2 > []
e > [e]
TRUE
32

Expand All @@ -86,10 +81,8 @@
*
m.write 1
try
[]
m.write (m.as-int.plus 1) > @
[e]
e > @
m.write (m.as-int.plus 1) > []
e > [e]
TRUE
and.
m.as-int.eq 2
Expand All @@ -107,8 +100,7 @@
*
5.div 0
m.write (m.plus 1)
[e]
e > @
e > [e]
TRUE
and.
m.eq 1
Expand Down
4 changes: 2 additions & 2 deletions eo-runtime/src/test/eo/org/eolang/while-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
[] > simple-while-with-false-first
while > res
FALSE
[i] (TRUE > @)
TRUE > [i]
(bool res).not > @

# Test.
[] > simple-bool-expression-via-memory-in-while
(memory TRUE).alloc > condition
while > res
condition
[i] (condition.write FALSE > @)
condition.write FALSE > [i]
and. > @
(bool res).not
condition.free
Expand Down

0 comments on commit af896ac

Please sign in to comment.