corps du collage affichésub ws {
s/\r/\n/gs;
s/\t/ /gs;
s/ +/ /gs;
s/\n+/\n/gs;
s/^\n+//gs;
s/\n+$//gs;
}
$_ = join "\n", <>;
# comments
s/;.*?$//gm;
# norats
s/\nNORATS.*?\n//gs;
# remove ws before *, +, and ?
s/ +[\+\*\?]//gs;
# add ws around parentheses and slashes
s/\(/ \( /gs;
s/\)/ \) /gs;
s/\// \/ /gs;
# make all - into _
s/\-/_/gs;
# clean up ws
ws;
my @lines = split "\n";
foreach(@lines) {
$typeR = qr/([A-Z]+ )?/;
$nameR = qr/([a-zA-Z0-9\-_]+)/;
$quoteR = qr/"[^"]*"/;
$concatR = qr/($nameR)( ($nameR))+/;
$stmtR = qr/($concatR)/;
($type, $name, $stmt) = /^$typeR$nameR <_ (.*?)$/;
next unless($stmt);
print $type, "\n";
print $name, "\n";
print $stmt, "\n";
}