[Jscodee-devel] generating JSCode from other languages
Status: Alpha
Brought to you by:
garyfred
From: Gary F. <gar...@js...> - 2003-01-21 13:27:29
|
I found a project on sourceforge that is generating XML from gcc. http://sourceforge.net/projects/introspector/ We can use their project to generate JSCode from any compiler gcc supports. That could include Java, C, C++, Ada, Fortran and Pascal for starters. The idea would be to take a program, compile to get the XML and then translate the XML to JSCode. This will let us do things like convert programs from NQC to Java and back and to see what they look like graphically by viewing them as bricks. The introspector project leader generated some info for me. Thanks Mike! This simple Java program: public class test { public static void bb_Forward (int x ) { } public static void bb_TurnLeft (int x ){ } public static void main(String[] args) throws InterruptedException { for (int myIx = 0; myIx < 4; myIx++) { bb_Forward(100); bb_TurnLeft(75); } } } outputs something called ntriples http://introspector.sourceforge.net/2003/01/21/test.java/_global__.class_.ntriples The declaration of myIx in the ntriples has this info <#id-25> <node_fields#filename> <#filename-test.java> . <#id-25> <node_fields#linenumber> "18" . <#id-25> <node_fields#name> <node_types#identifier_node> . <#id-25> <node_fields#name> <#id-32> . <#id-32> <node_fields#strg> "myIx" . <#id-32> <node_fields#tree-code> <node_types#identifier_node> . <#id-25> <node_fields#algn> "32" . <#id-25> <node_fields#size> <node_types#integer_cst> . <#id-25> <node_fields#size> <#id-33> . <#id-25> <node_fields#type> <node_types#integer_type> . <#id-25> <node_fields#type> <#id-27> . <#id-25> <node_fields#tree-code> <node_types#var_decl> . Compile the Jave source and we get XML or rdf. We can then read the XML/rdf and translate that into JSCode. The above tells us that #id-25 is a node that holds an identifier named 'myIx' and that myIx is an int. We could translate that into this JSCode <block kind="basic" name="Variable"> <param kind="identifier">myIx</param> <param kind="integer">0</param> </block> woo hoo... Back to getting V0.3 to V0.4 :-) Gary |