title: Pyparsing: changing default debug actions for all parser elements
body: <p>I want to improve the readability of pyparsing's debugging output by adding indentation. For example, instead of this:</p>
  
  <pre><code>Match part at loc 0(1,1)
  Match subpart1 at loc 0(1,1)
  Match subsubpart1 at loc 0(1,1)
  Matched subsubpart1 at loc 10(2,1) -&gt; ...
  Matched subpart1 at loc 20(3,1) -&gt; ...
  Match subpart2 at loc 20(3,1)
  Match subsubpart2 at loc 20(3,1)
  Matched subsubpart2 at loc 30(4,1) -&gt; ...
  Matched subpart2 at loc 40(5,1) -&gt; ...
  Matched part at loc 50(6,1) -&gt; ...
  </code></pre>
  
  <p>I would like to have it indented like this to better understand what's going on during parsing:</p>
  
  <pre><code>Match part at loc 0(1,1)
      Match subpart1 at loc 0(1,1)
          Match subsubpart1 at loc 0(1,1)
          Matched subsubpart1 at loc 10(2,1) -&gt; ...
      Matched subpart1 at loc 20(3,1) -&gt; ...
      Match subpart2 at loc 20(3,1)
          Match subsubpart2 at loc 20(3,1)
          Matched subsubpart2 at loc 30(4,1) -&gt; ...
      Matched subpart2 at loc 40(5,1) -&gt; ...
  Matched part at loc 50(6,1) -&gt; ...
  </code></pre>
  
  <p>So in pyparsing.py, I just changed <code>_defaultStartDebugAction</code>, <code>_defaultSuccessDebugAction</code> and <code>_defaultExceptionDebugAction</code> to:</p>
  
  <pre><code>pos = -1
  def _defaultStartDebugAction( instring, loc, expr ):
      global pos
      pos = pos + 1
      print ("\t" * pos + ("Match " + _ustr(expr) + " at loc " + _ustr(loc) + "(%d,%d)" % ( lineno(loc,instring), col(loc,instring) )))
  
  def _defaultSuccessDebugAction( instring, startloc, endloc, expr, toks ):
      print ("\t" * pos + "Matched " + _ustr(expr) + " -&gt; " + str(toks.asList()))
      global pos
      pos = pos - 1
  
  def _defaultExceptionDebugAction( instring, loc, expr, exc ):
      print ("\t" * pos + "Exception raised:" + _ustr(exc))
      global pos
      pos = pos - 1
  </code></pre>
  
  <p>(I just added the <code>pos</code> expressions and <code>"\t" * pos</code> to the output to get my desired result)</p>
  
  <p>However, I don't like tampering directly with the pyparsing library. On the other hand, I don't want to use the <code>.setDebugActions</code> method on every parser element I define, I want them all to use my modified default debug actions. </p>
  
  <p>Is there a way I can achieve this without having to tamper with the pyparsing.py library directly?</p>
  
  <p>Thanks!</p>