Skip to content

Commit

Permalink
Add qx{} and qqx{}, except for hash_to_env() because %*ENV is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Berends committed Feb 9, 2010
1 parent 8faeb9e commit c5dda73
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -33,3 +33,4 @@ perl6_group.?
libparrot.dll
src/binder/bind.bundle
src/binder/bind.o
docs/test_summary.times
10 changes: 10 additions & 0 deletions src/Perl6/Actions.pm
Expand Up @@ -1720,6 +1720,16 @@ method quote:sym<Q:PIR>($/) {
:pasttype('inline'),
:node($/) );
}
method quote:sym<qx>($/) {
make PAST::Op.new( :name('!qx'), :pasttype('call'),
$<quote_EXPR>.ast
);
}
method quote:sym<qqx>($/) {
make PAST::Op.new( :name('!qx'), :pasttype('call'),
$<quote_EXPR>.ast
);
}
method quote:sym</ />($/) {
my $past := Regex::P6Regex::Actions::buildsub($<p6regex>.ast);
make create_code_object($past, 'Regex', 0, '');
Expand Down
14 changes: 8 additions & 6 deletions src/Perl6/Grammar.pm
Expand Up @@ -855,12 +855,14 @@ token typename {
}

proto token quote { <...> }
token quote:sym<apos> { <?[']> <quote_EXPR: ':q'> }
token quote:sym<dblq> { <?["]> <quote_EXPR: ':qq'> }
token quote:sym<q> { 'q' <![(]> <.ws> <quote_EXPR: ':q'> }
token quote:sym<qq> { 'qq' <![(]> <.ws> <quote_EXPR: ':qq'> }
token quote:sym<Q> { 'Q' <![(]> <.ws> <quote_EXPR> }
token quote:sym<Q:PIR> { 'Q:PIR' <.ws> <quote_EXPR> }
token quote:sym<apos> { <?[']> <quote_EXPR: ':q'> }
token quote:sym<dblq> { <?["]> <quote_EXPR: ':qq'> }
token quote:sym<q> { 'q' <![(]> <.ws> <quote_EXPR: ':q'> }
token quote:sym<qq> { 'qq' <![(]> <.ws> <quote_EXPR: ':qq'> }
token quote:sym<qx> { 'qx' <![(]> <.ws> <quote_EXPR: ':q'> }
token quote:sym<qqx> { 'qqx' <![(]> <.ws> <quote_EXPR: ':qq'> }
token quote:sym<Q> { 'Q' <![(]> <.ws> <quote_EXPR> }
token quote:sym<Q:PIR> { 'Q:PIR' <.ws> <quote_EXPR> }
token quote:sym</null/> { '/' \s* '/' <.panic: "Null regex not allowed"> }
token quote:sym</ /> { '/'<p6regex=.LANG('Regex','nibbler')>'/' }

Expand Down
16 changes: 14 additions & 2 deletions src/builtins/Str.pir
Expand Up @@ -23,7 +23,6 @@ as the Perl 6 C<Str> class.
strproto = p6meta.'new_class'('Str', 'parent'=>'parrot;Perl6Str Any')
.end


.sub 'ACCEPTS' :method
.param string topic
.tailcall '&infix:<eq>'(topic, self)
Expand Down Expand Up @@ -238,11 +237,24 @@ Overridden for Str.
.tailcall 'prefix:?'($I0)
.end


=back

=cut

.sub '!qx'
.param string cmd
.local pmc pio
# '!hash_to_env'() # ng: TODO
pio = open cmd, 'rp'
unless pio goto err_qx
pio.'encoding'('utf8')
$P0 = pio.'readall'()
pio.'close'()
.return ($P0)
err_qx:
.tailcall '!FAIL'('Unable to execute "', cmd, '"')
.end

# Local Variables:
# mode: pir
# fill-column: 100
Expand Down

0 comments on commit c5dda73

Please sign in to comment.