Hi Kaspar,

Thanks for the quick response, splitting up expr into a rule to break the 
recursion solves it.  All clear now.

Vieni per caso dalla Svizzera?  (Sorry if not, I just guessed Florian knows you 
from Switzerland because of the name… I'm in Melbourne too).

Cheers,

Chris

On 04/11/2011, at 9:11 PM, Kaspar Schiess wrote:

> Hei Chris, 
> 
> You have to think about what moves the parse forward, just as if you were 
> coding it by hand. The two relevant functions would look something like this 
> (in your grammar): 
> 
> def parse_sum
>  parse_expr or return false
>  parse_wsp
>  parse('+') or return false
>  parse_wsp
>  parse_expr
> end
> 
> def parse_expr
>  return true if parse_sum
>  return true if parse_add_call 
>  parse_t_int
> end
> 
> (Assuming that parse functions return a boolean indicating their success.) So 
> what you have there is direct mutual recursion between expr and sum. And put 
> like this (in code), it is easy to see, isn't it?
> 
> I guess your sum doesn't really allow any kind of expression in front, but 
> rather something that can be an element of a sum, like integers or function 
> calls. That avoids the recursion. 
> 
> Here's something that works, maybe that helps you along as well: 
> https://gist.github.com/1339032
> 
> regards, 
> kaspar
> 

Reply via email to