title: PEG for Python style indentation
body: <p>How would you write a <a href="http://en.wikipedia.org/wiki/Parsing_expression_grammar" rel="noreferrer">Parsing Expression Grammar</a> in any of the following Parser Generators (<a href="http://pegjs.majda.cz/" rel="noreferrer">PEG.js</a>, <a href="http://mjackson.github.io/citrus/" rel="noreferrer">Citrus</a>, <a href="http://cjheath.github.io/treetop/" rel="noreferrer">Treetop</a>) which can handle Python/Haskell/CoffeScript style indentation:</p>
  
  <p>Examples of a not-yet-existing programming language:</p>
  
  <pre><code>square x =
      x * x
  </code></pre>
  
  <hr>
  
  <pre><code>cube x =
      x * square x
  </code></pre>
  
  <hr>
  
  <pre><code>fib n =
    if n &lt;= 1
      0
    else
      fib(n - 2) + fib(n - 1) # some cheating allowed here with brackets
  </code></pre>
  
  <p><strong>Update:</strong>
  Don't try to write an interpreter for the examples above. I'm only interested in the indentation problem. Another example might be parsing the following:</p>
  
  <pre><code>foo
    bar = 1
    baz = 2
  tap
    zap = 3
  
  # should yield (ruby style hashmap):
  # {:foo =&gt; { :bar =&gt; 1, :baz =&gt; 2}, :tap =&gt; { :zap =&gt; 3 } }
  </code></pre>