Login   Register  
PHP Classes
elePHPant
Icontem

File: testphp.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Andrea Giammarchi  >  SourceMap  >  testphp.php  >  Download  
File: testphp.php
Role: Example script
Content type: text/plain
Description: SimpleTest File
Class: SourceMap
Tokenize source code in several languages
Author: By
Last change:
Date: 2006-08-01 12:24
Size: 1,532 bytes
 

Contents

Class file image Download
<?php
# import of necessary files
require 'SourceMap.class.php';
require 
'delimeters.php';
require 
'common.php';

# SourceMap variable
$sourceMap = new SourceMap();

# chosed delimeter rules (JavaScript in this case)
$rules = &$jsRules;

# source code to map [requires specified JS file]
$source file_get_contents("dojo.js.uncompressed.js");

# Benchmark: start time variable
$startTime getTime();

# generated map
$map $sourceMap->getMap($source$rules);

# Benchmark: end time variable
$endTime getTime($startTime);

# Output and Verify
$tempCode '';
$correctParse '';
$output '';
$b count($map);
for(
$a 0$a $b$a++) {
    
$tempCode substr($source$map[$a]['start'], $map[$a]['end'] - $map[$a]['start']);
    
$correctParse .= $tempCode;
    
$output .= '<strong>'.$map[$a]['name'].'</strong><pre>'.str_replace(array('<''>'), array('&lt;''&gt;'), $tempCode).'</pre>';
    if(
$a $b)
        
$output .= '<hr />';
}
if(
$correctParse === $source)
    
$output '<h3>Source file successfull mapped ['.$endTime.' sec.] - Map length: ' $b '</h3><hr />'.$output;
else
    
$output '<h3>WARNING, map failure or invalid source code ['.$endTime.' sec.] - Map length: ' $b '</h3><hr />'.$output;
?>
<html>
    <head>
        <title>Class SourceMap :: PHP Test Version</title>
        <style type="text/css">
        * {
            margin:2;
            padding:0;
            font-family: Verdana, Helvetica, sans-serif;
            font-size: 8pt;
        }
        </style>
    </head>
    <body>
        <?php echo $output?>
    </body>
</html>