[Spirit] Stack overflow, suspect infinite recursion
Hi,
I'm writing a math string parser with boost::spirit and I'm stuck on this
stack overflow. I've seen this before when I wrote a rule that was
misleading.
It's the second time I get these and I'm really not sure how I can
troubleshoot this kind of problem. Help would be greatly appreciated.
I have no issues parsing the forms "A?B" (where A,B are floats and ? is
an arithmetic operator +,-,*,/). No issues parsing "(A)" either... At the
moment of writing this, I haven't tried but I will be trying to parse
simpler forms like "(A)?B" and "A?(B)", "(A?B)", "(A?B)?C" and
"A?(B?C)"... I suspect going through them will eventually help me fix the
bug with the form below...
Below is the final output of my program through valgrind and the rules I
have are at the end of my post. I suspect the prob is in the definition
for start, operation or operand (an operand may be the result of an
operation and an operation is performed on operands). There may be a nasty
infinite recursion between operand and operation... The resulting objects
are polymorphic and they are correct (as seen when used without spirit).
Simon
Parsing operations such as ( A?B ) ? ( C?D )
Parsing: (0.1+1.9)+(4.2+6.1) -> (AB=2.000000, CD=10.300000,
ABCD=12.300000)
==17013== Stack overflow in thread 1: can't grow stack to 0xb907cfbc
==17013==
==17013== Process terminating with default action of signal 11 (SIGSEGV)
==17013== Access not within mapped region at address 0xB907CFBC
==17013== at 0x13487A: bool
boost::spirit::qi::action
On 06/03/2013 04:26 PM, Simon wrote:
I'm writing a math string parser with boost::spirit and I'm stuck on this stack overflow. I've seen this before when I wrote a rule that was misleading.
When this happens, it is often due to left recursion: http://en.wikipedia.org/wiki/Left_recursion I did not check you grammar, though.
It is very likely to be the problem.
So my guess was right to think the stack overflow is a problem of infinite
recursion?
Thanks a lot for the link too!
Simon
On Mon, Jun 3, 2013 at 3:04 PM, Bjorn Reese
On 06/03/2013 04:26 PM, Simon wrote:
I'm writing a math string parser with boost::spirit and I'm stuck on
this stack overflow. I've seen this before when I wrote a rule that was misleading.
When this happens, it is often due to left recursion:
http://en.wikipedia.org/wiki/**Left_recursionhttp://en.wikipedia.org/wiki/Left_recursion
I did not check you grammar, though.
______________________________**_________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/**mailman/listinfo.cgi/boost-**usershttp://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Bjorn Reese
-
Simon