2015-01-15 06:51:17 +01:00
|
|
|
#!/usr/bin/env perl
|
2011-01-26 02:59:19 +01:00
|
|
|
|
2015-01-15 06:51:17 +01:00
|
|
|
use warnings;
|
2011-01-26 02:59:19 +01:00
|
|
|
use strict;
|
|
|
|
|
2015-01-16 06:20:34 +01:00
|
|
|
use File::Basename;
|
|
|
|
|
2015-01-15 06:51:17 +01:00
|
|
|
my $language = shift @ARGV // 'c11';
|
|
|
|
$language = lc $language;
|
2014-07-04 15:04:27 +02:00
|
|
|
|
2015-01-15 06:51:17 +01:00
|
|
|
eval {
|
|
|
|
use lib 'languages';
|
|
|
|
require "$language.pm";
|
|
|
|
} or do {
|
|
|
|
print "Language '$language' is not supported.\n";
|
2015-01-16 06:20:34 +01:00
|
|
|
|
|
|
|
my @languages = glob 'languages/*.pm';
|
|
|
|
my $comma = '';
|
|
|
|
print "Supported languages are: ";
|
|
|
|
foreach my $lang (sort @languages) {
|
|
|
|
$lang = basename($lang);
|
2015-01-18 14:41:48 +01:00
|
|
|
next if $lang =~ m/^_|~$/g;
|
2015-01-16 06:20:34 +01:00
|
|
|
$lang =~ s/\.pm$//;
|
|
|
|
print "$comma$lang";
|
|
|
|
$comma = ', ';
|
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
|
|
|
|
exit;
|
2012-09-01 07:20:01 +02:00
|
|
|
};
|
|
|
|
|
2015-01-15 06:51:17 +01:00
|
|
|
my $nick = shift @ARGV // (print "Missing nick argument.\n" and die);
|
|
|
|
my $channel = shift @ARGV // (print "Missing channel argument.\n" and die);
|
|
|
|
my $code = join(' ', @ARGV);
|
2014-04-03 01:48:43 +02:00
|
|
|
|
2015-01-17 13:39:19 +01:00
|
|
|
if (not length $code) {
|
|
|
|
print "$nick: Usage: cc [-paste] [-nomain] [-lang=<language>] [-info] [language options] <code> [-input=<stdin input>]\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2015-01-15 06:51:17 +01:00
|
|
|
my $lang = $language->new(nick => $nick, channel => $channel, lang => $language, code => $code);
|
2014-04-03 01:48:43 +02:00
|
|
|
|
2015-01-15 06:51:17 +01:00
|
|
|
$lang->process_interactive_edit;
|
|
|
|
$lang->process_standard_options;
|
|
|
|
$lang->process_custom_options;
|
|
|
|
$lang->process_cmdline_options;
|
|
|
|
$lang->preprocess_code;
|
|
|
|
$lang->execute;
|
|
|
|
$lang->postprocess_output;
|
|
|
|
$lang->show_output;
|