# Compiled values matching wizardry

The unit at lib/match.fs contains a few "match to constants" words that have the
peculiarity of being compiler words embedding the values to match, resulting in
very, very fast code.

## API

rmatch" ( "..." -- ) ( c -- f ) *IC*
  Given a list of character ranges following the opening quote, compile code
  with signature "c -- f" that checks whether input character is in that range.
  For example, ": foo rmatch"azAZ" ;" compiles the word "foo ( c -- f )" that
  yields f=1 if c is within a-z or A-Z.

  Input character list must be even (in pairs).

And we have a few compiled matcher words ( c -- f ):

  0-9?    rmatch"09"
  A-Za-z? rmatch"AZaz"
  alnum?  rmatch"AZaz09"

rfind" ( "..." -- ) ( a u -- ?idx f ) *IC*
  Piggy-backs on rmatch" and compiles code that looks in range "a u" for the
  first character fitting in the specified character ranges. If found, f=1 and
  "idx" is the index of the found character. Otherwise, f=0 and "idx" is absent.

=anyof" ( "..." -- ) ( n -- f ) *IC*
  Interpret the "..." code as regular Forth and record how many elements PS
  gained during that execution.

  For each element, compile a comparison of that number with W. The series of
  comparison result in code that has a ( n -- f ) signature where f=1 if any of
  the elements match the value of W. Example:

    : is42or54? =anyof"42 54" ;
    12 is42or54? . \ prints 0
    42 is42or54? . \ prints 1
