<?php
require_once __DIR__.'/../lime/parse_engine.php';
require_once __DIR__.'/common.php';
require_once __DIR__.'/python.execfile.php';
##
class lang_python extends lang_python_execfile {
##
private static $parser = null;
##
public static function getParser() {
if (static::$parser == null) {
static::$parser = new parse_engine(new lang_python());
}
return static::$parser;
}
}
/*
define('__PYTHON__',__DIR__);
$_PYTHON = array(
"DEBUG" => array(
"DUMP_TOKEN" => true
),
"PARSER" => null,
);
function python_start() {
global $_PYTHON;
require_once __LIME__ .'/parse_engine.php';
require_once __PYTHON__ .'/python.class.php';
require_once __PYTHON__ .'/python.tokenize.php';
require_once __PYTHON__ .'/python.interface.php';
require_once __PYTHON__ .'/python.eval.php';
$_PYTHON["PARSER"] = new parse_engine(new python());
}
function python_exec($filename) {
$code = file_get_contents($filename);
#echo '<pre>';
#echo htmlentities($code);
#echo '</pre>';
python_eval($code);
}
function python_build() {
require_once __LIME__.'/lime.php';
$code = parse_lime_grammar(__PYTHON__.'/python.lime');
file_put_contents(__PYTHON__.'/python.class.php',"<?php \n".$code."\n?>");
}
function python_sanitize($code) {
return $code;
}
function re($regex,$input,&$output) {
return preg_match($regex,$input,&$output);
}
function python_token($name,$value=null,$len=1) {
return array(
"name" => $name,
"value" => $value,
"len" => $len
);
}
function python_parse_comment($comment) {
global $_PYTHON;
if (re("/^#\{([a-zA-Z_][a-zA-Z0-9_]*)\}:(.*)/",$comment,$r)){
$_PYTHON["DEBUG"][$r[1]] = trim($r[2]);
#var_dump($_PYTHON["DEBUG"]);
}
}
function python_dump_token($token) {
echo '<span style="margin:0 2px 2px 0;display:inline-block;padding:0px 4px;font-family:arial;font-size:10px;background:yellow;color:#323232;border:1px solid #323232;">';
if (is_object($token["value"])) {
echo $token["name"].'('.strip_tags($token["value"]->name).')';
} else {
echo $token["name"].'('.strip_tags($token["value"]).')';
}
echo '</span>';
}
function python_run($script) {
#python_build();
python_start();
python_exec($script);
}
*
*
*/