Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
de7d59f
move 2 into new file
andrew4328 May 20, 2026
cc4bd37
progress
andrew4328 May 21, 2026
313705d
simplify one parser rule a bunch
andrew4328 May 21, 2026
3367cad
t
andrew4328 May 21, 2026
f4e4f41
l
andrew4328 May 21, 2026
0da77ab
hmm not at all fixed
andrew4328 May 21, 2026
626dc13
make a new rule that can handle uuids and ids
andrew4328 May 21, 2026
c88a15f
s
andrew4328 May 21, 2026
c835f53
forward progress
andrew4328 May 22, 2026
0b1c64b
improve blame for that rule
andrew4328 May 22, 2026
1da37a4
that didnt provide any more information
andrew4328 May 22, 2026
82268cb
wip
andrew4328 May 22, 2026
fb1dd21
trace more closely
andrew4328 May 22, 2026
1d3778b
forgot to consume if
andrew4328 May 22, 2026
1cfd61b
wrong case
andrew4328 May 22, 2026
235c906
progress
andrew4328 May 23, 2026
50e3735
very similar to earlier structure but also not
andrew4328 May 23, 2026
5ba7b2b
parser works, now need to fix macros
andrew4328 May 23, 2026
cbfc7ca
create a temporary place for patched macros
andrew4328 May 23, 2026
df338be
+1
andrew4328 May 23, 2026
fb23777
big progress
andrew4328 May 23, 2026
c9a051c
d
andrew4328 May 23, 2026
a60aa0e
macro
andrew4328 May 23, 2026
87caff5
copy for current
andrew4328 May 23, 2026
f4ee37a
going to work on unifying tagged lhs
andrew4328 May 23, 2026
8cfc5e1
fallible destructure
andrew4328 May 23, 2026
4fce34d
minimal changes to keep macros
andrew4328 May 24, 2026
e04f896
remove debug, maybe this will deploy ok now?
andrew4328 May 24, 2026
1fb28e0
mixed up a set with a let
andrew4328 May 24, 2026
9c38d03
ban the variable let case because it was confusing and not explicit
andrew4328 May 24, 2026
a8bc219
hmm
andrew4328 May 24, 2026
625cd68
something with view iterator is broken?
andrew4328 May 24, 2026
f49a470
progress
andrew4328 May 24, 2026
29c5a80
these wrappers could be cleaned up
andrew4328 May 24, 2026
2c36c8a
success
andrew4328 May 24, 2026
6b0f668
rewrite underscores in typecheck, not just macros
andrew4328 May 24, 2026
85c21ba
no, cant fix this that way. would violate any identifier principle
andrew4328 May 24, 2026
1ebdf26
fix with 100% macros
andrew4328 May 24, 2026
a1223bb
_ is not a macro::variable
andrew4328 May 24, 2026
2fee775
underscore
andrew4328 May 24, 2026
5981cd3
t
andrew4328 May 24, 2026
e8a4477
typo
andrew4328 May 25, 2026
6ba13a9
need tests for the default let/set rules somewhere
andrew4328 May 25, 2026
18cc3b2
Strings are constants too
andrew4328 May 25, 2026
8538f29
nested macro helpers werent hitting the right code path
andrew4328 May 25, 2026
2e72150
c
andrew4328 May 25, 2026
64bb850
destructure?
andrew4328 May 25, 2026
ee32947
OK, deploy is going well but needed to remove debugging prints
andrew4328 May 25, 2026
ec590fc
c
andrew4328 May 25, 2026
ed7beaf
deploy ok
andrew4328 May 25, 2026
6791003
b
andrew4328 May 25, 2026
048bdee
if let OK
andrew4328 May 25, 2026
215a0ba
forgot assign
andrew4328 May 25, 2026
2c0e213
if let OK
andrew4328 May 25, 2026
6b7f7fc
just had not deployed whatever had changed. while let is ok
andrew4328 May 25, 2026
ba51f83
there is still a loose linear type somewhere, but for now this works
andrew4328 May 25, 2026
e2f64a4
there is still a loose linear type somewhere, but for now this works
andrew4328 May 25, 2026
46993ae
now the while let is breaking
andrew4328 May 26, 2026
d24dae8
grammar bug
andrew4328 May 26, 2026
73fcfea
found a way to move those down in precedence without breaking grammar
andrew4328 May 26, 2026
e1c4587
somehow that made the compiler a bit faster
andrew4328 May 26, 2026
bd91734
remove dev
andrew4328 May 26, 2026
a2ad613
remove dev.save
andrew4328 May 26, 2026
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
8,891 changes: 4,381 additions & 4,510 deletions BOOTSTRAP/cli.c

Large diffs are not rendered by default.

2,001 changes: 1,205 additions & 796 deletions BOOTSTRAP/monolithic.lsts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LSTSFLAGS = MALLOC_CHECK_=3
# recommendation: ulimit -s unlimited

dev: install-production
lm tests/promises/lm-type/intern-type-tag.lsts
lm tests/promises/syntax/lhs-while-let.lsts
gcc tmp.c
./a.out

Expand Down
1 change: 1 addition & 0 deletions PLUGINS/FRONTEND/LSTS/index.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ import PLUGINS/FRONTEND/LSTS/lsts-smart-tokenize.lsts;
import PLUGINS/FRONTEND/LSTS/lsts-tokenize.lsts;
import PLUGINS/FRONTEND/LSTS/lsts-parse.lsts;
import PLUGINS/FRONTEND/LSTS/mk-lsts-token.lsts;
import PLUGINS/FRONTEND/LSTS/lsts-parse-lhs.lsts;
320 changes: 320 additions & 0 deletions PLUGINS/FRONTEND/LSTS/lsts-parse-lhs.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@

let lsts-parse-lhs-list(tokens: List<Token>): Tuple<AST,List<Token>> = (
let base = mk-eof();
lsts-parse-expect(c"[", tokens);
let loc = head(tokens).location;
tokens = tail(tokens);
if lsts-parse-head(tokens) == c"]" {
base = Lit ( c"MACRO::LHS-LIST-SENTINEL", with-location(mk-token("MACRO::LHS-LIST-SENTINEL"),loc) );
base = mk-app(base,base); # TODO FIX MACRO, this is for compatibility with macros 1.0
} else {
let base-rest = lsts-parse-lhs-big(tokens);
base = base-rest.first;
tokens = base-rest.second;
let bases = [base];
while non-zero(tokens) and lsts-parse-head(tokens)==c"." {
lsts-parse-expect(c".", tokens); tokens = tail(tokens);
lsts-parse-expect(c".", tokens); tokens = tail(tokens);
if lsts-parse-head(tokens)==c"]" {
let in-base = Lit ( c"MACRO::LHS-LIST-SENTINEL", with-location(mk-token("MACRO::LHS-LIST-SENTINEL"),loc) );
in-base = mk-app(in-base,in-base); # TODO FIX MACRO, this is for compatibility with macros 1.0
bases = cons( in-base, bases );
} else {
let next-rest = lsts-parse-lhs-big(tokens);
let next = next-rest.first;
tokens = next-rest.second;
bases = cons( next, bases );
}
};
base = head(bases); bases = tail(bases);
for b in bases {
base = mk-app(
Var( c"macro::lhs-head", with-location(mk-token("macro::lhs-head"),loc) ),
mk-cons(b, base)
);
}
};
lsts-parse-expect(c"]", tokens); tokens = tail(tokens);
Tuple ( base, tokens )
);

let lsts-parse-lhs-big(tokens: List<Token>): Tuple<AST,List<Token>> = (
(let base, tokens) = lsts-parse-lhs-one(tokens);
if lsts-parse-head(tokens) == c"=" {
let loc = head(tokens).location;
lsts-parse-expect(c"=", tokens); tokens = tail(tokens);
if base.is-var then base = mk-app( mk-var(c"macro::let-binding").with-location(loc), base );
(let val, tokens) = lsts-parse-lhs-one(tokens);
base = mk-app(
mk-var(c"macro::lhs-bind").with-location(loc),
mk-cons(base, val)
);
};
(base, tokens)
);

let lsts-parse-lhs(tokens: List<Token>): Tuple<AST,List<Token>> = (
(let base, tokens) = lsts-parse-lhs-one(tokens);

while non-zero(tokens) and (lsts-parse-head(tokens)==c"." or lsts-parse-head(tokens)==c"[") {
match tokens {
[Token{key:c"."}.. Token{key:c"."}.. rest] => (
let loc = head(tokens).location;
lsts-parse-expect(c".", tokens); tokens = tail(tokens);
lsts-parse-expect(c".", tokens); tokens = tail(tokens);
let next-rest = lsts-parse-lhs-one(tokens);
let next = next-rest.first;
tokens = next-rest.second;
base = mk-app(
Var( c"macro::lhs-prefix-or-suffix", with-location(mk-token("macro::lhs-prefix-or-suffix"),loc) ),
mk-cons(base, next)
);
);
[Token{key:c"."}.. rest] => (
let loc = head(tokens).location;
lsts-parse-expect(c".", tokens); tokens = tail(tokens);
(let field-name, tokens) = lsts-parse-identifier(tokens);
base = mk-app(
Var( c"macro::lhs-field", with-location(mk-token("macro::lhs-field"),loc) ),
mk-cons(base, mk-var(field-name))
);
);
[Token{key:c"["}.. rest] => (
let loc = head(tokens).location;
lsts-parse-expect(c"[", tokens); tokens = tail(tokens);
let next-rest = lsts-parse-expression(tokens);
let next = next-rest.first;
tokens = next-rest.second;
lsts-parse-expect(c"]", tokens); tokens = tail(tokens);
base = mk-app(
Var( c"macro::lhs-index", with-location(mk-token("macro::lhs-index"),loc) ),
mk-cons(base, next)
);
);
}
};

(base, tokens)
);

let lsts-parse-lhs-one(tokens: List<Token>): Tuple<AST,List<Token>> = (
let base = match tokens {
[ Token{key:c"["}.. _ ] => (
(let l, tokens) = lsts-parse-lhs-list(tokens);
l
);
[ Token{key:c"("}.. _] => (
let loc = head(tokens).location;
lsts-parse-expect(c"(", tokens); tokens = tail(tokens);
(let base, tokens) = lsts-parse-lhs-big(tokens);
let bases = mk-vector(type(AST)).push(base);
while lsts-parse-head(tokens)==c"," {
lsts-parse-expect(c",", tokens); tokens = tail(tokens);
(base, tokens) = lsts-parse-lhs-big(tokens);
bases = bases.push(base);
};
lsts-parse-expect(c")", tokens); tokens = tail(tokens);
if bases.length==1 then bases[0]
else {
base = mk-nil();
let bi = 0_sz;
while bi < bases.length {
let f = match bi {
0 => c".first";
1 => c".second";
2 => c".third";
3 => c".fourth";
};
let field-base = mk-app(
mk-var(c"macro::lhs-fields-field").with-location(loc),
mk-cons(
mk-var(f).with-location(loc),
mk-app(
mk-var(c"macro::lhs-bind").with-location(loc),
mk-cons(
bases[bi],
mk-var(c"_").with-location(loc)
)
)
)
);
base = mk-app(
mk-var(c"macro::lhs-fields").with-location(loc),
mk-cons(base, field-base)
);
bi = bi + 1;
};
mk-app(
mk-var(c"macro::lhs-tagged").with-location(loc),
mk-cons(
mk-lit(c"Tuple").with-location(loc),
base
)
)
};
);
[ Token{key:c"let"}.. _] => (
let loc = head(tokens).location;
lsts-parse-expect(c"let", tokens); tokens = tail(tokens);
(let field, tokens) = lsts-parse-lhs-one(tokens);
mk-app(
mk-var(c"macro::let-binding").with-location(loc),
field
).with-location(loc);
);
[ Token{key:c"set"}.. _] => (
let loc = head(tokens).location;
lsts-parse-expect(c"set", tokens); tokens = tail(tokens);
(let field, tokens) = lsts-parse-lhs-one(tokens);
mk-app(
mk-var(c"macro::set-binding").with-location(loc),
field
).with-location(loc);
);
_ => (
if lsts-parse-head(tokens)==c"uuid" or lsts-is-ident-head(lsts-parse-head(tokens)) {
(let id1, tokens) = lsts-parse-lhs-identifier(tokens);
id1
} else if lsts-parse-head(tokens)==c"&" {
let amp = head(tokens); tokens = tail(tokens);
(let lhs, tokens) = lsts-parse-lhs-one(tokens);
mk-cons( mk-var(c"&"), lhs )
} else if lsts-is-lit(lsts-parse-head(tokens)) and (not(non-zero(tokens)) or lsts-parse-head(tail(tokens))!=c"{") {
(let l, tokens) = lsts-parse-lit(tokens);
l
# TODO, make tag optional here
} else if non-zero(tokens) and lsts-parse-head(tail(tokens))==c"{" {
let loc = head(tokens).location;
let tag = lsts-parse-head(tokens); tokens = tail(tokens);
lsts-parse-expect(c"{", tokens); tokens = tail(tokens);
let des-args = mk-nil();
let early-tokens = tokens;
while non-zero(tokens) and lsts-parse-head(tokens)!=c"}" and (is(tokens,early-tokens) or lsts-parse-head(tokens)==c",") {
if lsts-parse-head(tokens) == c"," {
lsts-parse-expect(c",", tokens); tokens = tail(tokens);
};
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);
};
let is-let = true;
if lsts-parse-head(tokens)==c"=" {
binding = attr-key; tokens = tail(tokens);
if lsts-parse-head(tokens) == c"set" {
is-let = false; 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); };
};
let val = if lsts-parse-head(tokens)==c":" {
tokens = tail(tokens);
(let val, tokens) = lsts-parse-lhs-one(tokens);
val
} else { mk-eof() };
if not(non-zero(val)) and not(non-zero(binding)) and not(non-zero(attr-key)) {
lsts-parse-expect(c"[Struct LHS]", tokens); tokens = tail(tokens);
};
if not(non-zero(val)) {
val = Var( c"_", with-location(mk-token("_"),attr-loc) );
};
if non-zero(binding) {
let macro-binding = if is-let
then mk-var(c"macro::let-binding").with-location(attr-loc);
else mk-var(c"macro::set-binding").with-location(attr-loc);
val = mk-app(
Var( c"macro::lhs-bind", with-location(mk-token("macro::lhs-bind"),attr-loc) ),
mk-cons(
mk-app( macro-binding, mk-var(binding).with-location(attr-loc) ),
val
)
);
if raw {
val = mk-app(
Var( c"macro::lhs-bind-raw", with-location(mk-token("macro::lhs-bind-raw"),attr-loc) ),
val
);
};
};
if non-zero(attr-key) {
attr-key = c"." + attr-key;
val = mk-app(
Var( c"macro::lhs-fields-field", with-location(mk-token("macro::lhs-fields-field"),attr-loc) ),
mk-cons(
Var( attr-key, with-location(mk-token(attr-key),attr-loc) ),
val
)
);
};
des-args = mk-app(
mk-var(c"macro::lhs-fields").with-location(loc),
mk-cons(
des-args,
val
)
);
};
if not(non-zero(des-args)) { des-args = mk-nil(); };
lsts-parse-expect(c"}", tokens); tokens = tail(tokens);
let lhs-tag = if tag!=c"_"
then mk-lit(tag).with-location(loc)
else mk-nil();
mk-app(
mk-var(c"macro::lhs-tagged").with-location(loc),
mk-cons(
lhs-tag,
des-args
)
);
} else {
lsts-parse-expect(c"[LHS]", tokens);
mk-eof();
}
);
};

( base, tokens )
);

let lsts-parse-assign(tokens: List<Token>): Tuple<AST,List<Token>> = (
let base = mk-eof();
if lsts-has-assign(tokens) and lsts-parse-head(tokens)!=c"for" and lsts-parse-head(tokens)!=c"while" and lsts-parse-head(tokens)!=c"if" {
let loc = head(tokens).location;
(let lhs, tokens) = lsts-parse-lhs(tokens);
lsts-parse-expect(c"=", tokens); tokens = tail(tokens);
(let rhs, tokens) = lsts-parse-assign(tokens);
base = mk-app(
mk-var(c"macro::assign").with-location(loc),
mk-cons(lhs, rhs).with-location(loc)
);
} else {
(base, tokens) = lsts-parse-ascript(tokens);
};
( base, tokens )
);

let lsts-parse-lhs-identifier(tokens: List<Token>): (AST,List<Token>) = (
let loc = if non-zero(tokens) then head(tokens).location else mk-location();
if lsts-parse-head(tokens)==c"uuid" {
lsts-parse-expect(c"uuid", tokens); tokens = tail(tokens);
lsts-parse-expect(c"(", tokens); tokens = tail(tokens);
(let id2, tokens) = lsts-parse-identifier(tokens);
lsts-parse-expect(c")", tokens); tokens = tail(tokens);
(mk-app(
mk-var(c"uuid").with-location(loc),
mk-var(id2).with-location(loc)
), tokens)
} else {
(let id3, tokens) = lsts-parse-identifier(tokens);
(mk-var(id3).with-location(loc), tokens)
}
);
Loading
Loading