recognizers
A collection of recognizers
\ check for double number input
\ strictly following Forth 2012 spec
\ only trailing dots are allowed
\ TBD: base prefixes
S" ./Recognizer-gforth.4th" INCLUDED
\ S" ./Recognizer-vfx.4th" INCLUDED
: rec:dnum ( addr len -- d r:dnum | rfail )
2dup + 1- c@ [char] . = if
2>r 0 0 2r> >number
if drop r:dnum else drop 2drop r:fail then
else
2drop r:fail
then
;
T{ S" 1234." rec:dnum -> 1234. r:dnum }T
\ T{ S" -1234." rec:dnum -> -1234. r:dnum }T
\ T{ S" $1234." rec:dnum -> $1234. r:dnum }T
T{ S" 1234" rec:dnum -> r:fail }T
T{ S" ABC" rec:dnum -> r:fail }T
by mtrute
Versions
2.1.0, 2.0.0, 1.4.5, 1.4.4, 1.4.3, 1.4.2, 1.4.1, 1.4.0, 1.3.2, 1.3.1, 1.3.0, 1.2.1, 1.2.0, 1.1.0, 1.0.1, 1.0.0
Download current as zip
Tags
recognizer, recognizerstack, stack
Dependencies
ttester 1.x.x, stack 1.x.x
Dependents
None