General: Expand JSLexArrayParser to recognize [, ] and # in strings, and add debugging
[videosite.git] / videosite / JSArrayParser.pm
1 #
2 # This is a stub class for more complex JS*ArrayParser objects.
3 # It's new() method usually does _not_ return an object of
4 # type videosite::JSArrayParser, but rather a child object of itself
5 # which is able to do some actual work. The only time new() retuns
6 # an videosite::JSArrayParser onject is when no child objects are
7 # available.
8 #
9
10 package videosite::JSArrayParser;
11
12 use strict;
13
14 sub new {
15     my $class = shift;
16     my %params = @_;
17     my $self = {};
18
19     if ($class ne __PACKAGE__) {
20         # We were called from a child object. Return ourselves.
21         return bless($self, $class);
22     }
23
24     # Try to find a child object which is available and return that.
25     #
26     # See if videosite::JSLexArrayParser is available
27     eval {
28         require videosite::JSLexArrayParser;
29     };
30
31     unless($@) {
32         # Available. Return a JSLexArrayParser object
33         return videosite::JSLexArrayParser->new(%params);
34     }
35
36     # See if JSSimleArrayParser is available
37     eval {
38         require videosite::JSSimpleArrayParser;
39     };
40
41     unless ($@) {
42         # Available. Return a JSSimpleArrayParser object
43         return videosite::JSSimpleArrayParser->new(%params);
44     }
45
46     # Nothing available. Return ourselves.
47     return bless($self, $class);
48 }
49
50 sub parse {
51     my $self = shift;
52
53     # No functionality here
54     return undef;
55 }
56
57 1;