Compiler::Parser - Create Abstract Syntax Tree for Perl5
use Compiler::Lexer; use Compiler::Parser; use Compiler::Parser::AST::Renderer; my $filename = $ARGV[0]; open(my $fh, "<", $filename) or die("$filename could not find."); my $script = do { local $/; <$fh> }; my $lexer = Compiler::Lexer->new($filename); my $tokens = $lexer->tokenize($script); my $parser = Compiler::Parser->new(); my $ast = $parser->parse($tokens); Compiler::Parser::AST::Renderer->new->render($ast);
Compiler::Parser creates abstract syntax tree for perl5.
Create new instance of Compiler::Parser.
Get array reference includes abstract syntax tree each statement. This method requires $tokens from Compiler::Lexer::tokenize.
Create new instance of Compiler::Parser::AST::Renderer.
Render abstract syntax tree. This method requires $ast from Compiler::Parser::parse. Default rendering engine is Compiler::Parser::AST::Renderer::Engine::Text.
[Compiler::Lexer](http://search.cpan.org/perldoc?Compiler::Lexer)
Masaaki Goshima (goccy) <goccy54@gmail.com>
Copyright (C) Masaaki Goshima (goccy).
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Compiler::Parser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Compiler::Parser
CPAN shell
perl -MCPAN -e shell install Compiler::Parser
For more information on module installation, please visit the detailed CPAN module installation guide.