Compiler::Lexer - Lexical Analyzer for Perl5
use Compiler::Lexer;
use Data::Dumper;
my $filename = $ARGV[0];
open(my $fh, "<", $filename) or die("$filename is not found.");
my $script = do { local $/; <$fh> };
my $lexer = Compiler::Lexer->new($filename);
my $tokens = $lexer->tokenize($script);
print Dumper $tokens;
print Dumper $lexer->get_used_modules($script);
Compiler::Lexer is lexical analyzer for perl5.
-
my $lexer = Compiler::Lexer->new($filename);
Create new instance. You can create object from
$filename
in string. -
$lexer->tokenize($script);
Get token objects includes parameter of 'name' or 'type' or 'line' and so on. This method requires perl source code in string.
-
$lexer->get_used_modules($script);
Get names of used module. This method requires perl source code in string.
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.
Masaaki Goshima (goccy) [email protected]