Skip to content

Commit ce3456a

Browse files
define a normal programming implementation of argument processing
1 parent 6e3c000 commit ce3456a

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

STRICT/cli.lm

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,40 @@ import STDLIB/default-stdlib.lm;
66

77
import STRICT/utility.lm;
88

9-
config-strict := 0u8;
9+
config-strict := True;
10+
config-preprocess := True;
11+
config-target := 'tmp.s_s;
1012

11-
type CompileMode Tokenize | Parse | Compile;
12-
config-mode := Compile;
13+
type CompileMode ModeTokenize | ModeParse | ModeTypecheck | ModeCompile;
14+
config-mode := ModeCompile;
1315

1416
main := λ(: argc U64)(: argv U8[][]).(tail(
1517
(let argi 0u64)
1618
(let input SNil)
1719
(while (<( argi argc )) (
18-
(set input (SCons(
19-
(close (SAtom(
20-
([]( argv argi ))
20+
(match ([]( argv argi )) (
21+
()
22+
('--tokenize_s (set config-mode ModeTokenize))
23+
('--parse_s (set config-mode ModeParse))
24+
('--typecheck_s (set config-mode ModeTypecheck))
25+
('--compile_s (set config-mode ModeCompile))
26+
('--strict_s (set config-strict True))
27+
('--gradual_s (set config-strict False))
28+
('--macro_s (set config-preprocess True))
29+
('--nomacro_s (set config-preprocess False))
30+
('-o_s (tail(
31+
(set argi (+( argi 1u64 )))
32+
(set input (SCons(
33+
(close input)
34+
(close (SAtom([]( argv argi ))))
35+
)))
2136
)))
22-
(close input)
23-
)))
37+
(fp (set input (SCons(
38+
(close input)
39+
(close (SAtom( fp )))
40+
))))
41+
))
2442
(set argi (+( argi 1u64 )))
2543
))
2644
(print input)
27-
# (print (==( ([]( argv argi )) (: '--tokenize U8[]) )) )
28-
# if set_target { config_target().lock().unwrap().set(arg); }
29-
# else if arg=="--tokenize" {unsafe{ CONFIG_MODE = CompileMode::Tokenize; }}
30-
# else if arg=="--parse" {unsafe{ CONFIG_MODE = CompileMode::Parse; }}
31-
# else if arg=="--typecheck" {unsafe{ CONFIG_MODE = CompileMode::Typecheck; }}
32-
# else if arg=="--compile" {unsafe{ CONFIG_MODE = CompileMode::Compile; }}
33-
# else if arg=="--strict" {unsafe{ CONFIG_STRICT = true; }}
34-
# else if arg=="--gradual" {unsafe{ CONFIG_STRICT = false; }}
35-
# else if arg=="--noprep" {unsafe{ CONFIG_PREPROCESS = false; }}
36-
# else if arg=="-o" { set_target = true; }
3745
));

0 commit comments

Comments
 (0)