Closed AverageLinuxEnjoyer closed 5 months ago
I'm sorry, actually I realized my mistake. The fact that type_parser
calls expr_parser
which then calls type_parser
again creates an indirect recursion.
Is this a case in which I should use Recursive::declare()
?
Yes, the point of Recursive
is to remove the need to create parsers recursively.
So I have this monstrosity of a parser which you can pretty much ignore in its entirety, except for the clearly highlighted section between the comments. There I define a
refined_ty
(or_
in the first snippet) parser, which recursively calls this entire big parser (type_parser
) and another really big parser (expr_parser
, which also callstype_parser
inside several times).Anyways, this builds but the tests cause a stack overflow. The first thought is that I might have did something wrong on the grammar side and the grammar is accidentally left-recursive or something. But I actually forgot to use it.
refined_ty
is only defined, but not used anywhere. By further inspecting what tests cause the stack overflow it seems like any test can cause that. Every time I runcargo test
a random test stack overflows.Here is a shorter version, in case it's easier to look at. I'm using
_
to throw the value away immediately and illustrate I'm not using it, but a runtime stack overflow still happens. Any ideas? (the complete version is under)The long version: