To compile this program, put it in a file called "reverse.cmlt", say. To invoke the compiler on a DICE machine, typelet rev l acc = match l with  -> acc | h::t -> rev t (h::acc) let reverse l = rev l  let print_list l = match l with  -> print_string "\n" | h::t -> let _ = print_string (h ^ " ") in print_list t let start args = let _ = print_string "Input list: " in let _ = print_list args in let revargs = reverse args in let _ = print_string "Reversed list: " in print_list revargs
/group/project/mrg/bin/camelot reverse.cmlt(You can make a copy of the compiler or set up an alias to avoid having to type such a long command). The compiler should create a Java classfile called "reverse.class" along with another classfile which you can ignore for the time being.
export CLASSPATH=$CLASSPATH:/group/project/mrg/bin:.or by putting this command in your .bprofile file. Once the classpath has been set up properly the classfile is executed in the usual way:
java reverse 8 9 677 99 64 6 79 00 87 5This should run the program and print out the command-line arguments in reverse order.
For more information about Camelot, see the Camelot manual or a Gentle Introduction to Camelot (not yet complete).
/group/project/mrg/bin/camelot -g reverseThis will place the Grail translation of the program in the file "reverse.gr".
In addition, there are standalone programs called gdf and gf which will convert Grail to and from bytecode. For example, typing
/group/project/mrg/bin/gdf reverse.grwill compile the Grail program into JVM bytecode in the classfile reverse.class. This process can be reversed using the gf program:
/group/project/mrg/bin/gf reverseThis will decompile the classfile and write the Grail equivalent to the terminal. Note that you should leave out the .class extension to the filename when using gf. Note also that gf will usually only work with classfiles which have been compiled from Grail; the bytecode in classfiles compiled from Java is too irregular to allow decompilation to Grail.
If you wish to examine the actual JVM bytecode in a classfile, use the command "javap -c".