https://github.com/moznion/regexp-lexer
Lexer for regular expression of perl
https://github.com/moznion/regexp-lexer
Last synced: about 1 year ago
JSON representation
Lexer for regular expression of perl
- Host: GitHub
- URL: https://github.com/moznion/regexp-lexer
- Owner: moznion
- License: other
- Created: 2014-11-11T16:48:40.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-07T06:54:09.000Z (over 11 years ago)
- Last Synced: 2025-04-10T23:53:16.037Z (about 1 year ago)
- Language: Perl
- Homepage: https://metacpan.org/pod/Regexp::Lexer
- Size: 246 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/moznion/Regexp-Lexer)
# NAME
Regexp::Lexer - Lexer for regular expression of perl
# SYNOPSIS
use Regexp::Lexer qw(tokenize);
my $tokens = tokenize(qr{\Ahello\s+world\z}i);
# DESCRIPTION
Regexp::Lexer is a lexer for regular expression of perl.
This module splits the regular expression string to tokens
which has minimum meaning.
# FUNCTIONS
- `tokenize($re:Regexp)`
Tokenizes the regular expression.
This function takes an argument as `Regexp`, namely it must be regexp quoted variable (i.e. `qr/SOMETHING/`).
If not `Regexp` argument is given, this function throws exception.
This function returns the result like so;
{
tokens => [
{
char => '\A',
index => 1,
type => {
id => 67,
name => 'EscapedBeginningOfString',
},
},
{
char => 'h',
index => 2,
type => {
id => 1,
name => 'Character',
},
},
...
],
modifiers => ['^', 'i'],
}
`tokens` is the tokens list. Information about `type` of token is located in the [Regexp::Lexer::TokenType](https://metacpan.org/pod/Regexp::Lexer::TokenType).
`modifiers` is the list of modifiers of regular expression. Please see also [perlre](https://metacpan.org/pod/perlre).
# SEE ALSO
- [perlre](https://metacpan.org/pod/perlre)
- [perlrebackslash](https://metacpan.org/pod/perlrebackslash)
- [Regexp::Lexer::TokenType](https://metacpan.org/pod/Regexp::Lexer::TokenType)
# LICENSE
Copyright (C) moznion.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
# AUTHOR
moznion