rev 451 - in trunk: . pr src

SVN User <[email protected]> Tue, 04 May 2004 00:08:20 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-05-04 00:08:17 -0400 (Tue, 04 May 2004)
New Revision: 451

Modified:
   trunk/STATUS.txt
   trunk/pr/strmod.pr
   trunk/pr/test.pr
   trunk/src/builtins-string.c
   trunk/src/interp.c
   trunk/src/memory_mgr.c
   trunk/src/parser.h
   trunk/src/parser_routines.c
   trunk/src/prothon.y
   trunk/src/src.vcproj
Log:
fixed '\000abc'.len() bug, changed string method names to canelCase, added null chars to end of string objects,
some test programs don't run

Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt	2004-05-03 17:25:33 UTC (rev 450)
+++ trunk/STATUS.txt	2004-05-04 04:08:17 UTC (rev 451)
@@ -1,10 +1,14 @@
 
 ----------------------- TO-DO (highest priority first) ------------------------
 
+--- what C standard should project use?
+
+--- allow obj.func.bind() to default to obj.func.bind(obj)
+
+--- allow no parens in object statement
+
 --- add ^ as an obj
 
---- Add missing string functions
-
 --- fix str-to-obj in parser for '\000abc'.len()
 
 --- fix bug1.pr and bug2.pr

Modified: trunk/pr/strmod.pr
===================================================================
--- trunk/pr/strmod.pr	2004-05-03 17:25:33 UTC (rev 450)
+++ trunk/pr/strmod.pr	2004-05-04 04:08:17 UTC (rev 451)
@@ -39,15 +39,15 @@
 	print "capitalize() failed!"
 	failures = failures+1
 
-if "a\tb\tcde".expandtabs() != "a        b        cde":
+if "a\tb\tcde".expandTabs() != "a        b        cde":
 	print "expandtabs() failed!"
 	failures = failures+1
 
-if " \t \r\n abc".lstrip() != "abc":
+if " \t \r\n abc".lStrip() != "abc":
 	print "lstrip() failed!"
 	failures = failures+1
 
-if "abc \t \r\n ".rstrip() != "abc":
+if "abc \t \r\n ".rStrip() != "abc":
 	print "rstrip() failed!"
 	failures = failures+1
 

Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr	2004-05-03 17:25:33 UTC (rev 450)
+++ trunk/pr/test.pr	2004-05-04 04:08:17 UTC (rev 451)
@@ -1,31 +1,109 @@
 #!/usr/bin/env prothon
 
-def func():
-	print $
+# strmod.pr
+
+# TODO:
+#  *) More comprehensive tests, especially replace() and split().
+#  *) Test binary string handling (when parser is fixed).
+
+failures = 0
+
+s = "test %4d..%4.2e..%s" % (-12, 100/3, 'jhgdjhg')
+
+if s != 'test  -12..3.33e+01..jhgdjhg': 
+	print 'error 1'
+	print s
+	failures = failures+1
 	
-bf33 = func.bind(33)
-bf66 = func.bind(66)
-print bf33				#   <func:93b7c0:bound:33> 
-print bf66				#	<func:93b7e0:bound:66>
+if "abCDefG".lower() != "abcdefg":
+	print "lower() failed!"
+	failures = failures+1
 
-bf33()					# 33
-bf66()					# 66
-with 99: bf33()			# 33
-with 99: bf66()			# 66
+if "abCDefG345%^&".lower() != "abcdefg345%^&":
+	print "lower() failed!"
+	failures = failures+1
 
-print bf33				#   <func:93b7c0:bound:33>
-print bf33.__bindObj__	#	33
-del bf33.__bindObj__
-print bf33				#  <func:93b7c0>
+if "abCDefG".upper() != "ABCDEFG":
+	print "upper() failed!"
+	failures = failures+1
 
-print bf66				#  <func:93b7e0:bound:66> 
+if "+_098abCDefG".upper() != "+_098ABCDEFG":
+	print "upper() failed!"
+	failures = failures+1
 
-bf66 = bf66.bind(11)	#  <func:93b7e0:bound:66> 
-print bf66				#  <func:93bbc0:bound:11>
-bf66 = bf66.bind()
-print bf66				#  <func:93bc80>
+if "abCDefG".replace("CDe","456") != "ab456fG":
+	print "replace() failed!"
+	failures = failures+1
 
+if "abcdefg".capitalize() != "Abcdefg":
+	print "capitalize() failed!"
+	failures = failures+1
 
+if "a\tb\tcde".expandTabs() != "a        b        cde":
+	print "expandTabs() failed!","a\tb\tcde".expandTabs()
+	failures = failures+1
 
+if " \t \r\n abc".lStrip() != "abc":
+	print "lstrip() failed!"
+	failures = failures+1
 
+if "abc \t \r\n ".rStrip() != "abc":
+	print "rstrip() failed!"
+	failures = failures+1
 
+if " \t \r\n abc \t \r\n ".strip() != "abc":
+	print "strip() failed!"
+	failures = failures+1
+
+if ".a.bc.def.ghij.".split('.') != ['', 'a', 'bc', 'def', 'ghij', '']:
+	print "split() failed!"
+	failures = failures+1
+
+if "a.bc.def.ghij".split('.') != ['a', 'bc', 'def', 'ghij']:
+	print "split() failed!"
+	failures = failures+1
+
+if "a.bc.def.ghij.".split('.') != ['a', 'bc', 'def', 'ghij', '']:
+	print "split() failed!"
+	failures = failures+1
+
+if "..a.bc.def.ghij.".split('.') != ['', '', 'a', 'bc', 'def', 'ghij', '']:
+	print "split() failed!"
+	failures = failures+1
+
+if "a.bc.def.ghij".split('a') != ['', '.bc.def.ghij']:
+	print "split() failed!"
+	failures = failures+1
+
+if "a.ab.abc.abcd".split('a') != ['', '.', 'b.', 'bc.', 'bcd']:
+	print "split() failed!"
+	failures = failures+1
+
+if ".a.ab.abc.abcd".split('a') != ['.', '.', 'b.', 'bc.', 'bcd']:
+	print "split() failed!"
+	failures = failures+1
+
+if ".a.ab.abc.abcd.".split('a') != ['.', '.', 'b.', 'bc.', 'bcd.']:
+	print "split() failed!"
+	failures = failures+1
+
+if "aaaaabaacaadaaaaabaacaad".split("aab") != ["aaa","aacaadaaa","aacaad"]:
+	print "split() failed!"
+	failures = failures+1
+
+if "aaaaabaacaadaaaaabaacaad".find("aab",0) != 3:
+	print "split() failed!"
+	failures = failures+1
+
+s = "%d" % 3333
+
+if s != '3333': 
+	print 'error 2'
+	print s
+	failures = failures+1
+
+if failures==0:
+	print '\nall tests passed\n'
+else:
+	print "%d failure(s) occurred!\n"%failures
+	Sys.exit(1)

Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c	2004-05-03 17:25:33 UTC (rev 450)
+++ trunk/src/builtins-string.c	2004-05-04 04:08:17 UTC (rev 451)
@@ -69,6 +69,9 @@
 
 #define is_String(objid)        (has_proto_QUES(ist, objid, String_OBJ))
 
+MODULE_DECLARE(String);
+MODULE_DECLARE(StringGen);
+
 //********************************* new_string_obj ****************************
 // this cannot be used with binary data, for C strings only
 // for binary data with embedded nulls use NEW_STRINGN()
@@ -93,7 +96,7 @@
 }
 
 //********************************* new_string_n_obj **************************
-obj_p new_string_n_obj(isp ist, char* str, size_t len){
+obj_p new_string_n_obj(isp ist, char* str, size_t len) {
 	obj_p obj;
 	pr_str_p obj_str;
 	if(!str) return NULL;
@@ -130,12 +133,84 @@
 	obj->immutable = TRUE;
 }
 
-//********************************* STRING MODULE *****************************
+//********************************* changeCase ********************************
+// Generic case-changer function.
+#define AT_WORD_START -1
+static obj_p changeCase(isp ist,obj_p self,int (*changer)(int), size_t howMany) {
+	size_t str_len = pr_strlen(self), ii = 0;
+	char *src_ptr, *dest_ptr = 0;
+	obj_p obj=0;
+	pr_str_p obj_str=0;
+	int atStart = 1;
 
-MODULE_DECLARE(String);
-MODULE_DECLARE(StringGen);
+	obj = NEW_OBJ(String_OBJ);
+	obj_str = obj_malloc(ist, OBJ(STRING_PROTO), obj, sizeof(pr_str_t)+str_len+1);
+	if(!obj_str) {
+		raise_exception(ist, OBJ(OUTOFMEMORY_EXC),
+						"memory allocation failed for string.changeCase (used by lower(), upper(), etc.)");
+		return NULL;
+	}
+	obj_str->len = str_len;
+	dest_ptr = obj_str->str;
 
+	// Fill the copy.
+	src_ptr = pr_strptr(self);
+	for (ii=0; ii<str_len; ++ii) {
+		if (howMany == AT_WORD_START) {
+			if (atStart) {
+				dest_ptr[ii] = (char)(*changer)(src_ptr[ii]);
+			} else {
+				dest_ptr[ii] = src_ptr[ii];
+			}
+			if (isspace(src_ptr[ii])) atStart = 1; else atStart = 0;
+		} else {
+			if (ii<howMany) {
+				dest_ptr[ii] = (char)(*changer)(src_ptr[ii]);
+			} else {
+				dest_ptr[ii] = src_ptr[ii];
+			}
+		}
+	}
+	dest_ptr[str_len] = 0;
 
+	return obj;
+}
+
+//********************************* bin_strstr ********************************
+// strstr()-analog that works for strings that may contain nulls.
+// Totally dependent upon ASCII encoding; beware.
+static char* bin_strstr(char* haystack,size_t lhaystack, char* needle,size_t lneedle) {
+	char* lookfor = needle;
+	char* looking_at = haystack;
+	char* hs_end = haystack+lhaystack;
+	char* ndl_end = needle+lneedle;
+	while (looking_at < hs_end) {
+		if (*lookfor == *looking_at) {
+			// Matched a character.
+			++lookfor;
+			if (lookfor == ndl_end) {
+				// Matched the whole string. It started lneedle-1
+				// characters before the character we're looking at
+				// now.
+				return looking_at + 1 - lneedle;
+			}
+		} else {
+			// No match.
+			if (lookfor > needle) {
+				// We had recognized the beginning of a match. We must
+				// return to the character after the location at which
+				// the non-match began.
+				looking_at -= lookfor-needle;
+				lookfor = needle;
+			}
+		}
+		++looking_at;
+	}
+	return 0;
+}
+
+//********************************* STRING MODULE *****************************
+
 MODULE_START(String)
 {
 	String_OBJ = OBJ(STRING_PROTO);
@@ -171,11 +246,6 @@
 	return new_hash_obj(ist, res);
 }
 
-DEF(String, __objList__, FORM_RPARAM) {
-	BIN_CONTENT_CHK(String);
-	return parms[1];
-}
-
 DEF(String, __getItem__, FORM_RPARAM) {
 	BIN_CONTENT_CHK(String);
 	return get_sequence_item(ist, self, parms[1], SEQ_TYPE_STRING);
@@ -241,11 +311,11 @@
 	times = (size_t) parms[1]->data.i64;
 	if(times == 0) return NEW_STRING("");
 	if(times == 1) return self;
-	tlen = len*times+1;
+	tlen = len*times;
 	obj = NEW_OBJ(String_OBJ);
-	if (tlen < IMMEDIATE_DATA_LEN) {
+	if (tlen < IMMEDIATE_DATA_LEN-1) {
 		obj->data_type    = DATA_TYPE_IMMDATA;
-		obj->imm_data_len = (int) tlen-1;
+		obj->imm_data_len = (int) tlen;
 		for(i=0; i < times; i++)
 			memcpy(obj->data.str+i*len, pr_strptr(self), len);
 		obj->data.str[tlen] = 0;
@@ -255,7 +325,7 @@
 			raise_exception(ist, OBJ(OUTOFMEMORY_EXC), "memory allocation failed for string multiplication");
 			return NULL;
 		}
-		obj_str->len = tlen-1;
+		obj_str->len = tlen;
 		for(i=0; i < times; i++)
 			memcpy(obj_str->str+i*len, pr_strptr(self), len);
 		obj_str->str[tlen] = 0;
@@ -403,109 +473,36 @@
 	else                 return OBJ(PR_FALSE);
 }
 
-DEF(String, __cDataLen__, NULL) {
+DEF(String, lower, NULL) {
 	BIN_CONTENT_CHK(String);
-	return NEW_INT(sizeof(pr_str_t) + pr_strlen(self) + 1);
-}
-
-// Generic case-changer function.
-#define AT_WORD_START -1
-static obj_p changeCase(isp ist,obj_p self,int (*changer)(int), size_t howMany) {
-	size_t str_len = pr_strlen(self), ii = 0;
-	char* dest_ptr = 0;
-	obj_p obj=0;
-	pr_str_p obj_str=0;
-	int atStart = 1;
-
-	obj = NEW_OBJ(String_OBJ);
-	obj_str = obj_malloc(ist, OBJ(STRING_PROTO), obj, sizeof(pr_str_t)+str_len+1);
-	if(!obj_str) {
-		raise_exception(ist, OBJ(OUTOFMEMORY_EXC),
-						"memory allocation failed for string.changeCase (used by lower(), upper(), etc.)");
-		return NULL;
-	}
-	obj_str->len = str_len;
-	dest_ptr = obj_str->str;
-
-	// Fill the copy.
-	char* src_ptr = pr_strptr(self);
-	for (ii=0; ii<str_len; ++ii) {
-		if (howMany == AT_WORD_START) {
-			if (atStart) {
-				dest_ptr[ii] = (char)(*changer)(src_ptr[ii]);
-			} else {
-				dest_ptr[ii] = src_ptr[ii];
-			}
-			if (isspace(src_ptr[ii])) atStart = 1; else atStart = 0;
-		} else {
-			if (ii<howMany) {
-				dest_ptr[ii] = (char)(*changer)(src_ptr[ii]);
-			} else {
-				dest_ptr[ii] = src_ptr[ii];
-			}
-		}
-	}
-	dest_ptr[str_len] = 0;
-
-	return obj;
-}
-
-DEF(String, lower, NULL) {
 	return changeCase(ist,self,&tolower,pr_strlen(self));
 }
 
 DEF(String, upper, NULL) {
+	BIN_CONTENT_CHK(String);
 	return changeCase(ist,self,&toupper,pr_strlen(self));
 }
 
 DEF(String, capitalize, NULL) {
+	BIN_CONTENT_CHK(String);
 	return changeCase(ist,self,&toupper,1);
 }
 
-DEF(String, capwords, NULL) {
+DEF(String, capWords, NULL) {
+	BIN_CONTENT_CHK(String);
 	return changeCase(ist,self,&toupper,AT_WORD_START);
 }
 
-// strstr()-analog that works for strings that may contain nulls.
-// Totally dependent upon ASCII encoding; beware.
-static char* bin_strstr(char* haystack,size_t lhaystack, char* needle,size_t lneedle) {
-	char* lookfor = needle;
-	char* looking_at = haystack;
-	char* hs_end = haystack+lhaystack;
-	char* ndl_end = needle+lneedle;
-	while (looking_at < hs_end) {
-		if (*lookfor == *looking_at) {
-			// Matched a character.
-			++lookfor;
-			if (lookfor == ndl_end) {
-				// Matched the whole string. It started lneedle-1
-				// characters before the character we're looking at
-				// now.
-				return looking_at + 1 - lneedle;
-			}
-		} else {
-			// No match.
-			if (lookfor > needle) {
-				// We had recognized the beginning of a match. We must
-				// return to the character after the location at which
-				// the non-match began.
-				looking_at -= lookfor-needle;
-				lookfor = needle;
-			}
-		}
-		++looking_at;
-	}
-	return 0;
-}
-
 #define Int_value(objid)	(objid->data.i64)
 DEF(String, find, FPARM2( stringToFind, NULL, indexToStartLooking, NEW_INT(0) )) {
 	size_t str_len = pr_strlen(self);
 	size_t find_len = 0;
-	char* find_ptr = 0;
+	char *found, *find_ptr = 0;
 	size_t start = 0;
 	obj_p result = 0;
 
+	BIN_CONTENT_CHK(String);
+
 	if (!has_proto_QUES(ist, parms[1], String_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "find function parameter 1 must be a string");
 		return NULL;
@@ -522,7 +519,7 @@
 	if (find_len<1) {
 		return new_int_obj(ist,0);
 	}
-	char* found = bin_strstr(pr_strptr(self)+Int_value(parms[3]),str_len,find_ptr,find_len);
+	found = bin_strstr(pr_strptr(self)+Int_value(parms[3]),str_len,find_ptr,find_len);
 	if (found) {
 		result = new_int_obj(ist,found-pr_strptr(self));
 	} else {
@@ -547,6 +544,8 @@
 	char* a_match = 0;
 	char* where_ptr = 0;
 
+	BIN_CONTENT_CHK(String);
+
 	if (!has_proto_QUES(ist, parms[1], String_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "replace function parameter 1 must be a string");
 		return NULL;
@@ -583,10 +582,11 @@
 	// Create the copy.
 	// Create the copy.
 	obj = NEW_OBJ(String_OBJ);
-	if (result_len < IMMEDIATE_DATA_LEN) {
+	if (result_len < IMMEDIATE_DATA_LEN-1) {
 		obj->data_type = DATA_TYPE_IMMDATA;
 		obj->imm_data_len = (int) result_len;
 		dest_ptr = obj->data.str;
+		dest_ptr[result_len]=0;
 	} else {
 		obj_str = obj_malloc(ist, OBJ(STRING_PROTO), obj, sizeof(pr_str_t)+result_len+1);
 		if(!obj_str) {
@@ -595,6 +595,7 @@
 		}
 		obj_str->len = result_len;
 		dest_ptr = obj_str->str;
+		dest_ptr[result_len]=0;
 	}
 
 	// Fill the replaced copy.
@@ -604,7 +605,7 @@
 	while (a_match) {
 		// Copy everything from where we were to the beginning of the
 		// match.
-		int frag_len = a_match-where_ptr;
+		int frag_len = (int) (a_match - where_ptr);
 		memcpy(dest_ptr,where_ptr,frag_len);
 		dest_ptr += frag_len;
 
@@ -622,29 +623,35 @@
 	if (where_ptr<src_ptr+str_len) {
 		memcpy(dest_ptr,where_ptr,(src_ptr+str_len)-where_ptr);
 	}
-
 	return obj;
 }
 
-DEF(String, expandtabs, FPARM1( nSpaces, NEW_INT(8) )) {
-	obj_p tab = new_string_obj(ist,"\t");
-	obj_p tspace = new_string_obj(ist," ");
-	obj_p mul_args[] = {NULL,parms[1]};
-	obj_p spcs = String__mul__(ist,tspace,1,mul_args,0);
-	obj_p repl_args[] = {NULL,tab,NULL,spcs};
-	obj_p result = Stringreplace(ist,self,2,repl_args,0);
-	del_unlock(tab);
-	del_unlock(spcs);
-	del_unlock(tspace);
+DEF(String, expandTabs, FPARM1( nSpaces, NEW_INT(8) )) {
+	obj_p result;	
+	BIN_CONTENT_CHK(String);
+	{
+		obj_p tab = new_string_obj(ist,"\t");
+		obj_p tspace = new_string_obj(ist," ");
+		obj_p mul_args[]= {NULL, parms[1]};
+		obj_p spcs = String__mul__(ist,tspace,2,mul_args,0);
+		obj_p repl_args[] = {NULL, tab, NULL, spcs};
+		result = Stringreplace(ist,self,4,repl_args,0);
+		del_unlock(tab);
+		del_unlock(spcs);
+		del_unlock(tspace);
+	}
 	return result;
 }
 
 //===============================
-// ASSUMPTION: if we're using lstrip, rstrip, etc, then
+// ASSUMPTION: if we're using lStrip, rStrip, etc, then
 // we're dealing with null-terminated text strings.
 //===============================
-DEF(String, lstrip, NULL) {
+DEF(String, lStrip, NULL) {
 	char* cstr = pr_strptr(self);
+
+	BIN_CONTENT_CHK(String);
+
 	while (isspace(*cstr)) {
 		++cstr;
 	}
@@ -653,10 +660,13 @@
 	return new_string_obj(ist,cstr);
 }
 
-DEF(String, rstrip, NULL) {
+DEF(String, rStrip, NULL) {
 	// Count whitespace at the end.
 	char* cstr = pr_strptr(self)+pr_strlen(self)-1;
 	size_t result_len = 0;
+
+	BIN_CONTENT_CHK(String);
+
 	while (isspace(*cstr)) {
 		--cstr;
 	}
@@ -667,14 +677,18 @@
 }
 
 DEF(String, strip, NULL) {
-	char* cstr = pr_strptr(self);
+	char *cstr2, *cstr = pr_strptr(self);
+	size_t result_len;
+
+	BIN_CONTENT_CHK(String);
+
 	while (isspace(*cstr)) {
 		++cstr;
 	}
 	
 	// Count whitespace at the end.
-	char* cstr2 = pr_strptr(self)+pr_strlen(self)-1;
-	size_t result_len = 0;
+	cstr2 = pr_strptr(self)+pr_strlen(self)-1;
+	result_len = 0;
 	while (isspace(*cstr2)) {
 		--cstr2;
 	}
@@ -692,8 +706,9 @@
 	size_t temp_len = 0;
 	char* a_match = 0;
 	char* where_ptr = 0;
-	obj_p list_obj = new_list_obj(ist,0);
+	obj_p next_frag, list_obj = new_list_obj(ist,0);
 
+	BIN_CONTENT_CHK(String);
 	if (!has_proto_QUES(ist, parms[1], String_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "split function parameter 1 must be a string");
 		return NULL;
@@ -722,12 +737,21 @@
 	}
 
 	// Copy any trailing text after the last match.
-	obj_p next_frag = new_string_n_obj(ist,where_ptr,str_len-(where_ptr-src_ptr));
+	next_frag = new_string_n_obj(ist,where_ptr,str_len-(where_ptr-src_ptr));
 	list_append(ist,list_obj,next_frag);
 	
 	return list_obj;
 }
 
+DEF(String, __cDataLen__, NULL) {
+	BIN_CONTENT_CHK(String);
+	return NEW_INT(sizeof(pr_str_t) + pr_strlen(self) + 1);
+}
+
+DEF(String, __objList__, FORM_RPARAM) {
+	return parms[1];
+}
+
 //********************************* STRINGGEN MODULE **************************
 
 MODULE_START(StringGen)
@@ -777,19 +801,19 @@
 	MODULE_ADD_SYM(String, __notIn__QUES);
 	MODULE_ADD_SYM(String, __setItem__);
 	MODULE_ADD_SYM(String, __delItem__);
-	MODULE_ADD_SYM(String, __objList__);
-	MODULE_ADD_SYM(String, __cDataLen__);
 	MODULE_ADD_SYM(String, lower);
 	MODULE_ADD_SYM(String, upper);
 	MODULE_ADD_SYM(String, replace);
 	MODULE_ADD_SYM(String, capitalize);
-	MODULE_ADD_SYM(String, capwords);
-	MODULE_ADD_SYM(String, expandtabs);
-	MODULE_ADD_SYM(String, lstrip);
-	MODULE_ADD_SYM(String, rstrip);
+	MODULE_ADD_SYM(String, capWords);
+	MODULE_ADD_SYM(String, expandTabs);
+	MODULE_ADD_SYM(String, lStrip);
+	MODULE_ADD_SYM(String, rStrip);
 	MODULE_ADD_SYM(String, strip);
 	MODULE_ADD_SYM(String, split);
 	MODULE_ADD_SYM(String, find);
+	MODULE_ADD_SYM(String, __objList__);
+	MODULE_ADD_SYM(String, __cDataLen__);
 
 	MODULE_SUB_INIT(StringGen);
 	MODULE_ADD_SYM(StringGen, next);

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-05-03 17:25:33 UTC (rev 450)
+++ trunk/src/interp.c	2004-05-04 04:08:17 UTC (rev 451)
@@ -1118,6 +1118,7 @@
 					if (! (self = get_attr(ist, func_obj, SYM(__BINDOBJ__))) )
 						self = slf;   IF_EXC_BREAK;
 					pre_call_lock(ist, self, plist);  IF_EXC_BREAK;
+					assert(sizeof(obj_p) == sizeof(clist_item_t));
 					res = ((pr_func*)(func_obj->data.ptr))
 								(ist, self, 
 								(plist ? clist_len(plist) : 0), 

Modified: trunk/src/memory_mgr.c
===================================================================
--- trunk/src/memory_mgr.c	2004-05-03 17:25:33 UTC (rev 450)
+++ trunk/src/memory_mgr.c	2004-05-04 04:08:17 UTC (rev 451)
@@ -109,14 +109,11 @@
 void *mem_mgr_thread(apr_thread_t *handle, void *dummy) {
 	isp ist = get_ist(ACC_SYSTEM);
 	obj_p mm_obj_list = NEW_LIST(100);
-	obj_p mm_obj_act_param[2]; 
+	obj_p mm_obj_act_param[] = {NULL, mm_obj_list}; 
 	int last_obj_del_count = 0, last_obj_count = 0;     
 
 	register_thread(ist, handle);
 
-	mm_obj_act_param[0] = NULL; 
-	mm_obj_act_param[1] = mm_obj_list;
-
 #ifdef DEBUG_THREADS
 	printf("Memory manager thread started\n");
 	SetThreadName("mmgr");

Modified: trunk/src/parser.h
===================================================================
--- trunk/src/parser.h	2004-05-03 17:25:33 UTC (rev 450)
+++ trunk/src/parser.h	2004-05-04 04:08:17 UTC (rev 451)
@@ -91,7 +91,7 @@
 int yyerror (char* s);
 
 typedef struct {
-	isp	ist;
+	isp			ist;
 	int			line;
 	int			column;
 	int			old_column;
@@ -128,38 +128,38 @@
 
 
 clist_p append_import_param(void* param, clist_p list, clist_p iparam);
-clist_p append_label_to_import_path(void* param, clist_p list, char* label);
+clist_p append_label_to_import_path(void* param, clist_p list, obj_p label);
 clist_p append_list(void* param, clist_p list, code_p item);
-clist_p append_list_label(void* param, clist_p list, char* label);
+clist_p append_list_label(void* param, clist_p list, obj_p label);
 clist_p append_list_list(void* param, clist_p list, clist_p item);
 clist_p empty_list(void* param);
-clist_p import_path_as_label_to_import_param(void* param, clist_p list, char* label);
+clist_p import_path_as_label_to_import_param(void* param, clist_p list, obj_p label);
 clist_p import_path_to_import_param(void* param, clist_p list);
-clist_p label_to_forrefs(void* param, char* label1, char* label2);
-clist_p label_to_import_path(void* param, char* label);
+clist_p label_to_forrefs(void* param, obj_p label1, obj_p label2);
+clist_p label_to_import_path(void* param, obj_p label);
 clist_p new_import_param(void* param, clist_p list);
 clist_p new_list(void* param, code_p item);
 clist_p new_list2(void* param, code_p item1, code_p item2);
 clist_p new_list_list(void* param, clist_p params);
-code_p amp_label_to_attrref(void* param, char* label);
+code_p amp_label_to_attrref(void* param, obj_p label);
 code_p append_code(void* param, code_p p1, code_p p3, int size);
 code_p assign_cleanup(void* param, code_p ass_code);
 code_p assign_right(void* param, clist_p right);
-code_p at_label_to_attrref(void* param, char* label);
+code_p at_label_to_attrref(void* param, obj_p label);
 code_p attrref_to_tgtparm(void* param, code_p p1);
 code_p binary(void* param, code_p lparm, int op, code_p rparm);
 code_p body_except_else_to_tryexcept(void* param, code_p body, clist_p except_list, code_p els);
-code_p break_stmt(void* param, char* label);
-code_p caret_label_to_attrref(void* param, char* label);
+code_p break_stmt(void* param, obj_p label);
+code_p caret_label_to_attrref(void* param, obj_p label);
 code_p cond_exc_to_assert(void* param, code_p cond, code_p exc);
-code_p continue_stmt(void* param, char* label);
+code_p continue_stmt(void* param, obj_p label);
 code_p del_ref(void* param, code_p expr);
-code_p ds_label_to_attrref(void* param, char* label);
+code_p ds_label_to_attrref(void* param, obj_p label);
 code_p ds_to_obj(void* param);
 code_p exceptall(void* param);
 code_p exec_expr(void* param, code_p expr);
 code_p expr_andor_expr(void* param, code_p lparm, code_p rparm, int andor_flg);
-code_p expr_label_body_to_except(void* param, code_p expr, char* label, code_p body);
+code_p expr_label_body_to_except(void* param, code_p expr, obj_p label, code_p body);
 code_p expr_to_param(void* param, code_p expr);
 code_p expr_to_slice(void* param, code_p expr);
 code_p expr_to_sparm(void* param, code_p p1);
@@ -170,16 +170,16 @@
 code_p if_expr_body_elif_else(void* param, clist_p ifex_list, code_p body, clist_p elif, code_p els);
 code_p import_params(void* param, clist_p iparms);
 code_p int_to_obj(void* param, i64_t num);
-code_p label_eq_expr_to_formparm(void* param, char* label, code_p expr);
-code_p label_eq_expr_to_param(void* param, char* label, code_p expr);
-code_p label_to_attrref(void* param, char* label);
-code_p label_to_formparm(void* param, char* label);
+code_p label_eq_expr_to_formparm(void* param, obj_p label, code_p expr);
+code_p label_eq_expr_to_param(void* param, obj_p label, code_p expr);
+code_p label_to_attrref(void* param, obj_p label);
+code_p label_to_formparm(void* param, obj_p label);
 code_p lbl_proto_body_to_obj(void* param, code_p label, clist_p protos, code_p body);
 code_p new_dict(void* param, clist_p lst);
 code_p new_tuple_list(void* param, clist_p lst, int tuple_flag);
 code_p none(void* param);
 code_p obj_func_params(void* param, code_p obj, clist_p parms);
-code_p obj_label_to_attrref(void* param, code_p obj, char* label);
+code_p obj_label_to_attrref(void* param, code_p obj, obj_p label);
 code_p op_expr(int op, code_p expr, int size);
 code_p print_arglist(void* param, clist_p list);
 code_p raise_expr(void* param, code_p expr);
@@ -188,20 +188,20 @@
 code_p return_expr(void* param, code_p expr);
 code_p self_func_params(void* param, code_p attr_ref, clist_p parms);
 code_p unbound_func_params(void* param, code_p attr_ref, clist_p parms);
-code_p obj_ds_label_func_params(void* param, code_p attr_ref, char* label, clist_p parms);
+code_p obj_ds_label_func_params(void* param, code_p attr_ref, obj_p label, clist_p parms);
 code_p sparms_to_slice(void* param, code_p p1, code_p p2, code_p p3, int parm_cnt);
 code_p stack_check(void* param, code_p stmt);
-code_p star_ref_to_formparm(void* param, char* label);
+code_p star_ref_to_formparm(void* param, obj_p label);
 code_p star_seq_to_param(void* param, code_p expr);
 code_p star_star_dict_to_param(void* param, code_p expr);
-code_p star_star_ref_to_formparm(void* param, char* label);
-code_p string_to_obj(void* param, char* str, int long_flag);
+code_p star_star_ref_to_formparm(void* param, obj_p label);
+code_p string_to_obj(void* param, obj_p str, int long_flag);
 code_p tgt_eq_expr_to_stmt(void* param, clist_p left, clist_p right);
 code_p tgt_eq_stmt_to_stmt(void* param, clist_p left, code_p right);
 code_p tgtparm_to_obj(void* param, code_p expr);
 code_p tryfinally_body(void* param, code_p body, code_p final);
 code_p unary(void* param, int op, code_p parm);
-code_p while_expr_body_else(void* param, char* label, code_p expr, code_p body, code_p els);
+code_p while_expr_body_else(void* param, obj_p label, code_p expr, code_p body, code_p els);
 code_p word_expr_to_param(void* param, obj_p word, code_p expr);
 code_p yield_expr(void* param, code_p expr);
 void calc_code(code *p, int *len, int *stack_depth, int *max_stack_depth);

Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c	2004-05-03 17:25:33 UTC (rev 450)
+++ trunk/src/parser_routines.c	2004-05-04 04:08:17 UTC (rev 451)
@@ -245,7 +245,7 @@
 clist_p append_list_list(void* param, clist_p list, clist_p item){
 	return clist_append(list, item);
 }
-clist_p append_list_label(void* param, clist_p list, char* label){
+clist_p append_list_label(void* param, clist_p list, obj_p label){
 	return clist_append(list, label);
 }
 void calc_code(code *p, int *len, int *stack_depth, int *max_stack_depth){
@@ -277,17 +277,17 @@
 	}
 	return debug_retrn(__LINE__, p1);
 }
-clist_p label_to_import_path(void* param, char* label){
-	return new_clist_1(sym(IST, label));
+clist_p label_to_import_path(void* param, obj_p label){
+	return new_clist_1(sym(IST, pr_strptr(label)));
 }
-clist_p append_label_to_import_path(void* param, clist_p list, char* label){
-	return clist_append(list, sym(IST, label));
+clist_p append_label_to_import_path(void* param, clist_p list, obj_p label){
+	return clist_append(list, sym(IST, pr_strptr(label)));
 }
 clist_p import_path_to_import_param(void* param, clist_p list){
 	return ins_clist(new_clist_1(list), NULL, 1);	
 }
-clist_p import_path_as_label_to_import_param(void* param, clist_p list, char* label){
-	return ins_clist(new_clist_1(list), sym(IST, label), 1);	
+clist_p import_path_as_label_to_import_param(void* param, clist_p list, obj_p label){
+	return ins_clist(new_clist_1(list), sym(IST, pr_strptr(label)), 1);	
 }
 clist_p new_import_param(void* param, clist_p list){
 	return new_clist_1(list);
@@ -350,45 +350,45 @@
 	p->code_data[k++].bytecode.opcode = OP_POP;
 	return debug_retrn(__LINE__, p);
 }
-code_p label_to_attrref(void* param, char* label){
+code_p label_to_attrref(void* param, obj_p label){
 	code_p p;
-	if (*label >= 'A' && *label <= 'Z')
+	if (*(pr_strptr(label)) >= 'A' && *(pr_strptr(label)) <= 'Z')
 		p = new_code(param, 2, 2, 2, OP_PUSH_GLOBAL_REF);
 	else
 		p = new_code(param, 2, 2, 2, OP_PUSH_LOCAL_REF);
-	p->code_data[1].data = sym(IST, label);
+	p->code_data[1].data = sym(IST, (pr_strptr(label)));
 	return debug_retrn(__LINE__, p);
 }
-code_p ds_label_to_attrref(void* param, char* label){
+code_p ds_label_to_attrref(void* param, obj_p label){
 	code_p p;
 	p = new_code(param, 2, 2, 2, OP_PUSH_SELF_REF);
-	p->code_data[1].data = sym(IST, label);
+	p->code_data[1].data = sym(IST, pr_strptr(label));
 	return debug_retrn(__LINE__, p);
 }
-code_p caret_label_to_attrref(void* param, char* label){
+code_p caret_label_to_attrref(void* param, obj_p label){
 	code_p p;
 	p = new_code(param, 2, 2, 2, OP_PUSH_SUPER_REF);
-	p->code_data[1].data = sym(IST, label);
+	p->code_data[1].data = sym(IST, pr_strptr(label));
 	return debug_retrn(__LINE__, p);
 }
-code_p amp_label_to_attrref(void* param, char* label){
+code_p amp_label_to_attrref(void* param, obj_p label){
 	code_p p;
 	p = new_code(param, 2, 2, 2, OP_PUSH_SYN_REF);
-	p->code_data[1].data = sym(IST, label);
+	p->code_data[1].data = sym(IST, pr_strptr(label));
 	return debug_retrn(__LINE__, p);
 }
-code_p at_label_to_attrref(void* param, char* label){
+code_p at_label_to_attrref(void* param, obj_p label){
 	code_p p;
 	p = new_code(param, 2, 2, 2, OP_PUSH_DYN_REF);
-	p->code_data[1].data = sym(IST, label);
+	p->code_data[1].data = sym(IST, pr_strptr(label));
 	return debug_retrn(__LINE__, p);
 }
-code_p obj_label_to_attrref(void* param, code_p obj, char* label){
+code_p obj_label_to_attrref(void* param, code_p obj, obj_p label){
 	obj->len += 2;
 	obj = pr_realloc(obj, sizeof(code)+(obj->len)*sizeof(code_t));
 	obj->code_data[obj->len-2].bytecode.opcode = OP_PUSH;
 	obj->code_data[obj->len-2].bytecode.param = 2;
-	obj->code_data[obj->len-1].data = sym(IST, label);
+	obj->code_data[obj->len-1].data = sym(IST, pr_strptr(label));
 	obj->stack_depth += 1;
 	obj->max_stack_depth = max(obj->max_stack_depth, obj->stack_depth);
 	return debug_retrn(__LINE__, obj);
@@ -454,7 +454,7 @@
 	assert(k==res->len);
 	return debug_retrn(__LINE__, res);
 }
-code_p obj_ds_label_func_params(void* param, code_p obj, char* label,  clist_p parms) {
+code_p obj_ds_label_func_params(void* param, code_p obj, obj_p label,  clist_p parms) {
 	code_p res;
 	int i, k=0;
 	int len = obj->len+2;
@@ -467,7 +467,7 @@
 	add_code(obj, res, &k);
 	res->code_data[k  ].bytecode.opcode = OP_PUSH;
 	res->code_data[k++].bytecode.param = 2;
-	res->code_data[k++].data = sym(IST, label);
+	res->code_data[k++].data = sym(IST, pr_strptr(label));
 	for(i=0; i < llen; i++)
 		add_code(clist_item(parms,i), res, &k);
 	res->code_data[k  ].bytecode.opcode = OP_SUPERCALL;
@@ -476,14 +476,14 @@
 	assert(k==res->len);
 	return debug_retrn(__LINE__, res);
 }
-code_p label_to_formparm(void* param, char* label){
+code_p label_to_formparm(void* param, obj_p label){
 	code_p res = new_code(param, 3, 2, 2, OP_PUSH);
 	res->code_data[0].bytecode.param = 3;
-	res->code_data[1].data = sym(IST, label);
+	res->code_data[1].data = sym(IST, pr_strptr(label));
 	res->code_data[2].data = PARAM_NORMAL;
 	return debug_retrn(__LINE__, res);
 }
-code_p label_eq_expr_to_formparm(void* param, char* label, code_p expr){
+code_p label_eq_expr_to_formparm(void* param, obj_p label, code_p expr){
 	expr->len += 2;
 	expr->stack_depth++;
 	expr->max_stack_depth++;
@@ -491,7 +491,7 @@
 	memmove(expr->code_data+2, expr->code_data, ((expr->len)-2)*sizeof(code_t));
 	expr->code_data[0].bytecode.opcode = OP_PUSH;
 	expr->code_data[0].bytecode.param  = 2;
-	expr->code_data[1].data = sym(IST, label);
+	expr->code_data[1].data = sym(IST, pr_strptr(label));
 	return debug_retrn(__LINE__, expr);
 }
 code_p lbl_proto_body_to_obj(void* param, code_p ref, clist_p protos, code_p body) {
@@ -518,18 +518,18 @@
 	res->stack_depth -= (llen+1)*2-1;
 	return res;
 }
-code_p star_ref_to_formparm(void* param, char* label){
+code_p star_ref_to_formparm(void* param, obj_p label){
 	code_p res = new_code(param, 3, 2, 2, OP_PUSH);
 	res->code_data[0].bytecode.param = 3;
 	res->code_data[1].data = PARAM_STAR;
-	res->code_data[2].data = sym(IST, label);
+	res->code_data[2].data = sym(IST, pr_strptr(label));
 	return debug_retrn(__LINE__, res);
 }
-code_p star_star_ref_to_formparm(void* param, char* label){
+code_p star_star_ref_to_formparm(void* param, obj_p label){
 	code_p res = new_code(param, 3, 2, 2, OP_PUSH);
 	res->code_data[0].bytecode.param = 3;
 	res->code_data[1].data = PARAM_STAR_STAR;
-	res->code_data[2].data = sym(IST, label);
+	res->code_data[2].data = sym(IST, pr_strptr(label));
 	return debug_retrn(__LINE__, res);
 }
 code_p expr_to_sparm(void* param, code_p p1){
@@ -741,24 +741,24 @@
 	return debug_retrn(__LINE__, res);
 }
 
-code_p break_stmt(void* param, char* label){
+code_p break_stmt(void* param, obj_p label){
 	code_p res = new_code(param, 2, 0, 0, OP_BREAK);
-	res->code_data[1].pstr = label;
+	res->code_data[1].pstr = pr_strptr(label);
 	return debug_retrn(__LINE__, res);
 }
-code_p continue_stmt(void* param, char* label){
+code_p continue_stmt(void* param, obj_p label){
 	code_p res = new_code(param, 2, 0, 0, OP_CONTINUE);
-	res->code_data[1].pstr = label;
+	res->code_data[1].pstr = pr_strptr(label);
 	return debug_retrn(__LINE__, res);
 }
-void patch_break_continues(char* label, code_p body){
+void patch_break_continues(obj_p label, code_p body){
 	int p=0;
 	while(p < body->len){
 		int opcode = body->code_data[p].bytecode.opcode;
 		int param  = body->code_data[p].bytecode.param;
 		char* pstr = body->code_data[p+1].pstr;
 		if ( (opcode == OP_BREAK || opcode == OP_CONTINUE) &&
-			 (!strcmp(pstr, "~") || !strcmp(pstr, label)) ){
+			 (!strcmp(pstr, "~") || !strcmp(pstr, pr_strptr(label))) ){
 			body->code_data[p].bytecode.opcode = OP_BR;
 			body->code_data[p].bytecode.param  = (body->len - p) +
 									(opcode == OP_CONTINUE ?  0 : 1);
@@ -774,7 +774,7 @@
 			p++;
 	}
 }
-clist_p label_to_forrefs(void* param, char* label1, char* label2){
+clist_p label_to_forrefs(void* param, obj_p label1, obj_p label2){
 	return new_clist_2(label1, label2);
 }
 
@@ -894,12 +894,12 @@
 	end_loc  = clist_pop_num(loc_list);
 
 	for (i=1; i < llen; i++){
-		char* s = (char*)clist_item(forlst,i);
-		if ( !(*s >= 'a' && *s <= 'z') && ! *s == '_'){
-			printf("For variable not local: %s\n",s);
+		obj_p s = clist_item(forlst,i);
+		if ( !(*(pr_strptr(s)) >= 'a' && *(pr_strptr(s)) <= 'z') && ! *(pr_strptr(s)) == '_'){
+			printf("For variable not local: %s\n", pr_strptr(s));
 			pr_exit(1);
 		}
-		clist_item(forlst,i) = sym(IST, clist_item(forlst,i));
+		clist_item(forlst,i) = sym(IST, pr_strptr(s));
 	}
 	add_code(expr, res, k);
 	res->code_data[*k    ].bytecode.opcode = OP_PUSH;
@@ -982,12 +982,12 @@
 	code_p expr = clist_item(targets, llen);
 	patch_break_continues(clist_item(targets,0), body);
 	for (i=1; i < llen; i++){
-		char* s = (char*)clist_item(targets,i);
-		if ( !(*s >= 'a' && *s <= 'z') && ! *s == '_'){
-			printf("For variable not local: %s\n",s);
+		obj_p s = clist_item(targets,i);
+		if ( !(*(pr_strptr(s)) >= 'a' && *(pr_strptr(s)) <= 'z') && ! *(pr_strptr(s)) == '_'){
+			printf("For variable not local: %s\n", (pr_strptr(s)));
 			pr_exit(1);
 		}
-		clist_item(targets,i) = sym(IST, clist_item(targets,i));
+		clist_item(targets,i) = sym(IST, (pr_strptr(s)));
 	}
 	calc_code(expr, &len, &stack_depth, &max_stack_depth); 
 	len += 4;			
@@ -1117,7 +1117,7 @@
 	res->stack_depth -= 7;
 	return debug_retrn(__LINE__, res);
 }
-code_p while_expr_body_else(void* param, char* label, code_p expr, code_p body, code_p els){
+code_p while_expr_body_else(void* param, obj_p label, code_p expr, code_p body, code_p els){
 	code *res;
 	int k=0, len=0, stack_depth=0, max_stack_depth = 3;
 	int loop_loc, body_loc, els_loc, end_loc;
@@ -1341,8 +1341,8 @@
 code_p expr_to_param(void* param, code_p expr){
 	return debug_retrn(__LINE__, word_expr_to_param(param, PARAM_NORMAL, expr));
 }
-code_p label_eq_expr_to_param(void* param, char* label, code_p expr){
-	return debug_retrn(__LINE__, word_expr_to_param(param, sym(IST, label), expr));
+code_p label_eq_expr_to_param(void* param, obj_p label, code_p expr){
+	return debug_retrn(__LINE__, word_expr_to_param(param, sym(IST, pr_strptr(label)), expr));
 }
 code_p star_seq_to_param(void* param, code_p expr){
 	return debug_retrn(__LINE__, word_expr_to_param(param, PARAM_STAR, expr));
@@ -1354,6 +1354,7 @@
 	code_p res;
 	obj_p obj = new_object(IST, OBJ(INT_PROTO));
 	obj->data_type = DATA_TYPE_IMMDATA;
+	obj->imm_data_len = 8;
 	obj->data.i64 = num;
 	res = new_code(param, 2, 1, 1, OP_PUSH);
 	res->code_data[0].bytecode.param = 2;
@@ -1372,21 +1373,21 @@
 	add_to_const_list(param, obj);
 	return debug_retrn(__LINE__, res);	
 }
-code_p string_to_obj(void* param, char* str, int long_flag){
+code_p string_to_obj(void* param, obj_p str, int long_flag){
 	code_p p = new_code(param, 2, 1, 1, OP_PUSH);
 	pr_str_p obj_str;
-	size_t len = strlen(str);
+	size_t len = pr_strlen(str);
 	obj_p proto = (long_flag == NEW_LONG? OBJ(LONG_PROTO) : OBJ(STRING_PROTO));
 	obj_p obj = new_object(IST, proto);
 	if (len < IMMEDIATE_DATA_LEN) {
 		obj->data_type    = DATA_TYPE_IMMDATA;
 		obj->imm_data_len = (int) len;
-		memcpy(obj->data.str, str, len);
+		memcpy(obj->data.str, pr_strptr(str), len);
 		obj->data.str[len] = 0;
 	} else {
 		obj_str = obj_malloc(IST, proto, obj, sizeof(pr_str_t)+len+1);
 		obj_str->len = len;
-		memcpy(&(obj_str->str[0]), str, len);
+		memcpy(&(obj_str->str[0]), pr_strptr(str), len);
 		obj_str->str[len] = 0;
 	}
 	obj->immutable = TRUE;
@@ -1449,7 +1450,7 @@
 	res->code_data[1].data = OBJ(EXCEPTION);
 	return debug_retrn(__LINE__, res);
 }
-code_p expr_label_body_to_except(void* param, code_p expr, char* label, code_p body){
+code_p expr_label_body_to_except(void* param, code_p expr, obj_p label, code_p body){
 	code *res;
 	int k=0, len=3, stack_depth=1, max_stack_depth = 1;
 	calc_code(expr, &len, &stack_depth, &max_stack_depth);
@@ -1457,8 +1458,8 @@
 	add_code(expr, res, &k);
 	res->code_data[k  ].bytecode.opcode = OP_PUSH;
 	res->code_data[k++].bytecode.param  = 2;
-	if (label)
-		res->code_data[k++].data = sym(IST, label);
+	if (pr_strptr(label))
+		res->code_data[k++].data = sym(IST, pr_strptr(label));
 	else
 		res->code_data[k++].data = OBJ(NONE);
 	res->code_data[k  ].bytecode.opcode = OP_EXCEPT;

Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y	2004-05-03 17:25:33 UTC (rev 450)
+++ trunk/src/prothon.y	2004-05-04 04:08:17 UTC (rev 451)
@@ -75,6 +75,8 @@
 
 #define state ((parse_state*) yylex_param)
 
+#define TD new_string_obj(state->ist, "~")
+
 %}
 
 /* BISON Declarations */
@@ -84,7 +86,7 @@
 %union {
 	u64_t		int_type;
 	double		float_type;
-	char*		str_type;
+	obj_p		str_type;
 	code_p		code_type;
 	clist_p		list_type;
 }
@@ -197,11 +199,11 @@
 %nonassoc <str_type>	STRING			/*  python strs & \b[xX]['"][0-9a-fA-F]+['"]	*/
 %nonassoc <str_type>	LABEL			/*  \b\w+\b										*/
 
-%type <list_type>	import_path import_param import_params target
+%type <list_type> import_path import_param import_params target
 			target_params function_params brace_params
 			brace_params2 brace_param mul_except ass_expr_list
 			formal_params elif mul_elif list_params
-			list_params2 for_refs for_refs1 for_refs2 arg_list
+			list_params2 arg_list for_refs for_refs1 for_refs2
 			arg_list2 tuple_params tuple_params2 for_lc_clause
 			lc_clauses if_lc_clause protos proto_refs
 
@@ -281,7 +283,7 @@
 	;
 while_statement: 
 		WHILE expr compound_body else
-		{ $$ = while_expr_body_else(yylex_param, "~", $2, $3, $4); }
+		{ $$ = while_expr_body_else(yylex_param, TD, $2, $3, $4); }
 	|	LABEL ':' WHILE expr compound_body
 		{ $$ = while_expr_body_else(yylex_param, $1, $4, $5, NULL); }
 	;
@@ -307,21 +309,21 @@
 	|	for_refs2 ')'
 	;
 for_refs1:
-		FOR LABEL													{ $$ = label_to_forrefs(yylex_param, "~", $2); }
+		FOR LABEL													{ $$ = label_to_forrefs(yylex_param, TD, $2); }
 	|	LABEL ':' FOR LABEL											{ $$ = label_to_forrefs(yylex_param, $1, $4); }
 	|	for_refs1 ',' LABEL											{ $$ = append_list_label(yylex_param, $1, $3); }
 	;																
 for_refs2:
-		FOR '(' LABEL												{ $$ = label_to_forrefs(yylex_param, "~", $3); }
+		FOR '(' LABEL												{ $$ = label_to_forrefs(yylex_param, TD, $3); }
 	|	LABEL ':' FOR '(' LABEL										{ $$ = label_to_forrefs(yylex_param, $1, $5); }
 	|	for_refs2 ',' LABEL											{ $$ = append_list_label(yylex_param, $1, $3); }
 	;	
 break_statement: 
-		BREAK 														{ $$ = break_stmt(yylex_param, "~"); }
+		BREAK 														{ $$ = break_stmt(yylex_param, TD); }
 	|	BREAK LABEL													{ $$ = break_stmt(yylex_param, $2); }
 	;
 continue_statement: 
-		CONTINUE   													{ $$ = continue_stmt(yylex_param, "~"); }
+		CONTINUE   													{ $$ = continue_stmt(yylex_param, TD); }
 	|	CONTINUE LABEL 												{ $$ = continue_stmt(yylex_param, $2); }
 	;
 del_statement:
@@ -862,7 +864,7 @@
 	if (c == 'r' || c == 'R' || c == 'x' || c == 'X' || c == '\'' || c == '\"') {
 		int r_flag=0, x_flag=0, triple_flag=0, q_char=c;
 		int str_index=0, cur_size=INITIAL_STRING_ALLOC;
-		char string[INITIAL_STRING_ALLOC], *str_ptr=string;
+		char* str_ptr = pr_malloc(cur_size);
 		if (c == 'r' || c == 'R') {
 			if ((q_char=getch(state)) == '\'' || q_char == '\"' )
 				r_flag = 1;
@@ -991,12 +993,8 @@
 			add_string(c, &str_ptr, &str_index, &cur_size);
 		}
 		str_ptr[str_index++]=0;		
-		if (str_ptr == string) {
-			str_ptr = pr_malloc(str_index);
-			strcpy(str_ptr, string);
-		} else
-			str_ptr = pr_realloc(str_ptr, str_index);
-		lvalp->str_type = str_ptr;
+		str_ptr = pr_realloc(str_ptr, str_index);
+		lvalp->str_type = new_string_n_obj((((parse_state*) yylex_param)->ist), str_ptr, str_index-1); 
 		return STRING;
 	}
 	goto not_quote;
@@ -1109,7 +1107,7 @@
 	/* process LABEL or english keyword*/
 	if (c == '_' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')  ) {
 		int str_index=0, cur_size=INITIAL_STRING_ALLOC;
-		char string[INITIAL_STRING_ALLOC], *str_ptr=string;
+		char* str_ptr = pr_malloc(cur_size);
 		add_string(c, &str_ptr, &str_index, &cur_size);
 		while ((c=getch(state)) == '_' || c == '!' || c == '?' || 
 			    (c >= '0' && c <= '9')  || 
@@ -1152,12 +1150,8 @@
 		if (!strcmp(str_ptr,"with")) 	return WITH;
 		if (!strcmp(str_ptr,"yield")) 	return YIELD;
 
-		if (str_ptr == string) {
-			str_ptr = pr_malloc(str_index);
-			strcpy(str_ptr, string);
-		} else
-			str_ptr = pr_realloc(str_ptr, str_index);
-		lvalp->str_type = str_ptr;
+		str_ptr = pr_realloc(str_ptr, str_index);
+		lvalp->str_type = new_string_n_obj((((parse_state*) yylex_param)->ist), str_ptr, str_index-1); 
 		return LABEL;
 	}
 	/* process dot, int, or float */
@@ -1165,7 +1159,7 @@
 		int imag_flag=0, long_flag=0, nonzero_flag=0, past_e_flag=0;
 		int hex_flag=0, int_dot_flag=0;
 		int str_index=0, cur_size=INITIAL_STRING_ALLOC;
-		char string[INITIAL_STRING_ALLOC], *str_ptr=string;
+		char* str_ptr = pr_malloc(cur_size);
 		
 		add_string(c, &str_ptr, &str_index, &cur_size);
 		if (c == '.') {
@@ -1211,12 +1205,8 @@
 					ungetch(c, state);
 				str_ptr[str_index++]=0;
 				if (long_flag){
-					if (str_ptr == string) {
-						str_ptr = pr_malloc(str_index);
-						strcpy(str_ptr, string);
-					} else
-						str_ptr = pr_realloc(str_ptr, str_index);
-					lvalp->str_type = str_ptr;
+					str_ptr = pr_realloc(str_ptr, str_index);
+					lvalp->str_type = new_string_n_obj((((parse_state*) yylex_param)->ist), str_ptr, str_index-1); 
 					return LONG_;
 				}
 				if (str_ptr[0] == '0') {

Modified: trunk/src/src.vcproj
===================================================================
--- trunk/src/src.vcproj	2004-05-03 17:25:33 UTC (rev 450)
+++ trunk/src/src.vcproj	2004-05-04 04:08:17 UTC (rev 451)
@@ -19,7 +19,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include"
+				AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\apr\apr-util\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -33,10 +33,10 @@
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="apr.lib wsock32.lib"
+				AdditionalDependencies="apr.lib aprutil.lib wsock32.lib"
 				OutputFile="$(OutDir)/prothon.exe"
 				LinkIncremental="2"
-				AdditionalLibraryDirectories="C:\prothon\apr\apr\LibD"
+				AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR;C:\prothon\apr\apr-util\LibR"
 				IgnoreAllDefaultLibraries="FALSE"
 				IgnoreDefaultLibraryNames="LIBCMTD.lib"
 				GenerateDebugInformation="TRUE"
@@ -75,7 +75,7 @@
 				Optimization="2"
 				InlineFunctionExpansion="1"
 				OmitFramePointers="TRUE"
-				AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include"
+				AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\apr\apr-util\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
 				StringPooling="TRUE"
 				ExceptionHandling="FALSE"
@@ -92,10 +92,10 @@
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="apr.lib wsock32.lib"
+				AdditionalDependencies="apr.lib aprutil.lib wsock32.lib"
 				OutputFile="$(OutDir)/prothon.exe"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR"
+				AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR;C:\prothon\apr\apr-util\LibR"
 				IgnoreDefaultLibraryNames="LIBCMTD.lib"
 				GenerateDebugInformation="TRUE"
 				SubSystem="1"
@@ -247,15 +247,9 @@
 			Name="Resource Files"
 			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
 			<File
-				RelativePath="..\pr\bin.pr">
-			</File>
-			<File
 				RelativePath="init.pth">
 			</File>
 			<File
-				RelativePath="..\pr\prosist.pr">
-			</File>
-			<File
 				RelativePath="prothon.y">
 			</File>
 			<File