Skip to content

Commit

Permalink
Merge pull request #1065 from andrew-johnson-4/port-libs-to-lsts
Browse files Browse the repository at this point in the history
Port libs to lsts
  • Loading branch information
andrew-johnson-4 authored Jan 10, 2025
2 parents 9a60abb + 6762466 commit ab0694f
Show file tree
Hide file tree
Showing 9 changed files with 23,389 additions and 23,273 deletions.
46,624 changes: 23,357 additions & 23,267 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.2"
version = "1.20.3"
authors = ["Andrew <andrew@subarctic.org>"]
license = "MIT"
description = "Typed Macro Assembler (backed by Coq proofs-of-correctness)"
Expand Down
1 change: 1 addition & 0 deletions PLATFORM/C/LIB/default.lm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import PLATFORM/C/LIB/field-accessors.lm;
import PLATFORM/C/LIB/sized.lm;
import PLATFORM/C/LIB/bool.lm;
import PLATFORM/C/LIB/u8.lm;
import PLATFORM/C/LIB/u8.lsts;
import PLATFORM/C/LIB/i8.lm;
import PLATFORM/C/LIB/u16.lm;
import PLATFORM/C/LIB/i16.lm;
Expand Down
2 changes: 1 addition & 1 deletion PLATFORM/C/LIB/u8.lm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

fragment type U8; size U8 1; atom suffix U8 _u8;

(declare-binop( != U8 U8 U64 ( '\[_l x '!=_l y '\]_l ) ));
#(declare-binop( != U8 U8 U64 ( '\[_l x '!=_l y '\]_l ) ));
(declare-binop( == U8 U8 U64 ( '\[_l x '==_l y '\]_l ) ));
(declare-binop( < U8 U8 U64 ( '\[_l x '<_l y '\]_l ) ));
(declare-binop( <= U8 U8 U64 ( '\[_l x '<=_l y '\]_l ) ));
Expand Down
2 changes: 2 additions & 0 deletions PLATFORM/C/LIB/u8.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

declare-binop( $"!=", raw-type(U8), raw-type(U8), raw-type(U64), ( l"("; x; l"!="; y; l")"; ) );
17 changes: 14 additions & 3 deletions PLUGINS/FRONTEND/LSTS/lsts-parse.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ let lsts-unwrap-identifier(ident: CString): CString = (
} else ident
);

let lsts-unwrap-identifier(ident: Token): Token = (
match ident {
Token { key=key, nonce=nonce, location=location } => Token { lsts-unwrap-identifier(key), iuid(), location };
};
);

let lsts-parse-expect(expect: CString, tokens: List<Token>): Nil = (
if lsts-parse-head(tokens) != expect {
fail("Parse Error: Expected \{expect} at \{tokens.formatted-location}\n");
Expand Down Expand Up @@ -273,7 +279,7 @@ let lsts-make-maybe-var(tokens: List<Token>): Tuple<AST,List<Token>> = (
} else {
if not(non-zero(tokens)) { lsts-parse-expect(c"Identifier", tokens); };
let t = head(tokens);
let base = Var { lsts-unwrap-identifier(t.key), t };
let base = Var { lsts-unwrap-identifier(t.key), lsts-unwrap-identifier(t) };
if lsts-is-lit(t.key) { base = lsts-make-lit(t); };
tokens = tail(tokens);
Tuple { base, tokens }
Expand Down Expand Up @@ -919,6 +925,13 @@ let lsts-parse-atom(tokens: List<Token>): Tuple<AST,List<Token>> = (
tokens = term-rest.second;
lsts-parse-expect(c")", tokens); tokens = tail(tokens);
term = AType{ t2(c"Type", term-rest.first) };
} else if lsts-parse-head(tokens)==c"raw-type" {
tokens = tail(tokens);
lsts-parse-expect(c"(", tokens); tokens = tail(tokens);
let term-rest = lsts-parse-type(tokens);
tokens = term-rest.second;
lsts-parse-expect(c")", tokens); tokens = tail(tokens);
term = AType{ term-rest.first };
} else if lsts-is-ident-head(lsts-parse-head(tokens)) {
let term-rest = lsts-make-maybe-var(tokens);
tokens = term-rest.second;
Expand Down Expand Up @@ -1086,5 +1099,3 @@ let lsts-parse-atom-tail(base: AST, tokens: List<Token>): Tuple<AST,List<Token>>
};
Tuple { base, tokens }
);


2 changes: 1 addition & 1 deletion PLUGINS/FRONTEND/LSTS/lsts-smart-tokenize.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let lsts-tokenize-string(file-path: String, text: String): List<Token> = (
"^".. rest => (tokens = cons(text[:"^".length], tokens); text = rest;);
".".. rest => (tokens = cons(text[:".".length], tokens); text = rest;);

(lit=r/^c?["]([^"\\]|([\\].))*["]/).. rest => (
(lit=r/^[cl]?["]([^"\\]|([\\].))*["]/).. rest => (
tokens = cons(text[:lit.length], tokens); text = rest;
);

Expand Down
6 changes: 6 additions & 0 deletions SRC/mk-token.lm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ mk-lsts-token := λ(: s SmartString). (: (
(set us (.replace( us '\\"_s '"_s )))
(set us (+( us '_s_s )))
) ())
(if (.has-prefix( s 'l"_ss )) (
(set us (.remove-prefix( us 'l"_s )))
(set us (.remove-suffix( us '"_s )))
(set us (.replace( us '\\"_s '"_s )))
(set us (+( us '_l_s )))
) ())
(Token( us (iuid()) (location-of s) ))
) Token);

Expand Down
6 changes: 6 additions & 0 deletions SRC/substitute.lm
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ substitute := λ(: tctx Context)(: tt Type). (: (
(set tctx CtxEOF)
) (set tctx rst))
))
( (CtxBind( rst tk (AType( tv )) )) (
(if (==( tk v )) (
(set tt tv)
(set tctx CtxEOF)
) (set tctx rst))
))
( (CtxBind( rst tk tv )) (
(set tctx rst)
))
Expand Down

0 comments on commit ab0694f

Please sign in to comment.