diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-07-17 00:28:52 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-07-17 00:28:52 -0400 |
commit | 2d777b055b750c40d2698422202c4d3950822a0c (patch) | |
tree | 6850351691843d83db44593a0e2d9475ee4b9a78 /lib | |
parent | e371e62327f22039cbede6d4c40312ab046098f6 (diff) | |
download | parse-keyword-2d777b055b750c40d2698422202c4d3950822a0c.tar.gz parse-keyword-2d777b055b750c40d2698422202c4d3950822a0c.zip |
initial sketch of the framework
now, just need to expose the parser functions to perl
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/Keyword.pm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/Parse/Keyword.pm b/lib/Parse/Keyword.pm index e69de29..b2e2709 100644 --- a/lib/Parse/Keyword.pm +++ b/lib/Parse/Keyword.pm @@ -0,0 +1,30 @@ +package Parse::Keyword; +use strict; +use warnings; +use 5.014; +# ABSTRACT: write syntax extensions in perl + +use Devel::CallParser; +use XSLoader; + +XSLoader::load( + __PACKAGE__, + exists $Parse::Keyword::{VERSION} ? ${ $Parse::Keyword::{VERSION} } : (), +); + +sub import { + my $package = shift; + my ($keywords) = @_; + + my $caller = caller; + + for my $keyword (keys %$keywords) { + my $sub = do { + no strict 'refs'; + \&{ $caller . '::' . $keyword }; + }; + install_keyword_handler($sub, $keywords->{$keyword}); + } +} + +1; |