-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EnsoCompilerTest to verify compatibility of parsers (#3723)
Adding new _compatibility test_ `EnsoCompilerTest` to verify the new Rust based parser can produce the same `IR` as the original `AST` based one. The simplest way to execute the test from an empty repository is: ```bash enso$ sbt bootstrap enso$ sbt "testOnly *EnsoCompilerTest" ``` There are [GitHub Actions run](https://github.com/enso-org/enso/actions/runs/3087664644/jobs/4993266212#step:9:5187) on Linux as well as [run on Windows](https://github.com/enso-org/enso/actions/runs/3087664644/jobs/4993266370#step:9:5254) that show `EnsoCompilerTest` is being executed by the CI (good, as that means `.so` was properly built and linked to the JVM running the test). The [linux](https://github.com/enso-org/enso/actions/runs/3087664644/jobs/4993266212#step:9:5187) as well as [windows](https://github.com/enso-org/enso/actions/runs/3087664644/jobs/4993266370#step:9:5254) runs also demonstrate that failures in the `EnsoCompilerTest` suite fail the CI. # Important Notes Right now [there are five test failures](https://github.com/enso-org/enso/actions/runs/3087664644/jobs/4993266212#step:9:5187) - waiting for @kazcw to make sure `codeRepr()` doesn't contain spaces. However, as this PR is more about the infrastructure, I am disabling the currently failing tests in [031169b](031169b)
- Loading branch information
1 parent
97a28ee
commit 9134f9b
Showing
12 changed files
with
2,347 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
engine/runtime/src/main/java/org/enso/compiler/EnsoCompiler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.enso.compiler; | ||
|
||
import com.oracle.truffle.api.source.Source; | ||
import org.enso.compiler.core.IR; | ||
import org.enso.syntax2.Parser; | ||
import org.enso.syntax2.Tree; | ||
import org.enso.syntax2.UnsupportedSyntaxException; | ||
|
||
public final class EnsoCompiler implements AutoCloseable { | ||
private final Parser parser; | ||
|
||
public EnsoCompiler() { | ||
this.parser = Parser.create(); | ||
} | ||
|
||
@Override | ||
public void close() throws Exception { | ||
this.parser.close(); | ||
} | ||
|
||
IR.Module compile(Source src) throws UnsupportedSyntaxException { | ||
var tree = parse(src); | ||
return generateIR(tree); | ||
} | ||
|
||
Tree parse(Source src) throws UnsupportedSyntaxException { | ||
return parser.parse(src.getCharacters()); | ||
} | ||
|
||
public IR.Module generateIR(Tree t) { | ||
return TreeToIr.MODULE.translate(t); | ||
} | ||
} |
Oops, something went wrong.