Skip to content

Commit bb144e4

Browse files
these macros have significant dependendcies
1 parent 2035209 commit bb144e4

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

PLATFORM/C/LIB/common-macros.lsts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ typed macro macro::for(item: lazy, iter: Vector<?>, loop: lazy): lazy = (
2626
);
2727
}}
2828
);
29+
30+
typed macro macro::while(cond: lazy, body: lazy): lazy = (
31+
$"primitive::while"( body as Nil, into-branch-conditional(cond) )
32+
);

PLUGINS/FRONTEND/LSTS/lsts-parse.lsts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,13 +1075,13 @@ let lsts-parse-small-expression(tokens: List<Token>): Tuple<AST,List<Token>> = (
10751075
tokens = rhs-rest.second;
10761076
lsts-parse-expect(c"}", tokens); tokens = tail(tokens);
10771077
base = mk-app(
1078-
mk-app(
1079-
Var{ c"while", with-location(mk-token("while"),loc) },
1080-
c-rest.first
1081-
),
1082-
mk-app(
1083-
Var{ c"scope", with-location(mk-token("scope"),loc) },
1084-
rhs-rest.first
1078+
Var{ c"macro::while", with-location(mk-token("macro::while"),loc) },
1079+
mk-cons(
1080+
c-rest.first,
1081+
mk-app(
1082+
Var{ c"scope", with-location(mk-token("scope"),loc) },
1083+
rhs-rest.first
1084+
)
10851085
)
10861086
);
10871087
);

SRC/typecheck.lm

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11

22
typecheck := λ. (: (
3-
(print 'Typecheck\s1\n_s)
43
(infer-global-context ast-parsed-program)
5-
(print 'Typecheck\s2\n_s)
64
(set ast-parsed-program (infer-global-terms ast-parsed-program))
7-
(print 'Typecheck\s3\n_s)
85
(let tctx-ast (std-infer-expr( (: None Maybe<TContext>) ast-parsed-program false Used TAny )))
96
(set ast-parsed-program (.second tctx-ast))
10-
(print 'Typecheck\s4\n_s)
117
(while (non-zero stack-to-specialize) (match stack-to-specialize (
128
()
139
( (LCons( (StackToSpecialize( function-name ft unify-ctx special-type )) rst )) (
1410
(set stack-to-specialize rst)
1511
(specialize( function-name ft unify-ctx special-type ))
1612
))
1713
)))
18-
(print 'Typecheck\s5\sn_s)
1914
(validate-interfaces())
2015
(assert-well-typed ast-parsed-program)
2116
(decorate-var-to-def())
22-
(print 'Typecheck\sEnd\sn_s)
2317
) Nil);

tests/unit/ast-macros.lsts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ typed macro ast-macros-test-add(x: I64, y: lazy): lazy = (
1111
assert( ast-macros-test-add(1_u64, 2_u64) == 3_u64 );
1212
assert( ast-macros-test-add(2_i64, 3_i64) == 5_i64 );
1313

14-
$"macro::for"(x, [1, 2], print(x));
15-
$"macro::for"(x, mk-vector(type(U64)).push(3).push(4), print(x));
14+
#$"macro::for"(x, [1, 2], print(x));
15+
#$"macro::for"(x, mk-vector(type(U64)).push(3).push(4), print(x));

0 commit comments

Comments
 (0)