#! parrot
# Copyright (C) 2010, Parrot Foundation.
# $Id: common.pir 47062 2010-05-27 21:23:04Z bacek $

=head1 COMMON FUNCTIONS FOR TESTING

=cut

.loadlib 'io_ops'

.sub '_parse_buffer'
    .param string buffer

    .local pmc compiler
    compiler = compreg 'Ops'
    .tailcall compiler.'parse'(buffer, 'target'=>'parse')
.end

.sub '_parse_one_file'
    .param string filename
    .local string buf

    buf = '_slurp'(filename)
    .tailcall '_parse_buffer'(buf)
.end


.sub '_slurp'
    .param string file
    .local pmc pio
    pio  = open file
    $S0  = pio.'readall'()
    close pio
    .return ($S0)
.end

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
