Abstracted walk-comment
This commit is contained in:
parent
bcdd08bc4e
commit
a197c24b2a
|
@ -1,5 +1,7 @@
|
||||||
( init )
|
( init )
|
||||||
|
|
||||||
|
%emit { #18 DEO }
|
||||||
|
|
||||||
|0100 @program
|
|0100 @program
|
||||||
|
|
||||||
#1234 SWP
|
#1234 SWP
|
||||||
|
@ -11,8 +13,8 @@
|
||||||
;hello-word
|
;hello-word
|
||||||
|
|
||||||
&while
|
&while
|
||||||
( send ) LDAk #18 DEO
|
( send ) LDAk emit
|
||||||
( loop ) INC2 LDAk ,&while JCN
|
( loop ) INC2 LDAk ?&while
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
#010f DEO
|
#010f DEO
|
||||||
|
|
25
src/uxnasm.c
25
src/uxnasm.c
|
@ -313,15 +313,12 @@ doinclude(char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse(char *w, FILE *f)
|
walkcomment(char *w, FILE *f)
|
||||||
{
|
{
|
||||||
int i;
|
int i = 1;
|
||||||
char word[0x40], c;
|
char word[0x40];
|
||||||
Macro *m;
|
if(slen(w) != 1)
|
||||||
switch(w[0]) {
|
fprintf(stderr, "-- Malformed comment: %s\n", w);
|
||||||
case '(': /* comment */
|
|
||||||
if(slen(w) != 1) fprintf(stderr, "-- Malformed comment: %s\n", w);
|
|
||||||
i = 1; /* track nested comment depth */
|
|
||||||
while(fscanf(f, "%63s", word) == 1) {
|
while(fscanf(f, "%63s", word) == 1) {
|
||||||
if(slen(word) != 1)
|
if(slen(word) != 1)
|
||||||
continue;
|
continue;
|
||||||
|
@ -330,7 +327,17 @@ parse(char *w, FILE *f)
|
||||||
else if(word[0] == ')' && --i < 1)
|
else if(word[0] == ')' && --i < 1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
parse(char *w, FILE *f)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char c;
|
||||||
|
Macro *m;
|
||||||
|
switch(w[0]) {
|
||||||
|
case '(': return walkcomment(w, f);
|
||||||
case '~': return !doinclude(w + 1) ? error_asm("Invalid include") : 1;
|
case '~': return !doinclude(w + 1) ? error_asm("Invalid include") : 1;
|
||||||
case '%': return !makemacro(w + 1, f) ? error_asm("Invalid macro") : 1;
|
case '%': return !makemacro(w + 1, f) ? error_asm("Invalid macro") : 1;
|
||||||
case '@': return !makelabel(w + 1, 1) ? error_asm("Invalid label") : 1;
|
case '@': return !makelabel(w + 1, 1) ? error_asm("Invalid label") : 1;
|
||||||
|
|
Loading…
Reference in New Issue