Skip to content

Commit

Permalink
Merge pull request #1038 from andrew-johnson-4/phi-types
Browse files Browse the repository at this point in the history
Phi types
  • Loading branch information
andrew-johnson-4 authored Jan 2, 2025
2 parents ff1b226 + 333a8e9 commit a51c78e
Show file tree
Hide file tree
Showing 8 changed files with 22,145 additions and 22,099 deletions.
44,214 changes: 22,118 additions & 22,096 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.19.38"
version = "1.19.39"
authors = ["Andrew <andrew@subarctic.org>"]
license = "MIT"
description = "Typed Macro Assembler (backed by Coq proofs-of-correctness)"
Expand Down
11 changes: 11 additions & 0 deletions EXAMPLES/phi-types.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

import LIB/default.lm;

let fp = fopen(c"input-file.txt", c"r") :: File;

# The type system doesn't know that this is always true
# So fclose may or may not be called
# This creates an error because the φ-type can't be merged
if true {
fclose(fp);
};
1 change: 1 addition & 0 deletions EXAMPLES/phi-types.lsts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Error:
Empty file added EXAMPLES/phi-types.lsts.skip
Empty file.
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/propositional-types.lsts
lm EXAMPLES/phi-types.lsts
cc -O3 tmp.c
./a.out

Expand Down
2 changes: 1 addition & 1 deletion PLUGINS/FRONTEND/LSTS/lsts-parse.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ let lsts-parse-type(tokens: List<Token>): Tuple<Type,List<Token>> = (
};
lsts-parse-expect(c")", tokens); tokens = tail(tokens);
TGround { c"Tuple", close(args) };
} else if lsts-is-ident-head(lsts-parse-head(tokens)) {
} else if lsts-is-ident-head(lsts-parse-head(tokens)) && not(lsts-is-reserved-word(lsts-parse-head(tokens))) {
let varname = lsts-parse-head(tokens); tokens = tail(tokens);
TVar { varname }
} else {
Expand Down
12 changes: 12 additions & 0 deletions PLUGINS/FRONTEND/LSTS/lsts-tokenize.lm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ lsts-tokenize := λ(: fp String). (: (
(lsts-tokenize-string(fp text))
) List<Token>);

lsts-is-reserved-word := λ(: text String). (: (
(let r 0_u64)
(if (==( text 'if_s )) (set r 1_u64) ()) # $
(if (==( text 'then_s )) (set r 1_u64) ()) # $
(if (==( text 'else_s )) (set r 1_u64) ()) # $
(if (==( text 'let_s )) (set r 1_u64) ()) # $
(if (==( text 'while_s )) (set r 1_u64) ()) # $
(if (==( text 'for_s )) (set r 1_u64) ()) # $
(if (==( text 'type_s )) (set r 1_u64) ()) # $
r
) U64);

lsts-is-ident-head := λ(: text String). (: (
(let r 0_u64)
(if (&&( (>=( (head-string text) 48_u8 )) (<=( (head-string text) 57_u8 )) )) (set r 1_u64) ()) # 0-9
Expand Down

0 comments on commit a51c78e

Please sign in to comment.