commit 2fa40f1
zzo38
·
2023-09-06 16:51:59 +0000 UTC
parent 8895a82
Correct the uxntal lambda syntax to the newest version.
M
asm.doc
+3,
-4
1@@ -89,10 +89,9 @@ The following standard tokens are available:
2 you must use separate tokens such as 20 for spaces.)
3
4 { and } can be used around a lambda block (they can also be used for
5- macros as described above). The { represents a JSI to the matching } and
6- the } represents a STH2r instruction. In this way, the { } block is
7- skipped and the address of the beginning of the block (after the JSI
8- instruction) will be stored on the stack.
9+ macros as described above). This is the same as the nonstandard [& ]@
10+ block (described below), but internally uses a separate stack. You can
11+ also use other runes at the beginning e.g. ?{ } is like the [? ]@ block.
12
13 An instruction opcode consists of three uppercase letters, optionally
14 followed by any combination of instruction flags which can be "2" for
M
uxnasm.c
+16,
-15
1@@ -206,6 +206,13 @@ makelabel(char *name)
2 return 1;
3 }
4
5+static char*makelambda(int id) {
6+ scpy("lambda", p.lambda, 7);
7+ p.lambda[6] = '0' + (id >> 0x4);
8+ p.lambda[7] = '0' + (id & 0xf);
9+ return p.lambda;
10+}
11+
12 static int
13 makereference(char *scope, char *label, Uint16 addr)
14 {
15@@ -214,9 +221,13 @@ makereference(char *scope, char *label, Uint16 addr)
16 if(p.rlen == MAXREFS)
17 return error("References limit exceeded", label);
18 r = &p.refs[p.rlen++];
19- if(label[1] == '&' && scope)
20+ if(label[1] == '&' && scope) {
21 scpy(sublabel(subw, scope, label + 2), r->name, 0x40);
22- else {
23+ } else if(label[1] == '{') {
24+ if(p.lambda_ptr==256) return error("Lambda stack overflow", label);
25+ p.lambda_stack[p.lambda_ptr++] = p.lambda_count;
26+ scpy(makelambda(p.lambda_count++), r->name, 0x40);
27+ } else {
28 int pos = spos(label + 1, '/');
29 if(pos > 0) {
30 Label *l;
31@@ -230,13 +241,6 @@ makereference(char *scope, char *label, Uint16 addr)
32 return 1;
33 }
34
35-static char*makelambda(int id) {
36- scpy("?lambda", p.lambda, 8);
37- p.lambda[7] = '0' + (id >> 0x4);
38- p.lambda[8] = '0' + (id & 0xf);
39- return p.lambda;
40-}
41-
42 static int makeexp(Uint8 kind,char*name,Uint32 len,Uint8 misc) {
43 ExpItem*e;
44 if(p.xlen==MAXEXPS) return error("Expansion limit exceeded","");
45@@ -557,13 +561,10 @@ parse(char *w, FILE *f)
46 if(!makeexp('^',w+1,0,0)) return 0;
47 p.exps[p.xlen-1].len=p.ptr;
48 break;
49- case '{': /* lambda start */
50- p.lambda_stack[p.lambda_ptr++] = p.lambda_count;
51- makereference(p.scope, makelambda(p.lambda_count++), p.ptr + 1);
52- return writebyte(0x60) && writeshort(0xffff, 0);
53 case '}': /* lambda end */
54- if(!makelabel(makelambda(p.lambda_stack[--p.lambda_ptr])+1)) return error("Invalid label", w);
55- return writebyte(0x6f);
56+ if(!p.lambda_ptr) return error("Lambda stack underflow", w);
57+ if(!makelabel(makelambda(p.lambda_stack[--p.lambda_ptr]))) return error("Invalid label", w);
58+ break;
59 case '[':
60 case ']':
61 if(slen(w) == 1) break;