Skip to content

Commit e5b85c8

Browse files
Merge pull request #224 from andrew-johnson-4/strict-compiler-dev-rush
Strict compiler dev rush
2 parents 84c8c79 + 1d92431 commit e5b85c8

File tree

7 files changed

+70
-50
lines changed

7 files changed

+70
-50
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda_mountain"
3-
version = "1.11.87"
3+
version = "1.11.88"
44
authors = ["Andrew <andrew@subarctic.org>"]
55
license = "MIT"
66
description = "Lambda Mountain"

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
nostd: prod
3-
./production --nostd -o tmp.s tests/strict/match6.lm
3+
./production --nostd -o tmp.s tests/strict/match7.lm
44
as -o tmp.o tmp.s
55
ld -o tmp tmp.o
66
./tmp && echo $?

STDLIB/default-rules.lm

+30-30
Original file line numberDiff line numberDiff line change
@@ -32,47 +32,47 @@ macro ('match-pats-condition( term (:Tag: l lt) )) (
3232
);
3333

3434
macro ('match-pats-condition( term ((:Tag: l lt) ( x1 )) )) (tail(
35-
(let ok Trueu8)
36-
(if (==( (.0( term )) l )) () (set ok Falseu8))
37-
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set ok Falseu8))
38-
(==( ok Trueu8 ))
35+
(let (uuid ok) Trueu8)
36+
(if (==( (.0( term )) l )) () (set (uuid ok) Falseu8))
37+
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set (uuid ok) Falseu8))
38+
(==( (uuid ok) Trueu8 ))
3939
));
4040

4141
macro ('match-pats-condition( term ((:Tag: l lt) ( x2 x1 ) ))) (tail(
42-
(let ok Trueu8)
43-
(if (==( (.0( term )) l )) () (set ok Falseu8))
44-
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set ok Falseu8))
45-
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set ok Falseu8))
46-
(==( ok Trueu8 ))
42+
(let (uuid ok) Trueu8)
43+
(if (==( (.0( term )) l )) () (set (uuid ok) Falseu8))
44+
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set (uuid ok) Falseu8))
45+
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set (uuid ok) Falseu8))
46+
(==( (uuid ok) Trueu8 ))
4747
));
4848

4949
macro ('match-pats-condition( term ((:Tag: l lt) ( x3 x2 x1 ) ))) (tail(
50-
(let ok Trueu8)
51-
(if (==( (.0( term )) l )) () (set ok Falseu8))
52-
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set ok Falseu8))
53-
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set ok Falseu8))
54-
(if (match-pats-condition( (.3( (as term lt) )) x3 )) () (set ok Falseu8))
55-
(==( ok Trueu8 ))
50+
(let (uuid ok) Trueu8)
51+
(if (==( (.0( term )) l )) () (set (uuid ok) Falseu8))
52+
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set (uuid ok) Falseu8))
53+
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set (uuid ok) Falseu8))
54+
(if (match-pats-condition( (.3( (as term lt) )) x3 )) () (set (uuid ok) Falseu8))
55+
(==( (uuid ok) Trueu8 ))
5656
));
5757

5858
macro ('match-pats-condition( term ((:Tag: l lt) ( x4 x3 x2 x1 ) ))) (tail(
59-
(let ok Trueu8)
60-
(if (==( (.0( term )) l )) () (set ok Falseu8))
61-
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set ok Falseu8))
62-
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set ok Falseu8))
63-
(if (match-pats-condition( (.3( (as term lt) )) x3 )) () (set ok Falseu8))
64-
(if (match-pats-condition( (.4( (as term lt) )) x4 )) () (set ok Falseu8))
65-
(==( ok Trueu8 ))
59+
(let (uuid ok) Trueu8)
60+
(if (==( (.0( term )) l )) () (set (uuid ok) Falseu8))
61+
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set (uuid ok) Falseu8))
62+
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set (uuid ok) Falseu8))
63+
(if (match-pats-condition( (.3( (as term lt) )) x3 )) () (set (uuid ok) Falseu8))
64+
(if (match-pats-condition( (.4( (as term lt) )) x4 )) () (set (uuid ok) Falseu8))
65+
(==( (uuid ok) Trueu8 ))
6666
));
6767

6868
macro ('match-pats-condition( term ((:Tag: l lt) ( x5 x4 x3 x2 x1 ) ))) (tail(
69-
(let ok Trueu8)
70-
(if (==( (.0( term )) l )) () (set ok Falseu8))
71-
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set ok Falseu8))
72-
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set ok Falseu8))
73-
(if (match-pats-condition( (.3( (as term lt) )) x3 )) () (set ok Falseu8))
74-
(if (match-pats-condition( (.4( (as term lt) )) x4 )) () (set ok Falseu8))
75-
(if (match-pats-condition( (.5( (as term lt) )) x5 )) () (set ok Falseu8))
76-
(==( ok Trueu8 ))
69+
(let (uuid ok) Trueu8)
70+
(if (==( (.0( term )) l )) () (set (uuid ok) Falseu8))
71+
(if (match-pats-condition( (.1( (as term lt) )) x1 )) () (set (uuid ok) Falseu8))
72+
(if (match-pats-condition( (.2( (as term lt) )) x2 )) () (set (uuid ok) Falseu8))
73+
(if (match-pats-condition( (.3( (as term lt) )) x3 )) () (set (uuid ok) Falseu8))
74+
(if (match-pats-condition( (.4( (as term lt) )) x4 )) () (set (uuid ok) Falseu8))
75+
(if (match-pats-condition( (.5( (as term lt) )) x5 )) () (set (uuid ok) Falseu8))
76+
(==( (uuid ok) Trueu8 ))
7777
));
7878

STDLIB/default-stdlib.lm

+6-8
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,15 @@ print := λ(: x I8). (: (tail(
194194
(label start )
195195
(mov( R8 0u64 c1 ))
196196
(mov( R9 0u64 c2 ))
197-
(if (==( c1 c2 )) () (jmp end-false))
198-
(if (==( c1 0u8 )) () (jmp end-true))
197+
(if (==( c1 c2 )) (mov( 1u64 RAX )) (mov( 0u64 RAX )) )
198+
(cmp( 0u64 RAX ))
199+
(je end)
200+
(if (==( c1 0u8 )) (mov( 1u64 RAX )) (mov( 0u64 RAX )) )
201+
(cmp( 1u64 RAX ))
202+
(je end)
199203
(inc R8)
200204
(inc R9)
201205
(jmp start)
202-
(label end-true)
203-
(mov( 1u64 RAX ))
204-
(jmp( end ))
205-
(label end-false)
206-
(mov( 0u64 RAX ))
207-
(jmp( end ))
208206
(label end)
209207
(as RAX U64)
210208
)) U64);

STRICT/cli.lm

+9-10
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,19 @@ main := λ(: argc U64)(: argv U8[][]).(tail(
2727
('--gradual_s (set config-strict Falseu8))
2828
('--macro_s (set config-preprocess Trueu8))
2929
('--nomacro_s (set config-preprocess Falseu8))
30-
('-o_s (tail(
31-
(set argi (+( argi 1u64 )))
32-
(set input (SCons(
33-
(close input)
34-
(close (SAtom([]( argv argi ))))
35-
)))
36-
)))
37-
(fp (tail(
38-
(print fp)
30+
# ('-o_s (tail(
31+
# (set argi (+( argi 1u64 )))
32+
# (set input (SCons(
33+
# (close input)
34+
# (close (SAtom([]( argv argi ))))
35+
# )))
36+
# )))
37+
(fp (
3938
(set input (SCons(
4039
(close input)
4140
(close (SAtom( fp )))
4241
)))
43-
)))
42+
))
4443
))
4544
(set argi (+( argi 1u64 )))
4645
))

tests/strict/match7.lm

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
import STDLIB/default-instruction-set.lm;
3+
import STDLIB/default-primitives.lm;
4+
import STDLIB/default-rules.lm;
5+
import STDLIB/default-stdlib.lm;
6+
7+
import STRICT/utility.lm;
8+
9+
config-preprocess := 2u8;
10+
11+
main := λ(: argc U64)(: argv U8[][]).(tail(
12+
(print( (==( '--macro_s '--macro_s )) ))
13+
(print( (==( '--macro_s '--nomacro_s )) ))
14+
(print( (==( '--nomacro_s '--macro_s )) ))
15+
(print( (==( '--nomacro_s '--nomacro_s )) ))
16+
(match '--nomacro_s (
17+
()
18+
('--macro_s (set config-preprocess 1u8))
19+
('--nomacro_s (set config-preprocess 0u8))
20+
))
21+
(print config-preprocess)
22+
));

tests/strict/match7.lm.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ok

0 commit comments

Comments
 (0)