Integrate/Use JFlex and Cup in JDK

Hi all,

I wanted to know, how could one integrate the use of JFlex and Cup into JMonkeyEngine?
I know there is a plugin for Eclipse, but there doesn’t seem to be one for Netbeans (which JDK is based upon, if I’m not mistaken), although it seems there are syntax highlight possibilities…

Is there a simple way to achieve this, or should I stick to the use of Windows’ terminal?

What are you trying to archive?

Be able to use JFlex and Cup into JMonkeyEngine, having automatised compilation, so that I can write a parser for a script language that I’ll use in my game.

Well If thats possible with that librarys in a normal java application, I see no reason, why it should not work within jme.

Well, my problem is not to use it with the rest of my java files; but to be able to call JFlex and Cup (via Ant?) directly from JME SDK to parse my lexer and parser files, and then compile them.

Sure thats possible.

http://wiki.netbeans.org/NetBeansDeveloperFAQ

Ah ok,

btw you do know that java intself has internally already a scripting engine that supports for example javascript, that is performance wise fine.

(Also as you intend to use it only via developing and not live, why do you want a specialized script language for this? As in what is the benefit you want compared to using plain java.

I’m building my own scripting language, for a self-made game engine. The language is used to define a basic API which correspond to a Java written API.
The script is then “compiled” into bytecode (a hand made bytecode, too, which is already done) so that I execute only “atomic” instructions (in the meaning that it correspond to a small Java method, being very fast to execute).

The future user of my engine can then use the language to make something like :
[java]
function createWave takes nothing returns nothing
Unit u = noUnit;
for each Integer i from 0 to 9
u = createUnit(unitType, position);
orderUnitToPoint(u, orderType, point);
end for
end
[/java]

The benefit is that this way, I can manage to switch between different bytecode execution, thus allowing the use of a sole thread and not having the problem of cross threading and object locking time, etc. Also, I can know exactly the execution state of the script and can then save it easily, to reload the game later.

@nomen : Hum… Could you tell what I’m supposed to look for? I mean, how it would be called? I’m feeling dizzy when browsing this very long FAQ ‘_’…

Into Cup’s doc, I’ve found the following way to integrate it into an ANT build file :
[java]
<taskdef name=“cup”
classname=“java_cup.anttask.CUPTask”
classpathref=“cupclasspath”
/>
[/java]
and
[java]

<target name=“cup”>
<cup srcfile=“path/to/cupfile/Parser.cup”
destdir=“path/to/javafiles”
interface=“true”
/>
</target>

[/java]

My building script being the one created and maintained by JME, where do I have to add these modifications? I guess I can use the same for JFlex?

Up?

Edit the Build File listed under the Important Files of your project.

Yes, but I don’t know where those lines belong to.
I’m not sure if I can put them in the same place I find other
<target…
</target>

I don’t know if you have found a solution for this but you can add your lines anywhere after this line in the build file:

[java]<import file=“nbproject/build-impl.xml”/>[/java]