3 PGE::Dumper - various methods for displaying PGE structures
10 .namespace [ "PGE::Match" ]
12 =head2 C<PGE::Match> Methods
16 =item C<__dump(PMC dumper, STR label)>
18 This method enables Data::Dumper to work on Match objects.
25 .local string indent, subindent
28 .local pmc hash, array
31 (subindent, indent) = dumper."newIndent"()
34 dumper."genericString"("", $S0)
40 if_null hash, dump_array
41 iter = new 'Iterator', hash
43 unless iter goto dump_array
44 if hascapts goto dump_hash_2
55 dumper."dump"(label, val)
59 if_null array, dump_end
63 if $I0 >= $I1 goto dump_end
64 if hascapts goto dump_array_2
74 dumper."dump"(label, val)
78 unless hascapts goto end
83 dumper."deleteIndent"()
88 An alternate dump output for a Match object and all of its subcaptures.
92 .sub "dump_str" :method
93 .param string prefix :optional # name of match variable
94 .param int has_prefix :opt_flag
95 .param string b1 :optional # bracket open
96 .param int has_b1 :opt_flag
97 .param string b2 :optional # bracket close
98 .param int has_b2 :opt_flag
103 .local string prefix1, prefix2
111 out = concat prefix, ':'
112 unless self goto subpats
127 if_null capt, subrules
131 unless spi < spc goto subrules
132 prefix1 = concat prefix, b1
136 $I0 = defined capt[spi]
137 unless $I0 goto subpats_2
147 iter = new 'Iterator', capt
151 prefix1 = concat prefix, '<'
154 $I0 = defined capt[$S0]
155 unless $I0 goto subrules_1
161 $I0 = isa $P0, 'PGE::Match'
162 unless $I0 goto dumper_0
163 $S0 = $P0.'dump_str'(prefix1, b1, b2)
167 $I0 = does $P0, 'array'
168 unless $I0 goto dumper_3
172 if $I0 >= $I1 goto dumper_2
174 prefix2 = concat prefix1, b1
178 $S0 = $P1.'dump_str'(prefix2, b1, b2)
199 An alternate dump output for a Match object and all of its subcaptures.
200 Simply calls C<dump_str()> above and prints the results.
205 .param string prefix :optional # name of match variable
206 .param int has_prefix :opt_flag
207 .param string b1 :optional # bracket open
208 .param int has_b1 :opt_flag
209 .param string b2 :optional # bracket close
210 .param int has_b2 :opt_flag
215 .local string prefix1, prefix2
222 $S0 = self.'dump_str'(prefix, b1, b2)
230 =head2 C<PGE::Exp> methods
232 These methods print out a PGE expression tree. They may be
233 obsoleted in favor of a Data::Dumper method.
237 .namespace [ "PGE::Exp" ]
239 .sub "dumpindent" :method
241 $S0 = repeat ' ', indent
248 self."dumpindent"(indent)
249 print "EXP (abstract) "
256 .namespace [ "PGE::Exp::Start" ]
261 $S0 = self["firstchars"]
270 .namespace [ "PGE::Exp::End" ]
274 self."dumpindent"(indent)
279 .namespace [ "PGE::Exp::Literal" ]
284 literal = self["literal"]
285 self."dumpindent"(indent)
295 .namespace [ "PGE::Exp::Scalar" ]
300 cname = self["cname"]
301 self."dumpindent"(indent)
311 .namespace [ "PGE::Exp::Dot" ]
315 self."dumpindent"(indent)
323 .namespace [ "PGE::Exp::CharClass" ]
327 self."dumpindent"(indent)
329 $S0 = self["charmatch"]
332 $S0 = self["charclass"]
341 .namespace [ "PGE::Exp::WS" ]
345 self."dumpindent"(indent)
353 .namespace [ "PGE::Exp::Anchor" ]
358 self."dumpindent"(indent)
360 token = self["token"]
367 .namespace [ "PGE::Exp::Concat" ]
378 .namespace [ "PGE::Exp::Alt" ]
387 $I0 = isa exp, "PGE::Exp::Alt"
388 if $I0 goto print_exp1
392 self."dumpindent"(indent)
396 $I0 = isa exp, "PGE::Exp::Alt"
397 if $I0 goto print_exp2
405 .namespace [ "PGE::Exp::Group" ]
413 self."dumpindent"(indent)
417 $I0 = exists self["rname"]
418 unless $I0 goto dump_0
424 $I0 = exists self["cname"]
425 unless $I0 goto dump_1
426 print " capture as '"
431 $I0 = self["isarray"]
432 unless $I0 goto dump_2
436 unless $I0 goto dump_3
446 .namespace [ "PGE::OPTable" ]
448 =head2 C<PGE::OPTable> Methods
452 =item C<__dump(PMC dumper, STR label)>
454 This method enables Data::Dumper to work on PGE::OPTable objects.
458 .sub "__dump" :method
461 .local string indent, subindent
464 .local pmc hash, array
466 (subindent, indent) = dumper."newIndent"()
469 if_null hash, dump_rest
470 iter = new 'Iterator', hash
472 unless iter goto dump_rest
480 dumper."dump"(label, val)
484 $P0 = getattribute self, '%!key'
486 dumper."dump"(label, $P0)
488 $P0 = getattribute self, '%!klen'
490 dumper."dump"(label, $P0)
493 dumper."deleteIndent"()
504 # vim: expandtab shiftwidth=4 ft=pir: