| ... | ... |
@@ -82,8 +82,8 @@ expect_failure 'Recursion level too deep:' <<'EOD' |
| 82 | 82 |
%you { me }
|
| 83 | 83 |
|1000 me |
| 84 | 84 |
EOD |
| 85 |
-expect_failure 'Recursion level too deep: include' <<'EOD' |
|
| 86 |
-include asma-test/in.tal |
|
| 85 |
+expect_failure 'Recursion level too deep: ~asma-test/in.tal' <<'EOD' |
|
| 86 |
+~asma-test/in.tal |
|
| 87 | 87 |
EOD |
| 88 | 88 |
expect_failure 'Label not found: ;blah' <<'EOD' |
| 89 | 89 |
|1000 ;blah |
| ... | ... |
@@ -226,7 +226,7 @@ |
| 226 | 226 |
POP2 POP2 POP2 POP2 POP2 |
| 227 | 227 |
JMP2r |
| 228 | 228 |
|
| 229 |
-include projects/library/file-read-chunks.tal |
|
| 229 |
+~projects/library/file-read-chunks.tal |
|
| 230 | 230 |
|
| 231 | 231 |
( |
| 232 | 232 |
Assemble a chunk of source code, which begins with whitespace or the start |
| ... | ... |
@@ -303,7 +303,6 @@ include projects/library/file-read-chunks.tal |
| 303 | 303 |
asma/state contains several meaningful bits: |
| 304 | 304 |
0x02 we are in a comment, |
| 305 | 305 |
0x04 we are in a macro body, |
| 306 |
- 0x08 we are expecting an include filename, and |
|
| 307 | 306 |
0x10 we are in a macro body that we are ignoring |
| 308 | 307 |
(because the macro was already defined in a previous pass). |
| 309 | 308 |
Since 0x10 never appears without 0x04, the lowest bit set in asma/state is |
| ... | ... |
@@ -349,15 +348,11 @@ include projects/library/file-read-chunks.tal |
| 349 | 348 |
:asma-first-char-normal/_entry |
| 350 | 349 |
:asma-first-char-comment/_entry |
| 351 | 350 |
:asma-first-char-macro/_entry |
| 352 |
- $2 ( invalid position ) |
|
| 353 |
- $2 ( empty tree for include ) |
|
| 354 | 351 |
|
| 355 | 352 |
&body-routines |
| 356 | 353 |
:asma-normal-body |
| 357 | 354 |
:asma-ignore |
| 358 | 355 |
:asma-macro-body |
| 359 |
- $2 ( invalid position ) |
|
| 360 |
- :asma-include-filename |
|
| 361 | 356 |
|
| 362 | 357 |
@asma-parse-hex-digit ( charcode -- 00-0f if valid hex |
| 363 | 358 |
OR 10-ff otherwise ) |
| ... | ... |
@@ -410,14 +405,14 @@ include projects/library/file-read-chunks.tal |
| 410 | 405 |
%asma-RETURN-FLAG { #40 }
|
| 411 | 406 |
%asma-KEEP-FLAG { #80 }
|
| 412 | 407 |
|
| 413 |
-include projects/library/string.tal |
|
| 408 |
+~projects/library/string.tal |
|
| 414 | 409 |
|
| 415 | 410 |
@asma-traverse-tree ( incoming-ptr* -- binary-ptr* 00 if key found |
| 416 | 411 |
OR node-incoming-ptr* 01 if key not found ) |
| 417 | 412 |
;asma/token LDA2 |
| 418 | 413 |
( fall through to traverse-tree ) |
| 419 | 414 |
|
| 420 |
-include projects/library/binary-tree.tal |
|
| 415 |
+~projects/library/binary-tree.tal |
|
| 421 | 416 |
|
| 422 | 417 |
@asma-parse-opcode ( -- byte 00 if valid opcode |
| 423 | 418 |
OR 01 otherwise ) |
| ... | ... |
@@ -526,7 +521,7 @@ include projects/library/binary-tree.tal |
| 526 | 521 |
POP2 POP2 |
| 527 | 522 |
JMP2r |
| 528 | 523 |
|
| 529 |
-include projects/library/heap.tal |
|
| 524 |
+~projects/library/heap.tal |
|
| 530 | 525 |
|
| 531 | 526 |
( |
| 532 | 527 |
First character routines. |
| ... | ... |
@@ -793,12 +788,6 @@ include projects/library/heap.tal |
| 793 | 788 |
|
| 794 | 789 |
¬-macro |
| 795 | 790 |
POP2 |
| 796 |
- ;&include-string ;asma/token LDA2 |
|
| 797 |
- ;strcmp JSR2 NIP2 NIP2 NIP ,¬-include JCN |
|
| 798 |
- #08 asma-STATE-SET |
|
| 799 |
- JMP2r |
|
| 800 |
- |
|
| 801 |
- ¬-include |
|
| 802 | 791 |
;asma-msg-token ;asma/error STA2 |
| 803 | 792 |
JMP2r |
| 804 | 793 |
|
| ... | ... |
@@ -806,10 +795,8 @@ include projects/library/heap.tal |
| 806 | 795 |
;asma-msg-too-deep ;asma/error STA2 |
| 807 | 796 |
JMP2r |
| 808 | 797 |
|
| 809 |
- &include-string "include 00 |
|
| 810 |
- |
|
| 811 |
-@asma-include-filename |
|
| 812 |
- #08 asma-STATE-CLEAR |
|
| 798 |
+@asma-include |
|
| 799 |
+ .System/rst DEI #e0 GTH ,asma-normal-body/too-deep JCN |
|
| 813 | 800 |
;heap LDA2 |
| 814 | 801 |
;asma/token LDA2 ;append-heap-string JSR2 |
| 815 | 802 |
;asma-assemble-file-pass JSR2 |
| ... | ... |
@@ -864,7 +851,8 @@ include projects/library/heap.tal |
| 864 | 851 |
&5d :&40 :&7c '] 00 :asma-ignore |
| 865 | 852 |
&7b $2 $2 '{ 00 :asma-ignore
|
| 866 | 853 |
&7c :&7b :&7d '| 00 :asma-pad-absolute |
| 867 |
- &7d $2 $2 '} 00 :asma-ignore |
|
| 854 |
+ &7d $2 :&7e '} 00 :asma-ignore |
|
| 855 |
+ &7e $2 $2 '~ 00 :asma-include |
|
| 868 | 856 |
|
| 869 | 857 |
@asma-opcodes |
| 870 | 858 |
&_entry :>H :&ROT &_disasm "LIT 00 |
| ... | ... |
@@ -401,11 +401,11 @@ RTN |
| 401 | 401 |
2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d |
| 402 | 402 |
5053 5659 5c5f 6265 686b 6e71 7477 7a7d |
| 403 | 403 |
|
| 404 |
-include projects/library/check-rom.tal |
|
| 405 |
-include projects/library/load-rom.tal |
|
| 404 |
+~projects/library/check-rom.tal |
|
| 405 |
+~projects/library/load-rom.tal |
|
| 406 | 406 |
|
| 407 |
-include projects/assets/mascot0cx0c.tal |
|
| 408 |
-include projects/assets/msx01x02.tal |
|
| 407 |
+~projects/assets/mascot0cx0c.tal |
|
| 408 |
+~projects/assets/msx01x02.tal |
|
| 409 | 409 |
|
| 410 | 410 |
@dir |
| 411 | 411 |
&path ". $1 |
| ... | ... |
@@ -142,7 +142,7 @@ sublabel(char *src, char *scope, char *name) |
| 142 | 142 |
#pragma mark - Parser |
| 143 | 143 |
|
| 144 | 144 |
static int |
| 145 |
-error(char *name, char *msg) |
|
| 145 |
+error(const char *name, const char *msg) |
|
| 146 | 146 |
{
|
| 147 | 147 |
fprintf(stderr, "%s: %s\n", name, msg); |
| 148 | 148 |
return 0; |
| ... | ... |
@@ -310,17 +310,14 @@ parsetoken(char *w) |
| 310 | 310 |
} |
| 311 | 311 |
|
| 312 | 312 |
static int |
| 313 |
-doinclude(FILE *f, int (*pass)(FILE *)) |
|
| 313 |
+doinclude(const char *filename, int (*pass)(FILE *)) |
|
| 314 | 314 |
{
|
| 315 |
- char word[64]; |
|
| 316 |
- FILE *finc; |
|
| 315 |
+ FILE *f; |
|
| 317 | 316 |
int ret; |
| 318 |
- if(fscanf(f, "%63s", word) != 1) |
|
| 319 |
- return error("End of input", "include");
|
|
| 320 |
- if(!(finc = fopen(word, "r"))) |
|
| 321 |
- return error("Include failed to open", word);
|
|
| 322 |
- ret = pass(finc); |
|
| 323 |
- fclose(finc); |
|
| 317 |
+ if(!(f = fopen(filename, "r"))) |
|
| 318 |
+ return error("Include failed to open", filename);
|
|
| 319 |
+ ret = pass(f); |
|
| 320 |
+ fclose(f); |
|
| 324 | 321 |
return ret; |
| 325 | 322 |
} |
| 326 | 323 |
|
| ... | ... |
@@ -348,8 +345,8 @@ pass1(FILE *f) |
| 348 | 345 |
} else if(w[0] == '&') {
|
| 349 | 346 |
if(!makelabel(sublabel(subw, scope, w + 1))) |
| 350 | 347 |
return error("Pass 1 - Invalid sublabel", w);
|
| 351 |
- } else if(scmp(w, "include", 8)) {
|
|
| 352 |
- if(!doinclude(f, pass1)) |
|
| 348 |
+ } else if(w[0] == '~') {
|
|
| 349 |
+ if(!doinclude(w + 1, pass1)) |
|
| 353 | 350 |
return 0; |
| 354 | 351 |
} else if(sihx(w)) |
| 355 | 352 |
addr += slen(w) / 2; |
| ... | ... |
@@ -386,8 +383,8 @@ pass2(FILE *f) |
| 386 | 383 |
} else if(w[0] == '@') {
|
| 387 | 384 |
scpy(w + 1, scope, 64); |
| 388 | 385 |
continue; |
| 389 |
- } else if(scmp(w, "include", 8)) {
|
|
| 390 |
- if(!doinclude(f, pass2)) |
|
| 386 |
+ } else if(w[0] == '~') {
|
|
| 387 |
+ if(!doinclude(w + 1, pass2)) |
|
| 391 | 388 |
return 0; |
| 392 | 389 |
continue; |
| 393 | 390 |
} |