I’m writing a simple scripting language on top of Java/JVM, where you can also embed Java code using the {} brackets. The problem is, how do I parse this in the grammar? I have two options:
- Allow everything to be in it, such as:
[a-z|a-Z|0-9|_|$], and go on - Get an extra java grammar and use that grammar to parse that small code (is it actually possible and efficient?)
Since option 2] is basically a double-check since when evaluating java code it’s also being checked. Now my last question is — is way that can dynamically execute java code also with objects which have been created at runtime?
Thanks,
William van Doorn
You can’t just do that: you’ll have to account for opening and closing brackets.
Yes that’s possible. But I suggest you first get something working, and then worry about efficiency (is that really an issue here?).
Yes, since Java 6, there’s a way to compile source files dynamically. See the JavaCompiler API.