Skip to content

Instantly share code, notes, and snippets.

@robinedwards
Created April 17, 2011 09:19
Show Gist options
  • Save robinedwards/923883 to your computer and use it in GitHub Desktop.
Save robinedwards/923883 to your computer and use it in GitHub Desktop.
Keyword::API demo
package Methods;
use strict;
use warnings;
use Keyword::API;
sub import {
my ($class, %params) = @_;
my $name = %params && $params{-as} ? $params{-as} : "method";
$class->install_keyword($name);
}
sub unimport { uninstall_keyword() }
sub parser {
lex_read_space(0);
my $sub_name = lex_unstuff_token();
my $sig = lex_unstuff_to('{');
my ($roll) = $sig =~ /\((.+)\)\s*{/;
lex_stuff("sub $sub_name {my (\$self, $roll) = \@_;");
};
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment