commit 88fd374e5e9405489056dd7ffc8bfa65d0480e0e
parent a0fb2498a8e23a1fab71127da3f75de8219e7aae
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Thu, 2 Jan 2025 13:21:14 -0800
(uxnasm) Allow for special nested form in comments
Diffstat:
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/uxnasm.c b/src/uxnasm.c
@@ -161,12 +161,15 @@ walkcomment(FILE *f, Context *ctx)
char c, last = 0;
int depth = 1;
while(f && fread(&c, 1, 1, f)) {
- if(c == 0xa) ctx->line++;
- if(last <= 0x20){
- if(c == '(') depth++;
- if(c == ')' && --depth < 1) return 1;
- }
- last = c;
+ if(c <= 0x20) {
+ if(c == 0xa) ctx->line++;
+ if(last == '(') depth++;
+ else if(last == ')' && --depth < 1) return 1;
+ last = 0;
+ } else if(last <= 0x20)
+ last = c;
+ else
+ last = '~';
}
return error_asm("Comment incomplete");
}
@@ -364,7 +367,7 @@ parse(char *w, FILE *f, Context *ctx)
Item *m;
switch(w[0]) {
case 0x0: return 1;
- case '(': return walkcomment(f, ctx);
+ case '(': if (w[1] <= 0x20) return walkcomment(f, ctx); else return error_asm("Invalid word");
case '%': return makemacro(w + 1, f, ctx);
case '@': return makelabel(w + 1, 1, ctx);
case '&': return makelabel(w, 0, ctx);