Skip to content

Commit 03df85e

Browse files
Merge pull request #228 from andrew-johnson-4/strict-compiler-dev-6-3
Strict compiler dev 6 3
2 parents 3a473dd + 3a04c57 commit 03df85e

13 files changed

+12924
-11168
lines changed

BOOTSTRAP/cli.s

+12,839-11,131
Large diffs are not rendered by default.

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.92"
3+
version = "1.11.93"
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/match2.lm
3+
./production --nostd -o tmp.s STRICT/cli.lm
44
as -o tmp.o tmp.s
55
ld -o tmp tmp.o
66
./tmp && echo $?

PRODUCTION/stack.lm

+7
Original file line numberDiff line numberDiff line change
@@ -232,5 +232,12 @@ stack-define-destructure := λ ctx lhs offset . (match lhs (
232232
(set return (expr::set-offset( return (expr::get-offset more-e) )))
233233
return
234234
)))
235+
( Nil (tail(
236+
(local return)
237+
(set return (expr::new()))
238+
(set return (expr::set-context( return ctx )))
239+
(set return (expr::set-offset( return offset )))
240+
return
241+
)))
235242
( u (fail (UnknownStackArg lhs)))
236243
));

STDLIB/default-atom-allocator.lm

+6
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,16 @@ allocate-atom-grow := λ size . (tail(
5555
\t 'syscall \n
5656
\t 'mov \s '%rax, '%r8 \n
5757
\t 'add \s '$ page-size , \s '%r8 \n
58+
\t 'add \s '$ page-size , \s '%r8 \n
59+
\t 'add \s '$ page-size , \s '%r8 \n
60+
\t 'add \s '$ page-size , \s '%r8 \n
5861
\t 'mov \s '$12, \s '%rax \n # system call brk
5962
\t 'mov \s '%r8, \s '%rdi \n # new requested brk
6063
\t 'syscall \n
6164
\t 'sub \s '$ page-size , \s '%r8 \n
65+
\t 'sub \s '$ page-size , \s '%r8 \n
66+
\t 'sub \s '$ page-size , \s '%r8 \n
67+
\t 'sub \s '$ page-size , \s '%r8 \n
6268
\t 'mov \s '%r8, \s '%r9 \n
6369
\t 'mov \s '%r9 , \s '%r10 \n
6470
initialized ': \n

STDLIB/default-cons-allocator.lm

+6
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ allocate-cons := λ . (tail(
2929
\t 'syscall \n
3030
\t 'mov \s '%rax, '%r8 \n
3131
\t 'add \s '$ page-size , \s '%r8 \n
32+
\t 'add \s '$ page-size , \s '%r8 \n
33+
\t 'add \s '$ page-size , \s '%r8 \n
34+
\t 'add \s '$ page-size , \s '%r8 \n
3235
\t 'mov \s '$12, \s '%rax \n # system call brk
3336
\t 'mov \s '%r8, \s '%rdi \n # new requested brk
3437
\t 'syscall \n
3538
\t 'sub \s '$ page-size , \s '%r8 \n
39+
\t 'sub \s '$ page-size , \s '%r8 \n
40+
\t 'sub \s '$ page-size , \s '%r8 \n
41+
\t 'sub \s '$ page-size , \s '%r8 \n
3642
initialized ': \n
3743
\t 'add \s '$16, \s '%r8 \n
3844
\t 'mov \s '$ assemble_cons_tail , \s '%r9 \n

STRICT/ast.lm

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
3+
type AST ASTNil;
4+
5+
ast-tokenized-program := (: EOF Tokens);
6+
ast-parsed-program := (: ASTNil AST);

STRICT/cli.lm

+31-35
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import STDLIB/default-primitives.lm;
44
import STDLIB/default-rules.lm;
55
import STDLIB/default-stdlib.lm;
66

7+
import STRICT/ast.lm;
78
import STRICT/utility.lm;
89
import STRICT/tokenize.lm;
910
import STRICT/parse.lm;
@@ -18,7 +19,7 @@ config-strict := Trueu8;
1819
config-preprocess := Trueu8;
1920
config-target := 'tmp.s_s;
2021

21-
type CompileMode ModeTokenize | ModeParse | ModeTypecheck | ModeCompile;
22+
type CompileMode ModeTokenize | ModeParse | ModePreprocess | ModeTypecheck | ModeCompile;
2223
config-mode := (: ModeCompile CompileMode);
2324

2425
main := λ(: argc U64)(: argv U8[][]).(tail(
@@ -29,6 +30,7 @@ main := λ(: argc U64)(: argv U8[][]).(tail(
2930
()
3031
('--tokenize_s (set config-mode ModeTokenize))
3132
('--parse_s (set config-mode ModeParse))
33+
('--preprocess_s (set config-mode ModePreprocess))
3234
('--typecheck_s (set config-mode ModeTypecheck))
3335
('--compile_s (set config-mode ModeCompile))
3436
('--strict_s (set config-strict Trueu8))
@@ -54,41 +56,35 @@ main := λ(: argc U64)(: argv U8[][]).(tail(
5456
(print Preprocess:\s_s)(print config-preprocess)(print \n_s)
5557
(print Strict:\s_s)(print config-strict)(print \n_s)
5658

57-
# (let continue Trueu8)
58-
# (while (==( continue Trueu8 )) (match input (
59-
# ()
60-
# ( SNil (set continue Falseu8) )
61-
# ( (SCons( SNil rst )) (set input rst) )
62-
# ( (SCons( l rst )) (tail( (print l) (set input rst) )) )
63-
# ( (SCons( (SAtom( fp )) rst )) (tail( (cli-intake fp) (set input rst) )))
64-
# ( (SAtom( fp )) (tail( (cli-intake fp) (set continue False) )))
65-
# )))
59+
(let continue Trueu8)
60+
(while (==( continue Trueu8 )) (match input (
61+
()
62+
( SNil (set continue Falseu8) )
63+
( (SCons( rst SNil )) (set input rst) )
64+
( (SCons( rst (SAtom( fp )) )) (tail( (tokenize fp) (set input rst) )))
65+
( (SAtom( fp )) (tail( (tokenize fp) (set continue Falseu8) )))
66+
)))
6667

68+
(match config-mode (
69+
()
70+
( ModeTokenize () )
71+
( ModeParse (parse ast-tokenized-program) )
72+
( ModePreprocess (tail(
73+
(parse ast-tokenized-program)
74+
(preprocess ast-parsed-program)
75+
)))
76+
( ModeTypecheck (tail(
77+
(parse ast-tokenized-program)
78+
(preprocess ast-parsed-program)
79+
(typecheck())
80+
)))
81+
( ModeCompile (tail(
82+
(parse ast-tokenized-program)
83+
(preprocess ast-parsed-program)
84+
(typecheck())
85+
(compile())
86+
)))
87+
))
6788

68-
# (Compile (
69-
# (parse-program (tokenize-file (head inputs)))
70-
# (set inputs (tail inputs))
71-
# ))
72-
# (Parse (
73-
# (parse-program (tokenize-file (head inputs)))
74-
# (set inputs (tail inputs))
75-
# ))
76-
# (Typecheck (
77-
# (parse-program (tokenize-file (head inputs)))
78-
# (set inputs (tail inputs))
79-
# ))
80-
# (ParseExpression (
81-
# (print-s (parse-expression (tokenize-file (head inputs))))
82-
# (set inputs (tail inputs))
83-
# ))
84-
# (Tokenize (
85-
# (print-s (tokenize-file (head inputs)))
86-
# (set inputs (tail inputs))
87-
# ))
8889
));
8990

90-
cli-intake := λ(: fp U8[]) . (: (tail(
91-
(print 'Intake:\s_s)
92-
(print fp)
93-
(print '\n_s)
94-
)) Nil);

STRICT/codegen.lm

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
compile := λ. (: (tail(
3+
()
4+
()
5+
)) Nil);

STRICT/parse.lm

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
parse := λ(: fp Tokens). (: (tail(
3+
()
4+
()
5+
)) Nil);

STRICT/preprocess.lm

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
preprocess := λ(: program AST). (: (tail(
3+
()
4+
()
5+
)) Nil);

STRICT/tokenize.lm

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
type Tokens EOF;
3+
4+
tokenize := λ(: fp U8[]). (: (tail(
5+
()
6+
()
7+
)) Nil);

STRICT/typecheck.lm

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
typecheck := λ. (: (tail(
3+
()
4+
()
5+
)) Nil);

0 commit comments

Comments
 (0)