Parse::Gnaw::LinkedList - A Parsable linked list of Parse::Gnaw::Letter objects.
This class will create a basic, doubly-linked linked-list.
A <=> B <=> C <=> D
B prev will point to A A next will point to B
and so on.
If you want more sophisticated linked lists, then use this as a base class and override the create_interconnections_for_newly_appended_character method
Version 0.01
call letter package version of get_raw_address
return a hash containing the default values for constructor arguments. this gets overloaded by derived classes so base constructor always does the right thing.
The new method is a constructor for creating a linked list
my $newletter = $llist->append_character($lettertoappendto, $single_character_to_append, $location);
Note that the order in which you append individual characters becomes the default order for the next_start method.
for base class, don't make any connections automatically. let user, or derived class, make connections.
print out a formatted version of linked list object.
return an array of connections we can iterate. should be something like this:
[ [0,0], [0,1], [1,0], [1,1], [2,0], [2,1], ]
Note that by default, this method simply dies. We assume that for this class, we won't be parsing a stream, that all letters will be in memory.
If we want to handle parsing a stream, override this method to read text from a file and append it to the letter given.
$which will be "CONNECTIONS" or "NEXTSTART", depending on who ran out of letters.
$llist->get_more_letters($thisletter,$which,$axis);
call this subroutine and pass in a coderef. This sub will call coderef and trap grammarfailures. if grammar failed, return 0. if grammar passed, return 1. if grammar died for any other reason, pass the die along.
Given a grammar rule and a string:
rule('firstrule', 'a', call('subrule'), 'd'); my $ab_string=Parse::Gnaw::LinkedList->new('abcdefg');
Users can call parse() multiple ways.
The first way to call it is by passing in the array reference to the rule. Every rule defined creates an array reference in the caller's package namespace. And that array reference is the same name as the rule, and contains the rule structure.
$ab_string->parse($firstrule)
The second way to call it is by passing in the name of the rule as a string. This can either be a simple name without the package specifier:
$ab_string->parse('firstrule');
Or it can be a fully package specified name:
$ab_string->parse('main::firstrule');
$llist->parse($grammar);
Try to match the grammar to the llist, starting from where the CURR pointer points to. Do not try from any other location.
$llist->match($grammar);
Try to match the grammar to the llist, starting from where the CURR pointer points to, and trying every position until get a match or we hit the end of the llist.
To install Parse::Gnaw, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::Gnaw
CPAN shell
perl -MCPAN -e shell install Parse::Gnaw
For more information on module installation, please visit the detailed CPAN module installation guide.