Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow #93

Open
metadeus opened this issue Aug 13, 2015 · 6 comments
Open

Stack overflow #93

metadeus opened this issue Aug 13, 2015 · 6 comments

Comments

@metadeus
Copy link

    Rule TypeApplicationAsProxyType(@NotNull Var<IfDevNamespace> namespaceVar)
    {
        return FirstOf(PrimitiveTypeApplicationAsProxyType(),
                ArrayTypeApplicationAsProxyType(namespaceVar),
                Sequence(ElementIdAsFqn(), push(proxyDefaultNamespace((IfDevFqn) pop(),
                        namespaceVar.get()))));
    }

    Rule ArrayTypeApplicationAsProxyType(@NotNull Var<IfDevNamespace> namespaceVar)
    {
        return Sequence(Sequence('[', OptEW(), TypeApplicationAsProxyType(namespaceVar), drop(), OptEW(), ',', OptEW(), LengthFrom(),
                Optional(OptEW(), "..", OptEW(), LengthTo()), OptEW(), ']'),
                push(proxyForSystem(ImmutableIfDevName.newInstanceFromSourceName(match()))));
    }

Exception:

java.lang.StackOverflowError
    at ru.cpb9.ifdev.parser.IfDevParboiledParser$$parboiled.ArrayTypeApplicationAsProxyType(Unknown Source)
    at ru.cpb9.ifdev.parser.IfDevParboiledParser$$parboiled.TypeApplicationAsProxyType(Unknown Source)
    at ru.cpb9.ifdev.parser.IfDevParboiledParser$$parboiled.ArrayTypeApplicationAsProxyType(Unknown Source)
    at ru.cpb9.ifdev.parser.IfDevParboiledParser$$parboiled.TypeApplicationAsProxyType(Unknown Source)
    at ru.cpb9.ifdev.parser.IfDevParboiledParser$$parboiled.ArrayTypeApplicationAsProxyType(Unknown Source)
    at ru.cpb9.ifdev.parser.IfDevParboiledParser$$parboiled.TypeApplicationAsProxyType(Unknown Source)
    ...

What's wrong? Am I missing something important?

@sirthias
Copy link
Owner

Hmm...
What happens when you flatten the nested Sequence in ArrayTypeApplicationAsProxyType?
It doesn't appear to add any value, does it?

@metadeus
Copy link
Author

It does, it's followed by push(match()).
Flattening the nested Sequence does not fix the problem.
Removing the Var<> parameters from both rules does fix the problem.

@metadeus
Copy link
Author

Code to reproduce the bug:

@BuildParseTree
public class BugParser extends BaseParser<Object>
{
    Rule Root()
    {
        Var<Object> var = new Var<>();
        return Expr(var);
    }

    Rule Expr(Var<Object> var)
    {
        return SubExpr(var);
    }

    Rule SubExpr(Var<Object> var)
    {
        return Sequence('(', Expr(var), ')');
    }
}

@sirthias
Copy link
Owner

Ok, thank you!
That looks indeed like a bug.
Thanks for reporting!

@bvkatwijk
Copy link

Running into similar issues, any news?

@umazalakain
Copy link

Same for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants