rev 664 - in trunk: . include/prothon pr/test src

SVN User <[email protected]> Fri, 25 Jun 2004 02:37:21 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-06-25 02:37:18 -0400 (Fri, 25 Jun 2004)
New Revision: 664

Modified:
   trunk/STATUS.txt
   trunk/include/prothon/prothon.h
   trunk/include/prothon/prothon_dll.h
   trunk/pr/test/test.pr
   trunk/src/builtins-core.c
   trunk/src/console.c
   trunk/src/interp.c
Log:
added kludge to console to allow typing a var to see its value

Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt	2004-06-25 05:57:23 UTC (rev 663)
+++ trunk/STATUS.txt	2004-06-25 06:37:18 UTC (rev 664)
@@ -1,8 +1,6 @@
 
 ----------------------- TO-DO (highest priority first) ------------------------
 
---- function-as-command
-
 --- OSThread, Thread, and Gate
 --- lock keyword?
 

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-06-25 05:57:23 UTC (rev 663)
+++ trunk/include/prothon/prothon.h	2004-06-25 06:37:18 UTC (rev 664)
@@ -50,7 +50,7 @@
  * ====================================================================
  */     
 
-// Prothon.h
+// Prothon.h    -i -dpbc ..\pr\test\test.pr
  
 #ifndef PROTHON_H
 #define PROTHON_H
@@ -350,6 +350,7 @@
 	STOP_ITERATION_EXC,	//  
 	LOCK_EXC,			//  
 	PERMISSION_EXC,		//  
+	COMMAND_EXC,		//  
  
 // constants
 	ZERO_INT,			//  

Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h	2004-06-25 05:57:23 UTC (rev 663)
+++ trunk/include/prothon/prothon_dll.h	2004-06-25 06:37:18 UTC (rev 664)
@@ -166,7 +166,6 @@
 
 } pr_services_t;
 
-
 /* XXX: Need to document all this stuff */
 #define MODULE_DECLARE(name)    \
 static isp ist;                 \

Modified: trunk/pr/test/test.pr
===================================================================
--- trunk/pr/test/test.pr	2004-06-25 05:57:23 UTC (rev 663)
+++ trunk/pr/test/test.pr	2004-06-25 06:37:18 UTC (rev 664)
@@ -1,6 +1,10 @@
 #!/usr/bin/env prothon
 
+x=6
+x
+
 try:
-	1//0
+    print 1//0
 except DivideByZero as e:
-	print (e)
\ No newline at end of file
+    print e
+

Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c	2004-06-25 05:57:23 UTC (rev 663)
+++ trunk/src/builtins-core.c	2004-06-25 06:37:18 UTC (rev 664)
@@ -542,6 +542,7 @@
 EXCEPTION_DECLARE(Exception_OBJ, STOP_ITERATION_EXC,  StopIteration,     "Stop iteration (not an error)");
 EXCEPTION_DECLARE(Exception_OBJ, LOCK_EXC,            LockError,         "Locking Error");
 EXCEPTION_DECLARE(Exception_OBJ, PERMISSION_EXC,      PermissionError,   "Permission Error");
+EXCEPTION_DECLARE(Exception_OBJ, COMMAND_EXC,         CommandError,      "Invalid Command");
 }
 
 DEF(Exception, init_,  FORM_STAR_PARAM) {

Modified: trunk/src/console.c
===================================================================
--- trunk/src/console.c	2004-06-25 05:57:23 UTC (rev 663)
+++ trunk/src/console.c	2004-06-25 06:37:18 UTC (rev 664)
@@ -182,7 +182,7 @@
 #define PROTHON_HISTORY  ".prothon_history"
 
 void console(isp ist) {
-	obj_p res, new_self, new_locals;
+	obj_p res, exc, new_self, new_locals;
 	frame_p frame = NULL;
     char buf[16];
 	int ind_level = 0, colon_flg = FALSE;
@@ -231,6 +231,19 @@
 			colon_flg = (strlen(line) >= 2 && line[strlen(line)-2] == ':');
 		}
 		res = exec_string(ist, src, TRUE, &frame);
+		if (exc = catch_exception(ist, OBJ(COMMAND_EXC), NULL)) {
+			char* p;
+			for (p=src; *p > ' '; p++);
+			if (*p == 0 || *p == '\n') {
+				char* src2 = pr_malloc(strlen(src)+10);
+				strcpy(src2, "print ");
+				strcat(src2, src);
+				ist->frame = NULL;
+				res = exec_string(ist, src2, TRUE, &frame);
+				pr_free(src2);
+			} else
+				ist->exception_obj = exc;
+		}
 		if (check_exceptions(ist)) {
 			ist->frame = NULL;
 		} else {

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-06-25 05:57:23 UTC (rev 663)
+++ trunk/src/interp.c	2004-06-25 06:37:18 UTC (rev 664)
@@ -1204,8 +1204,8 @@
 				fr_sp -= 2+2*param;
 				func_obj = fr_stack[fr_sp];
 				if (cmd_flag && !get_attr(ist, func_obj, SYM(COMMAND_))) {
-					raise_exception( ist, OBJ(INTERPRETER_EXC), "invalid command: %s", 
-						                                        symch(ist, fr_data(1)) );
+					raise_exception( ist, OBJ(COMMAND_EXC), "Unknown: %s", 
+						                            symch(ist, fr_data(1)) );
 					break;
 				}
 				if (func_obj->data_type == DATA_TYPE_EXTPTR) {