package Syntax::Highlight::Engine::Simple::CPP;
use strict;
use warnings;
use base qw(Syntax::Highlight::Engine::Simple);

### ----------------------------------------------------------------------------
### set syntax
### ----------------------------------------------------------------------------
sub setSyntax {
	
	shift->{syntax} =
		[
			{
				class => 'quote',
				regexp => q@'.*?(?<!\\\\)'@,
			},
			{
				class => 'wquote',
				regexp => q@".*?(?<!\\\\)"@,
			},
			{
				class => 'comment',
				regexp => '//.*?$',
			},
			{
				class => 'comment',
				regexp => '\'.*?$',
			},
			{
				class => 'comment',
				regexp => '(?s)/\*.*?\*/',
			},
			{
				class => 'number',
				regexp => '\b\d+\b',
			},	
			{
				class => 'keyword',
				regexp => __PACKAGE__->array2regexp(&getKeywords()),
			},
		];
}

sub getKeywords {
	
	return (
		'reinterpret_cast',
		'dynamic_cast',
		'static_cast',
		'__declspec',
		'const_cast',
		'namespace',
		'protected',
		'#include',
		'__FILE__',
		'continue',
		'explicit',
		'operator',
		'register',
		'template',
		'typename',
		'unsigned',
		'volatile',
		'#define',
		'#ifndef',
		'#pragma',
		'default',
		'defined',
		'include',
		'mutable',
		'private',
		'typedef',
		'virtual',
		'wchar_t',
		'#endif',
		'#error',
		'#ifdef',
		'#undef',
		'define',
		'delete',
		'double',
		'export',
		'extern',
		'friend',
		'ifndef',
		'inline',
		'pragma',
		'public',
		'return',
		'signed',
		'sizeof',
		'static',
		'struct',
		'switch',
		'typeid',
		'#elif',
		'#else',
		'#line',
		'break',
		'catch',
		'class',
		'const',
		'endif',
		'error',
		'FALSE',
		'float',
		'ifdef',
		'short',
		'throw',
		'undef',
		'union',
		'using',
		'while',
		'auto',
		'bool',
		'case',
		'char',
		'elif',
		'else',
		'enum',
		'goto',
		'line',
		'long',
		'this',
		'TRUE',
		'void',
		'#if',
		'asm',
		'for',
		'int',
		'new',
		'try',
		'do',
		'if',
	);
}

return 1;

__END__

=head1 NAME

NT::CodeHighlight - HTML Markup for highlighting the given strings.

=head1 DESCRIPTION

This module markup the givin strings such a program code with HTML span tags so that the output strings, a part of HTML, easily highlight with CSS.

=head1 SYNOPSIS

	use NT::CodeHighlight;
	
	$highlight = NT::CodeHighlight->new(%hash);
	$highlight->setParam(%hash);
	$highlight->doLine(%hash);
	$highlight->doFile(%hash);
	$highlight->doStr(%hash);

=head1 ARGUMENT

=head1 EXAMPLE

=head1 AUTHOR

jamadam <info@jamadam.com>

=head1 SEE ALSO

=cut
