Skip to content

Commit

Permalink
Add qx{}, qqx{}, q:x{}, qq:x{}.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed May 20, 2009
1 parent 595d364 commit 5e2e2c1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
15 changes: 15 additions & 0 deletions src/builtins/io.pir
Expand Up @@ -169,6 +169,21 @@ Shows the supplied message and then waits for input from $*IN.
.return ($S0)
.end


.sub '!qx'
.param string cmd
.local pmc pio
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


=back

=cut
Expand Down
6 changes: 5 additions & 1 deletion src/parser/actions.pm
Expand Up @@ -2265,7 +2265,11 @@ method rad_number($/) {


method quote($/) {
make $<quote_expression>.ast;
my $past := $<quote_expression>.ast;
if $<x> eq 'x' {
$past := PAST::Op.new( :name('!qx'), :pasttype('call'), $past );
}
make $past;
}

method quote_expression($/, $key) {
Expand Down
23 changes: 13 additions & 10 deletions src/parser/grammar.pg
Expand Up @@ -921,19 +921,22 @@ token quote {
[ [':P5'|':Perl5'] <.ws> <quote_expression: :regex :P5>
| <quote_expression: :regex>
]
| qq [ <.ws> ':' ]?
[ w <.ws> <quote_expression: :qq :w>
| $<x>=[x?] <.ws> <quote_expression: :qq>
]
| q [ <.ws> ':' ]?
[ q <.ws> <quote_expression: :qq>
| w <.ws> <quote_expression: :q :w>
| 'PIR' <.ws> <quote_expression: :PIR>
| x <.ws> <.panic: "qx not yet implemented">
| <.ws> <quote_expression: :q>
[ q <.ws> <quote_expression: :qq>
| w <.ws> <quote_expression: :q :w>
| 'PIR' <.ws> <quote_expression: :PIR>
| $<x>=[x?] <.ws> <quote_expression: :q>
]
| Q [ <.ws> ':' ]?
[ 'PIR' <.ws> <quote_expression: :PIR>
| 'q' <.ws> <quote_expression: :q>
| 'qq' <.ws> <quote_expression: :qq>
| 'b' <.ws> <quote_expression: :b>
| <.ws> <quote_expression: >
[ 'PIR' <.ws> <quote_expression: :PIR>
| 'q' <.ws> <quote_expression: :q>
| 'qq' <.ws> <quote_expression: :qq>
| 'b' <.ws> <quote_expression: :b>
| $<x>=[x?] <.ws> <quote_expression: >
]
]
{*}
Expand Down

0 comments on commit 5e2e2c1

Please sign in to comment.