rev 452 - in trunk: pr src

SVN User <[email protected]> Tue, 04 May 2004 01:05:22 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-05-04 01:05:19 -0400 (Tue, 04 May 2004)
New Revision: 452

Modified:
   trunk/pr/test.pr
   trunk/src/parser_routines.c
   trunk/src/prothon.y
Log:
added object x: form (no parens)

Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr	2004-05-04 04:08:17 UTC (rev 451)
+++ trunk/pr/test.pr	2004-05-04 05:05:19 UTC (rev 452)
@@ -1,109 +1,7 @@
 #!/usr/bin/env prothon
 
-# 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
+object obj:
+	$x = 3
 	
-if "abCDefG".lower() != "abcdefg":
-	print "lower() failed!"
-	failures = failures+1
-
-if "abCDefG345%^&".lower() != "abcdefg345%^&":
-	print "lower() failed!"
-	failures = failures+1
-
-if "abCDefG".upper() != "ABCDEFG":
-	print "upper() failed!"
-	failures = failures+1
-
-if "+_098abCDefG".upper() != "+_098ABCDEFG":
-	print "upper() failed!"
-	failures = failures+1
-
-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)
+print obj.x

Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c	2004-05-04 04:08:17 UTC (rev 451)
+++ trunk/src/parser_routines.c	2004-05-04 05:05:19 UTC (rev 452)
@@ -497,8 +497,10 @@
 code_p lbl_proto_body_to_obj(void* param, code_p ref, clist_p protos, code_p body) {
 	obj_p func;
 	code_p res;
-	int code_len, llen = clist_len(protos);
+	int code_len, llen = 0;
 	int i, k=0, len=0, stack_depth=0, max_stack_depth=0;
+	if (protos)
+		llen = clist_len(protos);
 	calc_code(ref, &len, &stack_depth, &max_stack_depth);
 	for (i=0; i < llen; i++)
 		calc_code(clist_item(protos, i),&len, &stack_depth, &max_stack_depth);

Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y	2004-05-04 04:08:17 UTC (rev 451)
+++ trunk/src/prothon.y	2004-05-04 05:05:19 UTC (rev 452)
@@ -375,7 +375,8 @@
 		WITH obj compound_body										{ $$ = ref_parm_body_to_def(yylex_param, NULL, NULL, $2, $3, WTH_FLG); }						
 	;
 obj_statement:	
-		obj_ref '('  protos ')' compound_body						{ $$ = lbl_proto_body_to_obj(yylex_param, $1, $3, $5); }
+		obj_ref  compound_body										{ $$ = lbl_proto_body_to_obj(yylex_param, $1, NULL, $2); }
+	|	obj_ref '('  protos ')' compound_body						{ $$ = lbl_proto_body_to_obj(yylex_param, $1, $3, $5); }
 	;
 obj_ref:
 		OBJ_ LABEL													{ $$ = label_to_attrref(yylex_param, $2);		state->defdoc_flag=1; }