# $Header: /home/fergal/my/cvs/Code-Perl/lib/Code/Perl.pod,v 1.3 2003/06/17 21:45:34 fergal Exp $

=head1 NAME

Code::Perl - Produce Perl code from a tree

=head1 SYNOPSIS

  use Code::Perl::Expr qw( :easy );

  my $c = derefh(scal('hash'), calls('getkey'));

  print $c->perl; # ($hash)->{getkey()}

=head1 DESCRIPTION

Code::Perl allows you to build chunks of Perl code as a tree and then when
you're finished building, the tree can output the Perl code. This is useful
if you have built your own mini-language and you want to generate Perl from
it. Rather than generating the Perl at parse time and having to worry about
quoting, escaping, parenthese etc, you can just build a tree using
Code::Perl and then dump out the correct Perl at the end.

=head1 INTERFACE

All objects in Code::Perl conform to a basic interface. They all have a
method C<perl()> which when called returns a string of Perl code
corresponding to the object. So for example

  my $s_i = Code::Perl::Expr::Scalar->new(Name => 'i');
  print $s_i->perl; # $i

  my $string = Code::Perl::Expr::String->new(Value => 'hello');
  print $string->perl; # "hello"

  my $list = Code::Perl::Expr::List(Value => [$s_i, $string]);
  print $list->perl; # $i, "hello"

  my $sub = Code::Perl::Expr::CallSub(SubName => "fn", Args => $list);
  print $sub->perl; # fn($i, "hello")

Expression types may also implement other methods but they vary
from type to type, C<perl()> is the only method that is mandatory.

=head1 STATUS

Code::Perl is in development. There are no known bugs however it currently
only has support for a limited range of operators, just enough to allow me
to compile the TALES expression from Zope's TAL (F<http://www.zope.com/>).
Hopefully this will allow L<Petal> (a Perl implementation of TAL) to produce
faster code.

=head1 USAGE

See L<Code::Perl::Expr> for details of the available expression types.

=head1 PROBLEMS

Code::Perl currently has no knowledge of operator precedence, so to be safe
it uses parentheses even when they are not needed. The code is correct but
it will be a little longer and less readable. It should have no impact on
the efficience of the code produced.

=head1 AUTHOR

Written by Fergal Daly <fergal@esatclear.ie>.

=head1 COPYRIGHT

Copyright 2003 by Fergal Daly E<lt>fergal@esatclear.ieE<gt>.

This program is free software and comes with no warranty. It is distributed
under the LGPL license

See the file F<LGPL> included in this distribution or
F<http://www.fsf.org/licenses/licenses.html>.

=cut
