Greg London > Parse-Gnaw > Parse::Gnaw::LinkedList

Download:
Parse-Gnaw-0.601.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.001   Source  

NAME ^

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 ^

Version 0.01

SUBROUTINES/METHODS ^

get_raw_address

call letter package version of get_raw_address

constructor_defaults

return a hash containing the default values for constructor arguments. this gets overloaded by derived classes so base constructor always does the right thing.

new

The new method is a constructor for creating a linked list

append this gets overloaded by derived classes so base constructor always does the right thing.

get_location_of_caller If location is defined, just return that. If not, go through caller history and find first file/linenum that is not Parse::Gnaw related.

append_string append a single dimension line of text.

append_character

        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.

create_interconnections_for_newly_appended_character

for base class, don't make any connections automatically. let user, or derived class, make connections.

display

print out a formatted version of linked list object.

get_connection_iterator

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],
        ]

and so on.

get_more_letters

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);

run_coderef_and_catch_grammar_fail

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.

convert_rule_name_to_rule_reference

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');

parse

$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.

match

$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.

syntax highlighting: