cfgrep is a simplified, context-free version of egrep.
When the command "java -jar cfgrep.jar cfg-exp file" is applied to a text "file", all lines in the file which match the context free grammatical expression "cfg-exp" are printed to standard output. For example, to print out all palindromic lines consisting purely of a's and b's one would use the command:
cfgrep -jar 'S:aSa|bSb|a|b|aa|bb' filewhere the cfg-expression 'S:aSa|bSb|a|b|aa|bb' represents the grammar rules:
S → aSa | bSb | a | b | aa | bb
I use cfgrep in my Computer Science Theory course to teach students about regular expressions. I found that standard context-free parsing tools such as yacc were too heavyweight and disqualified too many grammar types to be integrated efficiently into a course emphasizing the theory of context free grammars.
If you would like to try out cfgrep you will need to have Java on your system. Then: