Skip to content

Instantly share code, notes, and snippets.

@daboe01
Created June 24, 2018 11:47
Show Gist options
  • Save daboe01/aa73239c3d76111151b04e3e0a33d2eb to your computer and use it in GitHub Desktop.
Save daboe01/aa73239c3d76111151b04e3e0a33d2eb to your computer and use it in GitHub Desktop.
perl script to convert gnustep code to cappuccino
#!/usr/bin/perl
use IO::All;
my $io = io $ARGV[0];
my $filecontent= $io->slurp();
$filecontent =~s/\breturn\b/0return/ogs;
$filecontent =~s/NS([a-zA-Z0-9_]+)(\s*)\*/CP$1$2/ogs;
$filecontent =~s/NS([a-zA-Z0-9_]+)/CP$1/ogs;
$filecontent =~s/([a-zA-Z0-9_]) \)/$1)/ogs;
$filecontent =~s/([a-zA-Z_][a-zA-Z0-9_]*)\s+\*([a-zA-Z_][a-zA-Z0-9]*)\s*=/$1 $2 =/ogs;
$filecontent =~s/ASSIGN\s*\(([a-zA-Z_][a-zA-Z0-9_]*)\s*,\s*([a-zA-Z_][a-zA-Z0-9_]*)\)/$1 = $2/ogs;
$filecontent =~s/(\n+)static\s+/$1/og;
$filecontent =~s/RELEASE\s*\([^\)]+\)\s*;\s+//ogs;
$filecontent =~s/\b[a-zA-Z_][a-zA-Z0-9_]*\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\=/var $1 =/ogs;
$filecontent =~s/\n(\s*)[a-zA-Z_][a-zA-Z0-9_]*\s+([_a-zA-Z_][a-zA-Z0-9,\s]*);/\n$1var $2;/ogs;
$filecontent =~s/\b0return\b/return/ogs;
print $filecontent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment