ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/Parse.pm
Revision: 1.11.4.1.2.1
Committed: Thu Mar 13 12:54:49 2008 UTC (17 years, 1 month ago) by muzaffar
Content type: text/plain
Branch: SCRAM_V2_0
CVS Tags: V2_2_2, V2_2_2_pre4, V2_2_2_pre3, V2_2_2_pre2, V2_2_2_pre1, V2_2_2-pre1, V2_2_1, forV2_2_1, V2_2_0, sm100112, V2_1_4, V2_1_3, V2_1_2, V2_1_1, V2_1_0, V2_0_6, V2_0_5, V2_0_4, V2_0_4_relcand2, V2_0_4_relcand1, V2_0_3, V2_0_3_relcand3, V2_0_3_relcand2, V2_0_3_relcand1, V2_0_2, V2_0_2_relcand1, V2_0_1, V2_0_1_relcand4, V2_0_1_relcand3, V2_0_1_relcand2, V2_0_1_relcand1, V2_0_0_relcand4, V2_0_0, V2_0_0_relcand3, V2_0_0_relcand2, V2_0_0_relcand1
Changes since 1.11.4.1: +3 -2 lines
Log Message:
scram v2.0 for multiple arch support and big lib stuff

File Contents

# User Rev Content
1 williamc 1.1 #
2     # Parse.pm
3     #
4     # Originally Written by Christopher Williams
5     #
6     # Description
7     # -----------
8     # maintain parse configurations
9     #
10     # Interface
11     # ---------
12 sashby 1.6 # new() : A new Parse object
13 williamc 1.1 # addtag(name,start,text,end,$object) : Add a new tag
14 sashby 1.6 # addgrouptags() : add <Group> tag functionality
15     # addignoretags() : add <ignore> tag functionality
16 williamc 1.1 # parse(filename,[streamhandle], [streamexcludetag]) :
17     # parse the given file - turn on the stream
18     # function of the switcher if a filehandle
19     # supplied as a second argument
20 sashby 1.6 # line() : return the current linenumber in the file
21 williamc 1.1 # tagstartline() : return the linenumber of the last tag opening
22 sashby 1.6 # includeparse(Parse) : include the settings from another parse object
23 williamc 1.2 # tags() : return list of defined tags
24 williamc 1.3 # cleartags() : clear of all tags
25 sashby 1.6 # opencontext(name) : open a parse context
26 williamc 1.4 # closecontext(name) : close a parse context
27     # includecontext(name) : Process when in a given context
28     # excludecontext(name) : No Processing when given context
29     # contexttag(tagname) : Register the tagname as one able to change context
30     # if not registerd - the close tag will be ignored
31     # too if outside of the specified context!
32 williamc 1.1
33     package ActiveDoc::Parse;
34     require 5.004;
35    
36 sashby 1.9 sub new()
37 sashby 1.6 {
38     my $class=shift;
39     $self={};
40     bless $self, $class;
41 muzaffar 1.11.4.1.2.1 my ($dataclass, $parse_style,$keep_running_onerr,$xml)=@_;
42 muzaffar 1.11.4.1 require SCRAM::Plugins::DocParser;
43 muzaffar 1.11.4.1.2.1 $self->{xml}=$xml || 0;
44 muzaffar 1.11.4.1 $self->{xmlparser} = new SCRAM::Plugins::DocParser($dataclass,$parse_style,$keep_running_onerr);
45 sashby 1.6 return $self;
46     }
47    
48 sashby 1.9 sub parsefilelist()
49 sashby 1.6 {
50     my $self=shift;
51 sashby 1.9 my ($files)=@_;
52 muzaffar 1.11 print __PACKAGE__."::parsefilelist(): Not used?\n";
53     }
54    
55     sub filehead ()
56     {
57     my $self=shift;
58     my $data=@_;
59     if (@_)
60     {
61     $self->{filehead}=shift;
62     return;
63     }
64     return $self->{filehead} || "";
65     }
66    
67     sub filetail ()
68     {
69     my $self=shift;
70     if (@_)
71     {
72     $self->{filetail}=shift;
73     return;
74     }
75     return $self->{filetail} || "";
76 sashby 1.6 }
77    
78 sashby 1.9 sub parse()
79 sashby 1.6 {
80     my $self=shift;
81 sashby 1.9 my ($file)=@_;
82 muzaffar 1.11.4.1 if (!$self->{xmlparser}->parse($file,$self->getfilestring_($file)))
83 muzaffar 1.11 {
84 muzaffar 1.11.4.1 print STDERR "**** ERROR: Failed parsing file: $file.\n";
85 muzaffar 1.11 }
86 sashby 1.9 return $self;
87 sashby 1.6 }
88    
89 sashby 1.9 sub getfilestring_()
90 sashby 1.7 {
91     my $self=shift;
92 sashby 1.9 my ($file)=@_;
93 muzaffar 1.11 my $filestring="";
94     my $read=0;
95 muzaffar 1.11.4.1.2.1 if (($file!~/\.xml$/) && ($self->{xml}==0))
96 muzaffar 1.11 {
97 muzaffar 1.11.4.1 eval("use SCRAM::Plugins::Doc2XML");
98 muzaffar 1.11 if (!$@)
99     {
100 muzaffar 1.11.4.1 my $xmlconvertor = SCRAM::Plugins::Doc2XML->new();
101 muzaffar 1.11 my $xml=$xmlconvertor->convert($file);
102     $filestring = join("",@$xml);
103     $xmlconvertor->clean();
104     $read=1;
105     }
106     }
107     if (!$read)
108     {
109     open (IN, "< $file") or die __PACKAGE__.": Cannot read file $file: $!\n";
110     $filestring = join("", <IN>);
111     close (IN) or die __PACKAGE__.": Cannot read file $file: $!\n";
112     }
113     $filestring = $self->filehead().$filestring.$self->filetail();
114 sashby 1.9 # Strip spaces at the beginning and end of the line:
115     $filestring =~ s/^\s+//g;
116     $filestring =~ s/\s+$//g;
117     $self->{filestring}=$filestring;
118     return $filestring;
119 sashby 1.7 }
120    
121 sashby 1.9 sub data()
122 sashby 1.6 {
123     my $self=shift;
124 muzaffar 1.11.4.1 return $self->{xmlparser}->getOutput();
125 sashby 1.6 }
126    
127     sub includeparse
128     {
129     my $self=shift;
130     my $obj=shift;
131     my $tag;
132    
133     # copy the tags from the remote parse object
134     foreach $tag ( $obj->tags() )
135     {
136     $self->addtag($tag,$obj->{tags}->tagsettings($tag));
137     }
138     }
139    
140     sub addtag
141     {
142     my $self=shift;
143     $self->{tags}->addtag(@_);
144     }
145    
146 sashby 1.9 1;