rev 294 - in trunk: . src
SVN User <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-04-06 13:25:19 -0400 (Tue, 06 Apr 2004)
New Revision: 294
Modified:
trunk/STATUS.txt
trunk/src/parser.h
trunk/src/parser_routines.c
trunk/src/prothon.y
Log:
new delegation partway imlemented
Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt 2004-04-06 16:39:57 UTC (rev 293)
+++ trunk/STATUS.txt 2004-04-06 17:25:19 UTC (rev 294)
@@ -43,7 +43,7 @@
Guido's regret list for Python
drop 3-way compare? (but... comparing lists) (what is this MCH?)
use (...) continuation
- drop lambda
+ drop lambda -- DONE
drop map(), filter()
drop reduce()
drop `x`, repr()
Modified: trunk/src/parser.h
===================================================================
--- trunk/src/parser.h 2004-04-06 16:39:57 UTC (rev 293)
+++ trunk/src/parser.h 2004-04-06 17:25:19 UTC (rev 294)
@@ -182,6 +182,7 @@
code* ref_parm_body_to_def(void* param, code* name, clist_p params, code* self, code* body, int flg) ;
code* return_expr(void* param, code* expr);
code* self_func_params(void* param, code* attr_ref, clist_p parms);
+code* unbound_func_params(void* param, code* attr_ref, clist_p parms);
code* sparms_to_slice(void* param, code* p1, code* p2, code* p3, int parm_cnt);
code* stack_check(void* param, code* stmt);
code* star_ref_to_formparm(void* param, char* label);
Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c 2004-04-06 16:39:57 UTC (rev 293)
+++ trunk/src/parser_routines.c 2004-04-06 17:25:19 UTC (rev 294)
@@ -435,6 +435,25 @@
assert(k==res->len);
return debug_retrn(__LINE__, res);
}
+code* unbound_func_params(void* param, code* attr_ref, clist_p parms){
+ code* res;
+ int i, k=0;
+ int len = attr_ref->len;
+ int stack_depth = attr_ref->stack_depth;
+ int max_stack_depth = attr_ref->max_stack_depth;
+ int llen = clist_len(parms);
+ for(i=0; i < llen; i++)
+ calc_code(clist_item(parms,i), &len, &stack_depth, &max_stack_depth);
+ res = new_code(param, len+1, stack_depth, max_stack_depth, 0);
+ add_code_to(attr_ref, res, &k);
+ for(i=0; i < llen; i++)
+ add_code_to(clist_item(parms,i), res, &k);
+ res->code_data[k].bytecode.opcode = OP_CALL;
+ res->code_data[k++].bytecode.param = clist_len(parms);
+ res->stack_depth -= 1+(2*llen);
+ assert(k==res->len);
+ return debug_retrn(__LINE__, res);
+}
code* label_to_formparm(void* param, char* label){
code* res = new_code(param, 3, 2, 2, OP_PUSH);
res->code_data[0].bytecode.param = 3;
Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y 2004-04-06 16:39:57 UTC (rev 293)
+++ trunk/src/prothon.y 2004-04-06 17:25:19 UTC (rev 294)
@@ -203,7 +203,7 @@
import_statement small_statement if_statement while_statement
for_statement gen_ref try_except_statement except else_except
try_finally_statement def_ref print_statement assert_statement
- target_param attr_ref ass_add_statement ass_sub_statement ass_mul_statement
+ target_param attr_ref unbound_ref ass_add_statement ass_sub_statement ass_mul_statement
ass_div_statement ass_tdv_statement ass_rem_statement
ass_band_statement ass_bor_statement ass_bxor_statement
ass_shr_statement ass_shl_statement ass_exp_statement
@@ -301,11 +301,13 @@
del_statement:
del_tgt
| del_statement ',' attr_ref { $$ = append_code(yylex_param, $1, del_ref(yylex_param, $3), 0); }
+ | del_statement ',' unbound_ref { $$ = append_code(yylex_param, $1, del_ref(yylex_param, $3), 0); }
| del_statement ',' obj '[' slice ']' { $$ = append_code(yylex_param, $1, del_ref(yylex_param, append_code(yylex_param, $3, $5, 0)), 0); }
;
del_tgt:
- DEL attr_ref { $$ = del_ref(yylex_param, $2); }
- | DEL obj '[' slice ']' { $$ = del_ref(yylex_param, append_code(yylex_param, $2, $4, 0)); }
+ DEL attr_ref { $$ = del_ref(yylex_param, $2); }
+ | DEL unbound_ref { $$ = del_ref(yylex_param, $2); }
+ | DEL obj '[' slice ']' { $$ = del_ref(yylex_param, append_code(yylex_param, $2, $4, 0)); }
;
exec_statement:
EXEC expr { $$ = exec_expr(yylex_param, $2); }
@@ -515,6 +517,7 @@
| '(' tuple_params ')' { $$ = new_tuple_list(yylex_param, $2, NEW_TUPLE); }
| obj '(' function_params ')' { $$ = obj_func_params(yylex_param, $1, $3); }
| attr_ref '(' function_params ')' { $$ = self_func_params(yylex_param, $1, $3); }
+ | unbound_ref '(' function_params ')' { $$ = unbound_func_params(yylex_param, $1, $3); }
;
target:
target_params
@@ -529,15 +532,18 @@
;
target_param:
attr_ref
+ | unbound_ref
| obj '[' slice ']' { $$ = append_code(yylex_param, $1, $3, 0); }
;
attr_ref:
+ '.' LABEL %prec UDOT { $$ = dot_label_to_attrref(yylex_param, $2); }
+ | '^' LABEL %prec UCARET { $$ = caret_label_to_attrref(yylex_param, $2); }
+ | obj '.' LABEL { $$ = obj_label_to_attrref(yylex_param, $1, $3); }
+ ;
+unbound_ref:
LABEL { $$ = label_to_attrref(yylex_param, $1); }
- | '.' LABEL %prec UDOT { $$ = dot_label_to_attrref(yylex_param, $2); }
- | '^' LABEL %prec UCARET { $$ = caret_label_to_attrref(yylex_param, $2); }
| '&' LABEL %prec UAMP { $$ = amp_label_to_attrref(yylex_param, $2); }
| '@' LABEL { $$ = at_label_to_attrref(yylex_param, $2); }
- | obj '.' LABEL { $$ = obj_label_to_attrref(yylex_param, $1, $3); }
;
arg_list:
/* empty string */ { $$ = empty_list(yylex_param); }