Skip to content

Commit

Permalink
fix(#2787): grammar + test
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Jan 17, 2024
1 parent a178c59 commit 7b591f4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.yaml.snakeyaml.Yaml;

/**
Expand Down Expand Up @@ -144,8 +145,9 @@ void convertsToXmirAndBack(final String pack, @TempDir final Path temp) throws E
);
}

@Test
void convertsValidXmirAndParsableEO(@TempDir final Path temp) throws IOException {
@ParameterizedTest
@CsvSource({"true", "false"})
void convertsValidXmirAndParsableEO(final boolean reversed, @TempDir final Path temp) throws Exception {
final Map<String, Path> map = new FakeMaven(temp)
.withProgram(
"[args] > app",
Expand All @@ -154,6 +156,7 @@ void convertsValidXmirAndParsableEO(@TempDir final Path temp) throws IOException
)
.with("printSourcesDir", temp.resolve("target/1-parse").toFile())
.with("printOutputDir", temp.resolve("target/generated-sources").toFile())
.with("printReversed", reversed)
.execute(ParseMojo.class)
.execute(OptimizeMojo.class)
.execute(PhiMojo.class)
Expand Down
16 changes: 7 additions & 9 deletions eo-parser/src/main/antlr4/org/eolang/parser/Eo.g4
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,8 @@ vapplication
// Vertical application head
vapplicationHead
: applicable
| hmethodExtended
| hmethodExtendedVersioned
| vmethod
| vmethodVersioned
| hmethodOptional
| vmethodOptional
| versioned
;

Expand All @@ -193,6 +191,11 @@ vapplicationHeadNamed
: vapplicationHead oname?
;

// Vertical application head with binding
vapplicationHeadAs
: vapplicationHead as
;

// Vertical application arguments
vapplicationArgs
: EOL
Expand Down Expand Up @@ -245,11 +248,6 @@ vapplicationArgHapplicationUnbinded
: happlicationExtended oname?
;

// Vertical application head with binding
vapplicationHeadAs
: (applicable | hmethodOptional | versioned) as
;

// Vertical anonym object as argument of vertical application
vapplicationArgVanonymUnbinded
: attributes oname? formatees?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,18 @@ eo: |
.b:0
c
.d
.e:1
.e:1
Q
.org
.eolang
.io
.stdout > third
Q
.org
.eolang
.string:0
Q.
.org
.eolang
.bytes
00-AX-23

0 comments on commit 7b591f4

Please sign in to comment.