|
Compiler
Compiles Kitsch code into an intermediate assembly-like language.
Setting UpDetails on downloading Kitsch and compiling the Compiler are available here. Using the CompilerAfter the compiler has been built, it resides in the projects /bin folder Usage: java Compiler infile [outfile] An input file must be specified for the compiler. The output file name is optional. If an output filename is not provided, it defaults to the infile with a ".ko" extension in the current directory. The compiler depends on other classes in the bin folder, therefore it must either be run from the /bin folder, or you must include it as part of Java's class path kitsch/bin $ java Compiler testFile.k kitsch $ java -classpath bin Compiler someFile.k Compiler DesignThe Compiler source code is available here. The design follows the standard Visitor pattern; pj2, which generates the parser for the language, is also kind enough to generate tree node classes and implement a visit() method for each of them. Rather than targeting an actual hardware platform - such as X86, or an existing virtual machine such as Sun Java's byte code or Microsoft's Common Language Runtime - Kitsch targets it's own simple 0-address (stack-based) assembly-like machine language. More details on target machine language can be found here. A virtual machine interprets the machine language. Details about the virtual machine can be found here. |