Exemplo n.º 1
0
 protected function debugTokens(array $tokens)
 {
     return \Webforge\Common\ArrayUtil::joinc($tokens, ', ', function ($token) {
         return is_string($token) ? $token : j_token_name($token);
     });
 }
Exemplo n.º 2
0
 */
$lines = array('');
$line =& $lines[0];
while (list(, $token) = each($tokens)) {
    list($t, $s, $l, $c) = $token;
    // generate a CSS class name for this token
    if ($s === 'true' || $s === 'false' || $s === 'null') {
        $class = 'J_LITERAL';
    } else {
        if (_j_token_is_word($token)) {
            $class = 'J_KEYWORD';
        } else {
            if (!is_int($t) && $s === $t) {
                $class = 'J_PUNCTUATOR';
            } else {
                $class = j_token_name($t);
            }
        }
    }
    // style and push onto source code lines array
    while (isset($s[0])) {
        if (!preg_match('/^(.*)(\\n|\\r\\n|\\r)/', $s, $r)) {
            $lines[0] .= '<span class="' . $class . '">' . _j_htmlentities($s) . '</span>';
            break;
        }
        $lines[0] .= '<span class="' . $class . '">' . _j_htmlentities($r[1]) . '</span>';
        array_unshift($lines, '');
        $s = substr($s, strlen($r[0]));
    }
}
// We have lines of highlighted source code - display in HTML document
Exemplo n.º 3
0
 public static function inBranch($branchName, $token)
 {
     return new static(sprintf("ParseError: in Branch: %s ist %s unerwartet", $branchName, is_strign($token) ? $token : j_token_name($token)));
 }