FP::AST::Perl -- abstract syntax tree for representing Perl code
use FP::AST::Perl ":all"; use FP::List; is Get(LexVar('foo'))->string, '$foo'; is Get(PackVarScalar "foo")->string, '$foo'; is Get(PackVarArray "foo")->string, '@foo'; is Get(PackVarHash "foo::bar")->string, '%foo::bar'; my $foo= PackVarCode("foo"); my $arrayfoo= PackVarArray("foo"); my $lexfoo= LexVar("foo"); is App(Get($foo), list())->string, '&foo()'; is AppProto(Get($foo), list())->string, 'foo()'; is AppProto(Get($lexfoo), list(Ref($foo)))->string, '$foo->(\&foo)'; is AppProto(Get($lexfoo), list(Get($lexfoo), Get($arrayfoo), Ref($arrayfoo)))->string, '$foo->($foo, @foo, \@foo)'; is AppProto(Get($foo), list(Get(LexVar 'foo'), Literal(Number 123)))->string, 'foo($foo, 123)'; is AppProto(Get($foo), list(Get($lexfoo), Literal(String 123)))->string, 'foo($foo, \'123\')';
This is not a parser, and hence should be outside the scope of the "can only parse Perl at runtime" issue.
The longer term aim is to support all of Perl, and to support conversion to and maybe from an op tree.
Implements: FP::Abstract::Pure, FP::Abstract::Show, FP::Abstract::Equal.
This is alpha software! Read the status section in the package README or on the website.
To install FunctionalPerl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FunctionalPerl
CPAN shell
perl -MCPAN -e shell install FunctionalPerl
For more information on module installation, please visit the detailed CPAN module installation guide.