I'd look into the atoms. I was originally intimidated by the source code, but it's actually rather easy to follow after you get the hang of it.
You can find most entry points in https://github.com/kschiess/parslet/blob/master/lib/parslet.rb or https://github.com/kschiess/parslet/blob/master/lib/parslet/atoms/dsl.rb and they normally funnel down to an atom like [str()](https://github.com/kschiess/parslet/blob/master/lib/parslet/atoms/str.rb). Pretty much all atoms interact with [source](https://github.com/kschiess/parslet/blob/master/lib/parslet/source.rb) and [context](https://github.com/kschiess/parslet/blob/master/lib/parslet/atoms/context.rb), but I would start at the atom level first. If you find an atom with the same internals being repeated a bajillion times (yeah comp sci degree kicking in there), that would be a red herring. Using ruby's [caller](http://www.ruby-doc.org/core-2.0/Kernel.html#method-i-caller) can be a handy way to figure out how you got there (e.g. `require "pp"; pp caller`). I'd also recommend trying out https://github.com/cldwalker/debugger if you haven't already. Again, there are probably quicker/easier ways to track this down. But if you can't find the key, might as well knock down the whole damn door. -Zach On Mar 22, 2013, at 1:18 PM, Thomas Ingram wrote: > I've never used ruby-prof before, so I'll have to find documentation. I > thought about hacking Parslet like you said, but didn't want to if it already > has an option. Any hints on where I should start? Thank you! > > > On Fri, Mar 22, 2013 at 9:49 AM, Zach Moazeni <[email protected]> wrote: > I've noticed that following a .maybe with .repeat would take my parser into a > tailspin (kinda makes sense). I took cursory look at your code and didn't > spot any of those though. > > Is it possible to use ruby-prof and kill mid-stream? Does that print out the > traces before it is killed? That may be one way to track it down. > > Other than that, I would clone the parslet repo, point your Gemfile to the > local path, and litter the parslet codebase with print statements. It's > crude, but it will get you what you are looking for. (And it won't leave code > turds in your installed gems as opposed to `bundle open parslet`) > > Good luck, > > -Zach > > On Mar 21, 2013, at 8:49 PM, Thomas Ingram wrote: > > > I am working on a new programming language > > (https://github.com/rip-lang/rip/tree/take-two), and I'm having trouble > > getting to the bottom of some infinite loops. Is there a way to print out > > each rule as it gets called, such that I can see the rules that are > > recursing? I've tried walking through the code in my head, and I just don't > > see it. Any help would be much appreciated. Thank you and thank you so much > > for Parslet! > > > > -- > > Thomas Ingram > > > > > -- > Thomas Ingram
