~rabbits/uxnfor

87a9f24d99ae9cda2981aff26f6932af311ec210 — neauoire 2 months ago 957a81c
Added more tests
2 files changed, 86 insertions(+), 7 deletions(-)

M etc/test.tal
M src/uxnfor.tal
M etc/test.tal => etc/test.tal +81 -2
@@ 1,8 1,87 @@
( devices )

|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|b0 @File2 &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
	( zero-page )

|0000

	@a $40
	@b $40
	@c $40
	@struct &a $1 &b $1 &c $1
	( main )

|0100

@vector1 ( -> )
	BRK
	( first comment ) BRK

@vector2 ( -> )
	BRK
	#01
	( second comment ) BRK

@comment ( -- )
	( foo ) #1234 #1234
	( bar ) #1234 #1234 #1234
	( dez ) #1234 #1234 #1234 JMP2r

@padded ( -- )
	( | foo )
	#1234 #1234
	( | bar )
	#1234 #1234 #1234
	( | dez )
	#1234 #1234 #1234 JMP2r

@inline-block ( -- )
	[ LIT &nest $1 ] ?&>no-nest
		#09 <emit> &>no-nest
	JMP2r

@eol-cond ( len* -- and )
	DUP2 #0002 EQU2 ?&byte
	DUP2 #0004 EQU2 ?&short
	DUP2 #000c GTH2 ?&long
	POP2 #03 JMP2r

@loop ( w* -- cap* )
	&w ( -- )
		INC2 & LDAk #20 GTH ?&w
	JMP2r

@lambdas ( -- )
	?{ short body }
	?{
		long body <send>
		#1234 <send>
		#5678 <send> }
	( | nesting )
	{ foo { bar }
		dez }
	foo { bar }
	dez

(
@|mark )

@icn [ 1234 1234 1234 1234 ]

@icn [ 12 34 12 34 12 34 12 34 ]

@chr [
	1234 1234 1234 1234 1234 1234 1234 1234 ]

@chr [
	12 34 12 34 12 34 12 34 12 34 12 34 12 34 12 34 ]

@block [
	1234 1234 1234 1234 1234 1234 1234 1234
	1234 1234 1234 1234 ]

@dict &a "foo $1
	&b "bar $1
	&c "dez $1


M src/uxnfor.tal => src/uxnfor.tal +5 -5
@@ 183,7 183,7 @@
	&tail ( -- )
		<emit-word>/
		( | Do not break when followed by label )
		DUP2 wcap/ INC2 LDA LIT "& EQU ?&>no-break
		DUP2 wcap/ INC2 LDA [ LIT "& ] EQU ?&>no-break
		DUP2 wcap/ INC2 LDA #28 EQU ?&>no-break
			<emit-break> &>no-break
		!eval-scope/w


@@ 228,11 228,11 @@
	!eval-scope/continue

@handle-jxi ( addr* -- addr* )
	INC2k LDA LIT "{ EQU ?handle-lambda
	INC2k LDA [ LIT "{ ] EQU ?handle-lambda
	INC2k is-defined-before #00 EQU ?{ #01 ;<emit-break>/nest STA }
	<emit-word>/
	<emit-space>
	INC2k LDA LIT "} EQU ?eval-scope/continue
	INC2k LDA [ LIT "} ] EQU ?eval-scope/continue
	INC2k LDA #00 EQU ?eval-scope/continue
	<emit-break>
	!eval-scope/continue


@@ 273,7 273,7 @@
		POP2 POP2 #01 JMP2r

@is-breaking ( str* -- bool )
	DUP2 wcap/ INC2 LDA LIT "} EQU ?&ignore
	DUP2 wcap/ INC2 LDA [ LIT "} ] EQU ?&ignore
	DUP2 wcap/ INC2 LDA2 LIT2 "&> EQU2 ?&ignore
	DUP2 wcap/ INC2 LDA #00 EQU ?&ignore
	LDAk LIT "< EQU ?&pass


@@ 512,7 512,7 @@
	&put ( c -- )
		#00 [ LIT2 &ptr =mem/scope ]
		( ) DUP2 ;mem/scope-cap EQU2 ?&overflow
		INC2k ,&ptr STR2
		( ) INC2k ,&ptr STR2
		STA2
		JMP2r
	&overflow ( c* ptr* -- )