# NAME

Keyword::API

# VERSION

version 0.0001

# SYNOPSIS

    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) = \@_;");
    };

# DESCRIPTION

This is an experimental module to provide a pure perl interface for the keywords API added to the perl core in 5.12.

## EXPORT

    install_keyword
    uninstall_keyword 
    lex_read_space
    lex_read
    lex_read_token
    lex_stuff
    lex_unstuff
    lex_unstuff_to
    lex_unstuff_token

# NAME

Keyword::API - Perl interface to the keyword API

# FUNCTIONS

## install_keyword

class method, provide name of your keyword e.g 'method'

## uninstall_keyword

remove the keyword hook, no arguments.

## lex_read_space

    lex_read_space(0);

reads white space and comments in the text currently being lexed. 

## lex_read

    my $str = lex_read($n);

Consumes $n bytes of text from the lexer buffer.

## lex_read_token

    my $toke = lex_read_token();

Consumes any text in the lexer until white space is reached.

## lex_stuff

    lex_stuff("sub foo { ...");

Injects a string into the lexer buffer.

## lex_unstuff

    my $discarded_text = lex_unstuff($n);

Discard $n bytes from the lexers buffer 

## lex_unstuff_to

    my $discarded_text = lex_unstuff_to("{");

Discard everything in the buffer until the character is met.

## lex_unstuff_token

    my $discarded_text = lext_unstuff_token();

Discard everything in the buffer until white space is met

# SEE ALSO

[perlapi](http://search.cpan.org/perldoc?perlapi) Devel::Declare Filter::Simple

# AUTHOR

Robin Edwards <robin.ge@gmail.com>

# COPYRIGHT AND LICENSE

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.