README.md
1[![Build Status](https://travis-ci.org/moznion/Regexp-Lexer.svg?branch=master)](https://travis-ci.org/moznion/Regexp-Lexer)
2# NAME
3
4Regexp::Lexer - Lexer for regular expression of perl
5
6# SYNOPSIS
7
8 use Regexp::Lexer qw(tokenize);
9 my $tokens = tokenize(qr{\Ahello\s+world\z}i);
10
11# DESCRIPTION
12
13Regexp::Lexer is a lexer for regular expression of perl.
14
15This module splits the regular expression string to tokens
16which has minimum meaning.
17
18# FUNCTIONS
19
20- `tokenize($re:Regexp)`
21
22 Tokenizes the regular expression.
23
24 This function takes an argument as `Regexp`, namely it must be regexp quoted variable (i.e. `qr/SOMETHING/`).
25 If not `Regexp` argument is given, this function throws exception.
26
27 This function returns the result like so;
28
29 {
30 tokens => [
31 {
32 char => '\A',
33 index => 1,
34 type => {
35 id => 67,
36 name => 'EscapedBeginningOfString',
37 },
38 },
39 {
40 char => 'h',
41 index => 2,
42 type => {
43 id => 1,
44 name => 'Character',
45 },
46 },
47 ...
48 ],
49 modifiers => ['^', 'i'],
50 }
51
52 `tokens` is the tokens list. Information about `type` of token is located in the [Regexp::Lexer::TokenType](https://metacpan.org/pod/Regexp::Lexer::TokenType).
53
54 `modifiers` is the list of modifiers of regular expression. Please see also [perlre](https://metacpan.org/pod/perlre).
55
56# SEE ALSO
57
58- [perlre](https://metacpan.org/pod/perlre)
59- [perlrebackslash](https://metacpan.org/pod/perlrebackslash)
60- [Regexp::Lexer::TokenType](https://metacpan.org/pod/Regexp::Lexer::TokenType)
61
62# LICENSE
63
64Copyright (C) moznion.
65
66This library is free software; you can redistribute it and/or modify
67it under the same terms as Perl itself.
68
69# AUTHOR
70
71moznion <moznion@gmail.com>
72