recognizers
A collection of recognizers
\
\ Purpose: dictionary lookup recognizer using Name Tokens
\ It does not use the search order, only the
\ forth-wordlist is searched
\
\ Requires: Forth 2012 TRAVERSE-WORDLIST and Quotations.
\
\ Author: Matthias Trute
\ Date: Oct 10, 2016
\ License: Public Domain
\
:NONAME NAME>INTERPRET EXECUTE ; ( nt -- ) \ interpret
:NONAME NAME>COMPILE EXECUTE ; ( nt -- ) \ compile
:NONAME POSTPONE LITERAL ; ( nt -- ) \ postpone
RECOGNIZER: R:NAME
\ the analogon to search-wordlist
: search-name ( addr len wid -- nt | 0 )
>R 0 \ used as flag inside the following quotation
[: ( addr len flag nt -- addr len false true | nt false )
>R DROP 2DUP R@ NAME>STRING COMPARE
IF R> DROP 0 -1 ELSE 2DROP R> 0 THEN
;] R> TRAVERSE-WORDLIST ( -- addr len false | nt )
DUP 0= IF NIP NIP THEN
;
\ a single wordlist is checked
: (rec:name) ( addr len wid -- nt R:NAME | R:FAIL )
search-name
?DUP IF R:NAME ELSE R:FAIL THEN
;
\ checks only the standard word-list
: rec:name ( addr len -- nt R:NAME | R:FAIL )
FORTH-WORDLIST (rec:name)
;
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