/******************************************************************
highlight.js Muze Helene
------------------------------------------------------------------
Author: Muze (info@muze.nl)
Date: 28 februari 2004
Copyright 2002 Muze
This file is part of Helene.
Helene is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Helene is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Helene; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
-------------------------------------------------------------------
This file contains the syntax highlighting parser
******************************************************************/
// Parsing smarty tags http://smarty.php.net/
// Cofigure the smarty delimiters below ('{%' and '%}' by default)
// Unset this flag if you need to parse only PHP
var parseSmarty = true;
/* states */
var YY_STATE_HTML = 0;
var YY_STATE_PINP = 1;
var YY_STATE_DQSTRING = 2;
var YY_STATE_SQSTRING = 3;
var YY_STATE_SCRIPT = 4;
var YY_STATE_BLOCKCOMMENT = 5;
/* Smarty states */
var YYS_STATE_TAG = 101;
var YYS_STATE_PARAM = 102;
var YYS_STATE_QPARAM = 103;
/* tokens */
var T_VAR = 0;
var T_IDENT = 1;
var T_FUNCTION = 2;
var T_TOKEN = 3;
var T_UNKNOWN = 4;
var T_PINP_START = 5;
var T_PINP_BLOCK = 6;
var T_PINP_END = 7;
var T_SPACE = 8;
var T_DQUOTE = 9;
var T_SQUOTE = 10;
var T_ESCAPE = 11;
var T_SPECIAL_CHAR = 12;
var T_OPERATOR = 13;
var T_SINGLE_COMMENTS = 14;
var T_BLOCKCOMMENT = 15;
var T_BLOCKCOMMENT_END = 16;
var T_PHP_START = 17;
var T_PHP_END = 18;
var T_SCRIPT_START = 19;
var T_SCRIPT_END = 20;
var T_TAB = 21;
var T_EMPTY_LINE = 22;
/*Smarty tokens*/
var TS_SMARTY_START = 101;
var TS_SMARTY_END = 102;
var TS_KEYWORD = 103;
var TS_ATTRIBUTE = 104;
var TS_ATTRVALUE = 105;
var TS_VAR = 106;
var TS_ENDTAG = 107;
var hLines = new Array();
var debug = 0;
var scannerPos = 0;
var hStyles = new Array();
var hStateStyles = new Array();
// May be there is the better place for it but now there
initStyleDefault();
// Making object from keywords, it makes a big perfomance overhead in IE
// and slightly better perfomance in Mozilla
// You can define any amount of keyword groups
// Words should match ([a-z0-9][a-z0-9_]*) and should be separated by spaces
var hPHPKeywords = cacheKeywords( /// TODO: Add more keywords here
"for php case default char include int string new endfor real __FILE__ M_LN10 else return switch bool __LINE__ integer long void M_LOG2E break endif endwhile var require extends while FALSE E_NOTICE M_SQRT1_2 E_WARNING class if float mixed do M_LN2 as continue E_PARSE array function global old_function PHP_VERSION elseif M_1_PI M_2_PI M_EULER M_2_SQRTPI M_PI_2 M_SQRT3 M_PI_4 E_ERROR double endswitch M_LNPI M_SQRT2 M_LOG10E foreach TRUE static M_E object M_PI PHP_OS M_SQRTPI",
"echo print count array" // standart functions
);
var hSmartyKeywords = cacheKeywords(
"if foreach capture section", // Block keywords
"include assign math counter else foreachelse sectionelse cycle elseif", // Other keywords
"getprices getarticles" // Own plugins for smarty
);
function hLineToken(tokenType, tokenData) {
this.type = tokenType;
this.data = tokenData;
this.reallength = tokenData.length;
this.newState = -1;
switch (this.data) {
case '<':
this.data='<';
break;
case '>':
this.data='>';
break;
case '&':
this.data='&';
break;
}
switch (this.type) {
case T_PINP_START:
case T_PHP_START:
case T_PINP_END:
case T_PHP_END:
case T_SCRIPT_START:
case T_SINGLE_COMMENTS:
this.data = this.data.replace(/[<]/g, '<');
this.data = this.data.replace(/[>]/g, '>');
var myTabRest = scannerPos % 8;
var addLength = 8 - myTabRest;
this.data = this.data.replace(/[\t]/g, ' ');
scannerPos += (addLength -1);
break;
case T_SCRIPT_END:
this.data = this.data.replace(/[<]/g, '<');
this.data = this.data.replace(/[>]/g, '>');
case T_SPACE:
this.data = this.data.replace(/[ ]/g, ' ');
break;
case T_TAB:
var myTabRest = scannerPos % 8;
var addLength = 8 - myTabRest;
// alert( 'scannerPos ' + scannerPos + ' myTabRest ' + myTabRest + ' addLength ' + addLength);
this.data = this.data.replace(/[\t]/g, '');
scannerPos += (addLength -1);
break;
case T_EMPTY_LINE:
this.data = '';
break;
}
scannerPos += tokenData.length;
}
function getToken(sData) {
var re, match;
/* empty line, required for Firefox 1.5.x */
if (sData == "")
{
result = new hLineToken(T_EMPTY_LINE, "");
return result;
}
/* white space */
re = /^([ ]+)/;
match = re.exec(sData);
if (match) {
result = new hLineToken(T_SPACE, match[1]);
return result;
}
re = /^([\t])/;
match = re.exec(sData);
if (match) {
result = new hLineToken(T_TAB, match[1]);
return result;
}
/* Smarty tokens */
if(parseSmarty) {
re = /^\{%/; // Matches $smarty->left_delimiter
match = re.exec(sData);
if(match) {
return new hLineToken(TS_SMARTY_START, match[0]);
}
re = /^%\}/; // Matches $smarty->right_delimiter
match = re.exec(sData);
if(match) {
return new hLineToken(TS_SMARTY_END, match[0]);
}
re = /^\/[a-z0-9][a-z0-9_]*/i;
match = re.exec(sData);
if (match) {
result = new hLineToken(TS_ENDTAG, match[0]);
return result;
}
}
/* end of smarty tokens */
/* variable or ident */
re = /^([$]|->)?([a-z0-9_][a-z0-9_]*)/i;
match = re.exec(sData);
if (match) {
if (match[1]) {
result = new hLineToken(T_VAR, match[0]);
} else {
result = new hLineToken(T_IDENT, match[2]);
}
return result;
}
/* single tokens */
re = /^([(){},"'\\])/;
match = re.exec(sData);
if (match) {
switch (match[1]) {
case '\\':
result = new hLineToken(T_ESCAPE, match[1]);
break;
case '"':
result = new hLineToken(T_DQUOTE, match[1]);
break;
case "'":
result = new hLineToken(T_SQUOTE, match[1]);
break;
default:
result = new hLineToken(T_SPECIAL_CHAR, match[1]);
break;
}
return result;
}
re = /^((\/[*])|([*]\/))/;
match = re.exec(sData);
if (match) {
if (match[2]) {
result = new hLineToken(T_BLOCKCOMMENT, match[2]);
} else {
result = new hLineToken(T_BLOCKCOMMENT_END, match[3]);
}
return result;
}
/* comments */
re = /^(\/\/.*)/;
match = re.exec(sData);
if (match) {
result = new hLineToken(T_SINGLE_COMMENTS, match[1]);
return result;
}
/* php end tags */
re = /^([\?\%]>)/;
match = re.exec(sData);
if (match) {
result = new hLineToken(T_PHP_END, match[0]);
return result;
}
re = /^([\-\+\.\*\/\=\%])/;
match = re.exec(sData);
if (match) {
result = new hLineToken(T_OPERATOR, match[1]);
return result;
}
/* pinp/php tags */
re = /^((<(\/)?pinp>)|(<[%?]php|<\?|