diff --git a/src/Raku/Grammar.nqp b/src/Raku/Grammar.nqp index 383e58585bf..2a10d7f3c9d 100644 --- a/src/Raku/Grammar.nqp +++ b/src/Raku/Grammar.nqp @@ -839,6 +839,10 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common { } + rule statement_control:sym { + <.end_keyword> <.obs("'foreach'", "'for'")> + } + rule statement_control:sym { <.kok> :my $*GOAL := '{'; @@ -1306,6 +1310,15 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common { token postfix:sym<⚛--> { } token postfix:sym<ⁿ> { ? + } + # TODO: report the correct bracket in error message + token postfix:sym«->» { + + [ + | ['[' | '{' | '(' ] <.obs('->(), ->{} or ->[] as postfix dereferencer', '.(), .[] or .{} to deref, or whitespace to delimit a pointy block')> + | <.obs('-> as postfix', 'either . to call a method, or whitespace to delimit a pointy block')> + ] + } + token infix:sym<**> { } token prefix:sym<+> { } @@ -1568,6 +1581,9 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common { token infix:sym { >> } token infix:sym { >> } + token infix:sym { \s <.obs('!~ to do negated pattern matching', '!~~')> } + token infix:sym<=~> { <.obs('=~ to do pattern matching', '~~')> } + token circumfix:sym<( )> { :dba('parenthesized expression') '(' ~ ')' @@ -1690,6 +1706,24 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common { token term:sym { } token term:sym { } + token term:sym { + + >> {} + [ + <.obs('$/ variable as input record separator', + "the filehandle's .slurp method")> + ]? + [ <.twigil>?\w ] > + <.obs('undef as a verb', 'undefine() or assignment of Nil')> + ]? + <.obs('undef as a value', "something more specific:\n\tan undefined type object such as Any or Int,\n\t:!defined as a matcher,\n\tAny:U as a type constraint,\n\tNil as the absence of an expected value\n\tor fail() as a failure return\n\t ")> + } + + token term:sym { + + 'new' \h+ \h* <.obs("C++ constructor syntax", "method call syntax", :ism)> + } + token term:sym { \h* '=>' <.ws> } @@ -1711,6 +1745,16 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common { token term:sym<::?IDENT> { $ = [ '::?' ] » } + token term:sym { + << __END__ >> + <.obs('__END__ as end of code', + 'the =finish pod marker and $=finish to read')> + } + token term:sym { + << __DATA__ >> + <.obs('__DATA__ as start of data', + 'the =finish pod marker and $=finish to read')> + } token term:sym { @@ -1858,6 +1902,167 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common { ] } + proto token special_variable { <...> } + + token special_variable:sym<$!{ }> { + [ '$!{' .*? '}' | '%!' ] + <.obsvar('%!')> + } + + token special_variable:sym<$`> { + > + <.obsvar('$`')> + } + + token special_variable:sym<$@> { + <[ \s ; , ) ]> . + <.obsvar('$@')> + } + + token special_variable:sym<$#> { + + {} + <.obsvar('$#', ~$)> + } + + token special_variable:sym<$$> { + \W + <.obsvar('$$')> + } + + token special_variable:sym<$&> { + > + <.obsvar('$&')> + } + + token special_variable:sym<@+> { + > + <.obsvar('@+')> + } + + token special_variable:sym<%+> { + > + <.obsvar('%+')> + } + + token special_variable:sym<$+[ ]> { + '$+[' + <.obsvar('@+')> + } + + token special_variable:sym<@+[ ]> { + '@+[' + <.obsvar('@+')> + } + + token special_variable:sym<@+{ }> { + '@+{' + <.obsvar('%+')> + } + + token special_variable:sym<@-> { + > + <.obsvar('@-')> + } + + token special_variable:sym<%-> { + > + <.obsvar('%-')> + } + + token special_variable:sym<$-[ ]> { + '$-[' + <.obsvar('@-')> + } + + token special_variable:sym<@-[ ]> { + '@-[' + <.obsvar('@-')> + } + + token special_variable:sym<%-{ }> { + '@-{' + <.obsvar('%-')> + } + + token special_variable:sym<$/> { + > + <.obsvar('$/')> + } + + token special_variable:sym<$\\> { + '$\\' > + <.obsvar('$\\')> + } + + token special_variable:sym<$|> { + + <.obsvar('$|')> + } + + token special_variable:sym<$;> { + + <.obsvar('$;')> + } + + token special_variable:sym<$'> { #' + > + <.obsvar('$' ~ "'")> + } + + token special_variable:sym<$"> { + + <.obsvar('$"')> + } + + token special_variable:sym<$,> { + + <.obsvar('$,')> + } + + token special_variable:sym<$.> { + {} + <.obsvar('$.')> + } + + token special_variable:sym<$?> { + {} + <.obsvar('$?')> + } + + token special_variable:sym<$]> { + {} + <.obsvar('$]')> + } + + regex special_variable:sym<${ }> { + '{' {} $=[.*?] '}' + + ~~ / '=>' || ':'<:alpha> || '|%' / }> + ~~ / ^ \s* $ / }> + .Str; + my $text := $.Str; + my $bad := $sigil ~ '{' ~ $text ~ '}'; + if $text ~~ /^\d+$/ { + $text := nqp::radix(10, $text, 0, 0)[0]; + $text := $text - 1 if $text > 0; + } + if $sigil ne '$' && $sigil ne '@' { + False; # not likely a P5ism + } + elsif !($text ~~ /^(\w|\:)+$/) { + $/.obs($bad, "$sigil\($text) for hard ref or $sigil\::($text) for symbolic ref"); + } + elsif $*QSIGIL { + $/.obs($bad, '{' ~ $sigil ~ $text ~ '}'); + } + else { + $/.obs($bad, $sigil ~ $text); + } + }> + } + token variable { :my $*IN_META := ''; [