Dr. Rick Perry

Copyright © June 2001 by CyberSoft, Incorporated.
Permission is granted to any individual or institution to use, copy, or redistribute this document so long
as it is not sold for profit, and provided that it is reproduced whole and this copyright notice is retained.

CHANGES
-------
 VFindd
  version       Notes
  -------       -----
  11.3.0        Changed 'c', '\n', \n, etc. to INTEGER instead of STRING,
                and added FUZZY operator.
  11.2.1        Initial documentation release.

FUZZY matches
-------------
Fuzziness is specified using two integers which specify minus and plus
values called m and p here for purpose of discussion.  Abstractly, letting
x represent a pattern array and d represent a data array, each of size n,
FUZZY -m +p x will match data d if x[i]-m <= d[i] <= x[i]+p for all
i=1..n.  So fuzziness is basically a convenient way of specifying ranges.
If either of m or p are not specified the default is 0, and if m==p that
can be written as m, +-m, or -+m.  Examples: FUZZY 2 100 is the same as
98-100; FUZZY -2 +3 "cow" is the same as 'a'-'f', 'm'-'r', 'u'-'z'.
Recognized case-sensitive spellings for the fuzzy operator are:
FUZZY, Fuzzy, fuzzy, FUZZ, Fuzz, fuzz.

Language Syntax Summary
-----------------------
Definitions:

  hex escape sequence   \x or \X followed by two hex digits.

  escape sequence       \c or hex escape sequence.
                        If character c is n, r, or t this represents newline,
                        carriage-return, or tab, respectively; otherwise
                        it represents character c itself.

Terminals:

  INTEGER       A decimal or hex integer (e.g. 1234, 0xa9BE, 0Xff)
                or a single character or escape sequence in single 'quotes', 
                (e.g. 'a', '\n', '\x9f') or an escape sequence with no quotes.

  STRING        One or more characters or escape sequences in double "quotes".

  NAME          Following a colon (:), any characters except comma (,)
                up to a terminating comma forms the VDL name.

Syntax:

(Note that items enclosed in 'quotes' below are actually written literally
without the quotes in VDL rules.)

  file:
                  empty
                  file vdl

  vdl:
                  ':' NAME ',' top_or '#'
                  ':' NAME ',' '<' ss_type_list '>' top_or '#'
                  ':' NAME ',' '<' '>' top_or '#'
                  '<' ss_type_list '>'
                  '<' '>'

  ss_type_list:
                  STRING
                  '!' STRING
                  ss_type_list ',' STRING

  top_or:
                  top_xor
                  top_or 'OR' top_xor

  top_xor:
                  and
                  top_xor 'XOR' and

  and:
                  not
                  and 'AND' not

  not:
                  cat
                  'NOT' not
                  '(' top_or ')'

  cat:
                  or
                  cat ',' or

  or:
                  code
                  or '|' code

  code:
                  data
                  '@' offset_expr ',' data
                  'ABS' INTEGER ',' data
                  '(' cat ')'

  offset_expr:
                  INTEGER
                  INTEGER '-'
                  '-' INTEGER
                  INTEGER '-' INTEGER

  data:
                  byte_expr
                  string_data
                  meta_data
                  'WS1'
                  'WS0'
                  '\d+' 
                  repetition_expr
                  fuzzy byte
                  fuzzy STRING

  fuzzy:
                  'FUZZY' INTEGER
                  'FUZZY' '+-' INTEGER
                  'FUZZY' '-+' INTEGER
                  'FUZZY' '-' INTEGER
                  'FUZZY' '+' INTEGER
                  'FUZZY' '-' INTEGER '+' INTEGER
                  'FUZZY' '+' INTEGER '-' INTEGER

  repetition_expr:
                  byte_expr '[' INTEGER ']'
                  string_data '[' INTEGER ']'

  byte_expr:
                  byte
                  '^' byte
                  byte_range
                  '^' byte_range

  byte_range:
                  '-' byte
                  byte '-'
                  byte '-' byte

  byte:
                  INTEGER

  string_data:
                  STRING
                  '~' STRING

  meta_data:
                  '~~' STRING
                  '~#' STRING
                  '~#' INTEGER STRING