Make your own free website on Tripod.com
  This php code is converted into HTML using 
     Colorizator v1.0 (c) 2001 by Alexander Yanuar Koentjara
                                  (lexzeus@hotmail.com) 

<? /* Program name : Pas_Colorizator v1.0 Author : Alexander Yanuar Koentjara lexzeus@hotmail.com Usage : php -q PAS_colorizator.php source.pas output.htm Purpose : To make PASCAL/Delphi code become a nice colorful HTML file !! */ set_time_limit(0); if (!trim($argv[2])) print "Need <param1> and <param2\n". "Usage : php -q PAS_colorizator.php source.pas output.htm"; $arr_RESERVED_WORD = array( "if", "while", "for", "string", "pointer", "repeat", "until", "with", "do", "true", "false", "to", "nil", "uses", "case", "else", "then", "begin", "end", "of", "and", "or"); $arr_DECLARATION_WORD = array( "type", "var", "function", "procedure", "implementation", "record", "const", "class", "unit", "interface"); $color_RESERVED_WORD = "RED"; $color_DECLARATION_WORD = "BLUE"; $color_COMMENT = "#707090"; $color_DEFAULT = "#3333aa"; $color_STRING = "#800000"; $color_VARIABLE = "GREEN"; $color_HTML = "BLACK"; $splitter = "|X*-(LexZ)"."-*X|"; $splitter2 = "|X*-(Kick)"."-*X|"; function generate_ereg($arr) { $x=""; for($i=0;$i<count($arr);$i++) $x.="|$arr[$i]"; return substr($x,1); } $RESERVED_WORD = generate_ereg($arr_RESERVED_WORD); $DECLARATION_WORD = generate_ereg($arr_DECLARATION_WORD); $file_from = trim($argv[1]); $file_to = trim($argv[2]); $f_arr = join("",file($file_from)); $fr = fopen($file_to,"w"); fputs($fr, "<HTML> <!-- This PASCAL/Delphi code is converted into HTML using PAS_Colorizator v1.0 (c) 2001 by Alexander Yanuar Koentjara (lexzeus@hotmail.com) --> <BODY BGCOLOR=WHITE> <PRE>\n"); fputs($fr,"<FONT FACE='Courier New' size=2 color=$color_DEFAULT>"); $delimiter=array(0=>0, "//"=>array(2,"[\r\n]",$color_COMMENT), "'"=>array(1,"'",$color_STRING), "{"=>array(1,"}",$color_COMMENT)); function x_parse($fr, $str) { GLOBAL $delimiter, $splitter, $splitter2, $color_VARIABLE, $RESERVED_WORD, $DECLARATION_WORD, $color_RESERVED_WORD, $color_DECLARATION_WORD; $flag = 0; $pos2 = -1; $all = ""; while($pos2<strlen($str)-1) { $pos2++; if ($flag) { if (ereg($delimiter[$flag][1],substr($str,$pos2,$delimiter[$flag][0]))) { $all.=htmlspecialchars(substr($str,$pos2,1)). "$splitter2</FONT>"; $flag=0; } else { $all.=htmlspecialchars(substr($str,$pos2,1)); } } else { reset($delimiter); while (list($key,$val)=each($delimiter)) { if ($key) { if (substr($str,$pos2,$val[0])==$key) { $all.="<FONT COLOR=$val[2]>$splitter". htmlspecialchars(substr($str,$pos2,$val[0])); $pos2+=($val[0]-1); $flag=$key; break; } } } if (!$flag) $all.=htmlspecialchars(substr($str,$pos2,1)); } } $all=eregi_replace("([-()\r\n \t;=*+></\\.,])($RESERVED_WORD)([-()\r\n \t;=*+></\\.,])", "\\1<B><FONT COLOR=$color_RESERVED_WORD>\\2</FONT></B>\\3", $all); $all=eregi_replace("([-()\r\n \t;=*+></\\.,])($DECLARATION_WORD)([-()\r\n \t;=*+></\\.,])", "\\1<B><I><FONT COLOR=$color_DECLARATION_WORD>\\2</FONT></I></B>\\3", $all); $f_arr = explode($splitter,$all); $all = ""; if (count($f_arr)>1) for ($i=0;$i<count($f_arr);$i++) { $f_arr2 = explode($splitter2,$f_arr[$i]); if (count($f_arr2)>1) { $f_arr2[0] = eregi_replace( "(<[/]{0,1}FONT[^>]*>|<[/]{0,1}B>|<[/]{0,1}I>)", "",$f_arr2[0]); $all.=$f_arr2[0].$f_arr2[1]; } else $all.=$f_arr[$i]; } else $all = join("",$f_arr); fputs($fr,$all); } x_parse($fr,$f_arr); fputs($fr,"</FONT></PRE>\n"); fputs($fr,"</BODY>\n</HTML>\n"); fclose($fr); ?>