Is Perl 6 an undisclosed other special case for instruction separation?

In the doc syntax :

The closing curly brace followed by a newline means the delimiter of the statements, so you do not need to write a semicolon after the block of the if statement.

if True { say "Hello"; } say "world"; 

This is good and what happens to Why is this feed version of Perl 6 statement a "dummy expression"? .

However, how does this rule work for uncuddled else ? Is this a special case?

 if True { say "Hello"; } else { say "Something else"; } say "world"; 

Or, what about with-orwith example :

 my $s = "abc"; with $s.index("a") { say "Found a at $_" } orwith $s.index("b") { say "Found b at $_" } orwith $s.index("c") { say "Found c at $_" } else { say "Didn't find a, b or c" } 
+8
perl6
source share
1 answer

Looking at the if grammar in nqp and Rakudo , it seems that the if/elsif/else block of the blocks is parsed together as one control statement.

Rule for if in nqp

 rule statement_control:sym<if> { <sym>\s <xblock> [ 'elsif'\s <xblock> ]* [ 'else'\s <else=.pblock> ]? } 

( https://github.com/perl6/nqp/blob/master/src/NQP/Grammar.nqp#L243 , accessed 5 August 2017)

Rule for if in Rakudo

 rule statement_control:sym<if> { $<sym>=[if|with]<.kok> {} <xblock(so ~$<sym>[0] ~~ /with/)> [ [ | 'else'\h*'if' <.typed_panic: 'X::Syntax::Malformed::Elsif'> | 'elif' { $/.typed_panic('X::Syntax::Malformed::Elsif', what => "elif") } | $<sym>='elsif' <xblock> | $<sym>='orwith' <xblock(1)> ] ]* {} [ 'else' <else=.pblock(so ~$<sym>[-1] ~~ /with/)> ]? } 

( https://github.com/rakudo/rakudo/blob/nom/src/Perl6/Grammar.nqp#L1450 dated August 5, 2017)

+4
source share

All Articles