File: README.md

package info (click to toggle)
libcompiler-lexer-perl 0.23-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 612 kB
  • sloc: cpp: 5,127; perl: 1,167; makefile: 3
file content (66 lines) | stat: -rw-r--r-- 1,892 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
[![Build Status](https://travis-ci.org/goccy/p5-Compiler-Lexer.svg?branch=master)](https://travis-ci.org/goccy/p5-Compiler-Lexer) [![Coverage Status](https://img.shields.io/coveralls/goccy/p5-Compiler-Lexer/master.svg?style=flat)](https://coveralls.io/r/goccy/p5-Compiler-Lexer?branch=master)
# NAME

Compiler::Lexer - Lexical Analyzer for Perl5

# SYNOPSIS

    use Compiler::Lexer;
    use Data::Dumper;

    my $filename = $ARGV[0];
    open my $fh, '<', $filename or die "Cannot open $filename: $!";
    my $script = do { local $/; <$fh> };

    my $lexer = Compiler::Lexer->new($filename);
    my $tokens = $lexer->tokenize($script);
    print Dumper $tokens;

    my $modules = $lexer->get_used_modules($script);
    print Dumper $modules;

# METHODS

- my $lexer = Compiler::Lexer->new($options);

    create new instance.
    You can create object from $options in hash reference.

    **options list**

    - filename
    - verbose : includes token of Pod, Comment and WhiteSpace

- $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->set\_library\_path(\['path1', 'path2' ...\])

    set libraries path for reading recursively. Default paths are @INC.

- $lexer->recursive\_tokenize($script)

    get hash reference like { 'module\_nameA' => \[\], 'module\_nameB' => \[\] ... }.
    This method requires per source code in string.

- $lexer->get\_used\_modules($script);

    get names of used module.
    This method requires perl source code in string.

# AUTHOR

Masaaki Goshima (goccy) &lt;goccy(at)cpan.org>

# CONTRIBUTORS

tokuhirom: Tokuhiro Matsuno

# LICENSE AND COPYRIGHT

Copyright (c) 2013, Masaaki Goshima (goccy). All rights reserved.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.