Skip to content

Commit

Permalink
Merge pull request #961 from andrew-johnson-4/derive-fields-always-fa…
Browse files Browse the repository at this point in the history
…st-forward

Derive fields always fast forward
  • Loading branch information
andrew-johnson-4 authored Nov 21, 2024
2 parents 8c47989 + ea168bf commit 199056c
Show file tree
Hide file tree
Showing 6 changed files with 20,063 additions and 19,988 deletions.
39,923 changes: 19,976 additions & 19,947 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.15"
version = "1.19.16"
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 EXAMPLES/string-formatting.lsts
lm SRC/quick-prop.lsts
cc tmp.c
./a.out

Expand Down
2 changes: 0 additions & 2 deletions PLATFORM/C/LIB/string.lm
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

fragment type String; size String 8; atom suffix String _s;

type VariableData (CRAlloc( ptr:?[] , length:U64 , capacity:U64 ));

head-string := λ(: x String). (: (
([]( (as x U8[]) 0_u64 ))
) U8);
Expand Down
113 changes: 76 additions & 37 deletions PLUGINS/FRONTEND/LSTS/lsts-parse.lm
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ lsts-parse-let := λ(: tokens List<Token>). (: (
(set name (+( name (lsts-parse-head tokens) ))) (set tokens (tail tokens))
) ())
(set name (lsts-unwrap-identifier name))
(let args-list ASTNil)
(let args-list ASTEOF)
(let return-type TAny)
(if (==( (lsts-parse-head tokens) '\[_s )) (
(set args-list ASTNil)
(lsts-parse-expect( '\[_s tokens )) (set tokens (tail tokens))
(while (!=( (lsts-parse-head tokens) '\]_s )) (
(lsts-parse-expect( 'Identifier_s (lsts-is-ident-head(lsts-parse-head tokens)) tokens ))
Expand Down Expand Up @@ -177,24 +178,33 @@ lsts-parse-let := λ(: tokens List<Token>). (: (
) ())
(lsts-parse-expect( '=_s tokens )) (set tokens (tail tokens))
(let rhs-rest (lsts-parse-small-expression tokens))
(let rhs (.first rhs-rest))
(let return-term (App(
(close(Lit( ':_s (token::new ':_s) )))
(close(App(
(close rhs)
(close(AType return-type))
(let return-term (.first rhs-rest))
(if (non-zero args-list) (
(set return-term (App(
(close(Lit( ':_s (token::new ':_s) )))
(close(App(
(close return-term)
(close(AType return-type))
)))
)))
)))
) ())
(set tokens (.second rhs-rest))
(lsts-parse-expect( '\:_s tokens )) (set tokens (tail tokens))
(set ast-parsed-program (Seq(
(close ast-parsed-program)
(close(Glb( (token::new name) (close(Abs(
(close args-list)
(close return-term)
TAny
))) )))
)))
(if (non-zero args-list) (
(set ast-parsed-program (Seq(
(close ast-parsed-program)
(close(Glb( (token::new name) (close(Abs(
(close args-list)
(close return-term)
TAny
))) )))
)))
) (
(set ast-parsed-program (Seq(
(close ast-parsed-program)
(close(Glb( (token::new name) (close return-term) )))
)))
))
tokens
) List<Token>);

Expand Down Expand Up @@ -736,10 +746,10 @@ lsts-parse-map := λ(: tokens List<Token>). (: (
) Tuple<AST,List<Token>>);

lsts-parse-atom-tail := λ(: base AST)(: tokens List<Token>). (: (
(while (||( (==( (lsts-parse-head tokens) '\[_s ))
(while (||( (||( (==( (lsts-parse-head tokens) '\[_s )) (==( (lsts-parse-head tokens) '._s )) ))
(&&( (&&( (==( (lsts-parse-head tokens) ':_s )) (non-zero(tail tokens)) )) (==( (lsts-parse-head(tail tokens)) ':_s )) ))
)) (
(if (&&( (&&( (==( (lsts-parse-head tokens) ':_s )) (non-zero(tail tokens)) )) (==( (lsts-parse-head(tail tokens)) ':_s )) )) (
(if (&&( (&&( (==( (lsts-parse-head tokens) ':_s )) (non-zero(tail tokens)) )) (==( (lsts-parse-head(tail tokens)) ':_s )) )) (scope(
(set tokens (tail tokens))
(set tokens (tail tokens))
(let type-rest (lsts-parse-type tokens))
Expand All @@ -752,33 +762,62 @@ lsts-parse-atom-tail := λ(: base AST)(: tokens List<Token>). (: (
(close(AType a-type))
)))
)))
) (
(set tokens (tail tokens))
(if (==( (lsts-parse-head tokens) '\]_s )) (
)) (
(if (==( (lsts-parse-head tokens) '._s )) (scope(
(let loc (.location(head tokens)))
(set tokens (tail tokens))
(lsts-parse-expect( 'Identifier_s (lsts-is-ident-head(lsts-parse-head tokens)) tokens ))
(let method (+( '._s (.key(head tokens)) )))(set tokens (tail tokens))
(if (==( (lsts-parse-head tokens) '\[_s )) (
(lsts-parse-expect( '\[_s tokens ))(set tokens (tail tokens))
(while (&&( (non-zero tokens) (!=( (lsts-parse-head tokens) '\]_s )) )) (
(let next-rest (lsts-parse-expression tokens))
(let next (.first next-rest))
(set tokens (.second next-rest))
(if (&&( (non-zero tokens) (==( (lsts-parse-head tokens) ',_s )) )) (
(set tokens (tail tokens))
) (
(lsts-parse-expect( '\]_s tokens ))
))
(set base (App(
(close base)
(close next)
)))
))
(lsts-parse-expect( '\]_s tokens ))(set tokens (tail tokens))
) ())
(set base (App(
(close(Var( method (with-location( (token::new method) loc )) )))
(close base)
(close ASTNil)
)))
)) (
(set tokens (tail tokens))
) (
(let term2-rest (lsts-parse-expression tokens))
(let term2 (.first term2-rest))
(set tokens (.second term2-rest))
(while (==( (lsts-parse-head tokens) ',_s )) (
(if (==( (lsts-parse-head tokens) '\]_s )) (
(set base (App(
(close base)
(close ASTNil)
)))
(set tokens (tail tokens))
(let term3-rest (lsts-parse-expression tokens))
(let term3 (.first term3-rest))
(set tokens (.second term3-rest))
(set term2 (App(
) (
(let term2-rest (lsts-parse-expression tokens))
(let term2 (.first term2-rest))
(set tokens (.second term2-rest))
(while (==( (lsts-parse-head tokens) ',_s )) (
(set tokens (tail tokens))
(let term3-rest (lsts-parse-expression tokens))
(let term3 (.first term3-rest))
(set tokens (.second term3-rest))
(set term2 (App(
(close term2)
(close term3)
)))
))
(set base (App(
(close base)
(close term2)
(close term3)
)))
(lsts-parse-expect( '\]_s tokens ))(set tokens (tail tokens))
))
(set base (App(
(close base)
(close term2)
)))
(lsts-parse-expect( '\]_s tokens ))(set tokens (tail tokens))
))
))
))
Expand Down
9 changes: 9 additions & 0 deletions SRC/quick-prop.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import $"LIB/default.lm";

# let quick-prop = {} :: Hashtable<Tuple<String,U64>,Tuple<Type,Type>>;


let quick-prop = {} :: HashtableEq<U64,U64>;

print(quick-prop.lookup(1,2));

0 comments on commit 199056c

Please sign in to comment.