Example #1
0
 public static function handleStringHtml($string)
 {
     $lstr = trim(strtolower($string));
     if (self::$func_next) {
         self::$function_table[] = trim($string);
         $string = '<a id="' . trim($string) . '">' . $string . '</a>';
         self::$func_next = false;
         return array(array('token' => 'FUNC', 'string' => $string, 'noentities' => 1));
     } elseif (in_array(trim($string), self::$function_table)) {
         $string = '<a href="#' . trim($string) . '">' . $string . '</a>';
         return array(array('token' => 'FUNC', 'string' => $string, 'noentities' => 1));
     } elseif (function_exists(trim($string))) {
         $string = '<a href="http://php.net/' . trim($string) . '">' . $string . '</a>';
         return array(array('token' => 'PHP_BUILTIN', 'string' => $string, 'noentities' => 1));
     } else {
         return self::handleString($string);
     }
 }
Example #2
0
#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/../libs/PhpLexer.php';
require_once dirname(__FILE__) . '/../libs/PhpParser.php';
require_once dirname(__FILE__) . '/../libs/EventDispatcherHolder.php';
if ($_SERVER['argc'] <= 1) {
    echo "usage: ./show-php-parse-tree.php [php program]\n";
    exit(0);
}
$input_file = $_SERVER['argv'][1];
if (!file_exists($input_file)) {
    echo "error: no such file\n";
    exit(1);
}
EventDispatcherHolder::getDispatcher()->connect('start', 'output_dot_from_parser_tree');
$l = new PhpLexer();
$l->setPhpSource(file_get_contents($input_file));
$p = new PhpParser();
$p->yyparse($l);
function output_dot_from_parser_tree(sfEvent $ev)
{
    $node = $ev->getSubject();
    output_header();
    output_node_info($node);
    output_children($node);
    output_footer();
}
function output_header()
{
    echo 'digraph sample {
  node [shape = record, style = filled,