cvsuser 03/12/09 19:02:13
Modified: imcc imcc.y
Log:
Make .const work anywhere. If outside of sub, it is global.
Revision Changes Path
1.114 +8 -3 parrot/imcc/imcc.y
Index: imcc.y
===================================================================
RCS file: /cvs/public/parrot/imcc/imcc.y,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -w -r1.113 -r1.114
--- imcc.y 5 Dec 2003 06:36:04 -0000 1.113
+++ imcc.y 10 Dec 2003 03:02:13 -0000 1.114
@@ -228,7 +228,7 @@
%token <s> PARROT_OP
%type <t> type newsub
%type <i> program class class_body member_decls member_decl field_decl method_decl
-%type <i> global sub emit pcc_sub sub_body pcc_ret pcc_yield
+%type <i> global constdef sub emit pcc_sub sub_body pcc_ret pcc_yield
%type <i> compilation_units compilation_unit
%type <s> classname relop
%type <i> labels _labels label statements statement sub_call
@@ -269,6 +269,7 @@
compilation_unit:
class { $$ = $1; cur_unit = 0; }
+ | constdef { $$ = $1; }
| global { $$ = $1; }
| sub { $$ = $1; imc_close_unit(interp, cur_unit); cur_unit = 0; }
| pcc_sub { $$ = $1; imc_close_unit(interp, cur_unit); cur_unit = 0; }
@@ -290,6 +291,11 @@
}
;
+constdef:
+ CONST { is_def=1; } type IDENTIFIER '=' const
+ { mk_const_ident($4, $3, $6, 1);is_def=0; }
+ ;
+
pasmcode:
pasmline
| pasmcode pasmline
@@ -636,11 +642,10 @@
labeled_inst:
assignment
| if_statement
+ | constdef
| NAMESPACE IDENTIFIER { push_namespace($2); }
| ENDNAMESPACE IDENTIFIER { pop_namespace($2); }
| LOCAL { is_def=1; } type IDENTIFIER { mk_ident($4, $3); is_def=0; }
- | CONST { is_def=1; } type IDENTIFIER '=' const
- { mk_const_ident($4, $3, $6, 0);is_def=0; }
| GLOBAL_CONST { is_def=1; } type IDENTIFIER '=' const
{ mk_const_ident($4, $3, $6, 1);is_def=0; }
| PARAM { is_def=1; } type IDENTIFIER { $$ = MK_I(interp, cur_unit, "restore",