Menu

[r42]: / trunk / python / python.eval.php  Maximize  Restore  History

Download this file

41 lines (25 with data), 604 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require_once __DIR__.'/python.tokenize.php';
class lang_python_eval extends lang_python_tokenize {
public static function python_eval($code) {
$p = static::getParser();
$l = 0;
if (!strlen($code)) return;
try {
$t = static::python_tokenize($code);
$a = count($t);
$p->reset();
$c = 0;
while($c < $a) {
$k = $t[$c];
$p-> eat($k->name,$k->value);
$c++;
}
$p->eat_eof();
} catch (parse_error $e) {
echo '<pre>';
echo $e->getMessage(), "\nLine: $l;", "\n";
echo '</pre>';
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.