I read the tutorial on parser combinators for Scala, and I was wondering if there's something as "magical" for Java. The best thing I could find was JParsec.
Is there a parser combinator as awesome as the Scala one for Java?
Asked Answered
+1 - I didn't know the difference between a parser generator and a combinator until I read this. Thank you - I learned something today. –
Boscage
JParsec seems to do the trick, but I cannot comment on its quality. Java has no operator overloading, which is the syntactic part of the "magic" in parser combinators.
You could also use Scala to implement parsers, then call them from Java. But then the benefit over a code generator such as JavaCC isn't as great.
I didn't have time to read the links, so I was ignorant about the distinction. Thank you for the correction and the education. –
Boscage
Hmm. You can still get something better than JParsec without using any overloading. I'm thinking of the Newspeak Executable Grammars: bracha.org/executableGrammars.pdf . I just feels clumsy to have to define the tokenization separately, as in the JParsec tutorial. The grammar should be defined more modularly. Though I see that I can't express in hard criteria what it is that I'm looking for :). Just something beautiful! –
Extravehicular
If you want something beautiful, stay away from Java.
</flamebait>
–
Cesura I've come to enjoy jParsec, even if it isn't as hot as, say, the Newspeak parser combinator. We've shot an aweseome video tutorial on how to use JParsec.
Just want to mention here that I loved the video and it gave me a very quick idea of deciding on using JParsec. It definetly looks promising. Great work! –
Saddlery
Javacc, grammatica by percederberg.. Any one of these can be used.
These are compiler compilers, i.e. code generators. The idea of parser combinators is that you write them in the same language as the rest of the code. –
Cesura
© 2022 - 2024 — McMap. All rights reserved.