Java Reference
In-Depth Information
1.5 j--Compiler Source Tree
The zip file j--.zip containing the j-- distribution can be downloaded from http://www.cs
.umb.edu/j-- . The zip file may be unzipped into any directory of your choosing. Through-
out this topic, we refer to this directory as $j .
For a detailed description of what is in the software bundle; how to set up the compiler
for command-line execution; how to set up, run, and debug the software in Eclipse 10 ; and
how to add j-- test programs to the test framework, see Appendix A.
$j/j--/src/jminusminus contains the source files for the compiler, where jminusminus
is a package. These include
Main.java , the driver program;
a hand-written scanner ( Scanner.java ) and parser ( Parser.java );
J*.java files defining classes representing the AST nodes;
CL*.java files supplying the back-end code that is used by j-- for creating JVM byte
code; the most important file among these is CLEmitter.java , which provides the
interface between the front end and back end of the compiler;
S*.java files that translate JVM code to SPIM files (SPIM is an interpreter for the
MIPS machine's symbolic assembly language);
j--.jj , the input file to JavaCC 11 containing the specification for generating (as
opposed to hand-writing) a scanner and parser for the j-- language; JavaCCMain , the
driver program that uses the scanner and parser produced by JavaCC; and
Other Java files providing representation for types and the symbol table.
$j/j--/bin/j-- is a script to run the compiler. It has the following command-line
syntax:
Usage:j--<options><sourcefile>
wherepossibleoptionsinclude:
-tOnlytokenizeinputandprinttokenstoSTDOUT
-pOnlyparseinputandprintASTtoSTDOUT
-paOnlyparseandpre-analyzeinputandprintASTtoSTDOUT
-aOnlyparse,pre-analyze,andanalyzeinputandprintASTtoSTDOUT
-s<naive|linear|graph>GenerateSPIMcode
-r<num>Max.physicalregisters(1-18)availableforallocation;default=8
-d<dir>Specifywheretoplaceoutputfiles;default=.
For example, the j{ program $j/j--/tests/pass/HelloWorld.java can be compiled
using j-- as follows:
>$j/j--/bin/j--$j/j--/tests/pass/HelloWorld.java
to produce a HelloWorld.class file under pass folder within the current directory, which
can then be run as
>javapass.HelloWorld
to produce as output,
>Hello,World!
10 An open-source IDE; http://www.eclipse.org .
11 A scanner and parser generator for Java; http://javacc.dev.java.net/ .
 
Search WWH ::




Custom Search