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 $m
to aHash
via$m.hash
. But this keeps nestedMatch
objects. - 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
Match
objects' contents is obviously best accomplished viamake
/made
. I would love to have a super simpleActions
object to hand to.parse
with a default method for all matches that basically just does amake $/.hash
or something the like. I just have no idea on how to specify a default method.
Aucun commentaire:
Enregistrer un commentaire