/**
  * for Keil C51
  * family: AT89X52
  * add by wentao  http://blog.liuwentao.net
  * date: 2007.4.22
  * last modify: 2007.4.22
**/

dp.sh.Brushes.C51 = function()
{
	var datatypes = 
	'short signed unsigned char int float double long ' +
    'uchar';

	var keywords = 
	'auto break case const continue default do else extern for goto if return ' +
	'sizeof static struct switch typedef union void volatile while ' +
	'_at_ far alien large small _task_ compact _priority using reentrant ' +
    'sbit idata sfr bdata sfr16 bit code pdata data xdata';
	
	var register =
    'P0 SP DPL DPH PCON TCON TMOD TL0 TL1 TH0 TH1 P1 SCON SBUF P2 IE P3 IP ' +
    'T2CON T2MOD RCAP2L RCAP2H TL2 TH2 PSW ACC B P0_0 P0_1 P0_2 P0_3 P0_4 P0_5 P0_6 P0_7 ' +
    'IDL_ STOP_ PD_ GF0_ GF1_ SMOD_ IT0 IE0 IT1 IE1 TR0 TF0 TR1 TF1 ' +
    'T0_M0_ T0_M1_ T0_CT_ T0_GATE_ T1_M0_ T1_M1_ T1_CT_ T1_GATE_ T1_MASK_ T0_MASK_ ' +
    'P1_0 P1_1 P1_2 P1_3 P1_4 P1_5 P1_6 P1_7 T2 T2EX RI TI RB8 TB8 REN SM2 SM1 SM0 ' +
    'P2_0 P2_1 P2_2 P2_3 P2_4 P2_5 P2_6 P2_7 EX0 ET0 EX1 ET1 ES ET2 EA ' +
    'P3_0 P3_1 P3_2 P3_3 P3_4 P3_5 P3_6 P3_7 RXD TXD INT0 INT1 T0 T1 WR RD ' +
    'PX0 PT0 PX1 PT1 PS PT2 CP_RL2 C_T2 TR2 EXEN2 TCLK RCLK EXF2 TF2 DCEN_ T2OE_ ' +
    'P FL OV RS0 RS1 F0 AC CY IE0_VECTOR TF0_VECTOR IE1_VECTOR TF1_VECTOR SIO_VECTOR TF2_VECTOR EX2_VECTOR';

	var ownfunc =
	'abs acos asin atan atan2 atof atoi atol calloc ceil cos cosh exp fabs floor fmod free getchar gets ' +
	'isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit labs log log10 ' +
	'longjmp malloc memchr memcmp memcpy memmove memset modf pow printf putchar puts rand realloc scanf setjmp ' +
	'sin sinh sprintf sqrt srand sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk ' +
	'strrchr strspn strstr strtod strtol strtok strtoul tan tanh tolower toupper va_arg va_end va_start vprintf ' +
	'vsprintf ' +
	'acos517 asin517 atan517 atof517 cabs cos517 _crol_ _cror_ exp517 _getkey init_mempool _irol_ _iror_ ' +
	'log10517 log517 _lrol_ _lror_ memccpy _nop_ printf517 scanf517 sin517 sprintf517 sqrt517 sscanf517 ' +
	'strpos strrpbrk strrpos strtod517 tan517 _testbit_ toascii toint _tolower _toupper ungetchar';

	this.regexList = [
		{ regex: dp.sh.RegexLib.SingleLineCComments,				css: 'comment' },			// one line comments
		{ regex: dp.sh.RegexLib.MultiLineCComments,					css: 'comment' },			// multiline comments
		{ regex: dp.sh.RegexLib.DoubleQuotedString,					css: 'string' },			// strings
		{ regex: dp.sh.RegexLib.SingleQuotedString,					css: 'string' },			// strings
		{ regex: new RegExp('^ *#.*', 'gm'),						css: 'preprocessor' },
		{ regex: new RegExp(this.GetKeywords(datatypes), 'gm'),		css: 'datatypes' },
		{ regex: new RegExp(this.GetKeywords(keywords), 'gm'),		css: 'keyword' },
		{ regex: new RegExp(this.GetKeywords(register), 'gm'),		css: 'register' },
		{ regex: new RegExp('(interrupt)', 'g'),		            css: 'interrupt' }, 
		{ regex: new RegExp(this.GetKeywords(ownfunc), 'gm'),		css: 'ownfunc' }
		];

	this.CssClass = 'dp-c51';
}

dp.sh.Brushes.C51.prototype	= new dp.sh.Highlighter();
dp.sh.Brushes.C51.Aliases	= ['c51'];
