Changeset 22576
Legend:
- Unmodified
- Added
- Removed
-
src/perl6/STD.pm
r22575 r22576 984 984 :dba('infix or meta-infix') 985 985 [ 986 | <colonpair> { $<fake> = 1; $<sym> = ':'; %<O><prec> = %loose_unary<prec>; } 986 | <colonpair> { 987 $<fake> = 1; 988 $<sym> = ':'; 989 %<O><prec> = %loose_unary<prec>; 990 %<O><assoc> = 'left'; 991 } 987 992 | <infix> 988 993 [ … … 1180 1185 # <?{ $<sigil> eq '@' | '%' }> 1181 1186 <.unsp>? 1182 [1187 $<shape> = [ 1183 1188 | '(' ~ ')' <signature> 1184 1189 | :dba('shape definition') '[' ~ ']' <semilist> … … 1192 1197 1193 1198 <post_constraint>* 1194 1195 # XXX generalize to any assignment operator?1196 :dba('variable initializer')1197 [1198 | '=' <.ws> <EXPR( ($<SIGIL> // '') eq '$' ?? item %item_assignment !! item %list_prefix )>1199 | '.=' <.ws> <dottyop>1200 ]?1201 1199 } 1202 1200 … … 1204 1202 :dba('scoped declarator') 1205 1203 [ 1206 | <declarator> 1204 | <declarator> { $<SIGIL> = $<declarator><SIGIL> } 1207 1205 | <regex_declarator> 1208 1206 | <package_declarator> 1209 1207 | <fulltypename>+ <multi_declarator> 1210 | <multi_declarator> 1208 | <multi_declarator> { $<SIGIL> = $<multi_declarator><SIGIL> } 1211 1209 # | <?before <[A..Z]> > <name> <.panic("Apparent type name " ~ $<name>.text ~ " is not declared yet")> 1212 1210 ] … … 1214 1212 1215 1213 1216 token scope_declarator:my { <sym> <scoped> }1217 token scope_declarator:our { <sym> <scoped> }1218 token scope_declarator:state { <sym> <scoped> }1219 token scope_declarator:constant { <sym> <scoped> }1220 token scope_declarator:has { <sym> <scoped> }1214 token scope_declarator:my { <sym> <scoped> { $<SIGIL> = $<scoped><SIGIL> } } 1215 token scope_declarator:our { <sym> <scoped> { $<SIGIL> = $<scoped><SIGIL> } } 1216 token scope_declarator:state { <sym> <scoped> { $<SIGIL> = $<scoped><SIGIL> } } 1217 token scope_declarator:constant { <sym> <scoped> { $<SIGIL> = $<scoped><SIGIL> } } 1218 token scope_declarator:has { <sym> <scoped> { $<SIGIL> = $<scoped><SIGIL> } } 1221 1219 1222 1220 … … 1306 1304 token declarator { 1307 1305 [ 1308 | <variable_declarator> 1306 | <variable_declarator> { $<SIGIL> = $<variable_declarator><SIGIL> } 1309 1307 | '(' ~ ')' <signature> <trait>* 1310 1308 | <routine_declarator> … … 1314 1312 } 1315 1313 1316 token multi_declarator:multi { <sym> <.ws> [ <declarator> || <routine_def> ] }1317 token multi_declarator:proto { <sym> <.ws> [ <declarator> || <routine_def> ] }1318 token multi_declarator:only { <sym> <.ws> [ <declarator> || <routine_def> ] }1319 token multi_declarator:null { <declarator> }1314 token multi_declarator:multi { <sym> <.ws> [ <declarator> { $<SIGIL> = $<declarator><SIGIL> } || <routine_def> ] } 1315 token multi_declarator:proto { <sym> <.ws> [ <declarator> { $<SIGIL> = $<declarator><SIGIL> } || <routine_def> ] } 1316 token multi_declarator:only { <sym> <.ws> [ <declarator> { $<SIGIL> = $<declarator><SIGIL> } || <routine_def> ] } 1317 token multi_declarator:null { <declarator> { $<SIGIL> = $<declarator><SIGIL> } } 1320 1318 1321 1319 token routine_declarator:sub { <sym> <routine_def> } -
src/perl6/viv
r22575 r22576 14 14 my $OPT_pos = 0; 15 15 my $OPT_match = 0; 16 my $OPT_log = 0; 16 17 our $ORIG; 17 18 our $POS; 18 my %did_ws;19 my @did_ws; 19 20 20 21 … … 33 34 $output = 'p6'; 34 35 $OPT_pos = 1; 36 } 37 elsif ($switch eq '--log') { 38 $OPT_log = 1; 35 39 } 36 40 elsif ($switch eq '--pos') { … … 196 200 } 197 201 } 198 elsif ($arity eq 'CHAIN') { 202 elsif ($self->{sym} eq 'identifier') { 203 $text .= join('', reverse @zyg); 204 } 205 else { 199 206 $text .= join('', @zyg); 200 }201 else {202 $text .= join('', reverse @zyg);203 207 } 204 208 } … … 213 217 214 218 sub ret { my $self = shift; 215 warn ref $self, " returns ", $_[0], "\n" ;219 warn ref $self, " returns ", $_[0], "\n" if $OPT_log; 216 220 $_[0]; 217 221 } … … 255 259 my $ws = $self->{WS} // 0; 256 260 my $pos = $self->{POS}; 257 if ($ws and not $did_ws {$pos}++) {261 if ($ws and not $did_ws[$pos]++) { 258 262 substr($ORIG, $pos - $ws, $ws) 259 263 } … … 282 286 sub emit_p6 { my $self = shift; 283 287 my $text = $self->SUPER::emit_p6(@_); 284 my $finalws = $$POS[-1]{ws}; 285 $text .= substr($ORIG, $finalws, -1) if $finalws; 288 if (not @did_ws[@$POS-1]) { 289 my $finalws = $$POS[-1]{ws}; 290 $text .= substr($ORIG, $finalws, -1) if $finalws; 291 } 286 292 $self->ret($text); 287 293 } … … 357 363 } 358 364 365 { package VAST::scope_declarator; our @ISA = 'VAST::AddSym'; } 359 366 { package VAST::statement_control; our @ISA = 'VAST::AddSym'; } 360 367 { package VAST::version; our @ISA = 'VAST::AddSym'; } 361 368 369 { package VAST::variable_declarator; our @ISA = 'VAST::Base'; 370 sub emit_p6 { my $self = shift; 371 my $text = $self->get_ws; 372 $text .= ($self->get_zyg('variable'))[0]; 373 $text .= join '', $self->get_zyg('shape'); 374 $text .= join '', $self->get_zyg('trait'); 375 $text .= join '', $self->get_zyg('post_constraint'); 376 $text; 377 } 378 } 379 362 380 if ($0 eq __FILE__) { 363 381 ::MAIN(@ARGV);
