A collection of recognizers
- raw README.md
- raw Recognizer.4th
- raw Stack.4th
- raw literacy.4th
- raw package.4th
- raw rec-double-paren.4th
- raw rec-find.4th
- raw rec-name.4th
- raw rec-notfound.4th
- raw rec-num.4th
- raw rec-string.4th
- raw rec-time.4th
- raw tester.fs
Matthias Trute <firstname.lastname@example.org> Version 1.3.0 - 2016-10-10
This package is a collection of recognizer examples. To play with them a simple implementation for (old) gforth and VFX is included. These words are not (yet) able to compile code or are otherwise integrated into the underlying system.
Many examples contain test units that illustrate what the recognizer is supposed to do.
This file in combination with
Stack.4th gives a
playground for making experiments with recognizers. It
has been tested with gforth versions that currently
come with the linux distributions and MPE's vfxlin (a
random old version from 2014).
This file contains four recognizers. They deal with
numbers in various formats and use
>NUMBER for the
actual number conversion. Some features such as the
- sign or non standard but widely used prefix/sign permutations are left out. Your system shall have better ones, these are more educational.
rec:char ( addr len -- n r:num | r:fail)
Forth 2012 defined the 'c' syntax for single characters.
That means that
char c or
[char] c can be replaced
rec:snum ( addr len -- n r:num | r:fail)
This recognizer can handle single cell numbers. It honors the number prefixes and the - sign. It is very restrictive in what it accepts. Only the Forth 2012 spec <prefix><sign><digit> sequence is allowed.
rec:dnum ( addr len -- n r:dnum | r:fail)
This recognizer handles double cell numbers. It accepts only strictly standard conforming numbers: strings with trailing dot in addition to the prefixes and sign character.
These three recognizers are combined in the
recognizer that may be used to handle all number formats
in one call.
This file contains a dictionary lookup recognizer. It uses
FIND for the actual work thus uses the search order if
Another dictionary lookup recognizer. This one does not
FIND and searches the standard forth wordlist
only. It returns name tokens instead of the usual
execution tokens as well.
TRAVERSE-WORDLIST and the
from Forth 2012 to work. From the future, quotations are
Simple formatting of source code in the spirit von Don Knuth' literate programming. You can combine the real source code and its documentation in one file that the standard forth interpreter can handle directly.
Actually testing this recognizer requires a Forth that supports recognizers already.
Author: Julian Fondren, 2014 License: probably public domain.
check and convert for the hh:mm:ss notation returning a double cell number for the number of seconds it represents.