Zach,
The problem is that your operator rule is including the whitespace, so
:op => "+ " (note space) and thus your transform rule is not matching.
You should switch these two rules:
rule(:operator) { match('[+]') >> space? }
rule(:sum) { integer.as(:left) >> operator.as(:op) >> expression.as(:right) }
to this instead:
rule(:operator) { match('[+]').as(:op) >> space? }
rule(:sum) { integer.as(:left) >> operator >> expression.as(:right) }
and I believe that should work.
-mj
On Tue, Aug 23, 2011 at 8:22 PM, Zachary Drummond - BIA
<[email protected]> wrote:
> I followed the online docs pretty closely and got hit by the fact that the
> parser does not seem to always eat whitespace. If you run the following
> code, you will see that the intergers have no whitespace, but the + does,
> which causes the transform to fail. Any ideas of what I am doing wrong?
>
> Thanks,
>
> -Zach