Question

We have been exploring to write external DSL for our platform and the syntax will be similar to JAVA, however the underlying code generated will be bit different.

We gave a ANTLR spin and also tweaked out of box java grammar file to adhere to our rules, the next step is semantic analysis which is bit tough, so was curious to know availability of free semantic analyzer for JAVA. Similar to grammar file, if we manage to get out of box JAVA semantic analyzer code, then we can tweak it to meet our need.

Additionally, we are also looking into Scala DSL features.

Any help in this regard is appreciated. Thanks

Was it helpful?

Solution

Scala currently has experimental support for a macro system. Macros provide a convenient, lightweight way to define new language features; they allow you to define DSLs without having to duplicate all the work that went into the base language. They can't do everything, but they can do a lot, and when they do suit the task, they're far easier to create and debug than writing a whole new language.

OTHER TIPS

You can get a lot of help from the Eclipse source code. It has public API that exposes the AST of Java files, annotated with all type bindings. However, I think you'll find tweaking that code quite challenging.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top