-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pol compile and ir phase to test runner (#433)
* Add pol compile and ir phase to test runner * Improve pretty-printing of let in ir * Document Failure
- Loading branch information
1 parent
f63e288
commit e83eaae
Showing
59 changed files
with
1,322 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,35 @@ | ||
use std::fs; | ||
use std::path::{Path, PathBuf}; | ||
|
||
use driver::{Database, IR_PATH}; | ||
use printer::{Print, PrintCfg}; | ||
|
||
#[derive(clap::Args)] | ||
pub struct Args { | ||
#[clap(value_parser, value_name = "FILE")] | ||
filepath: PathBuf, | ||
} | ||
|
||
pub async fn exec(cmd: Args) -> miette::Result<()> { | ||
let mut db = Database::from_path(&cmd.filepath); | ||
let uri = db.resolve_path(&cmd.filepath)?; | ||
let ir = db.ir(&uri).await.map_err(|err| db.pretty_error(&uri, err))?; | ||
|
||
if !Path::new(IR_PATH).exists() { | ||
fs::create_dir_all(IR_PATH).expect("Failed to create IR directory"); | ||
} | ||
|
||
let ir_path = target_path(&cmd.filepath); | ||
let mut file = fs::File::create(&ir_path).expect("Failed to create file"); | ||
let cfg = PrintCfg::default(); | ||
ir.print_io(&cfg, &mut file).expect("Failed to print to file"); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn target_path(filepath: &Path) -> PathBuf { | ||
let mut path = | ||
Path::new(IR_PATH).join(filepath.file_name().unwrap().to_string_lossy().as_ref()); | ||
path.set_extension("ir"); | ||
path | ||
} |
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
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
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
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
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
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
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 @@ | ||
codef Id(a) { .ap(a0, b, x) => x } |
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 @@ | ||
codef Compose(a, b, c, f, g) { .ap(a', c', x) => g.ap(b, c, f.ap(a, b, x)) } |
Empty file.
Empty file.
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,6 @@ | ||
def .not { | ||
True => False, | ||
False => True | ||
} | ||
|
||
def .false { Unit => True.not } |
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 @@ | ||
def .foo(a, d) { Unit => d.match { MkD(a0) => MkD(a).match { MkD(x) => MkD(a) } } } |
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,4 @@ | ||
def .foo { | ||
CTrue => Z, | ||
CFalse absurd | ||
} |
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 @@ | ||
def .id(a) { Unit => comatch { .ap(_, _, x1) => x1 } } |
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,6 @@ | ||
def .id { App(e) => App(e) } | ||
|
||
def self.preservation(e2) { | ||
App(e) => | ||
comatch { .ap(_, _, h_eval) => h_eval.match { EBeta(f) => panic!("not yet implemented") } } | ||
} |
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,6 @@ | ||
def .id { App(e) => App(e) } | ||
|
||
def self.preservation(e2) { | ||
App(e) => | ||
comatch { .ap(_, _, h_eval) => h_eval.match { EBeta(f) => panic!("not yet implemented") } } | ||
} |
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,6 @@ | ||
def .foo { | ||
Foo1 => True, | ||
Foo2 absurd, | ||
Foo3 absurd, | ||
Foo4 absurd | ||
} |
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,6 @@ | ||
codef MyFoo { | ||
.foo1 => True, | ||
.foo2 absurd, | ||
.foo3 absurd, | ||
.foo4 absurd | ||
} |
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,6 @@ | ||
let add(x, y) { | ||
x.match { | ||
Z => y, | ||
S(x') => panic!("not yet implemented") | ||
} | ||
} |
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,11 @@ | ||
def .add(y) { | ||
Z => y, | ||
S(x') => S(x'.add(y)) | ||
} | ||
|
||
def .append'(n, m, ys) { | ||
Cons(n', x, xs) => Cons(n'.add(m), x, xs.append'(n', m, ys)), | ||
Nil => ys | ||
} | ||
|
||
let append(n, m, xs, ys) { xs.append'(n, m, ys) } |
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,3 @@ | ||
let transparentTwo { S(S(Z)) } | ||
|
||
let p2 { Refl(<ZST>, S(S(Z))) } |
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,10 @@ | ||
def .and(other) { | ||
True => other, | ||
False => False | ||
} | ||
|
||
let example1 { Cons(True, Nil) } | ||
|
||
let example2 { True.and(False) } | ||
|
||
let example3 { None(<ZST>) } |
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 @@ | ||
let example1 { MkPair(<ZST>, <ZST>, True, False) } |
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 @@ | ||
let example { None(panic!("not yet implemented")) } |
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,6 @@ | ||
def .elim_zero(a) { SNotZero(n) absurd } | ||
|
||
def .elim(a) { | ||
Ok(a0, x) => x, | ||
Absurd(x) => x.elim_zero(<ZST>) | ||
} |
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,12 @@ | ||
def self.rep { | ||
T => TrueRep, | ||
F => FalseRep | ||
} | ||
|
||
def .example(b) { | ||
Unit => | ||
b.match { | ||
T => TrueRep, | ||
F => FalseRep | ||
} | ||
} |
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,7 @@ | ||
def .diverge { Unit => Unit.diverge } | ||
|
||
def .before { Unit => Ignore(Unit.diverge) } | ||
|
||
def .after { Unit => comatch { .ap(a, b, x) => x } } | ||
|
||
codef Ignore(y) { .ap(a, b, x) => x } |
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 @@ | ||
let example { Cons(<ZST>, Unit, Nil(<ZST>)) } |
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,14 @@ | ||
def .id { Unit => comatch { .pi_elim(x, x0, a) => comatch { .ap(x1, x2, x3) => x3 } } } | ||
|
||
def .const { | ||
Unit => | ||
comatch { | ||
.pi_elim(x, x0, a) => | ||
comatch { | ||
.pi_elim(x1, x2, b) => | ||
comatch { .ap(x3, x4, x5) => comatch { .ap(x6, x7, y) => x5 } } | ||
} | ||
} | ||
} | ||
|
||
codef IdType { .ap(x, x0, a) => <ZST> } |
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,4 @@ | ||
def .unwrap(a) { | ||
WrapFoo(x) => x, | ||
WrapBar(x) => x | ||
} |
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,11 @@ | ||
use "../../../std/data/nat.pol" | ||
use "../../../std/data/bool.pol" | ||
|
||
def .iNeg { | ||
T => F, | ||
F => T | ||
} | ||
|
||
let one { S(Z) } | ||
|
||
let true { T } |
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,17 @@ | ||
def .sym(a, x, y) { Refl(a0, x0) => Refl(a, y) } | ||
|
||
def .subst(a, x, y, p) { Refl(a0, x0) => p } | ||
|
||
def .trans(a, x, y, z, h) { Refl(a0, x0) => h } | ||
|
||
def .cong(a, b, x, y, f) { Refl(a0, x0) => Refl(b, f.ap(a, b, y)) } | ||
|
||
def .not { | ||
True => False, | ||
False => True | ||
} | ||
|
||
def self.not_inverse { | ||
True => Refl(<ZST>, True), | ||
False => Refl(<ZST>, False) | ||
} |
Oops, something went wrong.