1. 10

  2. 1

    Am I correct to assume that parser combinators cannot be used if I want to parse same input, in 2 or 3 different runtime environments: JavaScript, JVM, C++, Python (as an example) ?

    In other words, am I correct to think that parser combinators are predicated on relying on particular programming language to run within?

    My yet-to-be implemented use case is being able to parse same DSL and interpret (execute) it, with a web app, android app, python app and a desktop C++ app.

    I sort of stayed away from learning how to do it in Parser combinators (although I had some experience years ago with C++ Spirit [1] by Joel De Guzman ). And instead, we were looking at tools that can generate parsers for several run-time/programming environments (the problems so far is that what I found had a pretty hefty (in terms of kb size) JavaScript runtime version – which exceeds size budget of our web app).

    [1] http://boost-spirit.com/home/

    1. 1

      In general you are correct, one of the cool things about parser combinators is that they are just regular functions, so you can programmatically build the parser while parsing. You could even take input or do randomness while parsing.

      But with a totality restriction you could implement a parser combinator which evaluates to a representation of its grammar, allowing you to generate code in any language.

    Stories with similar links:

    1. Applicative parsing via mseri 10 months ago | 14 points | no comments