use warnings;
no strict 'vars';
+require Exporter;
+our $VERSION = 1.0;
+our @ISA = qw(Exporter);
+our @EXPORT = qw(out);
+our @EXPORT_OK = qw();
+
use IO::File;
our @cond;
+sub out {
+ $T::out_func->(@_);
+}
+
sub get_nested($$$) {
my ($r,$left,$right) = @_;
pos $$r = pos($$r)-1;
# print "Cond stack: @cond\n";
} else {
my $res = eval_if_ok("$f($a)");
- print $res if defined $res;
+ out $res if defined $res;
}
}
pos $t = 0;
for(;;) {
if ($t =~ /\G([^\@]+)/cgs) {
- print $1 if $cond[0] > 0;
+ out $1 if $cond[0] > 0;
} elsif ($t =~ /\G\@\s*\n/cgs) {
# @ at end of line is ignored and eats the end of line
} elsif ($t =~ /\G\@#[^\n]*\n/cgs) {
# a comment, which is ignored
} elsif ($t =~ /\G\@\@/cgs) {
- print "\@";
+ out "\@";
} elsif ($t =~ /\G\@{/cgs) {
my $x = get_nested(\$t, "{", "}");
- print eval_if_ok($x);
+ out eval_if_ok($x);
} elsif ($t =~ /\G\@\[/cgs) {
my $x = get_nested(\$t, '\[', '\]');
$x =~ s/^\[//;
} elsif ($t =~ /\G\@(\w+)([^\n]*)\n/cgs) {
eval_func($1, "($2)");
} elsif ($t =~ /\G\@(\$\w+)/cgs) {
- print eval_if_ok($1);
+ out eval_if_ok($1);
} elsif ($t =~ /\G(\@[^\n]*)/cgs) {
die "Unknown control sequence $1";
} elsif ($t =~ /\G$/cgs) {
package T;
+import UCW::Temple;
+
our $temp;
+our $out_func = sub { print @_; };
sub include {
my $fn = shift @_;