robin dot ge at gmail dot com
TODO
-* remove stupid globals
+* remove globals
* add support for blockless keywords
* add eos inject see MXD
* cleanup parser construction (check if code exists etc)
* write default action to return whatever the parse routine matched
PLAN
-* rename Keyword::Parser to Keyword::Declare alter to sub class of DD:C:S with aliases
+* alter Keyword::Declare to sub class of DD:C:S?
* create new Keyword::Parser class for storing parse routines
SYNTAX
$block->terminate; # add semi colon
}
-#passed a Keyword::Parser object
+#passed a Keyword::Declare object
parse custom ($parser) {
if (my $len = $parser->scan_word(1)) {
my $l = $parser->line;
use Devel::Declare;
use B::Hooks::EndOfScope;
use Data::Dumper;
-use Keyword::Parser;
+use Keyword::Declare;
use Keyword::Parse::Block;
use Keyword::Parse::Proto;
use Keyword::Parse::Ident;
#parses keyword signature
sub keyword_parser {
- my $parser = Keyword::Parser->new;
+ my $parser = Keyword::Declare->new;
$parser->next_token;
$parser->skip_ws;
# parses the parse keyword
sub parse_parser {
- my $parser = Keyword::Parser->new;
+ my $parser = Keyword::Declare->new;
$parser->next_token;
$parser->skip_ws;
# parses the action keyword
sub action_parser {
- my $parser = Keyword::Parser->new;
+ my $parser = Keyword::Declare->new;
$parser->next_token;
$parser->skip_ws;
sub eos {
on_scope_end {
- my $parser = new Keyword::Parser;
+ my $parser = new Keyword::Declare;
my $l = $parser->line;
my $loffset = $parser->line_offset;
substr($l, $loffset, 0) = ';';
sub mk_parser {
my ($plist,$keyword) = @_;
return sub {
- my $parser = Keyword::Parser->new;
+ my $parser = Keyword::Declare->new;
$parser->next_token;
$parser->skip_ws;
return sub {
my $module_user = caller();
-
# module_user is the user of your Keyword based module
Devel::Declare->setup_for(
$module_user,
Its possible to write your own with the following syntax:
- parse something($parser) {
+ parse identifier($parser) {
if (my $len = $parser->scan_word(1)) {
my $l = $parser->line;
my $ident = substr($l, $parser->offset, $len);