Menu

Diff of /trunk/python/python.lib.php [r14] .. [r15]  Maximize  Restore

Switch to side-by-side view

--- a/trunk/python/python.lib.php
+++ b/trunk/python/python.lib.php
@@ -7,19 +7,33 @@
 $parser = new parse_engine(new python());
 
 function python_eval($pycode) {
+	
 	global $parser;
-	$line = $pycode;
 	$codeline = 1;
-	if (!strlen($line)) return;
+	if (!strlen($pycode)) return;
 	try {
 		$parser->reset();
-		foreach(python_tokenize($line) as $token) {
-			$parser->eat($token["name"], $token["value"]);
-			if ($token["name"] == "NEWLINE") {
+		$tokens = python_tokenize($pycode);
+		$alltok = count($tokens);
+		$cursor = 0;
+		
+		while($cursor < $alltok) {
+			$token0 = $tokens[$cursor];
+			$token1 = isset($tokens[$cursor+1]);
+			
+			dump_token($token0);
+			
+			$parser->eat($token0["name"], $token0["value"]);
+			
+			if ($token0["name"] == "NEWLINE") {
 				$codeline++;
 			}
+			
+			$cursor++;
 		}
+		
 		$parser->eat_eof();
+		
 	} catch (parse_error $e) {
 		echo '<pre>';
 		echo $e->getMessage(), "\nLine: $codeline;", "\n";
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.