//if arg's length = 1 private Node apply1(Node arg1) { string name = this.symbol.getName(); bool flag = name.Equals("car"); Node result; if (flag) { result = arg1.getCar(); }//end if else { bool flag2 = name.Equals("cdr"); if (flag2) { result = arg1.getCdr(); }//end if else { bool flag3 = name.Equals("number?"); if (flag3) { result = BoolLit.getInstance(arg1.isNumber()); }//end if else { bool flag4 = name.Equals("symbol?"); if (flag4) { result = BoolLit.getInstance(arg1.isSymbol()); }//end if else { bool flag5 = name.Equals("null?"); if (flag5) { result = BoolLit.getInstance(arg1.isNull()); }//end if else { bool flag6 = name.Equals("pair?"); if (flag6) { result = BoolLit.getInstance(arg1.isPair()); }//end if else { bool flag7 = name.Equals("procedure?"); if (flag7) { result = BoolLit.getInstance(arg1.isProcedure()); }//end if else { bool flag8 = name.Equals("write");// i am not sure if im handling this correctly if (flag8) { arg1.print(-1); result = Unspecific.getInstance(); }//end if else { bool flag9 = name.Equals("display"); // i am not sure if im handling this correctly if (flag9) { StringLit.printDoubleQuotes = false; arg1.print(-1); StringLit.printDoubleQuotes = true; result = Unspecific.getInstance(); }//end if else { bool flag10 = name.Equals("load"); if (flag10) { bool flag11 = !arg1.isString(); if (flag11) { Console.Error.WriteLine("Error: wrong type of argument"); result = Nil.getInstance(); } else { string stringVal = arg1.getStringVal(); try { //not sure why it has to be Parse.Scanner to call this Parse.Scanner s = new Parse.Scanner(File.OpenText(stringVal)); TreeBuilder b = new TreeBuilder(); Parse.Parser parser = new Parse.Parser(s, b); for (Node node = (Node)parser.parseExp(); node != null; node = (Node)parser.parseExp()) { node.eval(Scheme4101.env); } } catch (SystemException) { Console.Error.WriteLine("Could not find file " + stringVal); } result = Unspecific.getInstance(); } }//end if else { Console.Error.WriteLine("Error: wrong number of arguments"); result = Nil.getInstance(); } } } } } } }//end inner sub sub sub else }//end inner sub sub else }//end inner sub else }//end outer else return result; }
//if arg length = 0 private Node apply0() { string name = this.symbol.getName(); bool flag = name.Equals("read"); Node result; if (flag) { Parse.Scanner s = new Parse.Scanner(Console.In); Parse.Parser parser = new Parse.Parser(s, new TreeBuilder()); Node node = (Node)parser.parseExp(); bool flag2 = node != null; if (flag2) { result = node; } else { result = new Ident("end-of-file"); } }//end outer if else { bool flag3 = name.Equals("newline"); if (flag3) { Console.WriteLine(); result = Unspecific.getInstance(); } else { bool flag4 = name.Equals("interaction-environment"); if (flag4) { result = Scheme4101.env; } else { Console.Error.WriteLine("Error: wrong number of arguments"); result = Nil.getInstance(); } } }//end outer else return result; }