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

More lm to lsts 3 #1069

Merged
merged 8 commits into from
Jan 12, 2025
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
46,370 changes: 23,007 additions & 23,363 deletions BOOTSTRAP/cli.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lambda_mountain"
version = "1.20.4"
version = "1.20.5"
authors = ["Andrew <andrew@subarctic.org>"]
license = "MIT"
description = "Typed Macro Assembler (backed by Coq proofs-of-correctness)"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

dev: install-production
lm tests/regress/eprint.lsts
lm tests/lib/tuple.lsts
cc -O3 tmp.c
./a.out

Expand Down
9 changes: 9 additions & 0 deletions PLATFORM/C/LIB/cmp.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ let $"<"(l: x, r: x): U64 = cmp(l, r) < Equal;
let $"<="(l: x, r: x): U64 = cmp(l, r) <= Equal;
let $">"(l: x, r: x): U64 = cmp(l, r) > Equal;
let $">="(l: x, r: x): U64 = cmp(l, r) >= Equal;

let $"&&"(l: Ord, r: Ord): Ord = if l == Equal then r else l;

#TODO print(IO::File, String)
#let print(io: IO::File, o: Ord): Nil = (
# if o == GreaterThan then print(io, "GreaterThan") else
# if o == Equal then print(io, "Equal") else
# print(io, "LessThan");
#);
2 changes: 1 addition & 1 deletion PLATFORM/C/LIB/default.lm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import PLATFORM/C/LIB/string.lsts;
import PLATFORM/C/LIB/smart-string.lm;
import PLATFORM/C/LIB/smart-string.lsts;
import PLATFORM/C/LIB/s.lm;
import PLATFORM/C/LIB/tuple.lm;
import PLATFORM/C/LIB/tuple.lsts;
import PLATFORM/C/LIB/list.lm;
import PLATFORM/C/LIB/list.lsts;
import PLATFORM/C/LIB/vector.lsts;
Expand Down
35 changes: 0 additions & 35 deletions PLATFORM/C/LIB/tuple.lm

This file was deleted.

42 changes: 42 additions & 0 deletions PLATFORM/C/LIB/tuple.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

type Tuple<x,y> = Tuple { first: x, second: y };

let cmp(l: Tuple<x,y>, r: Tuple<x,y>): Ord = (
cmp(l.first, r.first) && cmp(l.second, r.second)
);

let deep-hash(l: Tuple<x,y>): U64 = (
deep-hash(l.first) + deep-hash(l.second)
);

let print(io: IO::File, l: Tuple<x,y>): Nil = (
print(io, "("); print(io, l.first); print(io, ","); print(io, l.second); print(io, ")");
);

let $"=="(l: Tuple<x,y>, r: Tuple<x,y>): U64 = (
l.first == r.first && l.second == r.second
);

let $"!="(l: Tuple<x,y>, r: Tuple<x,y>): U64 = (
l.first != r.first || l.second != r.second
);

let $"<"(l: Tuple<x,y>, r: Tuple<x,y>): U64 = (
l.first < r.first ||
(l.first == r.first && l.second < r.second)
);

let $"<="(l: Tuple<x,y>, r: Tuple<x,y>): U64 = (
l.first < r.first ||
(l.first == r.first && l.second <= r.second)
);

let $">"(l: Tuple<x,y>, r: Tuple<x,y>): U64 = (
l.first > r.first ||
(l.first == r.first && l.second > r.second)
);

let $">="(l: Tuple<x,y>, r: Tuple<x,y>): U64 = (
l.first > r.first ||
(l.first == r.first && l.second >= r.second)
);
2 changes: 2 additions & 0 deletions PLATFORM/C/LIB/u64.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ declare-binop( $">>", raw-type(U64), raw-type(U64+Constant), raw-type(U64), ( l"
declare-unop( not, raw-type(U64), raw-type(U64), ( l"(!"; x; l")"; ) );

declare-unop( into-branch-conditional, raw-type(U64), raw-type(BranchConditional), x );

let cmp(l: U64, r: U64): Ord = if l==r then Equal else if l<r then LessThan else GreaterThan;
36 changes: 36 additions & 0 deletions tests/lib/cmp.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

import LIB/default.lm;

assert( LessThan == LessThan );
assert( LessThan != Equal );
assert( LessThan != GreaterThan );
assert( Equal != LessThan );
assert( Equal == Equal );
assert( Equal != GreaterThan );
assert( GreaterThan != LessThan );
assert( GreaterThan != Equal );
assert( GreaterThan == GreaterThan );

assert( LessThan < Equal );
assert( LessThan < GreaterThan );
assert( Equal < GreaterThan );

assert( LessThan <= LessThan );
assert( LessThan <= Equal );
assert( LessThan <= GreaterThan );
assert( Equal <= Equal );
assert( Equal <= GreaterThan );
assert( GreaterThan <= GreaterThan );

assert( GreaterThan > LessThan );
assert( GreaterThan > Equal );
assert( Equal > LessThan );

assert( GreaterThan >= LessThan );
assert( GreaterThan >= Equal );
assert( GreaterThan >= GreaterThan );
assert( Equal >= LessThan );
assert( Equal >= Equal );
assert( LessThan >= LessThan );

print("Success\n");
1 change: 1 addition & 0 deletions tests/lib/cmp.lsts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Success
8 changes: 8 additions & 0 deletions tests/lib/tuple.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

import LIB/default.lm;

assert( Tuple(1, 2) == Tuple(1, 2) );
assert( Tuple(1, 2) != Tuple(1, 3) );
assert( Tuple(1, 2) != Tuple(2, 2) );

print("Success\n");
1 change: 1 addition & 0 deletions tests/lib/tuple.lsts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Success
13 changes: 13 additions & 0 deletions tests/regress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ fn regression_tests() {
}
}
}
for entry in glob("tests/lib/*.lsts").unwrap() {
let path = entry.unwrap().display().to_string();
if !std::path::Path::new(&(path.clone() + ".skip")).exists() {
let expected = std::fs::read_to_string(path.clone() + ".out")
.expect(&format!("Could not load expected output {}.out", path));
let expected = expected.trim().to_string();
let actual = run_bootstrap(&path);
let actual = actual.trim().to_string();
if expected != actual {
failures.push(( "--compile", path, expected, actual ));
}
}
}
for (mode,path,expected,actual) in &failures {
eprintln!("TEST {} {}", mode, path);
eprintln!("Expected: '{}'", &expected[..std::cmp::min(4000,expected.len())] );
Expand Down
Loading