Parslet & Stack size

Hello all,

I am using parslet to do some log-file parsing and have run into the
“stack level too deep” error, and I am only half-way though with
writing the rules for a single line to be parsed.

From what I gathered there is no option to easily increase the stack
size, it would require rebuilding ruby with some of the C flags set.
Is there any other way?

Can anyone with parslet experience recommend a method for writing the
rules that will reduce the internal recursion necessary?

Thank you,
Brian

Quoting PsiPro [email protected]:

Hello all,

I am using parslet to do some log-file parsing and have run into the
“stack level too deep” error, and I am only half-way though with
writing the rules for a single line to be parsed.

I don’t know the specific technology in Parslet, but if it’s a typical
recursive descent parser, you have to write your rules for lists a
particular
way, otherwise they become infinite recursion.

The two ways are:

list ::= word | word list

and

list ::= word | list word

Which ever one you are using, try the other. And try to reduce your
grammar
to the smallest piece that breaks, and then work with it until it
doesn’t.

I have been using Ruby and Rails for over 5 years and I have yet to see
a
stack overflow that wasn’t infinite recursion.

HTH,
Jeffrey

list ::= word | list word
I followed the parslet convention of ‘consuming first’, which is what
your saying there I think. I worked around it by simply removing the
recursion, not as fancy but it works. I’ll optimize it later.