commit 6276d18

Devine Lu Linvega  ·  2025-01-02 21:20:49 +0000 UTC
parent 5025c03
(uxnasm) Allow for special nested form in comments
1 files changed,  +10, -7
+10, -7
 1@@ -161,12 +161,15 @@ walkcomment(FILE *f, Context *ctx)
 2 	char c, last = 0;
 3 	int depth = 1;
 4 	while(f && fread(&c, 1, 1, f)) {
 5-		if(c == 0xa) ctx->line++;
 6-		if(last <= 0x20){
 7-			if(c == '(') depth++;
 8-			if(c == ')' && --depth < 1) return 1;
 9-		}
10-		last = c;
11+		if(c <= 0x20) {
12+			if(c == 0xa) ctx->line++;
13+			if(last == '(') depth++;
14+			else if(last == ')' && --depth < 1) return 1;
15+			last = 0;
16+		} else if(last <= 0x20)
17+			last = c;
18+		else
19+			last = '~';
20 	}
21 	return error_asm("Comment incomplete");
22 }
23@@ -364,7 +367,7 @@ parse(char *w, FILE *f, Context *ctx)
24 	Item *m;
25 	switch(w[0]) {
26 	case 0x0: return 1;
27-	case '(': return walkcomment(f, ctx);
28+	case '(': if (w[1] <= 0x20) return walkcomment(f, ctx); else return error_asm("Invalid word");
29 	case '%': return makemacro(w + 1, f, ctx);
30 	case '@': return makelabel(w + 1, 1, ctx);
31 	case '&': return makelabel(w, 0, ctx);