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

How to do recursion? #61

Open
JohnLCaron opened this issue Mar 12, 2023 · 0 comments
Open

How to do recursion? #61

JohnLCaron opened this issue Mar 12, 2023 · 0 comments

Comments

@JohnLCaron
Copy link

Im failing to do recursion:

    val group : Parser<OdlStruct> by (groupStart and zeroOrMore(group) and groupEnd).map {  // line 58
            (name1 : String, nested : List<OdlStruct>, name2 : String ) ->
        val result = OdlStruct(name1)
        result.nested.addAll(nested)
        result
    }

on input like:

GROUP=SwathStructure
    GROUP=SWATH_1
          GROUP=Dimension
          END_GROUP=Dimension
         ...
    END_GROUP=SWATH_1
END_GROUP=SwathStructure

I get error:

Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method com.github.h0tk3y.betterParse.grammar.Grammar.getValue, parameter <this>
	at com.github.h0tk3y.betterParse.grammar.Grammar.getValue(Grammar.kt)
	at com.sunya.netchdf.parser.OdlParser.getGroup(OdlParser.kt:58)
	at com.sunya.netchdf.parser.OdlParser.<clinit>(OdlParser.kt:58)

presumably from "zeroOrMore(group)"

I guess I need a to instantiate a new Parser instead of trying to reference the group(?), but im stymied how to do that.
Maybe something simple Im missing?

Thanks for your help and the cool library.

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

1 participant