Skip to content

Commit

Permalink
[rakudo]:
Browse files Browse the repository at this point in the history
* Rework handling of named unaries a bit.


git-svn-id: http://svn.perl.org/parrot/trunk/languages/perl6@28162 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
pmichaud committed Jun 7, 2008
1 parent b8c09a8 commit 0404104
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
6 changes: 0 additions & 6 deletions src/builtins/misc.pir
Expand Up @@ -12,12 +12,6 @@ src/builtins/misc.pir - miscellaneous builtins that need reclassification
.return($P0)
.end

.sub 'WHAT'
.param pmc x
.return x.'WHAT'()
.end


# Local Variables:
# mode: pir
# fill-column: 100
Expand Down
20 changes: 20 additions & 0 deletions src/builtins/named-unary.pir
Expand Up @@ -12,6 +12,26 @@ src/builtins/named-unary.pir - Perl6 named unary builtins

.namespace []

=item HOW($x)

=item WHAT($x)

Return the metaclass or protoobject for C<$x>.

=cut

.sub 'HOW'
.param pmc x
.return x.'HOW'()
.end


.sub 'WHAT'
.param pmc x
.return x.'WHAT'()
.end


=item defined($x)

Returns a true value if $x is defined, and a false value otherwise.
Expand Down
4 changes: 2 additions & 2 deletions src/builtins/op.pir
Expand Up @@ -323,13 +323,13 @@ src/builtins/op.pir - Perl6 builtin operators
.end


.sub 'prefix:true' :multi(_)
.sub 'true' :multi(_)
.param pmc a
.return 'prefix:?'(a)
.end


.sub 'prefix:not' :multi(_)
.sub 'not' :multi(_)
.param pmc a
.return 'prefix:!'(a)
.end
Expand Down
7 changes: 3 additions & 4 deletions src/parser/actions.pm
Expand Up @@ -1916,12 +1916,11 @@ method EXPR($/, $key) {
}
else {
my $past := PAST::Op.new(
:node($/),
:name($<type>),
:pasttype($<top><pasttype>),
:pirop($<top><pirop>),
:lvalue($<top><lvalue>),
:node($/)
:opattr($<top>)
);
if $<top><subname> { $past.name(~$<top><subname>); }
for @($/) {
unless +$_.from() == +$_.to() { $past.push( $($_) ) };
}
Expand Down
8 changes: 5 additions & 3 deletions src/parser/grammar-oper.pg
Expand Up @@ -69,10 +69,12 @@ proto infix:<^> is equiv(infix:<|>)

## named unary
proto prefix:<rand> is precedence('o=') { ... }
proto prefix:<sleep> is equiv(prefix:<rand>) { ... }
proto prefix:<HOW> is equiv(prefix:<rand>) is subname('HOW') { ... }
proto prefix:<WHAT> is equiv(prefix:<rand>) is subname('WHAT') { ... }
proto prefix:<abs> is equiv(prefix:<rand>)
is pirop('n_abs')
{ ... }
proto prefix:<sleep> is equiv(prefix:<rand>) { ... }

## nonchaining
proto infix:<..> is precedence('n=') { ... }
Expand Down Expand Up @@ -164,8 +166,8 @@ proto infix:<^=> is equiv(infix:<:=>) { ... }
proto infix:«=>» is equiv(infix:<:=>) { ... }

## loose unary
proto prefix:<true> is precedence('h=') { ... }
proto prefix:<not> is equiv(prefix:<true>) { ... }
proto prefix:<true> is precedence('h=') is subname('true') { ... }
proto prefix:<not> is equiv(prefix:<true>) is subname('not') { ... }

## comma
proto infix:<,> is precedence('g=')
Expand Down

0 comments on commit 0404104

Please sign in to comment.