# New Ticket Created by Stephane Payrard # Please include the string: [perl #31953] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=31953 >
This patch supports the declaration of multiple identifiers in a single .sym / .local directive Probably useless for code generated by compilers. Invaluable for hand-writen code and documentation. Patch attached Files affected: ./imcc/t/syn/pcc.t ./imcc/imcc.y ./imcc/docs/syntax.pod ./imcc/parser.h -- stef
--- ./imcc/t/syn/pcc.t.old 2004-03-30 16:50:00.000000000 +0200 +++ ./imcc/t/syn/pcc.t 2004-10-12 16:00:52.492675296 +0200 @@ -1,6 +1,6 @@ #!perl use strict; -use TestCompiler tests => 36; +use TestCompiler tests => 37; ############################## # Parrot Calling Conventions @@ -1394,3 +1394,14 @@ P 0 OUT +output_is(<<'CODE', "mongueur\nmonger\n", "multiple declaration in a .sym/.local directive"); +.sub main +.sym string s, t + s = "mongueur\n" + t = "monger\n" + print s + print t + end +.end +CODE + --- ./imcc/imcc.y.old 2004-10-12 11:00:06.000000000 +0200 +++ ./imcc/imcc.y 2004-10-12 15:36:17.572897184 +0200 @@ -247,6 +247,7 @@ %} %union { + IdList * idlist; int t; char * s; SymReg * sr; @@ -305,6 +306,7 @@ %token <sr> VAR %token <t> LINECOMMENT %token <s> FILECOMMENT +%type <idlist> id_list %nonassoc CONCAT DOT %nonassoc <t> POINTY @@ -738,12 +740,40 @@ { $$ = $2; } ; +id_list : IDENTIFIER + { + IdList* l = malloc(sizeof(IdList)); + l->next = NULL; + l->id = $1; + $$ = l; + } + + | id_list COMMA IDENTIFIER + { IdList* l = malloc(sizeof(IdList)); + l->id = $3; + l->next = $1; + $$ = l; + } + ; + labeled_inst: assignment | if_statement | NAMESPACE IDENTIFIER { push_namespace($2); } | ENDNAMESPACE IDENTIFIER { pop_namespace($2); } - | LOCAL { is_def=1; } type IDENTIFIER { mk_ident($4, $3); is_def=0; } + | LOCAL { is_def=1; } type id_list + { + IdList* l = $4; + while(l) { + IdList* l1; + mk_ident(l->id, $3); + l1 = l; + l = l->next; + free(l1); + } + is_def=0; $$=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 --- ./imcc/docs/syntax.pod.old 2003-10-23 19:02:54.000000000 +0200 +++ ./imcc/docs/syntax.pod 2004-10-12 16:04:33.111136192 +0200 @@ -113,7 +113,9 @@ =item .sym <type> <identifier> Define a local name B<identifier> for this I<compilation unit> and of -the given B<type>. +the given B<type>. You can define multiple identifiers of the same type by separating +them with commas: + .sym int i, j =item .const <type> <identifier> = <const> --- ./imcc/parser.h.old 2004-04-23 11:20:31.000000000 +0200 +++ ./imcc/parser.h 2004-10-12 15:26:35.116444024 +0200 @@ -7,8 +7,13 @@ #define EXTERN extern #endif -#include "imcparser.h" +typedef struct _IdList { + char* id; + struct _IdList* next; +} IdList; + +#include "imcparser.h" EXTERN int expect_pasm; EXTERN int pasm_file;