Browse code

Added detection of recursive include errors.

Andrew Alderwick authored on 07/10/2021 22:26:39
Showing 2 changed files
... ...
@@ -62,6 +62,11 @@ expect_failure 'Memory overwrite: SUB' <<'EOD'
62 62
 |2000 ADD
63 63
 |1000 SUB
64 64
 EOD
65
+expect_failure 'Recursion level too deep:' <<'EOD'
66
+%me { you }
67
+%you { me }
68
+|1000 me
69
+EOD
65 70
 
66 71
 echo 'All OK'
67 72
 
... ...
@@ -759,9 +759,8 @@ include projects/library/heap.tal
759 759
 	( hex short   ) ,asma-short-helper/raw JMP
760 760
 
761 761
 	&not-hex
762
-	;asma-trees/macros ;asma-traverse-tree JSR2 ,&not-macro JCN
763
-
764 762
 	.System/rst DEI #e0 GTH ,&too-deep JCN
763
+	;asma-trees/macros ;asma-traverse-tree JSR2 ,&not-macro JCN
765 764
 
766 765
 	&macro-loop
767 766
 	LDAk ,&keep-going JCN
... ...
@@ -770,9 +769,13 @@ include projects/library/heap.tal
770 769
 
771 770
 	&keep-going
772 771
 	DUP2k ;strlen JSR2 INC2 ADD2
773
-	SWP2 ;asma-assemble-token JSR2 asma-IF-ERROR ,&error JCN
772
+	SWP2 ;asma-assemble-token JSR2 asma-IF-ERROR ,&macro-error JCN
774 773
 	,&macro-loop JMP
775 774
 
775
+	&macro-error
776
+	POP2
777
+	JMP2r
778
+
776 779
 	&not-macro
777 780
 	POP2
778 781
 	;&include-string ;asma/token LDA2
... ...
@@ -782,11 +785,9 @@ include projects/library/heap.tal
782 785
 
783 786
 	&not-include
784 787
 	;asma-msg-label ;asma/error STA2
785
-	&error
786 788
 	JMP2r
787 789
 
788 790
 	&too-deep
789
-	POP2
790 791
 	;asma-msg-too-deep ;asma/error STA2
791 792
 	JMP2r
792 793
 
... ...
@@ -808,7 +809,7 @@ include projects/library/heap.tal
808 809
 @asma-msg-label     "Label 20 "not 20 "found 00
809 810
 @asma-msg-macro     "Macro 20 "already 20 "exists 00
810 811
 @asma-msg-rewound   "Memory 20 "overwrite 00
811
-@asma-msg-too-deep  "Macro 20 "expansion 20 "level 20 "too 20 "deep 00
812
+@asma-msg-too-deep  "Recursion 20 "level 20 "too 20 "deep 00
812 813
 
813 814
 ( trees )
814 815