Skip to content

Commit

Permalink
Merge pull request #1077 from andrew-johnson-4/umbra-2
Browse files Browse the repository at this point in the history
Umbra 2
  • Loading branch information
andrew-johnson-4 authored Jan 12, 2025
2 parents 6a86b79 + 72ebd23 commit cf6d8cf
Show file tree
Hide file tree
Showing 6 changed files with 23,275 additions and 23,172 deletions.
46,346 changes: 23,183 additions & 23,163 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.6"
version = "1.20.7"
authors = ["Andrew <andrew@subarctic.org>"]
license = "MIT"
description = "Typed Macro Assembler (backed by Coq proofs-of-correctness)"
Expand Down
71 changes: 70 additions & 1 deletion PLATFORM/C/LIB/common-macros.lm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ macro ('match-pats-arm( term ((:Tag: l lt) ( x4 x3 x2 x1 )) )) (
(if (match-pats-arm( (open(.3( (as (uuid v) lt) ))) x3 ))
(if (match-pats-arm( (open(.4( (as (uuid v) lt) ))) x4 ))
(set (uuid m) 1_u8)
()
()
)
()
)
Expand Down Expand Up @@ -285,6 +285,21 @@ macro ('match-pats-arm( term ((:Tag: l lt) ('macro::bind-field-by-key( x1-key x1
)
);

macro ('match-pats-arm( term ((:Tag: l lt) ('macro::bind-field-by-key( x1-key ('macro::bind-raw x1) )) ) )) (
(
(let (uuid v) term)
(let (uuid m) 0_u8)
(if (==( (.0( (uuid v) )) l ))
(if (match-pats-arm( (x1-key( (as (uuid v) lt) )) x1 ))
(set (uuid m) 1_u8)
()
)
()
)
(==( (uuid m) 1_u8 ))
)
);

macro ('match-pats-arm( term ((:Tag: l lt) ( ('macro::bind-field-by-key( x2-key x2 )) ('macro::bind-field-by-key( x1-key x1 )) )) )) (
(
(let (uuid v) term)
Expand All @@ -303,6 +318,60 @@ macro ('match-pats-arm( term ((:Tag: l lt) ( ('macro::bind-field-by-key( x2-key
)
);

macro ('match-pats-arm( term ((:Tag: l lt) ( ('macro::bind-field-by-key( x2-key x2 )) ('macro::bind-field-by-key( x1-key ('macro::bind-raw x1) )) )) )) (
(
(let (uuid v) term)
(let (uuid m) 0_u8)
(if (==( (.0( (uuid v) )) l ))
(if (match-pats-arm( (x1-key( (as (uuid v) lt) )) x1 ))
(if (match-pats-arm( (open(x2-key( (as (uuid v) lt) ))) x2 ))
(set (uuid m) 1_u8)
()
)
()
)
()
)
(==( (uuid m) 1_u8 ))
)
);

macro ('match-pats-arm( term ((:Tag: l lt) ( ('macro::bind-field-by-key( x2-key ('macro::bind-raw x2) )) ('macro::bind-field-by-key( x1-key x1 )) )) )) (
(
(let (uuid v) term)
(let (uuid m) 0_u8)
(if (==( (.0( (uuid v) )) l ))
(if (match-pats-arm( (open(x1-key( (as (uuid v) lt) ))) x1 ))
(if (match-pats-arm( (x2-key( (as (uuid v) lt) )) x2 ))
(set (uuid m) 1_u8)
()
)
()
)
()
)
(==( (uuid m) 1_u8 ))
)
);

macro ('match-pats-arm( term ((:Tag: l lt) ( ('macro::bind-field-by-key( x2-key ('macro::bind-raw x2) )) ('macro::bind-field-by-key( x1-key ('macro::bind-raw x1) )) )) )) (
(
(let (uuid v) term)
(let (uuid m) 0_u8)
(if (==( (.0( (uuid v) )) l ))
(if (match-pats-arm( (x1-key( (as (uuid v) lt) )) x1 ))
(if (match-pats-arm( (x2-key( (as (uuid v) lt) )) x2 ))
(set (uuid m) 1_u8)
()
)
()
)
()
)
(==( (uuid m) 1_u8 ))
)
);

macro ('match-pats-arm( term ((:Tag: l lt) ( ('macro::bind-field-by-key( x3-key x3 )) ('macro::bind-field-by-key( x2-key x2 )) ('macro::bind-field-by-key( x1-key x1 )) )) )) (
(
(let (uuid v) term)
Expand Down
13 changes: 6 additions & 7 deletions PLATFORM/C/LIB/umbra.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ let $"[]"(s: Umbra, i: U64): U8 = (
let u = s.backing;
match u {
UmbraShort { arr=arr } => arr[i];
UmbraLong { prefix=prefix, ptr=ptr } => (
1_u8
# #if i < 4 {
# # prefix[i]
# #} else {
# # ptr[i]
# #}
UmbraLong { prefix=prefix, raw ptr=ptr } => (
if i < 4 {
prefix[i]
} else {
ptr[i]
}
);
}
);
Expand Down
13 changes: 13 additions & 0 deletions PLUGINS/FRONTEND/LSTS/lsts-parse.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -842,11 +842,18 @@ let lsts-parse-lhs-one(tokens: List<Token>): Tuple<AST,List<Token>> = (
let attr-loc = head(tokens).location;
let binding = c"";
let attr-key = c"";
let raw = false;
if lsts-parse-head(tokens) == c"raw" {
raw = true; tokens = tail(tokens);
};
if lsts-is-ident-head(lsts-parse-head(tokens)) {
attr-key = lsts-parse-head(tokens); tokens = tail(tokens);
};
if lsts-parse-head(tokens)==c"=" {
binding = attr-key; tokens = tail(tokens);
if lsts-parse-head(tokens) == c"raw" {
raw = true; tokens = tail(tokens);
};
if lsts-is-ident-head(lsts-parse-head(tokens)) {
attr-key = lsts-parse-head(tokens); tokens = tail(tokens);
} else { lsts-parse-expect(c"[Identifier]", tokens); };
Expand All @@ -871,6 +878,12 @@ let lsts-parse-lhs-one(tokens: List<Token>): Tuple<AST,List<Token>> = (
close(val)
})
};
if raw {
val = App{
close(Var{ c"macro::bind-raw", with-location(mk-token("macro::bind-raw"),attr-loc) }),
close(val)
};
};
};
if non-zero(attr-key) {
attr-key = c"." + attr-key;
Expand Down
2 changes: 2 additions & 0 deletions PLUGINS/FRONTEND/LSTS/lsts-tokenize.lm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ lsts-is-reserved-word := λ(: text String). (: (
(if (==( text 'while_s )) (set r 1_u64) ()) # $
(if (==( text 'for_s )) (set r 1_u64) ()) # $
(if (==( text 'type_s )) (set r 1_u64) ()) # $
(if (==( text 'raw_s )) (set r 1_u64) ()) # $
(if (==( text 'match_s )) (set r 1_u64) ()) # $
r
) U64);

Expand Down

0 comments on commit cf6d8cf

Please sign in to comment.