private Boolean getBooleanImpl(String propertyName) { String value = props.getString(propertyName); if (value != null) { Boolean result = Parse.parseBoolean(value, messageBundle); if (result != null) { return result; } props.remove(propertyName); } value = props.getString(propertyName); if (value != null) { Boolean result = Parse.parseBoolean(value, null); if (result != null) { return result; } throwBrokenDefault(propertyName, value); } return null; }
public static void main(String[] args) { // read name of source file from command line String simplfile = args[0]; // filename for output is basename.svml StringTokenizer st = new StringTokenizer(simplfile, "."); String classname = st.nextToken(); String svmlfile = classname + ".svml"; try { // parse simPL expression Expression simpl = Parse.fromFileName(simplfile); try { Type t = simpl.check(new TypeEnvironment()); System.out.println("Well-typed with type: " + t); } catch (TypeError e) { System.out.println(e); } /* * simPL input: 'simpl' is a valid simpl program that has been type * checked. */ INSTRUCTION[] ia = new Compiler(simpl).compile(); Compiler.displayInstructionArray(ia); try { // create object output stream ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(svmlfile)); // and write resulting instruction array to output stream oos.writeObject(ia); oos.close(); // indicate successful compilation to user System.out.println("sVML code written to " + svmlfile); } catch (Exception ex) { System.out.println("\ncannot write virtual machine code " + ex); } } // Lexical errors are treated nicely, giving an // error message with line and character of the // error (unfortunately, parse errors do not enjoy // such treatment yet) catch (SyntaxError e) { try { System.out.println(e); FileReader fr = new FileReader(simplfile); BufferedReader br = new BufferedReader(fr); String record = null; int line = e.line; int column = e.column; int lineCount = 0; int columnCount = 0; while ((record = br.readLine()) != null & lineCount++ < line) ; System.out.println(record); while (columnCount++ != column) System.out.print(" "); System.out.println("^"); } catch (Exception ex) { System.out.println(e); } } catch (FileNotFoundException e) { System.out.println(e); } catch (Exception e) { System.out.println(e); } }