cfgrep Instructions

Usage:

java -jar cfgrep.jar [-c] [-v] cfg-exp file
where "cfg-exp" is a context free grammar expression in a format explained below and "file" is the text file to be parsed.

Explanation of flags:

none
use cfg-exp to scan through file returning all lines that match cfg-exp exactly (full-string matching, not sub-string)
-c
count the number of lines matched and return only this value
-v
return the lines that don't match the expression
-c and -v may be combined to produce the number of lines in the complement

The Context Free Grammar expression format cfg-exp:

cfg-exp is of the form 'list-of-productions' (ENCLOSE BY SINGLE QUOTES OR ON SOME SYSTEMS -eg. Windows- BY DOUBLE QUOTES: "list-of-productions") where list-of-productions is defined by the following regular expression:

list-of-productions = V:R(|R)*(,V:R(|R)*)*
where:
V
is a variable
R
is a production end-result
|
is alternation ( OR )
,
separates productions

For example, the abstract grammar for odd palindromes over {a,b} is:

S --> C | aSa | bSb
C --> a | b
The equivalent cfgrep context free expression is:
'S:C|aSa|bSb,C:a|b'

Special characters:

.
Matches any character
"
Matches epsilon, but only by itself (NOT RECOMMENDED AS ALGORITHM NOT GUARANTEED TO WORK WITH EPSILONS!)

Escapes for matching literally special characters:

\.
Matches period
\"
Matches double quotes
\:
Matches semicolon
\|
Matches pipe
\,
Matches comma
White space matches itself (as long as cfg-exp is enclosed by single quotes).
Last modified: Fri Oct 8 15:37:33 2004