#!/bin/bash
HTML_HEAD_extra=''
charset="utf-8"
. bin/cgistart.sh
style_url="S/th.css"
pagestart "RegToy"
begin main
tohtml() {
sed -e 's%^#### \(.*\)$%
\1
%' \
-e 's%^### \(.*\):$%
\1
%' \
-e 's%^--$%
%'
}
example() {
q=`echo -n "$1" | plain2url`
txt=`echo -n "$1" | plain2html`
link "regtoy.cgi?q=$q" "$txt"
echo " $2"
}
if [ -n "$QUERY_STRING" ] ; then
#hr
#begin pre
getquery
q=`qparse "$query" q`
#regtoy "$q" | plain2html | tohtml
regtoy -html "$q"
#end
else
imgtitlealt "P/dfa.svg" "" "(0|1)*0" "class=right"
p
echo "This Regular Expression Toy allows you to enter a regular expression"
echo "and view its translations to a NFA (Nondeterministic Finite Automaton)"
echo "and a DFA (Deterministic Finite Automaton)."
p
begin form method=get
begin label
echo "Enter a regular expression:"
tag "input name=q"
end
tag "input type=submit value=Submit"
end
p
echo "The examples below illustrate the supported regular experssion syntax."
begin ul
li; example "a" "Just one character"
li; example "abc" "Characters in sequence"
li; example "ab|cd" "Alternatives"
li; example "a*" "Repetition, 0 or more"
li; example "b+" "Repetition, 1 or more"
li; example "(a|bb)*" "Parentheses for grouping things"
end
begin ul
li; example "(0|1)*0" "Binary numbers that are multiples of two"
li; example "(a|b)*aa(a|b)*" "Strings of a
's and b
's containing consecutive a
's"
li; example "(a|b)*ab(a|b)*"
li; example "((ac|b)*|bd)a"
end
fi
end
begin footer
hr
begin address
link "regtoy.cgi" RegToy
echo " by"
link "/~hallgren/" "Thomas Hallgren"
end
endall