<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import java.io.StringWriter;
import java.io.PrintWriter;
import edu.cornell.cs.sam.io.SamTokenizer;

/**
 * This is an example of a BaliCompiler that does not work well.
 */
class BaliCompiler implements Compiler{
        /**
         * Compiles the Bali code into SaM code
         */
        public String compile(SamTokenizer in) throws IllegalBaliException{
                // Create a StringWriter to simplify printing stuff
                StringWriter outs = new StringWriter();
                // And a new PrintWriter to simplify things even more
                PrintWriter out = new PrintWriter(outs);
                // Print out some dumb code
                out.println("PUSHIMMSTR \"This compiler does not work\"");
                out.println("WRITESTR");
                out.println("PUSHIMM 0");
                out.println("STOP");
                // And dump it back
                return outs.toString();
        }
}
</pre></body></html>