rev 261 - in trunk: . include/prothon pr src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-04-02 21:40:08 -0500 (Fri, 02 Apr 2004)
New Revision: 261

Added:
   trunk/src/dict.h
   trunk/src/prlist.h
Removed:
   trunk/include/prothon/dict.h
   trunk/include/prothon/prlist.h
Modified:
   trunk/
   trunk/STATUS.txt
   trunk/include/prothon/prothon.h
   trunk/pr/test.pr
   trunk/src/builtins-core.c
   trunk/src/builtins-dict.c
   trunk/src/builtins-float.c
   trunk/src/builtins-int.c
   trunk/src/builtins-list.c
   trunk/src/builtins-string.c
   trunk/src/builtins-tuple.c
   trunk/src/clist.h
   trunk/src/init.pth
   trunk/src/memory_mgr.c
   trunk/src/object.c
   trunk/src/object.h
   trunk/src/parser.h
   trunk/src/parser_routines.c
   trunk/src/prothon.y
Log:
implemented variable indent widths and 
auto-intellitgent-continutation, 
moved prlist.h and dict.h to src folder


Property changes on: trunk
___________________________________________________________________
Name: svn:ignore
   - config.log
config.cache
config.status
Makefile
prothon.ncb
prothon.sln
prothon.suo
bison_prothon.bat.lnk
apr
Rules.mk
libtool
Shortcut to rel.bat.lnk
Shortcut to prothon.exe.lnk

   + config.log
config.cache
config.status
Makefile
prothon.ncb
prothon.sln
prothon.suo
bison_prothon.bat.lnk
apr
Rules.mk
libtool
Shortcut to rel.bat.lnk
Shortcut to prothon.exe.lnk
mro.py


Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/STATUS.txt	2004-04-03 02:40:08 UTC (rev 261)
@@ -44,10 +44,16 @@
 o = Obj(bases=Object, args):
 f = Func(args):
 
+o = base.new(args)
+o = base.create(args)
+o = base.instance(args)
+
 sets and other zephyr email items -- use <> ?
 
 Allow obj^attr ?
 
+Use self for any obj.func() when obj is proto of self?
+
 ----------------------- TO-DO (highest priority first) ------------------------
 
 --- add list comprehension

Deleted: trunk/include/prothon/dict.h
===================================================================
--- trunk/include/prothon/dict.h	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/include/prothon/dict.h	2004-04-03 02:40:08 UTC (rev 261)
@@ -1,56 +0,0 @@
-
-/* ====================================================================
- * The Prothon License Agreement, Version 1.1
- *
- * Copyright (c) 2004 Hahn Creative Applications, http://hahnca.com.
- * All rights reserved. 
- *
- * 1. This LICENSE AGREEMENT is between Hahn Creative Applications ("HCA"),
- * and the Individual or Organization ("Licensee") accessing and otherwise
- * using Prothon software in source or binary form and its associated
- * documentation.
- * 
- * 2. Subject to the terms and conditions of this License Agreement, HCA
- * hereby grants Licensee a nonexclusive, royalty-free, world-wide license
- * to reproduce, analyze, test, perform and/or display publicly, prepare
- * derivative works, distribute, and otherwise use Prothon alone or in any
- * derivative version, provided, however, that HCA's License Agreement and
- * HCA's notice of copyright, i.e., "Copyright (c) 2004 Hahn Creative
- * Applications; All Rights Reserved" are retained in Prothon alone or
- * in any derivative version prepared by Licensee.
- * 
- * 3. In the event Licensee prepares a derivative work that is based on or
- * incorporates Prothon or any part thereof, and wants to make the
- * derivative work available to others as provided herein, then Licensee
- * hereby agrees to include in any such work a brief summary of the
- * changes made to Prothon.
- * 
- * 4. HCA is making Prothon available to Licensee on an "AS IS" basis.
- * HCA MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  BY WAY
- * OF EXAMPLE, BUT NOT LIMITATION, HCA MAKES NO AND DISCLAIMS ANY
- * REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY
- * PARTICULAR PURPOSE OR THAT THE USE OF PROTHON WILL NOT INFRINGE ANY
- * THIRD PARTY RIGHTS.
- * 
- * 5. HCA SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PROTHON
- * FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A
- * RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PROTHON, OR ANY
- * DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
- * 
- * 6. This License Agreement will automatically terminate upon a material
- * breach of its terms and conditions.
- * 
- * 7. Nothing in this License Agreement shall be deemed to create any
- * relationship of agency, partnership, or joint venture between HCA and
- * Licensee.  This License Agreement does not grant permission to use HCA
- * trademarks or trade name in a trademark sense to endorse or promote
- * products or services of Licensee, or any third party.
- * 
- * 8. By copying, installing or otherwise using Prothon, Licensee agrees
- * to be bound by the terms and conditions of this License Agreement.
- * ====================================================================
- */
-
-// dict.h
-
-#define DEFAULT_INITIAL_DICT_SIZE  8

Deleted: trunk/include/prothon/prlist.h
===================================================================
--- trunk/include/prothon/prlist.h	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/include/prothon/prlist.h	2004-04-03 02:40:08 UTC (rev 261)
@@ -1,77 +0,0 @@
-/* ====================================================================
- * The Prothon License Agreement, Version 1.1
- *
- * Copyright (c) 2004 Hahn Creative Applications, http://hahnca.com.
- * All rights reserved. 
- *
- * 1. This LICENSE AGREEMENT is between Hahn Creative Applications ("HCA"),
- * and the Individual or Organization ("Licensee") accessing and otherwise
- * using Prothon software in source or binary form and its associated
- * documentation.
- * 
- * 2. Subject to the terms and conditions of this License Agreement, HCA
- * hereby grants Licensee a nonexclusive, royalty-free, world-wide license
- * to reproduce, analyze, test, perform and/or display publicly, prepare
- * derivative works, distribute, and otherwise use Prothon alone or in any
- * derivative version, provided, however, that HCA's License Agreement and
- * HCA's notice of copyright, i.e., "Copyright (c) 2004 Hahn Creative
- * Applications; All Rights Reserved" are retained in Prothon alone or
- * in any derivative version prepared by Licensee.
- * 
- * 3. In the event Licensee prepares a derivative work that is based on or
- * incorporates Prothon or any part thereof, and wants to make the
- * derivative work available to others as provided herein, then Licensee
- * hereby agrees to include in any such work a brief summary of the
- * changes made to Prothon.
- * 
- * 4. HCA is making Prothon available to Licensee on an "AS IS" basis.
- * HCA MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  BY WAY
- * OF EXAMPLE, BUT NOT LIMITATION, HCA MAKES NO AND DISCLAIMS ANY
- * REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY
- * PARTICULAR PURPOSE OR THAT THE USE OF PROTHON WILL NOT INFRINGE ANY
- * THIRD PARTY RIGHTS.
- * 
- * 5. HCA SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PROTHON
- * FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A
- * RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PROTHON, OR ANY
- * DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
- * 
- * 6. This License Agreement will automatically terminate upon a material
- * breach of its terms and conditions.
- * 
- * 7. Nothing in this License Agreement shall be deemed to create any
- * relationship of agency, partnership, or joint venture between HCA and
- * Licensee.  This License Agreement does not grant permission to use HCA
- * trademarks or trade name in a trademark sense to endorse or promote
- * products or services of Licensee, or any third party.
- * 
- * 8. By copying, installing or otherwise using Prothon, Licensee agrees
- * to be bound by the terms and conditions of this License Agreement.
- * ====================================================================
- */
-
-
-// prList.h
-
-#define DEFAULT_INITIAL_LIST_SIZE	8
-#define LIST_GROWTH_FACTOR			2
-
-#define LIST_SIZE_INDEX		0
-#define LIST_LEN_INDEX		1  
-#define LIST_OVERHEAD		2
-
-typedef union {
-	int     num;
-	obj_p	item;
-} list_t;
-
-typedef list_t* list_p;
-
-#define lstpsize(list_ptr)		(((list_p)(list_ptr))[LIST_SIZE_INDEX].num)
-#define lstplen(list_ptr)		(((list_p)(list_ptr))[LIST_LEN_INDEX].num)
-#define lstpitem(list_ptr,i)	(((list_p)(list_ptr))[LIST_OVERHEAD+(i)].item)
-
-#define listsize(list_obj)		lstpsize((list_obj)->data.ptr)
-#define listlen(list_obj)		 lstplen((list_obj)->data.ptr)
-#define listitem(list_obj,i)	lstpitem((list_obj)->data.ptr,i)
-

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/include/prothon/prothon.h	2004-04-03 02:40:08 UTC (rev 261)
@@ -1,5 +1,5 @@
 /* ====================================================================
- * The Prothon License Agreement, Version 1.1
+ * The Prothon License Agreement, Version 1.1  
  *
  * Copyright (c) 2004 Hahn Creative Applications, http://hahnca.com.
  * All rights reserved. 

Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/pr/test.pr	2004-04-03 02:40:08 UTC (rev 261)
@@ -3,13 +3,12 @@
 Point = Object()
 with Point:
 	.x0 = 0
-	def .__init__( x = 1 ):
-		print 'x:', x
-		.x0 = x
-		return .
-
+	def .__init__():
+			print 'x:', (33*2
+   +7+3)
+			print 'ok'
 p1 = Point()
-p2 = Point(2)
+p2 = Point()
 print 'Point.x0',Point.x0
 print 'p1.x0',p1.x0
 print 'p2.x0',p2.x0

Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/builtins-core.c	2004-04-03 02:40:08 UTC (rev 261)
@@ -59,7 +59,7 @@
 #include <apr_strings.h>
 
 #include <prothon/prothon.h>
-#include <prothon/dict.h>
+#include "dict.h"
 #include "parser.h"
 #include "object.h"
 #include <prothon/prothon_dll.h>

Modified: trunk/src/builtins-dict.c
===================================================================
--- trunk/src/builtins-dict.c	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/builtins-dict.c	2004-04-03 02:40:08 UTC (rev 261)
@@ -59,7 +59,7 @@
 #include <apr_strings.h>
 
 #include <prothon/prothon.h>
-#include <prothon/dict.h>
+#include "dict.h"
 #include "parser.h"
 #include "object.h"
 #include <prothon/prothon_dll.h>

Modified: trunk/src/builtins-float.c
===================================================================
--- trunk/src/builtins-float.c	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/builtins-float.c	2004-04-03 02:40:08 UTC (rev 261)
@@ -60,7 +60,7 @@
 #include <apr_strings.h>
 
 #include <prothon/prothon.h>
-#include <prothon/dict.h>
+#include "dict.h"
 #include "parser.h"
 #include "object.h"
 #include <prothon/prothon_dll.h>

Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/builtins-int.c	2004-04-03 02:40:08 UTC (rev 261)
@@ -59,7 +59,7 @@
 #include <apr_strings.h>
 
 #include <prothon/prothon.h>
-#include <prothon/dict.h>
+#include "dict.h"
 #include "parser.h"
 #include "object.h"
 #include <prothon/prothon_dll.h>

Modified: trunk/src/builtins-list.c
===================================================================
--- trunk/src/builtins-list.c	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/builtins-list.c	2004-04-03 02:40:08 UTC (rev 261)
@@ -59,7 +59,7 @@
 #include <apr_strings.h>
 
 #include <prothon/prothon.h>
-#include <prothon/dict.h>
+#include "dict.h"
 #include "parser.h"
 #include "object.h"
 #include <prothon/prothon_dll.h>

Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/builtins-string.c	2004-04-03 02:40:08 UTC (rev 261)
@@ -59,7 +59,7 @@
 #include <apr_strings.h>
 
 #include <prothon/prothon.h>
-#include <prothon/dict.h>
+#include "dict.h"
 #include "parser.h"
 #include "object.h"
 #include <prothon/prothon_dll.h>

Modified: trunk/src/builtins-tuple.c
===================================================================
--- trunk/src/builtins-tuple.c	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/builtins-tuple.c	2004-04-03 02:40:08 UTC (rev 261)
@@ -59,7 +59,7 @@
 #include <apr_strings.h>
 
 #include <prothon/prothon.h>
-#include <prothon/dict.h>
+#include "dict.h"
 #include "parser.h"
 #include "object.h"
 #include <prothon/prothon_dll.h>

Modified: trunk/src/clist.h
===================================================================
--- trunk/src/clist.h	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/clist.h	2004-04-03 02:40:08 UTC (rev 261)
@@ -96,9 +96,11 @@
 #define clist_item(list, index)			(((clist_p)(list))->items[index].ptr)
 #define clist_num(list, index)			(((clist_p)(list))->items[index].num)
 #define clist_tos(list)					((list)->items[(list)->len-1].ptr)
+#define clist_tos_num(list)				((list)->items[(list)->len-1].num)
 #define clist_append(list, item)		ins_clist(list, item, CLIST_APPEND)
 #define clist_append_num(list, num)		ins_clist_num(list, num, CLIST_APPEND)
 #define clist_push(list, item)			ins_clist(list, item, CLIST_APPEND)
+#define clist_push_num(list, num)		ins_clist_num(list, num, CLIST_APPEND)
 #define clist_pop(list)					((list)->items[--(list)->len].ptr)				
 
 #endif // #define CLIST_H

Added: trunk/src/dict.h
===================================================================
--- trunk/src/dict.h	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/dict.h	2004-04-03 02:40:08 UTC (rev 261)
@@ -0,0 +1,56 @@
+
+/* ====================================================================
+ * The Prothon License Agreement, Version 1.1
+ *
+ * Copyright (c) 2004 Hahn Creative Applications, http://hahnca.com.
+ * All rights reserved. 
+ *
+ * 1. This LICENSE AGREEMENT is between Hahn Creative Applications ("HCA"),
+ * and the Individual or Organization ("Licensee") accessing and otherwise
+ * using Prothon software in source or binary form and its associated
+ * documentation.
+ * 
+ * 2. Subject to the terms and conditions of this License Agreement, HCA
+ * hereby grants Licensee a nonexclusive, royalty-free, world-wide license
+ * to reproduce, analyze, test, perform and/or display publicly, prepare
+ * derivative works, distribute, and otherwise use Prothon alone or in any
+ * derivative version, provided, however, that HCA's License Agreement and
+ * HCA's notice of copyright, i.e., "Copyright (c) 2004 Hahn Creative
+ * Applications; All Rights Reserved" are retained in Prothon alone or
+ * in any derivative version prepared by Licensee.
+ * 
+ * 3. In the event Licensee prepares a derivative work that is based on or
+ * incorporates Prothon or any part thereof, and wants to make the
+ * derivative work available to others as provided herein, then Licensee
+ * hereby agrees to include in any such work a brief summary of the
+ * changes made to Prothon.
+ * 
+ * 4. HCA is making Prothon available to Licensee on an "AS IS" basis.
+ * HCA MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  BY WAY
+ * OF EXAMPLE, BUT NOT LIMITATION, HCA MAKES NO AND DISCLAIMS ANY
+ * REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY
+ * PARTICULAR PURPOSE OR THAT THE USE OF PROTHON WILL NOT INFRINGE ANY
+ * THIRD PARTY RIGHTS.
+ * 
+ * 5. HCA SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PROTHON
+ * FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A
+ * RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PROTHON, OR ANY
+ * DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+ * 
+ * 6. This License Agreement will automatically terminate upon a material
+ * breach of its terms and conditions.
+ * 
+ * 7. Nothing in this License Agreement shall be deemed to create any
+ * relationship of agency, partnership, or joint venture between HCA and
+ * Licensee.  This License Agreement does not grant permission to use HCA
+ * trademarks or trade name in a trademark sense to endorse or promote
+ * products or services of Licensee, or any third party.
+ * 
+ * 8. By copying, installing or otherwise using Prothon, Licensee agrees
+ * to be bound by the terms and conditions of this License Agreement.
+ * ====================================================================
+ */
+
+// dict.h
+
+#define DEFAULT_INITIAL_DICT_SIZE  8


Property changes on: trunk/src/dict.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/src/init.pth
===================================================================
--- trunk/src/init.pth	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/init.pth	2004-04-03 02:40:08 UTC (rev 261)
@@ -10,5 +10,5 @@
 
 # this is executed before Main1 as module PthMod1
 
-import File, Re
+#import File, Re
 
Modified: trunk/src/memory_mgr.c
===================================================================
--- trunk/src/memory_mgr.c	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/memory_mgr.c	2004-04-03 02:40:08 UTC (rev 261)
@@ -238,7 +238,7 @@
 				break;
 			}
 		}
-		apr_sleep(1);
+		apr_sleep(1000);
 		pr_lock(&to_be_scanned_list_lock);
 		if(clist_len(to_be_scanned_list)){
 			obj = clist_pop(to_be_scanned_list);

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/object.c	2004-04-03 02:40:08 UTC (rev 261)
@@ -65,7 +65,7 @@
 #include "clist.h"
 #include "memory_mgr.h"
 #include "interp.h"
-#include <prothon/dict.h>
+#include "dict.h"
 
 #ifdef ASSERT_
 void assert(int cond){

Modified: trunk/src/object.h
===================================================================
--- trunk/src/object.h	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/object.h	2004-04-03 02:40:08 UTC (rev 261)
@@ -58,7 +58,7 @@
 
 #include <prothon/prothon_dll.h>
 #include "lock.h"
-#include <prothon/prlist.h>
+#include "prlist.h"
 #include <apr_thread_proc.h>
 #include <apr_portable.h>
 

Modified: trunk/src/parser.h
===================================================================
--- trunk/src/parser.h	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/parser.h	2004-04-03 02:40:08 UTC (rev 261)
@@ -93,8 +93,10 @@
 	int			column;
 	int			old_column;
 	int			old_tab_count;
-	int			file_indent_flag;  // -1 -> tab, 0 -> unknown, + -> number of spaces per indent
+	int			indent_char;
 	int			indents_needed;
+	int			last_line_colon;
+	clist_p     indent_stack;
 	FILE*		stream;
 	int			char_ptr;
 	char		old_chars[10];

Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/parser_routines.c	2004-04-03 02:40:08 UTC (rev 261)
@@ -86,7 +86,8 @@
 	state->in_buf = in_buf;
 	state->num_errors = -1;
 	state->assert_enbld = TRUE;
-	state->const_objs = new_clist(10);
+	state->indent_stack = new_clist(10);
+	state->const_objs   = new_clist(10);
 	return state;
 }
 

Added: trunk/src/prlist.h
===================================================================
--- trunk/src/prlist.h	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/prlist.h	2004-04-03 02:40:08 UTC (rev 261)
@@ -0,0 +1,77 @@
+/* ====================================================================
+ * The Prothon License Agreement, Version 1.1
+ *
+ * Copyright (c) 2004 Hahn Creative Applications, http://hahnca.com.
+ * All rights reserved. 
+ *
+ * 1. This LICENSE AGREEMENT is between Hahn Creative Applications ("HCA"),
+ * and the Individual or Organization ("Licensee") accessing and otherwise
+ * using Prothon software in source or binary form and its associated
+ * documentation.
+ * 
+ * 2. Subject to the terms and conditions of this License Agreement, HCA
+ * hereby grants Licensee a nonexclusive, royalty-free, world-wide license
+ * to reproduce, analyze, test, perform and/or display publicly, prepare
+ * derivative works, distribute, and otherwise use Prothon alone or in any
+ * derivative version, provided, however, that HCA's License Agreement and
+ * HCA's notice of copyright, i.e., "Copyright (c) 2004 Hahn Creative
+ * Applications; All Rights Reserved" are retained in Prothon alone or
+ * in any derivative version prepared by Licensee.
+ * 
+ * 3. In the event Licensee prepares a derivative work that is based on or
+ * incorporates Prothon or any part thereof, and wants to make the
+ * derivative work available to others as provided herein, then Licensee
+ * hereby agrees to include in any such work a brief summary of the
+ * changes made to Prothon.
+ * 
+ * 4. HCA is making Prothon available to Licensee on an "AS IS" basis.
+ * HCA MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  BY WAY
+ * OF EXAMPLE, BUT NOT LIMITATION, HCA MAKES NO AND DISCLAIMS ANY
+ * REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY
+ * PARTICULAR PURPOSE OR THAT THE USE OF PROTHON WILL NOT INFRINGE ANY
+ * THIRD PARTY RIGHTS.
+ * 
+ * 5. HCA SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PROTHON
+ * FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A
+ * RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PROTHON, OR ANY
+ * DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+ * 
+ * 6. This License Agreement will automatically terminate upon a material
+ * breach of its terms and conditions.
+ * 
+ * 7. Nothing in this License Agreement shall be deemed to create any
+ * relationship of agency, partnership, or joint venture between HCA and
+ * Licensee.  This License Agreement does not grant permission to use HCA
+ * trademarks or trade name in a trademark sense to endorse or promote
+ * products or services of Licensee, or any third party.
+ * 
+ * 8. By copying, installing or otherwise using Prothon, Licensee agrees
+ * to be bound by the terms and conditions of this License Agreement.
+ * ====================================================================
+ */
+
+
+// prList.h
+
+#define DEFAULT_INITIAL_LIST_SIZE	8
+#define LIST_GROWTH_FACTOR			2
+
+#define LIST_SIZE_INDEX		0
+#define LIST_LEN_INDEX		1  
+#define LIST_OVERHEAD		2
+
+typedef union {
+	int     num;
+	obj_p	item;
+} list_t;
+
+typedef list_t* list_p;
+
+#define lstpsize(list_ptr)		(((list_p)(list_ptr))[LIST_SIZE_INDEX].num)
+#define lstplen(list_ptr)		(((list_p)(list_ptr))[LIST_LEN_INDEX].num)
+#define lstpitem(list_ptr,i)	(((list_p)(list_ptr))[LIST_OVERHEAD+(i)].item)
+
+#define listsize(list_obj)		lstpsize((list_obj)->data.ptr)
+#define listlen(list_obj)		 lstplen((list_obj)->data.ptr)
+#define listitem(list_obj,i)	lstpitem((list_obj)->data.ptr,i)
+


Property changes on: trunk/src/prlist.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y	2004-04-02 16:20:31 UTC (rev 260)
+++ trunk/src/prothon.y	2004-04-03 02:40:08 UTC (rev 261)
@@ -686,8 +686,7 @@
 }
 
 int yylex (YYSTYPE *lvalp, void* yylex_param){
-	int c, tab_spc_count=0, unknown_indent_flag=0, wrong_char_in_indent, spaces_per_tab;
-	spaces_per_tab = state->file_indent_flag;
+	int c, indent_cnt=0, unknown_indent_flag=0, mixed_indents;
 
 	if (state->indents_needed > 0){
 		state->indents_needed--;
@@ -728,31 +727,43 @@
 				ungetch(c2, state);
 		}
 		if (c == '\n'){
+			int llen = clist_len(state->indent_stack);
 			unknown_indent_flag = 0; 
-			if (spaces_per_tab == 0) {
-				if ((c=getch(state)) == '\t') {
-					spaces_per_tab = state->file_indent_flag = -1;
-					tab_spc_count = 1;
-				} else if (c == ' ') {
-					spaces_per_tab++;
-					while ((c=getch(state)) == ' ') spaces_per_tab++;
-					state->file_indent_flag = spaces_per_tab;
-					tab_spc_count = 1;
+			// if a ( { or [ is on top of indent stack then this is a continuation line
+			if (clist_len(state->indent_stack) && clist_tos_num(state->indent_stack) > 0)
+				continue;
+			if (!state->indent_char) {
+				if ((c=getch(state)) == '\t' || c == ' ') {
+					int new_chr_cnt = 1;
+					while ((c=getch(state)) == c) new_chr_cnt++;
+					if (!state->last_line_colon) continue;
+					state->indent_char = c;
+					clist_append_num(state->indent_stack, -new_chr_cnt);
+					indent_cnt = 1;
 				}
-			} else if (spaces_per_tab < 0) {
-				for(tab_spc_count=0; (c=getch(state)) == '\t'; tab_spc_count++) ;	
 			} else {
-				int tmp;
-				for(tmp=0; (c=getch(state)) == ' '; tmp++) ;
-				tab_spc_count = tmp / spaces_per_tab;
-				while (tmp != tab_spc_count * spaces_per_tab) {
-					ungetch(c, state);
-					c = ' '; 
-					tmp--;
+				int i, chr_cnt;
+				for(chr_cnt=0; (c=getch(state)) == state->indent_char; chr_cnt++) ;
+				indent_cnt = 0;
+				for (i=0; i < llen; i++) {
+					if (chr_cnt < 0) {
+						printf("Lexical error: indentation level does not match any previous level\n");
+						return ERR;
+					}
+					if (chr_cnt == 0) {
+						indent_cnt = i;
+						break;
+					}
+					chr_cnt -= -clist_num(state->indent_stack, i);
 				}
+				if (chr_cnt)  {
+					if (!state->last_line_colon) continue;
+					indent_cnt++;
+					clist_append_num(state->indent_stack, -chr_cnt);
+				}
 			}
-			wrong_char_in_indent = ( (spaces_per_tab < 0 && c == ' ') ||
-						 (spaces_per_tab > 0 && c == '\t')  );
+			mixed_indents = ( (state->indent_char == '\t' && c == ' ') ||
+						      (state->indent_char == ' '  && c == '\t')  );
 			while (c == ' ' || c == '\t') c = getch(state);
 			if (c == '\n' || c == '#')
 				goto check_comment;
@@ -765,14 +776,13 @@
 				}
 			}
 			ungetch(c, state);
-			if (tab_spc_count > state->old_tab_count+1)
-				continue;
-			if (wrong_char_in_indent){
+			if (mixed_indents){
 				printf("Lexical error: mixed tabs and spaces in indentation\n");
 				return ERR;
 			}
-			state->indents_needed = tab_spc_count - state->old_tab_count;
-			state->old_tab_count = tab_spc_count;
+			state->indents_needed = indent_cnt - state->old_tab_count;
+			state->old_tab_count = indent_cnt;
+			while (clist_len(state->indent_stack) > indent_cnt) clist_pop(state->indent_stack);
 			return EOL;			
 		}
 		break;
@@ -792,6 +802,7 @@
 		printf("Lexical error: Inline quote not allowed at beginning of indented line\n");
 		return ERR;
 	}
+	state->last_line_colon = FALSE;
 	/* process quotes */
 	if (c == 'r' || c == 'R' || c == 'x' || c == 'X' || c == '\'' || c == '\"') {
 		int r_flag=0, x_flag=0, triple_flag=0, q_char=c;
@@ -1213,6 +1224,31 @@
 			return FLOAT_;
 	}
 	/* return other chars */
+	if (c == '(') clist_push_num(state->indent_stack, c);
+	if (c == '{') clist_push_num(state->indent_stack, c);
+	if (c == '[') clist_push_num(state->indent_stack, c);
+	if (c == ')') {
+		if (!clist_len(state->indent_stack) || clist_tos_num(state->indent_stack) != '(') {
+			printf("Lexical error: mismatched parens ()\n");
+			return ERR;
+		}
+		clist_pop(state->indent_stack);
+	}
+	if (c == '}') {
+		if (!clist_len(state->indent_stack) || clist_tos_num(state->indent_stack) != '{') {
+			printf("Lexical error: mismatched braces {}\n");
+			return ERR;
+		}
+		clist_pop(state->indent_stack);
+	}
+	if (c == ']') {
+		if (!clist_len(state->indent_stack) || clist_tos_num(state->indent_stack) != '[') {
+			printf("Lexical error: mismatched brackets []\n");
+			return ERR;
+		}
+		clist_pop(state->indent_stack);
+	}
+	if (c = ':') state->last_line_colon = TRUE;
 	return c;                                
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.