Skip to content

Commit

Permalink
Add obs method and port the smart version of rand from STD.pm.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Feb 17, 2010
1 parent 2c23657 commit 761d05a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Perl6/Grammar.pm
Expand Up @@ -116,6 +116,11 @@ method is_name($name) {
!pir::isnull__IP($test);
}

# "when" arg assumes more things will become obsolete after Perl 6 comes out...
method obs ($old, $new, $when = ' in Perl 6') {
self.panic("Unsupported use of $old;$when please use $new");
}

## Lexer stuff

token apostrophe {
Expand Down Expand Up @@ -776,7 +781,11 @@ proto token term { <...> }
token term:sym<self> { <sym> <.nofun> }

token term:sym<Nil> { <sym> <.nofun> }
token term:sym<rand> { <sym> <.nofun> }
token term:sym<rand> {
<sym> »
[ <?before '('? \h* [\d|'$']> <.obs('rand(N)', 'N.rand or (1..N).pick')> ]?
[ <?before '()'> <.obs('rand()', 'rand')> ]?
}

token term:sym<...> { <sym> <args>? }
token term:sym<???> { <sym> <args>? }
Expand Down

0 comments on commit 761d05a

Please sign in to comment.