Re: Parser Combinator in SML -- Problem with MLton
Matthew Fluet <[email protected]>
| Newsgroups | gmane.comp.lang.ml.mlton.user |
|---|---|
| Message-ID | <CAMrhFL7O-4XyUHtZQzYhHhZO9gSizkmyVUzjP2UUOY2ndgChRA@mail.gmail.com> |
On Fri, Jan 10, 2014 at 12:49 PM, René Neumann <[email protected]> wrote: > >> fun expr _ = exprAdd () >> and exprAdd _ = sop #"+" (op +) exprMul >> and exprMul _ = sop #"*" (op *) exprBase >> and exprBase _ = "expression expected" !! >> trim (item #"(") >> expr() -- trim (item #")") >> || trim number > > From some more investigation, I now have the impression that the main > problem is not the parsing process itself, but the construction of the > parsers (in the above example 'expr()'). For instance, the construction > of the top-level parser takes MLton 130ms in my case. But the > constructed parser will still contain parts inside an unevaluated "fn _ > => ". And my guess is: Evaluating those throughout the parsing process > is the expensive part. That's a reasonable hypothesis, and fits with my thought that the new combinator library leads to fewer, but bigger, functions. And those fewer, bigger, functions might have more "active" code that is evaluated irrespective of whether the parser needs to explore that part of the grammar for a particular input. > This was not a problem with the old approach, as a parser then was in > essence only 'bind closure closure', which is easy to evaluate and the > closures are only evaluated as needed. > > @Matthew: It seems I cannot build a 'small' example. Should I share my > two versions of the parser (each version about 2000 loc) with you? Or is > this too much input to handle? Sure, share what you have. Worst that can happen is that we can't tease out the difference in the intermediate code. -Matthew To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk _______________________________________________ MLton-user mailing list [email protected]; [email protected] https://lists.sourceforge.net/lists/listinfo/mlton-user