~aleteoryx/uxn

41e8d49142998fca1751ef6c30e4ce4fe8bc027c — Aleteoryx 2 months ago 0bb975b
BITAP
1 files changed, 8 insertions(+), 8 deletions(-)

M grep.tal
M grep.tal => grep.tal +8 -8
@@ 1,7 1,7 @@
(	grep.tal
	by aleteoryx, all rights released
	
	an implementation of the bezza-yates-gonet "shift-or" bitlap
	an implementation of the bezza-yates-gonet "shift-or" bitap
	search algorithm, for fixed search patterns up to 16 bytes )




@@ 25,7 25,7 @@
	"grep.rom 0a
	"aleteoryx, 20 "all 20 "rights 20 "released 0a0a
	
	"bezza-yates-gonet 20 ""bitlap" 20 "text 20 "search 0a00
	"bezza-yates-gonet 20 ""bitap" 20 "text 20 "search 0a00

@args ( -> )
	#17 DEI


@@ 37,10 37,10 @@
	( we need to shift state up 10 - lut/len bits before orring it
	  with match, this is where that's calculated. )
	;lut/len LDA2 SUB 	( the high byte will be 00 )
	;bitlap/sft STA
	;bitap/sft STA
	
	;bitlap/in #10 DEO2
	[ LITr 80 ] #ffff	( prep the stack for bitlap/in )
	;bitap/in #10 DEO2
	[ LITr 80 ] #ffff	( prep the stack for bitap/in )
	BRK
	



@@ 62,7 62,7 @@

( --- check for a match --- )

@bitlap/in ( state* `match -> state* `match )
@bitap/in ( state* `match -> state* `match )
	( handle the line buffer )
	#0a12 DEI DUP		( get char, save a byte later )
	[ LIT2 &ptr =/line ]	( line pointer )


@@ 80,7 80,7 @@
	DUP2 [ LIT &sft $1 ] SFT2
	POP STH ANDr BRK

@bitlap/newline ( state* `match -> state* `match )
@bitap/newline ( state* `match -> state* `match )
	;/line ,/ptr STR2	( reset line ptr )
	POP2 #ffff		( reset state )
	STHr [ LITr 80 ]	( reset match )


@@ 121,4 121,4 @@


@lut ( ... ) $200 ( ... ) @lut/end
@bitlap/line ( the incoming line gets written here )
@bitap/line ( the incoming line gets written here )