Syntax-Kamelon

 view release on metacpan or  search on metacpan

bin/kamelon_bench  view on Meta::CPAN


use strict;
use Time::HiRes qw(time);

use Syntax::Kamelon;

my @attributes = Syntax::Kamelon->AvailableAttributes;

my %formtab = ();
for (@attributes) {
	$formtab{$_} = ["<font class=\"$_\">", "</font>"]
}

my $substitutions = {
	'<' => '&lt;',
	'>' => '&gt;',
	'&' => '&amp;',
	' ' => '&nbsp;',
	"\t" => '&nbsp;&nbsp;&nbsp;',
	"\n" => "<BR>\n",
};

my $cycles = 5;
my $mode = 'text';
my $verbose = 0;

my %shortargs = (
	'-c' => sub  {
		$cycles = shift @ARGV;
		unless ($cycles =~ /^\d+$/) { die '-c or -cycles should have a positive integer value' }
	},
	'-m' => sub  {
		$mode = shift @ARGV;
		unless ($mode =~ /^text|line|debug$/) { die '-m or -mode can be text, line or debug' }
	},
	'-v' => sub  { $verbose = 1 },
);

my %args = (%shortargs,
	'-cycles' => $shortargs{'-c'},
	'-mode' => $shortargs{'-m'},
	'-verbose' => $shortargs{'-v'},
);

while (@ARGV) {
	my $t = shift @ARGV;
	if (exists $args{$t}) {
		my $call = $args{$t};
		&$call;
	} else {
		die "invalid argument $t, valid arguments -c, -cycles, -m, -mode, -v, -verbose";
	}
}

print "\nMode: $mode\n";
print "Cycles: $cycles\n";
print "Verbose: $verbose\n\n";


my %langs = (
	'.desktop' => "highlight.desktop",
	'AHDL' => "highlight.ahdl",
	'ASP' => "highlight.asp",
	'AVR Assembler' => "highlight.asm",
	'AWK' => "highlight.awk",
	'Bash' => "highlight.sh",
	'BibTeX' => "highlight.bib",
	'C++' => "highlight.cpp",
	'CMake' => "highlight.cmake",
	'CSS' => "highlight.css",
	'Clipper' => "highlight.prg",
	'Common Lisp' => "highlight.lisp",
	'Doxygen' => "highlight.dox",
	'Eiffel' => "highlight.e",
	'Euphoria' => "highlight.exu",
	'Fortran' => "highlight.f90",
	'GLSL' => "highlight.glsl",
	'HTML' => "highlight.html",
	'Haskell' => "highlight.hs",
	'Intel x86 (NASM)' => "highlight.asm",
	'JSP' => "highlight.jsp",
	'Java' => "highlight.java",
	'JavaScript' => "highlight.js",
	'LaTeX' => "highlight.tex",
	'Lex/Flex' => "highlight.lex",
	'LilyPond' => "highlight.ly",
	'Literate Haskell' => "highlight.hs",
	'Matlab' => "highlight.m",
	'Octave' => "highlight.m",
	'PHP/PHP' => "highlight.php",
	'POV-Ray' => "highlight.pov",
	'Perl' => "highlight.pl",
	'PicAsm' => "highlight.asm",
	'Pike' => "highlight.pike",
	'PostScript' => "highlight.ps",
	'PureBasic' => "highlight.pb",
	'Python' => "highlight.py",
	'Quake Script' => "highlight.rib",
	'Ruby' => "highlight.rb",
	'Scheme' => "highlight.scheme",
	'Spice' => "highlight.sp",
	'Stata' => "highlight.do",
	'Tcl/Tk' => "highlight.tcl",
	'UnrealScript' => "highlight.uc",
	'VRML' => "highlight.wrl",
	'XML' => "highlight.xml",
	'xslt' => "highlight.xsl",
);

my $k = Syntax::Kamelon->new(
	verbose => $verbose,
	formatter => ['Base',
		substitutions => $substitutions,
		format_table => \%formtab,
	],
);

my @langl = sort keys %langs;

my %results = ();



( run in 0.920 second using v1.01-cache-2.11-cpan-39bf76dae61 )