Menu

Commit [r48]  Maximize  Restore  History

string test

francescobianco 2014-09-19

changed /trunk/python/python.eval.php
changed /trunk/python/python.execfile.php
changed /trunk/python/python.token.php
changed /trunk/python/python.tokenize.php
changed /trunk/test/test2/test2.py
/trunk/python/python.eval.php Diff Switch to side-by-side view
--- a/trunk/python/python.eval.php
+++ b/trunk/python/python.eval.php
@@ -3,7 +3,7 @@
 
 class lang_python_eval extends lang_python_tokenize {
 
-	public static function python_eval($code) {
+	public static function python_eval($code,$file) {
 		
 		$p = static::getParser();
 
@@ -29,12 +29,22 @@
 
 			$p->eat_eof();
 
-		} catch (parse_error $e) {
-			echo '<pre>';
-			echo $e->getMessage(), "\nLine: $l;", "\n";
+		} catch (Exception $e) {
+			echo '<pre style="padding:8px;background:f2f2f2;">';
+			//echo $e->getMessage(), "\nLine: $l;", "\n";			
+			echo '  File "'.$file.'", line '.$k->row."\n";
+			echo '    '.static::get_code_line($code,$k->row)."\n";
+			echo '    '.'^'."\n";
+			echo 'SyntaxError: invalid syntax';			
 			echo '</pre>';
 		}
 
 	}
 	
+	
+	public static function get_code_line($code,$row) {
+		$code = explode("\n",$code);
+		return trim($code[$row-1]);		
+	}
+	
 }
/trunk/python/python.execfile.php Diff Switch to side-by-side view
Loading...
/trunk/python/python.token.php Diff Switch to side-by-side view
Loading...
/trunk/python/python.tokenize.php Diff Switch to side-by-side view
Loading...
/trunk/test/test2/test2.py Diff Switch to side-by-side view
Loading...
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.