I am currently gettin' my hands dirty on some Perl6. Specifically I am trying to write a Fortran parser based on grammars (the Fortran::Grammar module)
For testing purposes, I would like to have the possiblity to convert a Match object into a JSON-serializable Hash.
Googling / official Perl6 documentation didn't help. My apologies if I overlooked something.
My attempts so far:
- I know that one can convert a
Match $mto aHashvia$m.hash. But this keeps nestedMatchobjects. - Since this just has to be solvable via recursion, I tried but gave up in favor of asking first for the existance of a simpler/existing solution here
- Dealing with
Matchobjects' contents is obviously best accomplished viamake/made. I would love to have a super simpleActionsobject to hand to.parsewith a default method for all matches that basically just does amake $/.hashor something the like. I just have no idea on how to specify a default method.