Subject: | [PATCH] New feature to set RD_TRACE output format column size |
Traditionally when ::RD_TRACE is set, the output is very compact like
this, but this is not ergonomic, so to say.
3|FUNCTION_DE|Trying subrule: |
| |[_alternation_1_of_production_1_of_rul|
| |e_FUNCTION_DEFINITION] |
4|_alternatio|Trying rule: |
| |[_alternation_1_of_production_1_of_rul|
| |e_FUNCTION_DEFINITION] |
The following path adds dynamic format definition to this module, so
this changes the column width for the second column (with index == 0):
$::RD_TRACE = 1;
Parse::RecDescent::open_trace_and_context_format( 0 => 120 );
This is helps a lot on a big monitors, and since the automatic generated
symbol names are rather long, become readable.
Apply the path against the most recent CPAN release which is the
distribution Parse-RecDescent-1.96.0 from 2008.
Cheers,
Murat
PS: Actually on column 0 can be set for now, while it is easy to see in
the patch where to allow the others to be modified as well.
Subject: | Parse-RecDescent-1.96.0_RD_TRACE_COLS.patch |
--- lib/Parse/RecDescent.pm 2009-01-21 11:32:30.000000000 +0100
+++ /home/murat/.cpan/build/Parse-RecDescent-1.96.0-xezeAj/lib/Parse/RecDescent.pm 2008-10-02 22:08:24.000000000 +0200
@@ -2921,52 +2921,27 @@
use vars '$tracerulename';
use vars '$tracelevel';
-sub open_trace_and_context_format
-{
- my @RD_TRACE_COLS = (9);
-
- for( keys %{{@_}} )
- {
- $RD_TRACE_COLS[$_] = {@_}->{$_};
- }
-
open (TRACE, ">&STDERR");
-
-my $format_trace_string = "format TRACE = \n".
-q{@>|@}."|"x$RD_TRACE_COLS[0].q{@^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|}."\n".
-q{$tracelevel, $tracerulename, '|', $tracemsg}."\n".
-q{ | ~~}." "x($RD_TRACE_COLS[0]-2).q{|^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|}."\n".
-q{ $tracemsg}."\n".
-q{.}
-;
-
-eval $format_trace_string;
-
-die $@ if $@;
+format TRACE =
+@>|@|||||||||@^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|
+$tracelevel, $tracerulename, '|', $tracemsg
+ | ~~ |^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|
+ $tracemsg
+.
set_autoflush(\*TRACE);
-
open (TRACECONTEXT, ">&STDERR");
+format TRACECONTEXT =
+@>|@|||||||||@ |^<<<<<<<<<<<<<<<<<<<<<<<<<<<
+$tracelevel, $tracerulename, '|', $tracecontext
+ | ~~ | |^<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $tracecontext
+.
-my $format_tracecontext_string = "format TRACECONTEXT = \n".
-q{@>|@}."|"x$RD_TRACE_COLS[0].q{@ |^<<<<<<<<<<<<<<<<<<<<<<<<<<<}."\n".
-q{$tracelevel, $tracerulename, '|', $tracecontext}."\n".
-q{ | ~~}." "x($RD_TRACE_COLS[0]-2).q{| |^<<<<<<<<<<<<<<<<<<<<<<<<<<<}."\n".
-q{ $tracecontext}."\n".
-q{.}."\n"
-;
-
-eval $format_tracecontext_string;
-
-die $@ if $@;
set_autoflush(\*TRACECONTEXT);
-}
-
-open_trace_and_context_format();
-
sub _verbosity($)
{
defined $::RD_TRACE