Keyword::API
version 0.0004
use Keyword::API; sub import { my ($class, %params) = @_; my $name = %params && $params{-as} ? $params{-as} : "method"; install_keyword(__PACKAGE__, $name); } sub unimport { uninstall_keyword() } sub parser { lex_read_space(0); my $sub_name = lex_unstuff_to_ws(); my $sig = lex_unstuff_to('{'); my ($roll) = $sig =~ /\((.+)\)\s*{/; lex_stuff("sub $sub_name {my (\$self, $roll) = \@_;"); };
This module provides a pure perl interface for the keywords API added to the perl core in 5.12.
Keyword::API - Perl interface to the keyword API
This module is likely to change in the near future. Patches and feedback most welcome.
install_keyword uninstall_keyword lex_read_space lex_read lex_read_to_ws lex_stuff lex_unstuff lex_unstuff_to lex_unstuff_to_ws
pass your package name and provide the name of your keyword e.g 'method'
remove the keyword hook, no arguments required.
lex_read_space(0);
reads white space and comments in the text currently being lexed.
my $str = lex_read($n);
Consumes $n bytes of text from the lexer buffer.
my $toke = lex_read_token();
Consumes any text in the lexer until white space is reached.
lex_stuff("sub foo { ...");
Injects a string into the lexer buffer.
my $discarded_text = lex_unstuff($n);
Discard $n bytes from the lexers buffer
my $discarded_text = lex_unstuff_to("{");
Discard everything in the buffer until the character is met.
my $discarded_text = lext_unstuff_token();
Discard everything in the buffer until white space is met
perlapi Devel::Declare Filter::Simple Syntax::Feature::Method
Robin Edwards <robin.ge@gmail.com>
This software is copyright (c) 2011 by Robin Edwards.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Keyword::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Keyword::API
CPAN shell
perl -MCPAN -e shell install Keyword::API
For more information on module installation, please visit the detailed CPAN module installation guide.