Decl

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

lib/Decl/Node.pm
lib/Decl/Parser.pm
lib/Decl/Semantics.pm
lib/Decl/Template.pm
lib/Decl/NodalValuator.pm
lib/Decl/Util.pm
lib/Decl/Semantics/Code.pm
lib/Decl/Semantics/Commandline.pm
lib/Decl/Semantics/Data.pm
lib/Decl/Semantics/Database.pm
lib/Decl/Semantics/Macro.pm
lib/Decl/Semantics/Parse.pm
lib/Decl/Semantics/POD.pm
lib/Decl/Semantics/Repeat.pm
lib/Decl/Semantics/Table.pm
lib/Decl/Semantics/Template.pm
lib/Decl/Semantics/Text.pm
lib/Decl/Semantics/Use.pm
lib/Decl/Semantics/Value.pm
t/00-load.t
t/01a-nodes.t

lib/Decl.pm  view on Meta::CPAN


Special case: returns a slash.  (It's the root.)

=cut

sub mylocation { '/'; }

=head2 describe([$use])

Returns a reconstructed set of source code used to compile this present C<Decl> object.  If it was assembled
in parts, you still get the whole thing back.  Macro results are not included in this dump (they're presumed to be the result
of macros in the tree itself, so they should be regenerated the next time anyway).

If you specify a true value for $use, the dump will include a "use" statement at the start in order to make the result an
executable Perl script.
The dump is always in filter format (if you built it with -nofilter) and contains C<Decl>'s best guess of the
semantic modules used.  If you're using a "use lib" to affect your %INC, the result won't work right unless you modify it,
but if it's all standard modules, the dump result, after loading, should work the same as the original entry.

=cut

lib/Decl/Node.pm  view on Meta::CPAN

   return $self->{replaced}->build if $self->{replaced};
   
   if ($self->{state} ne 'built') {
      if ($self->root()->{macro_definitions}->{$self->tag}) { # This is required because in some cases, the macro definition may have been
                                                              # registered *after* the class was already assigned to the macro instance.
                                                              # E.g.:
                                                              #  define my_macro
                                                              #  ...
                                                              #  my_macro
                                                              # (On the same level with the same parent, my_macro has already been split out.)
         bless $self, 'Decl::Semantics::Macro';
      }
      $self->{force_text} = 0;
      $self->preprocess_line;
      $self->decode_line;
      $self->preprocess;
      $self->parse_body unless $self->{force_text};
      $self->build_payload;
      $self->build_children unless $self->{force_text};
      $self->add_to_parent;
      $self->post_build;

lib/Decl/Semantics/Macro.pm  view on Meta::CPAN

package Decl::Semantics::Macro;

use warnings;
use strict;

use base qw(Decl::Node);
use Data::Dumper;

=head1 NAME

Decl::Semantics::Macro - defines or instantiates a macro.

=head1 VERSION

Version 0.01

=cut

our $VERSION = '0.01';


lib/Decl/Semantics/Macro.pm  view on Meta::CPAN

Copyright 2010 Michael Roberts.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

=cut

1; # End of Decl::Semantics::Macro

lib/Decl/Semantics/Parse.pm  view on Meta::CPAN


=cut
sub defines { ('parse') }
sub tags_defined { Decl->new_data(<<EOF); }
parse (body=vanilla)
EOF

=head2 build_payload ()

The C<build> function is then called when this object's payload is built (i.e. in the stage when we're adding semantics to our
parsed syntax).  It builds the parser and registers its tag with the application.  Instances are handled by L<Decl::Semantics::Macro>.

=cut

sub build_payload {
   my ($self) = @_;
   
   my $p = Decl::Parser->new();
   $self->{payload} = $p;
   
   my $t = $self->find ('tokens');
   foreach ($t->elements) {
      $p->add_tokenizer ($_->name, $_->label); # TODO: error handling and default definitions for selected tokenizers
   }
   
   if ($self->name) {
      my $root = $self->root();
      $root->build_handler($self->name . "*", "", sub { Decl::Macro->new($self, @_) });
   }
}


=head1 AUTHOR

Michael Roberts, C<< <michael at vivtek.com> >>

=head1 BUGS

t/06-macros.t  view on Meta::CPAN

#!perl -T

use Test::More tests => 20;

# --------------------------------------------------------------------------------------
# This first bit tests the macro insertion code.  Macro insertions are nodes that are
# added to the tree "invisibly", that is, they're there but don't appear in the code's
# self-dump.  This is because they're presumed to have been added at runtime based on
# specifications already present in the defined code, and will be added on the next
# runtime based on those same specifications.
# --------------------------------------------------------------------------------------
use Decl qw(-nofilter Decl::Semantics);
use Data::Dumper;

$tree = Decl->new();



( run in 0.748 second using v1.01-cache-2.11-cpan-49f99fa48dc )