while(<>) {
  if (/^enum /) { $n = 0; }
  if (/^  ([A-Z0-9_]*)/) { print "val $1 = $n;\n"; $n++; }
}
  