Passing more tests

This commit is contained in:
Devine Lu Linvega 2024-08-10 11:01:48 -07:00
parent 3494edeece
commit 54e758bce5
6 changed files with 23 additions and 27 deletions

View File

@ -70,23 +70,27 @@
;src
( >> )
@handle-file ( f* -- )
@<handle-file> ( f* -- )
.File/name DEO2
#0001 .File/length DEO2
#0000
&>s ( len* -- )
;&c feof ?{
INC2 [ LIT &c $1 ] handle-char !&>s }
INC2 [ LIT &c $1 ] <handle-char>
[ LIT2 00 -halt ] LDZ EQU ?&>s }
ORA ?{
;include/mem ;token <scpy>
;err/source !<set-error> }
JMP2r
@handle-char ( c -- )
@<handle-char> ( c -- )
DUP #20 GTH ?{
POP ;token LDAk ?{ POP2 JMP2r }
DUP2 <parse-token> !<sclr> }
#00 ;token scap/ STA2
#00 ;token scap/
( | test token size )
DUP2 ;token SUB2 NIP #30 LTH ?{ ;err/token <set-error> }
STA2
JMP2r
@<parse-token> ( t* -- )
@ -267,7 +271,7 @@
&comment POP2 !<walk-comment>
&inctal INC2k ;include/mem <scpy>
<sclr>
;include/mem !handle-file
;include/mem !<handle-file>
&ignore POP2 JMP2r
(
@ -561,9 +565,10 @@
&hex "Hexadecimal 20 "invalid: $1
&zeropage "Writing 20 "zero-page: $1
&opcode "Opcode 20 "invalid: $1
&length "Length $1
&reference "Reference $1
&reference "Reference 20 "invalid: $1
&distance "Reference 20 "too 20 "far: $1
&length "Program 20 "size 20 "exceeded. $1
&token "Token 20 "size 20 "exceeded: $1
&sublabel "Sublabel $1
&refs-overflow "Refs 20 "Overflow $1

View File

@ -53,7 +53,7 @@ echo "Opcode invalid: ADD2q"
$asm "tests/err-opc.tal" "bin/res.rom"
echo ""
echo "Label unknown: .missing"
echo "Reference invalid: missing"
$asm "tests/err-ref.tal" "bin/res.rom"
echo ""
@ -65,19 +65,10 @@ echo "Reference too far: prev"
$asm "tests/err-farbwd.tal" "bin/res.rom"
echo ""
echo " Length ab in RESET"
echo "Program size exceeded."
$asm "tests/err-length.tal" "bin/res.rom"
echo ""
echo " Token @token-length-30-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa in reset"
$asm "tests/err-toklen.tal" "bin/res.rom"
echo "Token size exceeded: @aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
$asm "tests/err-token.tal" "bin/res.rom"
echo ""
echo " Sublabel &some-long-sublabel in token-length-20-aaaaaaaaaaaaaaaa"
$asm "tests/err-lablen.tal" "bin/res.rom"
echo ""
echo ""
echo "Assembled bin/res.rom in 148 bytes"
$asm "tests/err-farall.tal" "bin/res.rom"

View File

@ -1,3 +1,4 @@
( distance too far, backward )
( fails ff7f -129 ) &back $7e ,&back
( fails ff7f -129 ) &back $7e ,&back

View File

@ -1,3 +1,4 @@
( distance too far, forward )
( fails 0080 +128 ) ,&next $81 &next
( fails 0080 +128 ) ,&next $81 &next

3
tests/err-token.tal Normal file
View File

@ -0,0 +1,3 @@
( token length too long )
@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1234

View File

@ -1,5 +0,0 @@
( token length too long )
|0100 #1234 BRK
@token-length-30-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa