├── Arrow.class ├── Arrow.java ├── ArrowDB.class ├── ArrowDB.java ├── Atom.class ├── Atom.java ├── Conscell.class ├── Conscell.java ├── DrawingConscellsPanel.class ├── DrawingConscellsPanel.java ├── DrawingTreesPanel$1.class ├── DrawingTreesPanel.class ├── DrawingTreesPanel.java ├── DrawingVarsPanel$1.class ├── DrawingVarsPanel$2.class ├── DrawingVarsPanel$3.class ├── DrawingVarsPanel$4.class ├── DrawingVarsPanel.class ├── DrawingVarsPanel.java ├── Environment.class ├── Environment.java ├── ErrorMess.class ├── ErrorMess.java ├── FileReaderWriter.class ├── FileReaderWriter.java ├── Function.class ├── Function.java ├── FunctionManager.class ├── FunctionManager.java ├── Interpreter.class ├── Interpreter.java ├── ListCC.class ├── ListCC.java ├── ListManager.class ├── ListManager.java ├── ListMatrix.class ├── ListMatrix.java ├── LogoPanel.class ├── LogoPanel.java ├── Mess.class ├── Mess.java ├── PVTS.class ├── PVTS.java ├── PVTSFrame$1.class ├── PVTSFrame$10.class ├── PVTSFrame$11.class ├── PVTSFrame$12.class ├── PVTSFrame$13.class ├── PVTSFrame$14.class ├── PVTSFrame$15.class ├── PVTSFrame$16.class ├── PVTSFrame$17.class ├── PVTSFrame$18.class ├── PVTSFrame$19.class ├── PVTSFrame$2.class ├── PVTSFrame$20.class ├── PVTSFrame$21.class ├── PVTSFrame$22.class ├── PVTSFrame$23.class ├── PVTSFrame$24.class ├── PVTSFrame$25.class ├── PVTSFrame$26.class ├── PVTSFrame$27.class ├── PVTSFrame$28.class ├── PVTSFrame$29.class ├── PVTSFrame$3.class ├── PVTSFrame$30.class ├── PVTSFrame$31.class ├── PVTSFrame$32.class ├── PVTSFrame$33.class ├── PVTSFrame$34.class ├── PVTSFrame$35.class ├── PVTSFrame$36.class ├── PVTSFrame$37.class ├── PVTSFrame$38.class ├── PVTSFrame$39.class ├── PVTSFrame$4.class ├── PVTSFrame$40.class ├── PVTSFrame$41.class ├── PVTSFrame$42.class ├── PVTSFrame$43.class ├── PVTSFrame$44.class ├── PVTSFrame$45.class ├── PVTSFrame$46.class ├── PVTSFrame$47.class ├── PVTSFrame$48.class ├── PVTSFrame$49.class ├── PVTSFrame$5.class ├── PVTSFrame$50.class ├── PVTSFrame$51.class ├── PVTSFrame$52.class ├── PVTSFrame$53.class ├── PVTSFrame$54.class ├── PVTSFrame$55.class ├── PVTSFrame$56.class ├── PVTSFrame$57.class ├── PVTSFrame$58.class ├── PVTSFrame$59.class ├── PVTSFrame$6.class ├── PVTSFrame$60.class ├── PVTSFrame$61.class ├── PVTSFrame$62.class ├── PVTSFrame$63.class ├── PVTSFrame$7.class ├── PVTSFrame$8.class ├── PVTSFrame$9.class ├── PVTSFrame$MyHighlightPainter.class ├── PVTSFrame.class ├── PVTSFrame.form ├── PVTSFrame.java ├── Primitive.class ├── Primitive.java ├── PrintUtilities.class ├── PrintUtilities.java ├── Procedure.class ├── Procedure.java ├── ProcedureAndArgs.class ├── ProcedureAndArgs.java ├── ReadEvalPrint$ParseError.class ├── ReadEvalPrint.class ├── ReadEvalPrint.java ├── RecuFunc.class ├── RecuFunc.java ├── SEBool.class ├── SEBool.java ├── SEChar.class ├── SEChar.java ├── SEFloat.class ├── SEFloat.java ├── SEInt.class ├── SEInt.java ├── SEName.class ├── SEName.java ├── SENumber.class ├── SENumber.java ├── SEString.class ├── SEString.java ├── SESymbol.class ├── SESymbol.java ├── SExpression.class ├── SExpression.java ├── TextIO.class ├── TextIO.java └── dist └── 0.243 ├── PVTS.exe └── PVTS.jar /Arrow.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/Arrow.class -------------------------------------------------------------------------------- /Arrow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Arrow.java 4 | * 5 | * Author: David Pilo 6 | * 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | 30 | 31 | import java.awt.*; 32 | import java.awt.event.*; 33 | import java.util.*; 34 | 35 | class Arrow { 36 | Conscell conscell; 37 | SExpression sexpr; 38 | static int antiColVarVARIANCE = 20; 39 | int my_antiColVar; 40 | int unitDraw = DrawingConscellsPanel.zoom; 41 | int startX, startY, endX, endY; 42 | static int antiColVar = 0; 43 | static Random ran = new Random(); 44 | 45 | Arrow(Conscell c, SExpression s) { 46 | conscell = c; 47 | sexpr = s; 48 | updateantiColVar(); 49 | my_antiColVar = antiColVar; 50 | ArrowDB.addAndChangeColVar(this); 51 | } 52 | 53 | public int getColVar() { 54 | return my_antiColVar; 55 | } 56 | 57 | public void setColVar(int i) { 58 | my_antiColVar = i; 59 | } 60 | 61 | public static void updateantiColVar() { 62 | antiColVar = ran.nextInt(antiColVarVARIANCE) - antiColVarVARIANCE/2; 63 | //TextIO.putln("ran =" + my_antiColVar); 64 | } 65 | 66 | 67 | public void setXYs(int sX, int sY, int eX, int eY) { 68 | startX = sX; 69 | startY = sY; 70 | endX = eX; 71 | endY = eY; 72 | } 73 | 74 | public int getsX() { 75 | return startX; 76 | } 77 | 78 | public int getsY() { 79 | return startY; 80 | } 81 | 82 | public int geteX() { 83 | return endX; 84 | } 85 | 86 | public int geteXY() { 87 | return endY; 88 | } 89 | 90 | 91 | public void drawCdr(Graphics g) { 92 | //updatemy_antiColVar(); 93 | if (conscell.getY() == sexpr.getY()) { 94 | setXYs(conscell.getX() + (int)(1.5 * unitDraw),conscell.getY() - (int) (0.5 * unitDraw),sexpr.getX(),sexpr.getY()-(int)(0.5 * unitDraw)); 95 | g.drawLine(startX,startY,endX,endY); 96 | g.drawLine(endX-3,endY-3,endX,endY); 97 | if (startX == endX) // then vertical line 98 | g.drawLine(endX+3,endY-3,endX,endY); 99 | else 100 | g.drawLine(endX-3,endY+3,endX,endY); 101 | } else // that is the case when the conscells are not in the same "horizontal" line. 102 | { 103 | g.drawLine(conscell.getX() + (int)(1.5 * unitDraw),conscell.getY() - (int) (0.5 * unitDraw),conscell.getX() + (int)(2.5 * unitDraw),conscell.getY() - (int) (0.5 * unitDraw)); 104 | int tempX = sexpr.getX() - conscell.getX(); 105 | int tempY = sexpr.getY() - conscell.getY(); 106 | if (tempY > 0) 107 | tempY = tempY - unitDraw; 108 | else 109 | tempY = tempY + unitDraw; 110 | g.drawLine(conscell.getX() + (int)(2.5 * unitDraw),conscell.getY() - (int) (0.5 * unitDraw), conscell.getX() + (int)(2.5 * unitDraw), conscell.getY() - (int) (0.5 * unitDraw) + tempY+my_antiColVar); 111 | g.drawLine(conscell.getX() + (int)(2.5 * unitDraw), conscell.getY() - (int) (0.5 * unitDraw) + tempY+my_antiColVar, conscell.getX() + (int)(2.5 * unitDraw) + tempX - (3 * unitDraw), conscell.getY() - (int) (0.5 * unitDraw) + tempY+my_antiColVar); 112 | int temp = 0; 113 | if (tempY > 0) 114 | temp = unitDraw; 115 | else 116 | temp = (0 - unitDraw); 117 | g.drawLine(conscell.getX() + (int)(2.5 * unitDraw) + tempX - (3 * unitDraw), conscell.getY() - (int) (0.5 * unitDraw) + tempY+my_antiColVar, conscell.getX() + (int)(2.5 * unitDraw) + tempX - (3 * unitDraw), conscell.getY() - (int) (0.5 * unitDraw) + tempY + temp); 118 | setXYs(conscell.getX() + (int)(2.5 * unitDraw) + tempX - (3 * unitDraw), conscell.getY() - (int) (0.5 * unitDraw) + tempY + temp, conscell.getX() + (int)(2.5 * unitDraw) + tempX - (3 * unitDraw) + (unitDraw / 2), conscell.getY() - (int) (0.5 * unitDraw) + tempY + temp); 119 | g.drawLine(startX,startY,endX,endY); 120 | // g.drawLine(endX-3,endY-3,endX,endY); 121 | // g.drawLine(endX-3,endY+3,endX,endY); 122 | 123 | 124 | 125 | 126 | } 127 | 128 | Polygon tmpPoly=new Polygon(); 129 | tmpPoly.addPoint(endX,endY); 130 | tmpPoly.addPoint(endX-3,endY-3); 131 | tmpPoly.addPoint(endX-3,endY+3); 132 | tmpPoly.addPoint(endX,endY); 133 | g.drawPolygon(tmpPoly); 134 | g.fillPolygon(tmpPoly); 135 | } 136 | public void drawCar(Graphics g) { 137 | int sx,sy,ex,ey; 138 | //updatemy_antiColVar(); 139 | //int tempX,tempY; 140 | if (sexpr.getClass().getName().equals("ListCC") && (!(((ListCC) sexpr).isEmpty()))) { 141 | //TextIO.putln("its a list"); 142 | sx = conscell.getX() + (int)(0.5 * unitDraw); 143 | sy = conscell.getY() - (int) (0.5 * unitDraw); 144 | ex = ((ListCC) sexpr).getFirst().getX() + (int)(0.5 * unitDraw); 145 | ey = ((ListCC) sexpr).getFirst().getY() - (int) (0.5 * unitDraw); 146 | } else { 147 | sx = conscell.getX() + (int) (0.5 * unitDraw); 148 | sy = conscell.getY() - (int) (0.5 * unitDraw); 149 | ex = sexpr.getX() + (int) (0.5 * unitDraw); 150 | ey = sexpr.getY() - (int) (0.5 * unitDraw); 151 | } 152 | 153 | // int temp = 0; 154 | if (ey == sy) 155 | my_antiColVar = 0; 156 | 157 | if ((ey - sy) > 0) { 158 | g.drawLine(sx,sy,sx,ey - (unitDraw)+my_antiColVar); 159 | g.drawLine(sx,ey - (unitDraw)+my_antiColVar, ex, ey - (unitDraw)+my_antiColVar); 160 | setXYs(ex, ey - (unitDraw)+my_antiColVar,ex,ey - (unitDraw/2)); 161 | g.drawLine(startX,startY,endX,endY); 162 | // g.drawLine(endX-3,endY-3,endX,endY); 163 | //if (startX == endX) // then vertical line 164 | // g.drawLine(endX+3,endY-3,endX,endY); 165 | Polygon tmpPoly=new Polygon(); 166 | tmpPoly.addPoint(endX,endY); 167 | tmpPoly.addPoint(endX+3,endY-3); 168 | tmpPoly.addPoint(endX-3,endY-3); 169 | tmpPoly.addPoint(endX,endY); 170 | g.drawPolygon(tmpPoly); 171 | g.fillPolygon(tmpPoly); 172 | // else 173 | // g.drawLine(endX-3,endY+3,endX,endY); 174 | } else { 175 | g.drawLine(sx,sy,sx,sy - (unitDraw)+my_antiColVar); 176 | if (ex > sx) 177 | g.drawLine(sx,sy-(unitDraw)+my_antiColVar,ex-(unitDraw)+my_antiColVar,sy-(unitDraw)+my_antiColVar); 178 | else { 179 | g.drawLine(sx,sy-(unitDraw)+my_antiColVar,ex,sy-(unitDraw)+my_antiColVar); 180 | g.drawLine(ex,sy-(unitDraw)+my_antiColVar, ex-(unitDraw)+my_antiColVar,sy-(unitDraw)+my_antiColVar); 181 | } 182 | g.drawLine(ex-(unitDraw)+my_antiColVar,sy-(unitDraw)+my_antiColVar, ex - unitDraw+my_antiColVar, ey - unitDraw); 183 | g.drawLine(ex - unitDraw+my_antiColVar, ey - unitDraw, ex, ey -unitDraw); 184 | setXYs(ex, ey -unitDraw,ex,ey - (unitDraw/2)); 185 | g.drawLine(startX,startY,endX,endY); 186 | // g.drawLine(endX-3,endY-3,endX,endY); 187 | //if (startX == endX) // then vertical line 188 | // g.drawLine(endX+3,endY-3,endX,endY); 189 | Polygon tmpPoly=new Polygon(); 190 | tmpPoly.addPoint(endX,endY); 191 | tmpPoly.addPoint(endX+3,endY-3); 192 | tmpPoly.addPoint(endX-3,endY-3); 193 | tmpPoly.addPoint(endX,endY); 194 | g.drawPolygon(tmpPoly); 195 | g.fillPolygon(tmpPoly); 196 | } 197 | 198 | 199 | } 200 | 201 | } -------------------------------------------------------------------------------- /ArrowDB.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/ArrowDB.class -------------------------------------------------------------------------------- /ArrowDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * ArrowDB.java 4 | * 5 | * Author: David Pilo 6 | * 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | 30 | 31 | import java.awt.*; 32 | import java.awt.event.*; 33 | import java.util.*; 34 | 35 | 36 | class ArrowDB { 37 | static ArrayList arrowArray = new ArrayList(); 38 | 39 | ArrowDB() { 40 | 41 | } 42 | 43 | 44 | public static void addAndChangeColVar(Arrow a) { 45 | boolean contained = false; 46 | for (Arrow ar: arrowArray) { 47 | if (sameArrow(a, ar)) { 48 | a.setColVar(ar.getColVar()); 49 | contained = true; 50 | } 51 | } 52 | if (!contained) 53 | arrowArray.add(a); 54 | } 55 | 56 | 57 | 58 | public static boolean sameArrow(Arrow a, Arrow b) { 59 | //return (a.conscell == b.conscell && a.sexpr == b.sexpr); 60 | return (a.conscell.x == b.conscell.x && a.conscell.y == b.conscell.y && a.sexpr.x == b.sexpr.x && a.sexpr.y == b.sexpr.y); 61 | } 62 | 63 | 64 | 65 | } -------------------------------------------------------------------------------- /Atom.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/Atom.class -------------------------------------------------------------------------------- /Atom.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Atom.java 4 | * 5 | * Author: David Pilo 6 | * 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | 30 | abstract class Atom extends SExpression { 31 | 32 | abstract String getPrintable(); 33 | public String toString() { 34 | return getPrintable(); 35 | } 36 | } -------------------------------------------------------------------------------- /Conscell.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/Conscell.class -------------------------------------------------------------------------------- /Conscell.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Conscell.java 4 | * 5 | * Author: David Pilo 6 | * 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | 30 | 31 | 32 | 33 | import java.awt.*; 34 | import java.awt.event.*; 35 | 36 | public class Conscell extends SExpression { 37 | int unitDraw = DrawingConscellsPanel.zoom; 38 | SExpression car; 39 | Conscell cdr; 40 | SExpression dotted; 41 | 42 | 43 | public Conscell() { 44 | car = null; 45 | cdr = null; 46 | dotted = null; 47 | x = 0; 48 | y = 0; 49 | } 50 | 51 | public Conscell (SExpression e1, SExpression e2) { 52 | car = e1; 53 | dotted = e2; 54 | cdr = null; 55 | x = 0; 56 | y = 0; 57 | } 58 | 59 | public Conscell(SExpression cr) { 60 | car = cr; 61 | cdr = null; 62 | dotted = null; 63 | x = 0; 64 | y = 0; 65 | } 66 | 67 | public Conscell copy() { 68 | Conscell temp = new Conscell(); 69 | temp.setCar(this.getCar().copy()); 70 | if (this.getDotted() != null) 71 | temp.setDotted(this.getDotted().copy()); 72 | if (!(this.getCdr() == null)) 73 | temp.setCdr(this.getCdr().copy()); 74 | //TextIO.put("done conscell copy"); 75 | return temp; 76 | } 77 | 78 | 79 | 80 | /* public Conscell (SExpression cr, Conscell cd) 81 | { 82 | car = cr; 83 | cdr = cd; 84 | x = 0; 85 | y = 0; 86 | }*/ 87 | 88 | 89 | public String toString() { 90 | return car.toString(); 91 | } 92 | 93 | // May not need this one 94 | boolean hasSuccessor() { 95 | return (cdr != null); 96 | } 97 | 98 | boolean isDottedPair() { 99 | return (dotted != null); 100 | } 101 | 102 | void setCar(SExpression c) { 103 | car = c; 104 | } 105 | 106 | void setCdr(Conscell c) { 107 | cdr = c; 108 | } 109 | 110 | void setDotted (SExpression c) { 111 | dotted = c; 112 | } 113 | 114 | SExpression getDotted() { 115 | return dotted; 116 | } 117 | 118 | SExpression getCar() { 119 | return car; 120 | } 121 | 122 | Conscell getCdr() { 123 | return cdr; 124 | } 125 | 126 | 127 | void print() { 128 | if (this.isDottedPair()) { 129 | car.print(); 130 | dotted.print(); 131 | } 132 | else 133 | car.print(); 134 | } 135 | 136 | 137 | public int getX() { 138 | return x; 139 | } 140 | 141 | public int getY() { 142 | return y; 143 | } 144 | 145 | 146 | 147 | 148 | public void draw(Graphics g) { 149 | Color temp = g.getColor(); 150 | g.setColor(DrawingConscellsPanel.color); 151 | g.fillRect(x,y-unitDraw,(2*unitDraw),(unitDraw)); 152 | g.setColor(temp); 153 | g.drawLine( x, y, x+(2*unitDraw), y); 154 | g.drawLine( x+(2*unitDraw), y, x+(2*unitDraw), y-unitDraw); 155 | g.drawLine( x+(2*unitDraw), y-unitDraw, x, y-unitDraw); 156 | g.drawLine( x, y-unitDraw, x, y); 157 | g.drawLine( x+unitDraw, y, x+unitDraw, y-unitDraw); 158 | 159 | if (this.getCar() != null) { 160 | Arrow toCar = new Arrow(this,this.getCar()); 161 | toCar.drawCar(g); 162 | this.getCar().draw(g); 163 | } 164 | if (this.getCdr() == null && !this.isDottedPair()) 165 | { 166 | drawNull(g,this); 167 | } 168 | if (this.isDottedPair()) { 169 | g.drawLine(x+unitDraw+(unitDraw/2),y-(unitDraw/2),x+unitDraw+(unitDraw/2),y+unitDraw); 170 | // g.drawLine(x+unitDraw+(unitDraw/2),y+unitDraw,x+unitDraw+(unitDraw/2)-3,y+unitDraw-3); 171 | // g.drawLine(x+unitDraw+(unitDraw/2),y+unitDraw,x+unitDraw+(unitDraw/2)+3,y+unitDraw-3); 172 | Polygon tmpPoly=new Polygon(); 173 | tmpPoly.addPoint(x+unitDraw+(unitDraw/2),y+unitDraw); 174 | tmpPoly.addPoint(x+unitDraw+(unitDraw/2)-3,y+unitDraw-3); 175 | tmpPoly.addPoint(x+unitDraw+(unitDraw/2)+3,y+unitDraw-3); 176 | tmpPoly.addPoint(x+unitDraw+(unitDraw/2),y+unitDraw); 177 | g.drawPolygon(tmpPoly); 178 | g.fillPolygon(tmpPoly); 179 | dotted.setXY(x+unitDraw,y+unitDraw+unitDraw); 180 | dotted.draw(g); 181 | } 182 | else { 183 | if (this.getCdr() != null) { 184 | Arrow toCdr = new Arrow(this, this.getCdr()); 185 | toCdr.drawCdr(g); 186 | this.getCdr().draw(g); 187 | } 188 | } 189 | 190 | } 191 | 192 | public void drawNull(Graphics g, Conscell c) { 193 | 194 | g.drawLine(c.getX() + unitDraw,c.getY(),c.getX() + (2*unitDraw), c.getY() - unitDraw); 195 | } 196 | 197 | 198 | } //END conscell -------------------------------------------------------------------------------- /DrawingConscellsPanel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/DrawingConscellsPanel.class -------------------------------------------------------------------------------- /DrawingConscellsPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * DrawingConscellsPanel.java 4 | * 5 | * Author: David Pilo 6 | * 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | 30 | 31 | 32 | 33 | import javax.swing.*; 34 | import java.awt.*; 35 | import java.util.*; 36 | 37 | public class DrawingConscellsPanel extends JPanel { 38 | 39 | public static int veryold_a = 0; 40 | public static int old_a = 0; 41 | public static Color color; 42 | public static Color bcolor; 43 | static public Color defaultc; 44 | static public int zoom = 16; 45 | 46 | 47 | DrawingConscellsPanel () { 48 | // Set background color for the applet's panel. 49 | this.color = new Color(153,204,255); 50 | defaultc = this.getBackground(); 51 | this.bcolor = Color.white; 52 | setBackground (bcolor); 53 | } // ctor 54 | 55 | public void paintComponent(Graphics g) { 56 | // Paint background 57 | super.paintComponent(g); 58 | 59 | 60 | // Get the drawing area 61 | this.setBackground(this.bcolor); 62 | draw_list_of_lists(PVTS.orphan_list_of_lists,Color.gray,g,true); 63 | draw_list_of_lists(PVTS.list_of_lists,Color.black,g,false); 64 | 65 | this.setPreferredSize(new Dimension(PVTS.b,PVTS.a)); 66 | 67 | 68 | } // paintComponent 69 | 70 | 71 | 72 | 73 | public void draw_list_of_lists(LinkedList l, Color c, Graphics g,boolean t){ 74 | // Prints the whole list of Conscells 75 | 76 | if (l == null) { 77 | //TextIO.put("yo i got a null list"); 78 | return; 79 | } 80 | // TextIO.putln("0"); 81 | ListIterator lI = l.listIterator(); 82 | g.setColor(c); 83 | Color temp = g.getColor(); 84 | //old_a = 0; 85 | while (lI.hasNext()){ 86 | ListCC e = (ListCC) lI.next(); 87 | // e.draw(g); 88 | if (PVTSFrame.stepper_mode && t) { 89 | g.setColor(Color.YELLOW); 90 | /* Polygon tmpPoly=new Polygon(); 91 | tmpPoly.addPoint(0,old_a); 92 | tmpPoly.addPoint(10,old_a); 93 | tmpPoly.addPoint(10,old_a-10); 94 | tmpPoly.addPoint(15,old_a); 95 | tmpPoly.addPoint(10,old_a+20); 96 | tmpPoly.addPoint(0,old_a+20); 97 | g.fillPolygon(tmpPoly);*/ 98 | if (old_a == PVTS.a) 99 | g.fillRect(0,veryold_a-25,5000,PVTS.a - veryold_a); 100 | else 101 | g.fillRect(0,old_a-25,5000,PVTS.a - old_a); 102 | g.setColor(temp); 103 | 104 | if (old_a != PVTS.a) 105 | veryold_a = old_a; 106 | old_a = PVTS.a; 107 | } 108 | e.draw(g); 109 | } 110 | } 111 | } // class DrawingConscellsPanel 112 | -------------------------------------------------------------------------------- /DrawingTreesPanel$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/DrawingTreesPanel$1.class -------------------------------------------------------------------------------- /DrawingTreesPanel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/DrawingTreesPanel.class -------------------------------------------------------------------------------- /DrawingTreesPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DrawingTreesPanel.java 3 | * 4 | * Created on August 3, 2006, 11:50 AM 5 | * 6 | * Author: David Pilo 7 | * 8 | * Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | import java.awt.event.MouseEvent; 30 | import javax.swing.*; 31 | import java.awt.*; 32 | import java.util.*; 33 | /** 34 | * 35 | * @author david 36 | */ 37 | public class DrawingTreesPanel extends JPanel { 38 | 39 | 40 | 41 | //static PopupFactory factory = PopupFactory.getSharedInstance(); 42 | // static LinkedList list_of_popups = new LinkedList(); 43 | // public static LinkedList tagList = new LinkedList(); 44 | // public static Popup popup; 45 | // public static int old_x=0; 46 | public static int old_y=0; 47 | public static int veryold_y=0; 48 | public static ProcedureAndArgs currentlySelected = null; 49 | public static Color color; 50 | public static Color bcolor; 51 | static public Color defaultc; 52 | /** Creates a new instance of DrawingTreesPanel */ 53 | public DrawingTreesPanel() { 54 | this.color = new Color(255,204,153); 55 | defaultc = this.getBackground(); 56 | this.bcolor = Color.WHITE; 57 | setBackground (bcolor); 58 | //JInternalFrame funcTag = new JInternalFrame(); 59 | 60 | /* this.addMouseMotionListener(new javax.swing.event.MouseInputListener() { 61 | public void mouseClicked(MouseEvent mouseEvent) { 62 | } 63 | public void mouseDragged(MouseEvent mouseEvent) { 64 | } 65 | public void mouseEntered(MouseEvent mouseEvent) { 66 | } 67 | public void mouseExited(MouseEvent mouseEvent) { 68 | } 69 | public void mouseMoved(MouseEvent mouseEvent) { 70 | Point loc = mouseEvent.getPoint(); 71 | ProcedureAndArgs current; 72 | for (int i = 0; i < PVTS.list_of_trees.size(); i++) { 73 | for (int j = 0; j < ((FunctionManager) PVTS.list_of_trees.get(i)).theTree.size() ; j++) { 74 | for (int k = 0; k < ((LinkedList)((FunctionManager)PVTS.list_of_trees.get(i)).theTree.get(j)).size(); k++) { 75 | if (((LinkedList)((FunctionManager)PVTS.list_of_trees.get(i)).theTree.get(j)).get(k).getClass().getName().equalsIgnoreCase("ProcedureAndArgs")) { 76 | current = ((ProcedureAndArgs)((LinkedList)((FunctionManager)PVTS.list_of_trees.get(i)).theTree.get(j)).get(k)); 77 | if (popup != null) popup.hide(); 78 | if (loc.x <= (current.xCoor + current.width) && loc.x >= current.xCoor 79 | && loc.y <= (current.yCoor + current.height) && loc.y >= current.yCoor) { 80 | 81 | String s = current.p+current.sexprs.toString(); 82 | if (current.result.isListCC() || current.result.isAtom()) 83 | s = s + " => " + current.result.toString(); 84 | // PVTSFrame.functag.setText(s); 85 | // currentlySelected = current; 86 | 87 | 88 | // if (!list_of_popups.contains(current)) { 89 | // list_of_popups.add(current); 90 | 91 | popup = factory.getPopup(PVTSFrame.ftrees, 92 | new JLabel(s),java.awt.MouseInfo.getPointerInfo().getLocation().x+20, 93 | java.awt.MouseInfo.getPointerInfo().getLocation().y-20); 94 | 95 | // Popup popup = factory.getPopup(PVTSFrame.ftrees, 96 | //// new JLabel(s),loc.x, 97 | // loc.y+22); 98 | 99 | 100 | 101 | popup.show(); 102 | // popup.wait() 103 | PVTSFrame.ftrees.repaint(); 104 | } 105 | } 106 | } 107 | } 108 | } 109 | 110 | } 111 | public void mousePressed(MouseEvent mouseEvent) { 112 | } 113 | public void mouseReleased(MouseEvent mouseEvent) { 114 | } 115 | });*/ 116 | 117 | this.addMouseListener(new java.awt.event.MouseListener() { 118 | public void mouseClicked(MouseEvent mouseEvent) { 119 | Point loc = mouseEvent.getPoint(); 120 | ProcedureAndArgs current; 121 | for (int i = 0; i < PVTS.list_of_trees.size(); i++) { 122 | for (int j = 0; j < ((FunctionManager) PVTS.list_of_trees.get(i)).theTree.size() ; j++) { 123 | for (int k = 0; k < ((LinkedList)((FunctionManager)PVTS.list_of_trees.get(i)).theTree.get(j)).size(); k++) { 124 | if (((LinkedList)((FunctionManager)PVTS.list_of_trees.get(i)).theTree.get(j)).get(k).getClass().getName().equalsIgnoreCase("ProcedureAndArgs")) { 125 | current = ((ProcedureAndArgs)((LinkedList)((FunctionManager)PVTS.list_of_trees.get(i)).theTree.get(j)).get(k)); 126 | if (loc.x <= (current.xCoor + current.width) && loc.x >= current.xCoor 127 | && loc.y <= (current.yCoor + current.height) && loc.y >= current.yCoor) { 128 | 129 | String s = current.p+current.sexprs.toString(); 130 | if (current.result.isListCC() || current.result.isAtom()) 131 | s = s + " => " + current.result.toString(); 132 | PVTSFrame.functag.setText(s); 133 | currentlySelected = current; 134 | PVTSFrame.ftrees.repaint(); 135 | 136 | // if (!list_of_popups.contains(current)) { 137 | // list_of_popups.add(current); 138 | 139 | // // Popup popup = factory.getPopup(PVTSFrame.ftrees, 140 | // new JLabel(s),loc.x+PVTSFrame.ftrees.getLocation().x, 141 | // loc.y+22+PVTSFrame.ftrees.getLocation().y); 142 | 143 | // Popup popup = factory.getPopup(PVTSFrame.ftrees, 144 | //// new JLabel(s),loc.x, 145 | // loc.y+22); 146 | 147 | // popup.show(); 148 | //PVTSFrame.scrollPaneT.get 149 | // list_of_popups.add(popup); 150 | // } 151 | 152 | 153 | 154 | // tagList.add(new JFrame()); 155 | //PVTSFrame.ftrees.add(tagList.getLast()); 156 | // tagList.getLast().setAlwaysOnTop(true); 157 | // tagList.getLast().add(new JLabel(current.p+current.sexprs.toString())); 158 | // tagList.getLast().setSize(new Dimension((current.p+current.sexprs.toString()).length()*5,10)); 159 | // tagList.getLast().setLocation(loc.x+PVTSFrame.ftrees.getLocation().x,loc.y+PVTSFrame.ftrees.getLocation().y+22); 160 | // tagList.getLast().setVisible(true); 161 | } 162 | } 163 | 164 | } 165 | } 166 | } 167 | } 168 | public void mouseEntered(MouseEvent mouseEvent) { 169 | } 170 | public void mouseExited(MouseEvent mouseEvent) { 171 | } 172 | public void mousePressed(MouseEvent mouseEvent) { 173 | } 174 | public void mouseReleased(MouseEvent mouseEvent) { 175 | } 176 | 177 | } 178 | ); 179 | } 180 | 181 | 182 | /* public static void clearTagList () { 183 | for (int i = 0; i < tagList.size(); i++) { 184 | tagList.get(0).dispose(); 185 | tagList.remove(tagList.get(0)); 186 | } 187 | //tagList.removeAll(); 188 | }*/ 189 | public void paintComponent(Graphics g) { 190 | // Paint background 191 | super.paintComponent(g); 192 | this.setBackground(this.bcolor); 193 | draw_list_of_trees(PVTS.list_of_trees,g); 194 | // draw_popups(); 195 | this.setPreferredSize(new Dimension(FunctionManager.max_x, FunctionManager.current_y+150)); 196 | } // paintComponent 197 | 198 | 199 | /* public void draw_popups() { 200 | int min_x = PVTSFrame.ftrees.getLocation().x; 201 | int min_y = PVTSFrame.ftrees.getLocation().y; 202 | int max_x = PVTSFrame.ftrees.getSize().width; 203 | int max_y = PVTSFrame.ftrees.getSize().height; 204 | int p = PVTSFrame.scrollPaneT.getVerticalScrollBar().getValue(); 205 | 206 | // for (int i = 1; i < list_of_popups.size(); i = i+2) { 207 | // if (((Popup)list_of_popups.get(i)). 208 | // } 209 | 210 | }*/ 211 | //java.awt.RenderingHints //antialiasing? 212 | 213 | public void draw_list_of_trees(LinkedList l,Graphics g) { 214 | 215 | 216 | if( l == null) { 217 | return; 218 | } 219 | Color temp = g.getColor(); 220 | ListIterator lI = l.listIterator(); 221 | FunctionManager.current_y = 10; 222 | FunctionManager.max_x = 0; 223 | while (lI.hasNext()){ 224 | /* if (PVTSFrame.stepper_mode) { 225 | g.setColor(Color.YELLOW); 226 | Polygon tmpPoly=new Polygon(); 227 | tmpPoly.addPoint(0,old_a); 228 | tmpPoly.addPoint(10,old_a); 229 | tmpPoly.addPoint(10,old_a-10); 230 | tmpPoly.addPoint(15,old_a); 231 | tmpPoly.addPoint(10,old_a+20); 232 | tmpPoly.addPoint(0,old_a+20); 233 | g.fillPolygon(tmpPoly); 234 | if (old_y == FunctionManager.current_y) 235 | g.fillRect(0,veryold_y-25,5000,FunctionManager.current_y - veryold_y); 236 | else 237 | g.fillRect(0,old_y-25,5000,FunctionManager.current_y - old_y); 238 | g.setColor(temp); 239 | 240 | if (old_y != FunctionManager.current_y) 241 | veryold_y = old_y; 242 | old_y = FunctionManager.current_y; 243 | } */ 244 | FunctionManager m = (FunctionManager) lI.next(); 245 | m.draw(g); 246 | FunctionManager.current_y = FunctionManager.current_y + (int)( 50 * FunctionManager.zoom); 247 | 248 | } 249 | if (currentlySelected != null) { 250 | g.setColor(Color.RED); 251 | g.drawRoundRect(currentlySelected.xCoor,currentlySelected.yCoor,currentlySelected.width,currentlySelected.height,20,20); 252 | g.drawRoundRect(currentlySelected.xCoor-1,currentlySelected.yCoor-1,currentlySelected.width+2,currentlySelected.height+2,20,20); 253 | } 254 | } 255 | 256 | 257 | 258 | 259 | } 260 | -------------------------------------------------------------------------------- /DrawingVarsPanel$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/DrawingVarsPanel$1.class -------------------------------------------------------------------------------- /DrawingVarsPanel$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/DrawingVarsPanel$2.class -------------------------------------------------------------------------------- /DrawingVarsPanel$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/DrawingVarsPanel$3.class -------------------------------------------------------------------------------- /DrawingVarsPanel$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/DrawingVarsPanel$4.class -------------------------------------------------------------------------------- /DrawingVarsPanel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/DrawingVarsPanel.class -------------------------------------------------------------------------------- /DrawingVarsPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DrawingVarsPanel.java 3 | * 4 | * Created on August 22, 2006, 4:31 PM 5 | * 6 | * Author: David Pilo 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | import java.awt.event.MouseEvent; 30 | import javax.swing.*; 31 | import java.awt.*; 32 | import java.util.*; 33 | /** 34 | * 35 | 36 | /** 37 | * 38 | * @author david 39 | */ 40 | public class DrawingVarsPanel extends JPanel { 41 | 42 | 43 | public static boolean varTableShow = true; 44 | public static boolean primTableShow = false; 45 | public static boolean procTableShow = true; 46 | public static boolean listTableShow = true; 47 | public JTable primTable = new JTable(300,1); 48 | public JTable procTable = new JTable(300,2); 49 | public JTable listTable = new JTable(300,2); 50 | public JTable varsTable = new JTable(300,2); 51 | public JLabel primLabel = new JLabel("Primitives:"); 52 | public JLabel procLabel = new JLabel("Procedures:"); 53 | public JLabel listLabel = new JLabel("Lists Variables:"); 54 | public JLabel varsLabel = new JLabel("Other Variables:"); 55 | public JPanel primPanel = new JPanel(); 56 | public JPanel procPanel = new JPanel(); 57 | public JPanel listPanel = new JPanel(); 58 | public JPanel varsPanel = new JPanel(); 59 | 60 | /** Creates a new instance of DrawingTreesPanel */ 61 | public DrawingVarsPanel() { 62 | primPanel.add(primLabel); 63 | primPanel.add(primTable); 64 | primPanel.setLayout(new BoxLayout(primPanel, BoxLayout.PAGE_AXIS)); 65 | procPanel.add(procLabel); 66 | procPanel.add(procTable); 67 | procPanel.setLayout(new BoxLayout(procPanel, BoxLayout.PAGE_AXIS)); 68 | listPanel.add(listLabel); 69 | listPanel.add(listTable); 70 | listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.PAGE_AXIS)); 71 | varsPanel.add(varsLabel); 72 | varsPanel.add(varsTable); 73 | varsPanel.setLayout(new BoxLayout(varsPanel, BoxLayout.PAGE_AXIS)); 74 | 75 | 76 | this.add(listPanel); 77 | this.add(varsPanel); 78 | this.add(procPanel); 79 | //this.add(primPanel); 80 | 81 | addTableListeners(); 82 | 83 | 84 | 85 | 86 | } 87 | public void paintComponent(Graphics g) { 88 | // Paint background 89 | super.paintComponent(g); 90 | this.removeAll(); 91 | if (listTableShow) { 92 | this.add(listPanel); 93 | drawListsTable(); 94 | } 95 | 96 | if (varTableShow) { 97 | this.add(varsPanel); 98 | drawVariablesTable(); 99 | } 100 | if (procTableShow) { 101 | this.add(procPanel); 102 | drawProceduresTable(); 103 | } 104 | if (primTableShow) { 105 | this.add(primPanel); 106 | drawPrimitivesTable(); 107 | } 108 | 109 | this.revalidate(); 110 | } // paintComponent 111 | 112 | 113 | 114 | public void addTableListeners() { 115 | procTable.addMouseListener(new java.awt.event.MouseListener() { 116 | public void mouseClicked(MouseEvent mouseEvent) { 117 | } 118 | public void mouseEntered(MouseEvent mouseEvent) { 119 | } 120 | public void mouseExited(MouseEvent mouseEvent) { 121 | } 122 | public void mousePressed(MouseEvent mouseEvent) { 123 | } 124 | public void mouseReleased(MouseEvent mouseEvent) { 125 | JFrame f = new JFrame("Information:"); 126 | JTextArea t = new JTextArea(); 127 | t.setLineWrap(true); 128 | f.add(t); 129 | t.setText((procTable.getValueAt(procTable.getSelectedRow(),procTable.getSelectedColumn())).toString()); 130 | f.setVisible(true); 131 | f.setLocation(java.awt.MouseInfo.getPointerInfo().getLocation()); 132 | f.setSize(new Dimension(400,150)); 133 | } 134 | }); 135 | primTable.addMouseListener(new java.awt.event.MouseListener() { 136 | public void mouseClicked(MouseEvent mouseEvent) { 137 | } 138 | public void mouseEntered(MouseEvent mouseEvent) { 139 | } 140 | public void mouseExited(MouseEvent mouseEvent) { 141 | } 142 | public void mousePressed(MouseEvent mouseEvent) { 143 | } 144 | public void mouseReleased(MouseEvent mouseEvent) { 145 | JFrame f = new JFrame("Information:"); 146 | JTextArea t = new JTextArea(); 147 | t.setLineWrap(true); 148 | f.add(t); 149 | t.setText((primTable.getValueAt(primTable.getSelectedRow(),primTable.getSelectedColumn())).toString()); 150 | f.setVisible(true); 151 | f.setLocation(java.awt.MouseInfo.getPointerInfo().getLocation()); 152 | f.setSize(new Dimension(400,150)); 153 | } 154 | }); 155 | varsTable.addMouseListener(new java.awt.event.MouseListener() { 156 | public void mouseClicked(MouseEvent mouseEvent) { 157 | } 158 | public void mouseEntered(MouseEvent mouseEvent) { 159 | } 160 | public void mouseExited(MouseEvent mouseEvent) { 161 | } 162 | public void mousePressed(MouseEvent mouseEvent) { 163 | } 164 | public void mouseReleased(MouseEvent mouseEvent) { 165 | JFrame f = new JFrame("Information:"); 166 | JTextArea t = new JTextArea(); 167 | t.setLineWrap(true); 168 | f.add(t); 169 | t.setText((varsTable.getValueAt(varsTable.getSelectedRow(),varsTable.getSelectedColumn())).toString()); 170 | f.setVisible(true); 171 | f.setLocation(java.awt.MouseInfo.getPointerInfo().getLocation()); 172 | f.setSize(new Dimension(400,150)); 173 | } 174 | }); 175 | listTable.addMouseListener(new java.awt.event.MouseListener() { 176 | public void mouseClicked(MouseEvent mouseEvent) { 177 | } 178 | public void mouseEntered(MouseEvent mouseEvent) { 179 | } 180 | public void mouseExited(MouseEvent mouseEvent) { 181 | } 182 | public void mousePressed(MouseEvent mouseEvent) { 183 | } 184 | public void mouseReleased(MouseEvent mouseEvent) { 185 | //if (listTable.(listTable.getSelectedRow(),listTable.getSelectedColumn())) { 186 | JFrame f = new JFrame("Information:"); 187 | JTextArea t = new JTextArea(); 188 | t.setLineWrap(true); 189 | f.add(t); 190 | t.setText((listTable.getValueAt(listTable.getSelectedRow(),listTable.getSelectedColumn())).toString()); 191 | f.setVisible(true); 192 | f.setLocation(java.awt.MouseInfo.getPointerInfo().getLocation()); 193 | f.setSize(new Dimension(400,150)); 194 | // } 195 | } 196 | }); 197 | } 198 | 199 | 200 | public void drawVariablesTable () { 201 | varsTable.setBackground(new Color(210,210,210)); 202 | // varsTable.selectAll(); 203 | // varsTable.removeAll(); 204 | // varsTable.clearSelection(); 205 | clearTable(varsTable); 206 | varsTable.setValueAt("Name:",0,0); 207 | varsTable.setValueAt("Value:",0,1); 208 | LinkedList l = PVTS.envStack.getAllVariables(); 209 | for (int i=0; i < ((LinkedList)l.get(0)).size(); i= i+2) { 210 | //varsTable.setSize(new Dimension(30,2)); 211 | varsTable.setValueAt(((LinkedList)l.get(0)).get(i),i/2+1,0); 212 | varsTable.setValueAt(((LinkedList)l.get(0)).get(i+1),i/2+1,1); 213 | } 214 | 215 | } 216 | 217 | 218 | public void drawListsTable () { 219 | listTable.setBackground(new Color(210,210,210)); 220 | // listTable.removeAll(); 221 | clearTable(listTable); 222 | listTable.setValueAt("Name:",0,0); 223 | listTable.setValueAt("Value:",0,1); 224 | LinkedList l = PVTS.envStack.getAllLists(); 225 | for (int i=0; i < ((LinkedList)l.get(0)).size(); i= i+2) { 226 | //varsTable.setSize(new Dimension(30,2)); 227 | listTable.setValueAt(((LinkedList)l.get(0)).get(i),i/2+1,0); 228 | listTable.setValueAt(((LinkedList)l.get(0)).get(i+1),i/2+1,1); 229 | } 230 | 231 | } 232 | 233 | 234 | public void drawPrimitivesTable () { 235 | primTable.setBackground(new Color(210,210,210)); 236 | clearTable(primTable); 237 | primTable.setValueAt("Name:",0,0); 238 | LinkedList l = PVTS.envStack.getAllPrimitives(); 239 | for (int i=0; i < ((LinkedList)l.get(0)).size(); i= i+1) { 240 | //varsTable.setSize(new Dimension(30,2)); 241 | primTable.setValueAt(((LinkedList)l.get(0)).get(i),i+1,0); 242 | } 243 | 244 | } 245 | 246 | public void drawProceduresTable () { 247 | procTable.setBackground(new Color(210,210,210)); 248 | // procTable.selectAll(); 249 | //procTable.clearSelection(); 250 | clearTable(procTable); 251 | procTable.setValueAt("Name:",0,0); 252 | procTable.setValueAt("Value:",0,1); 253 | LinkedList l = PVTS.envStack.getAllProcedures(); 254 | for (int i=0; i < ((LinkedList)l.get(0)).size(); i= i+2) { 255 | //varsTable.setSize(new Dimension(30,2)); 256 | procTable.setValueAt(((LinkedList)l.get(0)).get(i),i/2+1,0); 257 | procTable.setValueAt(((LinkedList)l.get(0)).get(i+1),i/2+1,1); 258 | } 259 | 260 | } 261 | 262 | 263 | 264 | public void clearTable(JTable t) { 265 | for (int i = 0 ; i < t.getColumnCount(); i ++) { 266 | for (int j = 0; j < t.getRowCount(); j ++) { 267 | t.setValueAt("",j,i); 268 | } 269 | } 270 | } 271 | 272 | 273 | } 274 | 275 | 276 | -------------------------------------------------------------------------------- /Environment.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/Environment.class -------------------------------------------------------------------------------- /Environment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Environment.java 3 | * 4 | * Created on June 20, 2006, 11:46 AM 5 | * 6 | * Author: David Pilo 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | 30 | import java.util.*; 31 | /** 32 | * 33 | * @author david 34 | */ 35 | public class Environment { 36 | //public static GlobalEnv = new Hashtable(); 37 | public static Stack enviro = new Stack(); 38 | 39 | 40 | public static String convertString(String s) { 41 | Environment env = new Environment(); 42 | String return_string = ""; 43 | int temp1 = 0; 44 | char c = s.charAt(0); 45 | for (int i = 0; i < s.length() - 1; i++) { 46 | c = s.charAt(i); 47 | //while ((c != ' ') || (c!= '\n') || (c!='\t') || (c!=')') || (c!='(')) { 48 | if(!Character.isLetter(c)) 49 | return_string = return_string + c; 50 | else { 51 | temp1 = i; 52 | while (((c != ' ') && (c!= '\n') && (c!='\t') && (c!=')') && (c!='(')) && temp1 <= s.length()) { 53 | temp1++; 54 | c = s.charAt(temp1); 55 | } 56 | if (env.containsKey(s.substring(i,temp1))) 57 | return_string = return_string + env.get(s.substring(i,temp1)); 58 | else { 59 | return_string = return_string + s.substring(i,temp1); 60 | 61 | i = temp1; 62 | 63 | } 64 | } 65 | 66 | } 67 | return return_string; 68 | } 69 | 70 | /** Creates a new instance of Environment */ 71 | public Environment() { 72 | 73 | 74 | } 75 | 76 | public SExpression get(String id) { 77 | //SExpression return_exp = new ErrorMess (""); 78 | 79 | for (int i=1; i <= enviro.size(); i++) { 80 | if (enviro.get(enviro.size()-i).containsKey(id.toLowerCase())) 81 | return (SExpression) enviro.get(enviro.size()-i).get(id.toLowerCase()); 82 | //return_exp = (SExpression) enviro.get(enviro.size()-i).get(id); 83 | //if (return_exp != null) 84 | // return return_exp; 85 | 86 | } 87 | return new Mess("undefined variable "+id); 88 | } 89 | 90 | public int getLevel(String id) { 91 | 92 | for (int i=1; i <= enviro.size(); i++) { 93 | if (enviro.get(enviro.size()-i).containsKey(id.toLowerCase())) 94 | return enviro.size()-i; 95 | } 96 | return -1; // this should never happen since we should always call containsKey before getLevel. 97 | } 98 | 99 | public void put(String id, SExpression o) { 100 | enviro.peek().put(id.toLowerCase(),o); 101 | // if (PVTS.procedure_environments.size() != 0) 102 | // PVTS.procedure_environments.peek().put(id.toLowerCase(),o); 103 | } 104 | 105 | public void add(Hashtable h) { 106 | enviro.add(h); 107 | } 108 | 109 | public boolean containsKey(String st) { 110 | 111 | for (int i=1; i <= enviro.size(); i++) { 112 | if (enviro.get(enviro.size()-i).containsKey(st.toLowerCase())) 113 | return true; 114 | } 115 | return false; 116 | } 117 | 118 | public boolean containsKeyPeek(String st) { 119 | return enviro.peek().containsKey(st.toLowerCase()); 120 | } 121 | 122 | 123 | 124 | 125 | public boolean containsListCCPeek(ListCC e) { 126 | Boolean temp = false; 127 | Hashtable table = enviro.peek(); 128 | Enumeration ele = table.elements(); 129 | while (ele.hasMoreElements()) { 130 | SExpression next = ele.nextElement(); 131 | if (next.isListCC()) 132 | if (((ListCC) next).isSameListAs(e)) 133 | temp = true; 134 | } 135 | 136 | return temp; 137 | } 138 | 139 | public ListCC getListCCPeek(ListCC e) { 140 | ListCC dummy = null; 141 | Hashtable table; 142 | Enumeration ele; 143 | table = enviro.peek(); 144 | ele = table.elements(); 145 | while (ele.hasMoreElements()) { 146 | SExpression next = ele.nextElement(); 147 | if (next.isListCC()) 148 | if (((ListCC) next).isSameListAs(e)) 149 | return ((ListCC) next); 150 | } 151 | return dummy; // should never get to this point. 152 | } 153 | 154 | 155 | public void removePeek(String st) { 156 | enviro.peek().remove(st.toLowerCase()); 157 | } 158 | 159 | public LinkedList getAllVariables() { 160 | LinkedList varList = new LinkedList(); 161 | for (int i = 0; i < enviro.size(); i++) { 162 | Enumeration ele = enviro.get(0).elements(); 163 | Enumeration keys = enviro.get(0).keys(); 164 | varList.add(new LinkedList()); 165 | while (ele.hasMoreElements()) { 166 | SExpression e = ((SExpression) ele.nextElement()); 167 | String id = (String) keys.nextElement(); 168 | if ((e.isAtom() && !e.isFunction())) { 169 | ((LinkedList) varList.get(0)).add(id); 170 | ((LinkedList) varList.get(0)).add(e); 171 | } 172 | } 173 | } 174 | return varList; 175 | 176 | } 177 | 178 | 179 | public LinkedList getAllLists() { 180 | LinkedList varList = new LinkedList(); 181 | for (int i = 0; i < enviro.size(); i++) { 182 | Enumeration ele = enviro.get(0).elements(); 183 | Enumeration keys = enviro.get(0).keys(); 184 | varList.add(new LinkedList()); 185 | while (ele.hasMoreElements()) { 186 | SExpression e = ((SExpression) ele.nextElement()); 187 | String id = (String) keys.nextElement(); 188 | if ((e.getClass().getName().equals("ListCC"))) { 189 | ((LinkedList) varList.get(0)).add(id); 190 | ((LinkedList) varList.get(0)).add(e); 191 | } 192 | } 193 | } 194 | return varList; 195 | 196 | } 197 | 198 | 199 | public LinkedList getAllPrimitives() { 200 | LinkedList l = new LinkedList(); 201 | for (int i = 0; i < enviro.size(); i++) { 202 | Enumeration ele = enviro.get(0).elements(); 203 | l.add(new LinkedList()); 204 | while (ele.hasMoreElements()) { 205 | SExpression e = ((SExpression) ele.nextElement()); 206 | if (e.isPrimitiveG()) { 207 | ((LinkedList) l.get(0)).add(e); 208 | } 209 | } 210 | } 211 | return l; 212 | 213 | } 214 | 215 | 216 | public LinkedList getAllProcedures() { 217 | LinkedList l = new LinkedList(); 218 | for (int i = 0; i < enviro.size(); i++) { 219 | Enumeration ele = enviro.get(0).elements(); 220 | Enumeration keys = enviro.get(0).keys(); 221 | l.add(new LinkedList()); 222 | while (ele.hasMoreElements()) { 223 | SExpression e = ((SExpression) ele.nextElement()); 224 | String id = (String) keys.nextElement(); 225 | if (e.isProcedure()) { 226 | ((LinkedList) l.get(0)).add(id); 227 | ((LinkedList) l.get(0)).add(e); 228 | } 229 | } 230 | } 231 | return l; 232 | 233 | } 234 | 235 | 236 | } 237 | -------------------------------------------------------------------------------- /ErrorMess.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/ErrorMess.class -------------------------------------------------------------------------------- /ErrorMess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ErrorMess.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | 30 | import java.awt.*; 31 | import java.awt.event.*; 32 | 33 | class ErrorMess extends SExpression { 34 | 35 | static String allmessages; 36 | String message; 37 | static int pos; 38 | 39 | public ErrorMess(String st) { 40 | pos = TextIO.getPos(); 41 | PVTS.error = true; 42 | message = st; 43 | allmessages = allmessages + "\nat Line "+PVTS.currentLine+": " + st; 44 | } 45 | 46 | public ErrorMess copy() { 47 | return new ErrorMess(this.message); 48 | } 49 | 50 | 51 | 52 | public void print() { 53 | if (PVTS.debug) 54 | PVTSFrame.put(message); 55 | } 56 | 57 | 58 | 59 | public void draw(Graphics g) { 60 | } 61 | 62 | public int getX() { 63 | return x; 64 | } 65 | 66 | public int getY() { 67 | return y; 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /FileReaderWriter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/FileReaderWriter.class -------------------------------------------------------------------------------- /FileReaderWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * FileReaderWriter.java 3 | * 4 | * author: David Pilo 5 | * 6 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 7 | Copyright (C) 2007 David A. Pilo Mansion 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | Contact information: 24 | David Pilo 25 | davidpilo@gmail.com 26 | * 27 | */ 28 | 29 | import javax.swing.*; 30 | import java.io.IOException; 31 | import java.io.FileWriter; 32 | import java.io.PrintWriter; 33 | import java.io.FileReader; 34 | import java.io.BufferedReader; 35 | import java.io.BufferedWriter; 36 | 37 | 38 | 39 | public class FileReaderWriter { 40 | 41 | public static FileReader reader; 42 | public static FileWriter writer; 43 | public static String currentFilePath; 44 | 45 | public static void save (JTextArea ta) { 46 | try { 47 | //PVTSFrame.s 48 | writer = new FileWriter(currentFilePath); 49 | BufferedWriter buf_writer = new BufferedWriter(writer); 50 | String s = ta.getText(); 51 | buf_writer.write(s); 52 | buf_writer.close(); 53 | java.awt.Toolkit.getDefaultToolkit ().beep(); 54 | } 55 | 56 | catch (IOException e) { 57 | PVTSFrame.outputTextArea.append(e.toString()); 58 | System.exit(1); 59 | } 60 | } 61 | 62 | public static void saveAs(String out_file, JTextArea ta) { 63 | try { 64 | writer = new FileWriter(out_file); 65 | currentFilePath = out_file; 66 | save(ta); 67 | } 68 | catch (IOException e) { 69 | PVTSFrame.outputTextArea.append(e.toString()); 70 | System.exit(1); 71 | } 72 | } 73 | 74 | public static void readFile(String in_file, JTextArea ta) { 75 | try { 76 | reader = new FileReader(in_file); 77 | currentFilePath = in_file; 78 | BufferedReader buf_reader = 79 | new BufferedReader(reader); 80 | //FileWriter writer = new FileWriter(in_file); 81 | //BufferedWriter buf_writer = 82 | // new BufferedWriter(writer); 83 | String ln = null; 84 | ta.setText(""); 85 | while ((ln = buf_reader.readLine()) != null){ 86 | //buf_writer.write(ln); 87 | //buf_writer.newLine(); 88 | ta.append(ln+"\n"); 89 | } 90 | buf_reader.close(); 91 | //buf_writer.close(); 92 | } 93 | catch (IOException e) { 94 | System.err.println(e); 95 | System.exit(1); 96 | } 97 | } 98 | 99 | } 100 | 101 | -------------------------------------------------------------------------------- /Function.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/Function.class -------------------------------------------------------------------------------- /Function.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Function.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | 30 | abstract class Function extends Atom { 31 | 32 | int prim_code; 33 | String op; 34 | 35 | public String getPrintable() { 36 | return op; 37 | } 38 | 39 | public int getCode() { 40 | return prim_code; 41 | } 42 | } -------------------------------------------------------------------------------- /FunctionManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/FunctionManager.class -------------------------------------------------------------------------------- /FunctionManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * FunctionManager.java 3 | * 4 | * Created on August 30, 2006, 7:36 PM 5 | * 6 | * author: David Pilo 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | import java.util.*; 30 | import java.awt.*; 31 | import javax.swing.*; 32 | /** 33 | * 34 | * @author David Pilo 35 | */ 36 | public class FunctionManager { 37 | 38 | //public static int shiftConstant = 100; 39 | /** Creates a new instance of FunctionManager */ 40 | public FunctionManager() { 41 | theTree = new ArrayList(); 42 | for (int i = 0; i <50 ; i++) { 43 | this.theTree.add(i,new LinkedList()); 44 | } 45 | 46 | } 47 | 48 | 49 | public void add(ProcedureAndArgs p, int i,boolean isdummy) { 50 | if (!isdummy) 51 | this.theTree.get(i).add(p); 52 | else 53 | this.theTree.get(i).add("dummy"); 54 | 55 | } 56 | 57 | 58 | 59 | public ProcedureAndArgs getParent(int i, int j) { 60 | int numOfdummies = 0; 61 | for (int k = 0; k < j; k++) { 62 | if (!this.theTree.get(i).get(k).getClass().getName().equalsIgnoreCase("ProcedureAndArgs")) 63 | numOfdummies ++; 64 | 65 | } 66 | int temp = 0; 67 | int dum = numOfdummies; 68 | for (int l = 0; l <= dum;l++) { 69 | if (!this.theTree.get(i-1).get(l).getClass().getName().equalsIgnoreCase("ProcedureAndArgs")) { 70 | temp ++; 71 | dum++; 72 | } 73 | 74 | } 75 | // PVTSFrame.put("\nparent of: ("+i+", "+j+") is "); 76 | // PVTSFrame.put("(" + (i-1) +", "+numOfdummies+"+"+temp+")"); 77 | return ((ProcedureAndArgs)this.theTree.get(i-1).get(numOfdummies+temp)); 78 | } 79 | 80 | 81 | public static void drawArrow(Graphics2D g2d, int xCenter, int yCenter, int x, int y, float stroke) { 82 | double aDir=Math.atan2(xCenter-x,yCenter-y); 83 | g2d.drawLine(x,y,xCenter,yCenter); 84 | g2d.setStroke(new BasicStroke(1f)); 85 | Polygon tmpPoly=new Polygon(); 86 | int i1=12+(int)(stroke*2); 87 | int i2=6+(int)stroke; 88 | tmpPoly.addPoint(x,y); 89 | tmpPoly.addPoint(x+xCor(i1,aDir+.5),y+yCor(i1,aDir+.5)); 90 | tmpPoly.addPoint(x+xCor(i2,aDir),y+yCor(i2,aDir)); 91 | tmpPoly.addPoint(x+xCor(i1,aDir-.5),y+yCor(i1,aDir-.5)); 92 | tmpPoly.addPoint(x,y); 93 | g2d.fillPolygon(tmpPoly); 94 | // g2d.setColor(Color.black); 95 | // g2d.drawPolygon(tmpPoly); 96 | } 97 | private static int yCor(int len, double dir) {return (int)(len * Math.cos(dir));} 98 | private static int xCor(int len, double dir) {return (int)(len * Math.sin(dir));} 99 | 100 | public void drawBranch (Graphics g,ProcedureAndArgs child, ProcedureAndArgs parent) { 101 | g.drawLine(child.xCoor+(child.width)/2,child.yCoor,parent.xCoor+(parent.width)/2,parent.yCoor+parent.height); 102 | int xend = child.xCoor+(child.width)/2; 103 | int yend = child.yCoor; 104 | int xCenter = parent.xCoor+(parent.width)/2; 105 | int yCenter = parent.yCoor+parent.height; 106 | double aDir=Math.atan2(xCenter-xend,yCenter-yend); 107 | g.drawLine(xend,yend,xCenter,yCenter); 108 | 109 | Polygon tmpPoly=new Polygon(); 110 | int i1=12;//+(int)(stroke*2); 111 | int i2=10;//+(int)stroke; 112 | tmpPoly.addPoint(xend,yend); 113 | tmpPoly.addPoint(xend+xCor(i1,aDir+.5),yend+yCor(i1,aDir+.5)); 114 | tmpPoly.addPoint(xend+xCor(i2,aDir),yend+yCor(i2,aDir)); 115 | tmpPoly.addPoint(xend+xCor(i1,aDir-.5),yend+yCor(i1,aDir-.5)); 116 | tmpPoly.addPoint(xend,yend); 117 | // g.drawPolygon(tmpPoly); 118 | g.fillPolygon(tmpPoly); 119 | } 120 | 121 | 122 | public void draw (Graphics g) { 123 | ProcedureAndArgs current; 124 | int temp_y = current_y; 125 | x = -1; 126 | y = -1; 127 | int max_x_panel = PVTSFrame.ftrees.getSize().width - ((int)(100*zoom)); 128 | //PVTSFrame.put(max_x_panel); 129 | int num_of_calls; 130 | int coeff; 131 | for(int i = 0; i < this.theTree.size(); i++) { 132 | if (this.theTree.get(i).size() != 0) { 133 | y++; 134 | x = -1; 135 | for (int j = 0; j current_y) 166 | current_y = current.yCoor + 50; 167 | if (current.xCoor > max_x) 168 | max_x = current.xCoor + 50; 169 | g.setColor(Color.gray); 170 | g.fillRoundRect(current.xCoor+5,current.yCoor+4,current.width,current.height,20,20); 171 | g.setColor(DrawingTreesPanel.color); 172 | if (i == 0) 173 | g.setColor(DrawingTreesPanel.color.darker()); 174 | g.fillRoundRect(current.xCoor,current.yCoor,current.width,current.height,20,20); 175 | //g.fillOval(current.xCoor,current.yCoor,current.width,current.height); 176 | g.setColor(Color.black); 177 | //g.drawOval(current.xCoor,current.yCoor,current.width,current.height); 178 | g.drawRoundRect(current.xCoor,current.yCoor,current.width,current.height,20,20); 179 | String s; 180 | if (funcNameDisplay) 181 | s = current.p.substring(0,1) + current.sexprs.toString(); 182 | else 183 | s = current.p + current.sexprs.toString(); 184 | int l = s.length(); 185 | if (l*7 > (current.width)) 186 | s = s.substring(0,l-(l*7-current.width)/7); 187 | if ((current.result.isListCC() || current.result.isAtom()) && result_bubble) { 188 | g.drawString(current.result.toString(), current.xCoor + current.width + ((int)(30*zoom)) , current.yCoor+((current.height)/2)+6); 189 | Color temp = g.getColor(); 190 | g.setColor(Color.red); 191 | Polygon p = new Polygon(); 192 | p.addPoint(current.xCoor+current.width+((int)(8*zoom)),current.yCoor+((int)current.height/3)); 193 | p.addPoint(current.xCoor+current.width+((int)(14*zoom)),current.yCoor+((int)current.height/3)); 194 | p.addPoint(current.xCoor+current.width+((int)(14*zoom)),current.yCoor+((int)current.height/5)); 195 | p.addPoint(current.xCoor+current.width+((int)(25*zoom)),current.yCoor+((int)current.height/2)); 196 | p.addPoint(current.xCoor+current.width+((int)(14*zoom)),current.yCoor+((int)current.height*4/5)); 197 | p.addPoint(current.xCoor+current.width+((int)(14*zoom)),current.yCoor+((int)current.height/3*2)); 198 | p.addPoint(current.xCoor+current.width+((int)(8*zoom)),current.yCoor+((int)current.height/3*2)); 199 | g.fillPolygon(p); 200 | g.setColor(Color.black); 201 | g.drawPolygon(p); 202 | g.setColor(temp); 203 | //g.drawLine(current.xCoor + current.width + 3, current) 204 | } 205 | g.drawString(s,current.xCoor+5,current.yCoor+((current.height)/2)+6); 206 | if (i != 0) { // draw child to parent branch if not root 207 | ProcedureAndArgs parent = getParent(i,j); 208 | drawBranch(g,current,parent); 209 | } 210 | 211 | } 212 | else { 213 | x--; 214 | } 215 | } 216 | } 217 | } 218 | } 219 | 220 | public ArrayList theTree; 221 | // public ArrayL 222 | public int x; 223 | public int y; 224 | public static int max_x; 225 | public static int current_y; 226 | public static double zoom = 1.0; 227 | public static int viewMode = 0; 228 | public static boolean funcNameDisplay = true; 229 | public static boolean result_bubble = true; 230 | 231 | } 232 | -------------------------------------------------------------------------------- /Interpreter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/Interpreter.class -------------------------------------------------------------------------------- /ListCC.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/ListCC.class -------------------------------------------------------------------------------- /ListCC.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ListCC.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | 30 | import java.awt.*; 31 | import java.awt.event.*; 32 | import java.util.*; 33 | 34 | class ListCC extends SExpression { 35 | Conscell first,last; 36 | int size; 37 | int unitDraw = DrawingConscellsPanel.zoom; 38 | 39 | ListCC() { 40 | first = null; 41 | last = null; 42 | size = 0; 43 | } 44 | 45 | public ListCC copy() { 46 | if (isEmpty()) { 47 | //TextIO.put("got the emptylist"); 48 | return new ListCC();} else { 49 | ListCC temp = new ListCC(); 50 | temp.first = this.first.copy(); 51 | // temp.first.setCar(car().copy()); 52 | // temp.first.setCdr(cdr().first.copy()); 53 | // TextIO.put("done list copy"); 54 | // have to traverse the list and set the last! 55 | int temp_size = 1; 56 | ListCC c = temp; 57 | while (!(c.cdr().isEmpty())) { 58 | c = c.cdr(); 59 | temp_size ++; 60 | } 61 | temp.last = c.first; 62 | temp.size = temp_size; 63 | return temp; 64 | 65 | } 66 | 67 | 68 | } 69 | 70 | public Conscell getFirst() { 71 | return first; 72 | } 73 | 74 | public Conscell getLast() { 75 | return last; 76 | } 77 | 78 | public int getSize() { 79 | return size; 80 | } 81 | 82 | ListCC(Conscell c) { 83 | first = c; 84 | last = c; 85 | size = 1; 86 | } 87 | 88 | 89 | 90 | 91 | 92 | public void print() { 93 | PVTSFrame.put("("); 94 | Conscell current = first; 95 | for(int i = 0;i 0) PVTSFrame.put(" "); 97 | current.getCar().print(); 98 | current = current.getCdr(); 99 | } 100 | if (last != null) { 101 | if (last.isDottedPair()) { 102 | PVTSFrame.put(" . "); 103 | last.getDotted().print(); 104 | } 105 | } 106 | PVTSFrame.put(")"); 107 | } 108 | 109 | public String toString() { 110 | String str = "("; 111 | Conscell current = first; 112 | for(int i = 0;i 0) str = str + " "; 114 | str = str + current.getCar().toString(); 115 | current = current.getCdr(); 116 | } 117 | if (last != null) { 118 | if (last.isDottedPair()) { 119 | str = str + " . "; 120 | str = str + last.getDotted().toString(); 121 | } 122 | } 123 | str = str +")"; 124 | return str; 125 | } 126 | 127 | 128 | public String toStringList() { 129 | String str = "'( "; 130 | Conscell current = first; 131 | for(int i = 0;i 0) str = str + " "; 133 | str = str + current.getCar().toString(); 134 | current = current.getCdr(); 135 | } 136 | if (last != null) { 137 | if (last.isDottedPair()) { 138 | str = str + " . "; 139 | str = str + last.getDotted().toString(); 140 | } 141 | } 142 | str = str +")"; 143 | return str; 144 | } 145 | 146 | public SExpression car() { 147 | return first.getCar(); 148 | } 149 | 150 | 151 | 152 | public ListCC cdr() { 153 | ListCC lc = new ListCC(first.getCdr()); 154 | lc.last = last; 155 | lc.size = size - 1; 156 | return lc; 157 | } 158 | 159 | 160 | 161 | public void removeAllButFirst() { 162 | last = first; 163 | first.dotted = null; 164 | size = 1; 165 | } 166 | 167 | public void add(Conscell c) { 168 | if (first == null) { 169 | first = c; 170 | last = c; 171 | size = 1; 172 | } else { 173 | last.setCdr(c); 174 | last = c; 175 | size = size + 1; 176 | } 177 | } 178 | 179 | public void addL(ListCC l) { 180 | if (first == null) { 181 | first = l.getFirst(); 182 | last = l.getLast(); 183 | size = l.getSize(); 184 | } else { 185 | last.setDotted(null); 186 | last.setCdr(l.getFirst()); 187 | last = l.getLast(); 188 | size = size + l.getSize(); 189 | } 190 | } 191 | 192 | 193 | public static ListCC makeReverseList(ArrayList sexprs) { 194 | ListCC myList = new ListCC(); 195 | // Conscell last = null; 196 | ArrayList l = new ArrayList(); 197 | Conscell current = ((ListCC) sexprs.get(0)).getFirst(); 198 | for(int i = 0 ; i < ((ListCC) sexprs.get(0)).size; i++) { 199 | l.add(current.getCar()); 200 | current = current.getCdr(); 201 | } 202 | for (int i = 0; i < l.size(); i++) { 203 | // TextIO.put(sxpr.toString()+" *** "); 204 | Conscell c = new Conscell(l.get(l.size()-i-1)); 205 | myList.add(c); 206 | } 207 | return myList; 208 | } 209 | 210 | public static ListCC makeList(ArrayList sexprs) { 211 | // if (sexprs.size() == 0) 212 | //TextIO.put("enter makelist"); 213 | ListCC myList = new ListCC(); 214 | // Conscell last = null; 215 | for (SExpression sxpr : sexprs) { 216 | // TextIO.put(sxpr.toString()+" *** "); 217 | Conscell c = new Conscell(sxpr); 218 | myList.add(c); 219 | } 220 | return myList; 221 | } 222 | 223 | public static ListCC makeListDotted(ArrayList sexprs) { 224 | // if (sexprs.size() == 0) 225 | int s = sexprs.size(); 226 | ListCC myList = new ListCC(); 227 | // Conscell last = null; 228 | for (int i= 0; i 0) { 146 | if (listMatrix.get(MAX-i-1,MAX-j-1).contains(l)) // have to do it from bottom up 147 | { 148 | listMatrix.get(MAX-i-1,MAX-j-1).remove(l); 149 | if (!(listMatrix.get(MAX-i-1+1,MAX-j-1).contains(l))) 150 | listMatrix.get(MAX-i-1+1,MAX-j-1).addFirst(l); // or addFirst()?? or add() 151 | } 152 | } 153 | } 154 | } 155 | } 156 | 157 | 158 | public void shiftDownSingleExp(SExpression s) { 159 | // Shifts an object (conscell or SEInt) down by xStep units down in the canvas. 160 | s.setY(s.getY()+xStep); 161 | if (s.getY() > yMax) 162 | yMax = s.getY(); // update the yMax; 163 | } 164 | 165 | 166 | public ListCC detectCollision() { 167 | // First detects a collision in the matrix (that is where there is more than one elemenent, 168 | // in other words where more than one pointer to a list is found). Then returns the list to be shifted down. 169 | for (int i = 0; i < MAX; i++) { 170 | for (int j = 0; j < MAX; j++) { 171 | if (listMatrix.get(i,j).size() > 1) 172 | return (ListCC) giveListCC(listMatrix.get(i,j),i,j); 173 | } 174 | } 175 | return null; 176 | } 177 | 178 | public ListCC giveListCC(LinkedList l,int x, int y) { 179 | // Returns the list that needs to be shifted down. 180 | if ((l.size() > 2) || (detectType(l,x,y) == 0)) { 181 | for(int i = 0; i < orderOfLists.size(); i++) { 182 | for (int j = 0; j < l.size(); j++) { 183 | if (((ListCC)orderOfLists.get(i)) == ((ListCC)l.get(j))) 184 | return (ListCC) l.get(j); 185 | } 186 | } 187 | } else// collision between SEInt and conscell 188 | { 189 | if (detectType(l,x,y) == 1) { 190 | return (ListCC) l.get(1); 191 | } 192 | if (detectType(l,x,y) == 2) { 193 | return (ListCC) l.get(0); 194 | } 195 | } 196 | 197 | PVTSFrame.put(" this should never happen!"); 198 | return null; 199 | 200 | } 201 | 202 | public int detectType(LinkedList l, int i, int j) {// detects the type of collision found, that is collisions between conscells and/or SEInts. 203 | ListCC temp0 = (ListCC) l.get(0); 204 | ListCC temp1 = (ListCC) l.get(1); 205 | if (thereIs(temp0,i-1,j)) // then temp0 is an SEInt 206 | { 207 | if (thereIs(temp1,i-1,j)) // temp1 is SEInt 208 | { 209 | return 0; // both are SEInts 210 | } else 211 | return 1; // temp0 is SEInt and temp1 is conscell 212 | } else // temp0 is a conscell 213 | { 214 | if (thereIs(temp1,i-1,j)) // temp1 is SEInt 215 | { 216 | return 2; // temp0 is a conscell and temp1 is an SEInt 217 | } else 218 | return 0; // both are conscells. 219 | } 220 | } 221 | 222 | public boolean thereIs(ListCC list, int i, int j) {// returns true if "list" is in the linkedlist of lists at position ij in the matrix. 223 | ListIterator lI = listMatrix.get(i,j).listIterator(); 224 | while (lI.hasNext()) { 225 | ListCC l = (ListCC) lI.next(); 226 | if (l == list) 227 | return true; 228 | } 229 | // TextIO.putln("could not find the list in "+i+", "+j+". "); 230 | return false; 231 | } 232 | 233 | public int giveMaxY() { 234 | return yMax; 235 | } 236 | 237 | public void createInitMatrix(SExpression c, int x, int y, ListCC currentList) {// Creates the initial matrix and sets the apropriate coordinates to the lists (and its elements) 238 | // according to the initial matrix. This results in the visualization of a list that isn't 239 | // concerned about collisions. 240 | if (((ListCC) c).isEmpty()) { 241 | c.name_obj.setXY(yStep*y+yOffset,xStep*x+xOffset); // set the pos of the name of the list 242 | c.setXY(yStep*y+yOffset,xStep*x+xOffset); // set the pos of the list. 243 | if (c.getY() > yMax) 244 | yMax = c.getY(); 245 | } else { 246 | while (c != null) { 247 | if (c.getClass().getName().equals("ListCC")) { 248 | currentList = (ListCC) c; 249 | // if (!((ListCC)c).isEmpty()) 250 | // { 251 | if (((Conscell) ((ListCC)c).first).managed == true) { 252 | c.setXY(((Conscell) ((ListCC)c).first).getX(),((Conscell) ((ListCC)c).first).getY()); 253 | c.name_obj.setXY(yStep*y+yOffset,xStep*x+xOffset); // set the pos of the name of the list 254 | } else { 255 | c.name_obj.setXY(yStep*y+yOffset,xStep*x+xOffset); // set the pos of the name of the list 256 | c.setXY(yStep*y+yOffset,xStep*x+xOffset); // set the pos of the list. 257 | } 258 | if (c.getY() > yMax) 259 | yMax = c.getY(); 260 | // TextIO.putln("the object: " + c + "has position: " + c.getX() + ", " + c.getY()); 261 | c = ((ListCC)c).first; 262 | } 263 | // } 264 | listMatrix.get(x,y).add(currentList); // add the current list in the correct spot in the matrix 265 | if (!(orderOfLists.contains(currentList))) 266 | orderOfLists.add(currentList); 267 | c.setXY(yStep*y+yOffset,xStep*x+xOffset); // have to invert and y because in matrix and graph coordinates its inverted 268 | if (c.getY() > yMax) 269 | yMax = c.getY(); 270 | // TextIO.putln("the object: " + c + "has position: " + c.getX() + ", " + c.getY()); 271 | // if (isAtom(((Conscell) c).getCar())) 272 | // if (((Conscell) c).getCar().getClass().getName().equals ("SEInt") || ((Conscell) c).getCar().getClass().getName().equals ("SEBool")) 273 | if ((((Conscell) c).getCar()).isAtom()) { 274 | listMatrix.get(x+1,y).add(currentList); 275 | if (!(orderOfLists.contains(currentList))) 276 | orderOfLists.add(currentList); 277 | ((Conscell)c).getCar().setXY(yStep*(y)+yOffset,xStep*(x+1)+xOffset);// have to invert and y because in matrix and graph coordinates its inverted 278 | // TextIO.putln("the object: " + ((Conscell)c).getCar() + "has position: " + ((Conscell)c).getCar().getX() + ", " + ((Conscell)c).getCar().getY()); 279 | } else { 280 | if (((Conscell) c).getCar().getClass().getName().equals("ListCC")) 281 | 282 | { 283 | if (((ListCC)((Conscell) c).getCar()).isEmpty()) { 284 | listMatrix.get(x+1,y).add(currentList); 285 | if (!(orderOfLists.contains(currentList))) 286 | orderOfLists.add(currentList); 287 | ((Conscell)c).getCar().setXY(yStep*(y)+yOffset,xStep*(x+1)+xOffset); 288 | } else 289 | createInitMatrix(((Conscell) c).getCar(),x+1,y,currentList); 290 | } else 291 | createInitMatrix(((Conscell) c).getCar(),x+1,y,currentList); 292 | // TextIO.putln("the object: " + ((Conscell)c).getCar() + "has position: " + ((Conscell)c).getCar().getX() + ", " + ((Conscell)c).getCar().getY()); 293 | } 294 | c = ((Conscell) c).getCdr(); 295 | y++; 296 | 297 | } 298 | } 299 | } 300 | } 301 | 302 | 303 | -------------------------------------------------------------------------------- /ListMatrix.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/ListMatrix.class -------------------------------------------------------------------------------- /ListMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ListMatrix.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | 30 | import java.util.*; 31 | /** 32 | * A class for storing and operating on two dimensional matrices that will 33 | * hold LinkedList that will hold ListCC's 34 | */ 35 | public class ListMatrix { 36 | /** 37 | Construct a Matrix object 38 | @arg rows the number of rows in the matrix 39 | @arg cols the number of rows in the matrix 40 | */ 41 | public ListMatrix(int rows, int cols) { 42 | this.rows = rows; 43 | this.cols = cols; 44 | elements = new LinkedList[rows][cols]; 45 | } 46 | 47 | /** 48 | Get the number of rows in this matrix 49 | @return the number of rows in the matrix 50 | */ 51 | public int getRows() { 52 | return rows; 53 | } 54 | 55 | /** 56 | Get the number of columns in this matrix 57 | @return the number of columns in the matrix 58 | */ 59 | public int getCols() { 60 | return cols; 61 | } 62 | 63 | /** 64 | Get the value of a particular element from this matrix 65 | @arg r the row of the element to get 66 | @arg c the column of the element to get 67 | @return the value of the specified element from the matrix 68 | */ 69 | public LinkedList get(int r, int c) { 70 | return elements[r][c]; 71 | } 72 | 73 | /** 74 | Set the value of a particular element from this matrix 75 | @arg r the row of the element to get 76 | @arg c the column of the element to get 77 | @arg v the value to store in the specified location 78 | */ 79 | public void set(int r, int c, LinkedList v) { 80 | elements[r][c] = v; 81 | } 82 | 83 | 84 | public static ListMatrix emptyMatrix(int rows, int cols) { 85 | ListMatrix result = new ListMatrix(rows, cols); 86 | for (int i = 0; i < rows; i++) 87 | for (int j = 0; j < cols; j++) 88 | result.set(i,j,new LinkedList()); 89 | 90 | return result; 91 | } 92 | 93 | 94 | 95 | public void printMatrix() { 96 | TextIO.putln(); 97 | for (int i=0; i < rows; i++) { 98 | for(int j=0; j < cols; j++) { 99 | if (j==0) TextIO.put("["); 100 | //TextIO.put((int) get(i,j)); 101 | TextIO.putln(get(i,j).toString()); 102 | if (j==cols-1) TextIO.putln("]"); 103 | else 104 | TextIO.put(" "); 105 | } 106 | } 107 | TextIO.putln(" "); 108 | } 109 | 110 | 111 | private LinkedList[][] elements; 112 | private int rows, cols; 113 | } -------------------------------------------------------------------------------- /LogoPanel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/LogoPanel.class -------------------------------------------------------------------------------- /LogoPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * LogoPanel.java 3 | * 4 | * Created on January 24, 2007, 12:15 PM 5 | * 6 | * author: David Pilo 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | 30 | /** 31 | * 32 | * @author david 33 | */ 34 | import javax.swing.*; 35 | import java.awt.*; 36 | import java.util.*; 37 | 38 | public class LogoPanel extends JPanel { 39 | 40 | LogoPanel () { 41 | 42 | } 43 | 44 | public void paintComponent(Graphics g) { 45 | // Paint background 46 | super.paintComponent(g); 47 | 48 | 49 | // Get the drawing area 50 | g.setColor(Color.black); 51 | g.drawRect(11,11,61,41); 52 | g.drawRect(21,21,61,41); 53 | g.drawRect(31,31,61,41); 54 | g.fillRect(12,12,61,41); 55 | g.setColor(Color.GRAY); 56 | g.fillRect(22,22,60,40); 57 | g.setColor(Color.LIGHT_GRAY); 58 | g.fillRect(32,32,60,40); 59 | g.setFont(new java.awt.Font("Courier", Font.BOLD, 15)); 60 | g.setColor(Color.BLACK); 61 | g.drawString("PVTS",40,55); 62 | 63 | 64 | } // paintComponent 65 | 66 | 67 | 68 | 69 | } // class LogoPanel 70 | 71 | -------------------------------------------------------------------------------- /Mess.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/Mess.class -------------------------------------------------------------------------------- /Mess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Mess.java 3 | * 4 | * author: David Pilo 5 | * 6 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 7 | Copyright (C) 2007 David A. Pilo Mansion 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | Contact information: 24 | David Pilo 25 | davidpilo@gmail.com 26 | */ 27 | 28 | 29 | import java.awt.*; 30 | import java.awt.event.*; 31 | 32 | class Mess extends SExpression { 33 | int dummy_id; 34 | String message; 35 | 36 | public Mess(String st) { 37 | message = st; 38 | } 39 | public Mess(String st, int id){ 40 | message = st; 41 | dummy_id = id; 42 | } 43 | public Mess copy() { 44 | return new Mess(this.message); 45 | } 46 | 47 | public String toString() { 48 | return message; 49 | } 50 | 51 | public int getCode() 52 | {return dummy_id;} 53 | 54 | public void print() { 55 | if (PVTS.debug) 56 | PVTSFrame.put(message); 57 | } 58 | 59 | 60 | 61 | public void draw(Graphics g) { 62 | } 63 | 64 | public int getX() { 65 | return x; 66 | } 67 | 68 | public int getY() { 69 | return y; 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /PVTS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTS.class -------------------------------------------------------------------------------- /PVTS.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * PVTS.java 4 | * 5 | * author: David Pilo 6 | * 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | 30 | 31 | import java.awt.*; 32 | import java.awt.event.*; 33 | import java.util.*; 34 | 35 | class PVTS // Pilo's Visualization tool for Scheme 36 | { 37 | 38 | // public static Stack procedure_environments = new Stack(); 39 | // public static int backup_pos = 0; 40 | // public static int current_pos = 0; 41 | public static SExpression current_SExpression = null; 42 | public static boolean consMode = false; 43 | public static boolean quote_mode = false; 44 | public static boolean define_body_func = false; 45 | public static boolean evaluatingProcedure = false; 46 | public static int current_level = 0; 47 | public static Stack parenthesisLocStack = new Stack(); 48 | 49 | public static boolean debug = false; 50 | public static int currentLine = 1; 51 | 52 | public static LinkedList list_of_lists;// = new LinkedList(); 53 | public static LinkedList orphan_list_of_lists;// = new LinkedList(); 54 | public static LinkedList list_of_trees; 55 | 56 | public static int a;// = 35; 57 | public static int b;// = 55; 58 | public static Environment envStack = new Environment(); 59 | public static Hashtable globalEnv = new Hashtable(); 60 | public static Stack bufferStack = new Stack(); 61 | public static String globalBuffer; 62 | public static boolean error; 63 | 64 | 65 | // parameters for coordinates of Recursive Function drawings 66 | public static int yRec; 67 | 68 | 69 | PVTS() { 70 | // parameters for coordinates of Recursive Function drawings 71 | // DrawingTreesPanel.clearTagList(); 72 | PVTSFrame.recuTextArea.setText(""); 73 | PVTSFrame.functag.setText(""); 74 | DrawingTreesPanel.currentlySelected = null; 75 | yRec = 50; 76 | FunctionManager.current_y = 0; 77 | String globalBuffer = ""; 78 | int initPos = 0; 79 | currentLine = 1; 80 | ErrorMess.allmessages = ""; 81 | bufferStack.clear(); 82 | bufferStack.push(globalBuffer); 83 | bufferStack.push(initPos); 84 | envStack.enviro.clear(); 85 | globalEnv.clear(); 86 | envStack.enviro.push(globalEnv); 87 | quote_mode = false; 88 | a = 32;// affects y 89 | b = 150;// affects x 90 | list_of_lists = new LinkedList();// this list will hold all the Cons Cell lists. 91 | orphan_list_of_lists = new LinkedList(); // this list will hold all the orphan lists. 92 | list_of_trees = new LinkedList(); // this list will hold all the trees related to the recursive functions drawn. 93 | error = false; 94 | ReadEvalPrint.loadPrimitives(envStack); 95 | 96 | 97 | } // end PVTS() 98 | 99 | public static void resetPVTS(String g) { 100 | PVTSFrame.recuTextArea.setText(""); 101 | ArrowDB.arrowArray = new ArrayList(); 102 | // DrawingTreesPanel.clearTagList(); 103 | PVTSFrame.functag.setText(""); 104 | DrawingTreesPanel.currentlySelected = null; 105 | yRec = 50; 106 | FunctionManager.current_y = 0; 107 | String globalBuffer = g; 108 | int initPos = 0; 109 | bufferStack.clear(); 110 | bufferStack.push(globalBuffer); 111 | bufferStack.push(initPos); 112 | envStack.enviro.clear(); 113 | globalEnv.clear(); 114 | envStack.enviro.push(globalEnv); 115 | quote_mode = false; 116 | currentLine = 1; 117 | ErrorMess.allmessages = ""; 118 | a = 32; // affects y 119 | b = 150;// affects x 120 | list_of_lists = new LinkedList();// this list will hold all the Cons Cell lists. 121 | orphan_list_of_lists = new LinkedList(); // this list will hold all the orphan lists. 122 | list_of_trees = new LinkedList(); // this list will hold all the trees related to the recursive functions drawn. 123 | error = false; 124 | ReadEvalPrint.loadPrimitives(envStack); 125 | } 126 | 127 | public static boolean moreInput() { 128 | ReadEvalPrint.skipBlanks(); 129 | return (TextIO.peek() != '~' );//(TextIO.pos < (TextIO.buffer.length())); 130 | } 131 | 132 | public static boolean anotherSExpr() { 133 | ReadEvalPrint.skipBlanks(); 134 | char c = TextIO.peek(); 135 | //TextIO.putln("in anotherExpr"); // DEBUG 136 | //TextIO.putln(c); // DEBUG 137 | boolean b = (c == '(') || Character.isLetter(c) || Character.isDigit(c) || (c == '#') || (c == '\'') 138 | || (c == '+') || (c == '-') || (c == '/') || (c == '*') || (c == '<') || (c == '>') 139 | || (c == '=') || (c == '!') || (c == '"'); 140 | // if (!b) TextIO.getln(); // Flush the line 141 | return (b && (c != '\n') && (c != '\r')); 142 | } 143 | 144 | 145 | 146 | public static SExpression repProcedure() { 147 | ArrayList posible_body = new ArrayList(); 148 | //posible_body.add(new Primitive("begin",86)); 149 | SExpression exp = new Mess("the procedure has no return statement! revise syntax"); 150 | // will do the same as rep() except that will return in the end the las SExpression. 151 | while (moreInput() && !error) { 152 | ReadEvalPrint.skipBlanks(); 153 | if (TextIO.peek() == ';') // it denotes that the current line is a comment 154 | TextIO.getln(); // flush the line 155 | if (!anotherSExpr() && !(TextIO.peek() == ';')) { 156 | PVTSFrame.put("read: bad syntax, unexpected "+TextIO.getAnyChar()+"\n"); 157 | PVTS.error = true; 158 | break; 159 | } 160 | // if (!anotherSExpr()) 161 | // break; 162 | 163 | while (anotherSExpr() && !error) { 164 | Interpreter interp = new Interpreter(); 165 | try { 166 | // read eval print loop 167 | exp = interp.parse_eval(envStack); 168 | //if (!exp.getClass().getName().equalsIgnoreCase("Mess")) 169 | posible_body.add(exp); 170 | 171 | } catch (Exception e) { 172 | PVTSFrame.put(e.getMessage()); 173 | PVTSFrame.put(ErrorMess.allmessages); 174 | } 175 | 176 | } // END while (anotherSExpr()) 177 | 178 | } 179 | if (exp.isProcedure()) { 180 | //((Procedure) exp).body = posible_body; 181 | Procedure p = new Procedure(((Procedure)exp).op); 182 | p.parameters = ((Procedure)exp).parameters; 183 | p.body = posible_body; 184 | //p.environment = new Hashtable(); 185 | //Enumeration ele = PVTS.envStack.enviro.peek().elements(); 186 | //Enumeration keys = PVTS.envStack.enviro.peek().keys(); 187 | /* while (ele.hasMoreElements()) { 188 | SExpression next = ele.nextElement(); 189 | String s = keys.nextElement(); 190 | p.environment.put(s,next); 191 | }*/ 192 | //p.environment = PVTS.envStack.enviro.peek(); 193 | 194 | //p.environment = PVTS.procedure_environments.peek(); 195 | // p.body.add(posible_body.get(0)); 196 | // p.body.add(posible_body.get(1)); 197 | // p.body.add(((Procedure) exp).body.get(0)); 198 | 199 | //for (int i=0 ; i < posible_body.size() ; i ++) { 200 | // if (!((Procedure)exp).name_obj.equals("SExpression!")) 201 | // ((Procedure)exp).addToBody(posible_body.get(i)); 202 | // else 203 | // return new ErrorMess("returned an SExpression! @ pvts.java (repProcedure())"); 204 | //} 205 | return p; 206 | } 207 | //return eval_procedure(posible_body,new Primitive("begin",86), PVTS.envStack); 208 | else 209 | return exp; 210 | } 211 | 212 | public static SExpression repLet() { 213 | SExpression exp = new Mess("the procedure has no return statement! revise syntax"); 214 | // will do the same as rep() except that will return in the end the las SExpression. 215 | while (TextIO.peek() != ')' && !error) { 216 | ReadEvalPrint.skipBlanks(); 217 | if (TextIO.peek() == '~') // end of file error 218 | new ErrorMess("read: expected ')'"); 219 | if (TextIO.peek() == ';') // it denotes that the current line is a comment 220 | TextIO.getln(); // flush the line 221 | 222 | while (anotherSExpr() && !error) { 223 | Interpreter interp = new Interpreter(); 224 | try { 225 | // read eval print loop 226 | exp = interp.parse_eval(envStack); 227 | 228 | } catch (Exception e) { 229 | PVTSFrame.put(e.getMessage()); 230 | PVTSFrame.put(ErrorMess.allmessages); 231 | } 232 | 233 | } // END while (anotherSExpr()) 234 | } 235 | return exp; 236 | } 237 | 238 | public static SExpression repCond() { 239 | SExpression exp = new Mess("the procedure has no return statement! revise syntax"); 240 | // will do the same as rep() except that will return in the end the las SExpression. 241 | while (TextIO.peek() != ')' && !error) { 242 | ReadEvalPrint.skipBlanks(); 243 | if (TextIO.peek() == ';') // it denotes that the current line is a comment 244 | TextIO.getln(); // flush the line 245 | if (!anotherSExpr() && !(TextIO.peek() == ';')) { 246 | PVTSFrame.put("read: bad syntax, unexpected "+TextIO.getAnyChar()+"\n"); 247 | PVTS.error = true; 248 | break; 249 | } 250 | // if (!anotherSExpr()) 251 | // break; 252 | while (anotherSExpr() && !error) { 253 | Interpreter interp = new Interpreter(); 254 | try { 255 | // read eval print loop 256 | exp = interp.parse_eval(envStack); 257 | 258 | } catch (Exception e) { 259 | PVTSFrame.put(e.getMessage()); 260 | PVTSFrame.put(ErrorMess.allmessages); 261 | } 262 | 263 | } // END while (anotherSExpr()) 264 | } 265 | return exp; 266 | } 267 | 268 | public static void rep() { 269 | //ReadEvalPrint.skipBlanks(); 270 | if(!PVTSFrame.stepper_mode) { 271 | while (moreInput() && !error) { 272 | ReadEvalPrint.skipBlanks(); 273 | if (TextIO.peek() == ';') // it denotes that the current line is a comment 274 | {TextIO.getln(); PVTSFrame.startHighlight = TextIO.getPos();} // flush the line 275 | if (!anotherSExpr() && !(TextIO.peek() == ';') && moreInput()) { 276 | PVTSFrame.put("read: bad syntax, unexpected "+TextIO.getAnyChar()+"\n"); 277 | PVTS.error = true; 278 | break; 279 | } 280 | // if (!anotherSExpr()) 281 | // break; 282 | while (anotherSExpr() && !error) { 283 | runInterpreter(); 284 | } // END while (anotherSExpr()) 285 | } // END while (moreInput()) 286 | 287 | 288 | }//end if stepper_mode 289 | else { 290 | ReadEvalPrint.skipBlanks(); 291 | while (TextIO.peek() == ';') { 292 | 293 | ReadEvalPrint.skipBlanks(); 294 | TextIO.getln(); 295 | PVTSFrame.startHighlight = TextIO.getPos(); 296 | ReadEvalPrint.skipBlanks(); 297 | }// flush the line 298 | // ReadEvalPrint.skipBlanks(); 299 | if(moreInput() && anotherSExpr() && !error) { 300 | // if (!anotherSExpr()) 301 | // break; 302 | // ReadEvalPrint.skipBlanks(); 303 | runInterpreter(); 304 | 305 | } else if (!anotherSExpr() && !(TextIO.peek() == ';') && (moreInput())) { 306 | PVTSFrame.put("read: bad syntax, unexpected "+TextIO.getAnyChar()+"\n"); 307 | PVTS.error = true; 308 | } else { 309 | if (error) 310 | PVTSFrame.put(ErrorMess.allmessages); 311 | else { 312 | PVTSFrame.stopStepper = true; 313 | //PVTSFrame.stopStepper(); 314 | //PVTSFrame.put("system: done! Please Stop Stepper.\n"); 315 | Toolkit.getDefaultToolkit().beep(); 316 | } 317 | } 318 | } 319 | 320 | } // end rep () 321 | 322 | 323 | public static void runInterpreter() { 324 | Interpreter interp = new Interpreter(); 325 | try { 326 | // read eval print loop 327 | SExpression exp = interp.parse_eval(envStack); 328 | if (!exp.getClass().getName().equals("Mess")) { 329 | if (exp != null) exp.print(); 330 | PVTSFrame.put("\n"); 331 | if (!PVTS.orphan_list_of_lists.contains(exp) && !PVTS.list_of_lists.contains(exp) && exp.getClass().getName().equals("ListCC")) { 332 | PVTS.orphan_list_of_lists.add(exp); 333 | ListManager lm = new ListManager((ListCC) exp); 334 | lm.setOffsets(PVTS.a,PVTS.b); 335 | lm.manage(); 336 | PVTS.a = 64 + lm.giveMaxY(); 337 | } 338 | } 339 | } catch (Exception e) { 340 | PVTSFrame.put(e.getMessage()); 341 | PVTSFrame.put(ErrorMess.allmessages); 342 | } 343 | 344 | 345 | } 346 | } -------------------------------------------------------------------------------- /PVTSFrame$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$1.class -------------------------------------------------------------------------------- /PVTSFrame$10.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$10.class -------------------------------------------------------------------------------- /PVTSFrame$11.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$11.class -------------------------------------------------------------------------------- /PVTSFrame$12.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$12.class -------------------------------------------------------------------------------- /PVTSFrame$13.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$13.class -------------------------------------------------------------------------------- /PVTSFrame$14.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$14.class -------------------------------------------------------------------------------- /PVTSFrame$15.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$15.class -------------------------------------------------------------------------------- /PVTSFrame$16.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$16.class -------------------------------------------------------------------------------- /PVTSFrame$17.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$17.class -------------------------------------------------------------------------------- /PVTSFrame$18.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$18.class -------------------------------------------------------------------------------- /PVTSFrame$19.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$19.class -------------------------------------------------------------------------------- /PVTSFrame$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$2.class -------------------------------------------------------------------------------- /PVTSFrame$20.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$20.class -------------------------------------------------------------------------------- /PVTSFrame$21.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$21.class -------------------------------------------------------------------------------- /PVTSFrame$22.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$22.class -------------------------------------------------------------------------------- /PVTSFrame$23.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$23.class -------------------------------------------------------------------------------- /PVTSFrame$24.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$24.class -------------------------------------------------------------------------------- /PVTSFrame$25.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$25.class -------------------------------------------------------------------------------- /PVTSFrame$26.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$26.class -------------------------------------------------------------------------------- /PVTSFrame$27.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$27.class -------------------------------------------------------------------------------- /PVTSFrame$28.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$28.class -------------------------------------------------------------------------------- /PVTSFrame$29.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$29.class -------------------------------------------------------------------------------- /PVTSFrame$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$3.class -------------------------------------------------------------------------------- /PVTSFrame$30.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$30.class -------------------------------------------------------------------------------- /PVTSFrame$31.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$31.class -------------------------------------------------------------------------------- /PVTSFrame$32.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$32.class -------------------------------------------------------------------------------- /PVTSFrame$33.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$33.class -------------------------------------------------------------------------------- /PVTSFrame$34.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$34.class -------------------------------------------------------------------------------- /PVTSFrame$35.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$35.class -------------------------------------------------------------------------------- /PVTSFrame$36.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$36.class -------------------------------------------------------------------------------- /PVTSFrame$37.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$37.class -------------------------------------------------------------------------------- /PVTSFrame$38.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$38.class -------------------------------------------------------------------------------- /PVTSFrame$39.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$39.class -------------------------------------------------------------------------------- /PVTSFrame$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$4.class -------------------------------------------------------------------------------- /PVTSFrame$40.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$40.class -------------------------------------------------------------------------------- /PVTSFrame$41.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$41.class -------------------------------------------------------------------------------- /PVTSFrame$42.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$42.class -------------------------------------------------------------------------------- /PVTSFrame$43.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$43.class -------------------------------------------------------------------------------- /PVTSFrame$44.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$44.class -------------------------------------------------------------------------------- /PVTSFrame$45.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$45.class -------------------------------------------------------------------------------- /PVTSFrame$46.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$46.class -------------------------------------------------------------------------------- /PVTSFrame$47.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$47.class -------------------------------------------------------------------------------- /PVTSFrame$48.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$48.class -------------------------------------------------------------------------------- /PVTSFrame$49.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$49.class -------------------------------------------------------------------------------- /PVTSFrame$5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$5.class -------------------------------------------------------------------------------- /PVTSFrame$50.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$50.class -------------------------------------------------------------------------------- /PVTSFrame$51.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$51.class -------------------------------------------------------------------------------- /PVTSFrame$52.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$52.class -------------------------------------------------------------------------------- /PVTSFrame$53.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$53.class -------------------------------------------------------------------------------- /PVTSFrame$54.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$54.class -------------------------------------------------------------------------------- /PVTSFrame$55.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$55.class -------------------------------------------------------------------------------- /PVTSFrame$56.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$56.class -------------------------------------------------------------------------------- /PVTSFrame$57.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$57.class -------------------------------------------------------------------------------- /PVTSFrame$58.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$58.class -------------------------------------------------------------------------------- /PVTSFrame$59.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$59.class -------------------------------------------------------------------------------- /PVTSFrame$6.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$6.class -------------------------------------------------------------------------------- /PVTSFrame$60.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$60.class -------------------------------------------------------------------------------- /PVTSFrame$61.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$61.class -------------------------------------------------------------------------------- /PVTSFrame$62.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$62.class -------------------------------------------------------------------------------- /PVTSFrame$63.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$63.class -------------------------------------------------------------------------------- /PVTSFrame$7.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$7.class -------------------------------------------------------------------------------- /PVTSFrame$8.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$8.class -------------------------------------------------------------------------------- /PVTSFrame$9.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$9.class -------------------------------------------------------------------------------- /PVTSFrame$MyHighlightPainter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame$MyHighlightPainter.class -------------------------------------------------------------------------------- /PVTSFrame.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame.class -------------------------------------------------------------------------------- /PVTSFrame.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PVTSFrame.java -------------------------------------------------------------------------------- /Primitive.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/Primitive.class -------------------------------------------------------------------------------- /Primitive.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Primitive.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | 30 | import java.awt.*; 31 | import java.awt.event.*; 32 | 33 | class Primitive extends Function { 34 | 35 | 36 | Primitive(String s,int c) { 37 | prim_code = c; 38 | op = s; 39 | x = 0; 40 | y = 0; 41 | } 42 | 43 | void print() { 44 | PVTSFrame.put("#"); 45 | } 46 | 47 | public SEBool copy() { 48 | return new SEBool(this.op); 49 | } 50 | 51 | public void setOp(String st) { 52 | op = st; 53 | } 54 | 55 | public String getOp() { 56 | return op; 57 | } 58 | 59 | 60 | public int getX() { 61 | return x; 62 | } 63 | 64 | public int getY() { 65 | return y; 66 | } 67 | 68 | 69 | 70 | 71 | 72 | public void draw(Graphics g) { 73 | g.drawString(""+ op,x,y); 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /PrintUtilities.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/PrintUtilities.class -------------------------------------------------------------------------------- /PrintUtilities.java: -------------------------------------------------------------------------------- 1 | import java.awt.*; 2 | import javax.swing.*; 3 | import java.awt.print.*; 4 | 5 | /** A simple utility class that lets you very simply print 6 | * an arbitrary component. Just pass the component to the 7 | * PrintUtilities.printComponent. The component you want to 8 | * print doesn't need a print method and doesn't have to 9 | * implement any interface or do anything special at all. 10 | *

11 | * If you are going to be printing many times, it is marginally more 12 | * efficient to first do the following: 13 | *

14 |  *    PrintUtilities printHelper = new PrintUtilities(theComponent);
15 |  *  
16 | * then later do printHelper.print(). But this is a very tiny 17 | * difference, so in most cases just do the simpler 18 | * PrintUtilities.printComponent(componentToBePrinted). 19 | * 20 | * 7/99 Marty Hall, http://www.apl.jhu.edu/~hall/java/ 21 | * May be freely used or adapted. 22 | */ 23 | 24 | public class PrintUtilities implements Printable { 25 | private Component componentToBePrinted; 26 | 27 | public static void printComponent(Component c) { 28 | new PrintUtilities(c).print(); 29 | } 30 | 31 | public PrintUtilities(Component componentToBePrinted) { 32 | this.componentToBePrinted = componentToBePrinted; 33 | } 34 | 35 | public void print() { 36 | PrinterJob printJob = PrinterJob.getPrinterJob(); 37 | printJob.setPrintable(this); 38 | if (printJob.printDialog()) 39 | try { 40 | printJob.print(); 41 | } catch(PrinterException pe) { 42 | System.out.println("Error printing: " + pe); 43 | } 44 | } 45 | 46 | public int print(Graphics g, PageFormat pageFormat, int pageIndex) { 47 | if (pageIndex > 0) { 48 | return(NO_SUCH_PAGE); 49 | } else { 50 | Graphics2D g2d = (Graphics2D)g; 51 | g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY()); 52 | disableDoubleBuffering(componentToBePrinted); 53 | componentToBePrinted.paint(g2d); 54 | enableDoubleBuffering(componentToBePrinted); 55 | return(PAGE_EXISTS); 56 | } 57 | } 58 | 59 | /** The speed and quality of printing suffers dramatically if 60 | * any of the containers have double buffering turned on. 61 | * So this turns if off globally. 62 | * @see enableDoubleBuffering 63 | */ 64 | public static void disableDoubleBuffering(Component c) { 65 | RepaintManager currentManager = RepaintManager.currentManager(c); 66 | currentManager.setDoubleBufferingEnabled(false); 67 | } 68 | 69 | /** Re-enables double buffering globally. */ 70 | 71 | public static void enableDoubleBuffering(Component c) { 72 | RepaintManager currentManager = RepaintManager.currentManager(c); 73 | currentManager.setDoubleBufferingEnabled(true); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Procedure.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/Procedure.class -------------------------------------------------------------------------------- /Procedure.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Procedure.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | 30 | import java.awt.*; 31 | import java.awt.event.*; 32 | import java.util.*; 33 | 34 | class Procedure extends Function { 35 | 36 | ArrayList parameters; 37 | ArrayList body; 38 | Stack environments; 39 | boolean isVariableNumberOfParameters = false; 40 | 41 | String parametersToString() { 42 | String s = ""; 43 | for (int i = 0; i < parameters.size(); i++) { 44 | s = s+parameters.get(i)+" "; 45 | } 46 | return s; 47 | } 48 | 49 | Procedure copyReturn () { 50 | Procedure p = new Procedure(this.op); 51 | p.parameters = this.parameters; 52 | p.body = this.body; 53 | return p; 54 | } 55 | 56 | Procedure(String s) { 57 | parameters = new ArrayList(); 58 | environments = new Stack(); 59 | op = s; 60 | body = new ArrayList(); 61 | x = 0; 62 | y = 0; 63 | isVariableNumberOfParameters = false; 64 | } 65 | 66 | 67 | /* void setBody (SExpression b) { 68 | body = b; 69 | }*/ 70 | 71 | 72 | 73 | 74 | 75 | void addToBody (SExpression b) { 76 | body.add(b); 77 | } 78 | 79 | public String toString() { 80 | String temp = ""; 81 | 82 | for (int i = 0; i"); 102 | } 103 | 104 | public SEBool copy() { 105 | return new SEBool(this.op); 106 | } 107 | 108 | public void setOp(String st) { 109 | op = st; 110 | } 111 | 112 | public String getOp() { 113 | return op; 114 | } 115 | 116 | 117 | public int getX() { 118 | return x; 119 | } 120 | 121 | public int getY() { 122 | return y; 123 | } 124 | 125 | 126 | 127 | 128 | 129 | public void draw(Graphics g) { 130 | g.drawString(""+ op,x,y); 131 | } 132 | 133 | } -------------------------------------------------------------------------------- /ProcedureAndArgs.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/ProcedureAndArgs.class -------------------------------------------------------------------------------- /ProcedureAndArgs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ProcedureAndArgs.java 3 | * 4 | * Created on September 7, 2006, 8:27 PM 5 | * 6 | * author: David Pilo 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | import java.util.*; 30 | /** 31 | * 32 | * @author david 33 | */ 34 | public class ProcedureAndArgs { 35 | 36 | /** Creates a new instance of ProcedureAndArgs */ 37 | public ProcedureAndArgs() { 38 | } 39 | public String p; 40 | public ArrayList sexprs; 41 | //public int index; 42 | public int xCoor; 43 | public int yCoor; 44 | public int height; 45 | public int width; 46 | public SExpression result; 47 | public String display; 48 | 49 | //SExpression result; 50 | ProcedureAndArgs(String pro , ArrayList args) { 51 | this.sexprs = args; 52 | this.p = pro; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ReadEvalPrint$ParseError.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/ReadEvalPrint$ParseError.class -------------------------------------------------------------------------------- /ReadEvalPrint.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/ReadEvalPrint.class -------------------------------------------------------------------------------- /ReadEvalPrint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ReadEvalPrint.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | 30 | import java.util.*; 31 | 32 | /* 33 | This class loads the primitives into the global environment 34 | */ 35 | 36 | 37 | 38 | public class ReadEvalPrint { 39 | 40 | 41 | static class ParseError extends Exception { 42 | // Represents a syntax found in the user's input. 43 | ParseError(String message) { 44 | super(message); 45 | } 46 | } // end nested class ParseError 47 | 48 | 49 | 50 | 51 | static void loadPrimitives(Environment env) { // load current collection of system primitives 52 | env.put("SExpression!",new Mess("SExpression!",-1)); 53 | env.put("list",new Primitive("list",1)); 54 | env.put("car",new Primitive("car",2)); 55 | env.put("cdr",new Primitive("cdr",3)); 56 | env.put("cons",new Primitive("cons",4)); 57 | env.put("set-car!",new Primitive("set-car!",5)); 58 | env.put("set-cdr!",new Primitive("set-cdr!",6)); 59 | env.put("append", new Primitive("append", 7)); 60 | env.put(">", new Primitive(">", 8)); 61 | env.put("<", new Primitive("<",9)); 62 | env.put(">=", new Primitive(">=",10)); 63 | env.put("<=", new Primitive("<=",11)); 64 | env.put("=", new Primitive("=",12)); 65 | env.put("+",new Primitive("+",13)); 66 | env.put("-",new Primitive("-",14)); 67 | env.put("*",new Primitive("*",15)); 68 | env.put("/",new Primitive("/",16)); 69 | env.put("and",new Primitive("and",17)); 70 | env.put("or",new Primitive("or",18)); 71 | env.put("not",new Primitive("not",19)); 72 | env.put("display",new Primitive("display",20)); 73 | env.put("null?",new Primitive("null?",21)); 74 | env.put("assoc",new Primitive("assoc",22)); 75 | env.put("equal?",new Primitive("equal?",23)); 76 | env.put("list?",new Primitive("list?",24)); 77 | env.put("odd?",new Primitive("odd?",25)); 78 | env.put("even?",new Primitive("even?",26)); 79 | env.put("abs",new Primitive("abs",27)); 80 | env.put("cos",new Primitive("cos",28)); 81 | env.put("sin",new Primitive("sin",29)); 82 | env.put("tan",new Primitive("tan",30)); 83 | env.put("acos",new Primitive("acos",31)); 84 | env.put("asin",new Primitive("asin",32)); 85 | env.put("atan",new Primitive("atan",33)); 86 | env.put("sqrt",new Primitive("sqrt",34)); 87 | env.put("zero?",new Primitive("zero?",35)); 88 | env.put("max",new Primitive("max",36)); 89 | env.put("min",new Primitive("min",37)); 90 | env.put("eq?",new Primitive("eq?",38)); 91 | env.put("eqv?",new Primitive("eqv?",39)); 92 | env.put("newline",new Primitive("newline",40)); 93 | env.put("exp",new Primitive("exp",41)); 94 | env.put("expt",new Primitive("expt",42)); 95 | env.put("positive?",new Primitive("positive?",43)); 96 | env.put("negative?",new Primitive("negative?",44)); 97 | env.put("ceiling",new Primitive("ceiling",45)); 98 | env.put("floor",new Primitive("floor",46)); 99 | env.put("integer?",new Primitive("integer?",47)); 100 | env.put("real?",new Primitive("real?",48)); 101 | env.put("number?",new Primitive("number?",49)); 102 | env.put("modulo",new Primitive("modulo",50)); 103 | env.put("procedure?",new Primitive("procedure?",51)); 104 | env.put("log",new Primitive("log",52)); 105 | env.put("reverse", new Primitive("reverse",53)); 106 | env.put("caar", new Primitive("caar",54)); 107 | env.put("cadr", new Primitive("cadr",55)); 108 | env.put("cdar", new Primitive("cdar",56)); 109 | env.put("cddr", new Primitive("cddr",57)); 110 | env.put("caaar", new Primitive("caaar",58)); 111 | env.put("caadr", new Primitive("caadr",59)); 112 | env.put("cadar", new Primitive("cadar",60)); 113 | env.put("cdaar", new Primitive("cdaar",61)); 114 | env.put("caddr", new Primitive("caddr",62)); 115 | env.put("cdadr", new Primitive("cdadr",63)); 116 | env.put("cddar", new Primitive("cddar",64)); 117 | env.put("cdddr", new Primitive("cdddr",65)); 118 | env.put("caaaar", new Primitive("caaaar",66)); 119 | env.put("cdaaar", new Primitive("cdaaar",67)); 120 | env.put("cadaar", new Primitive("cadaar",68)); 121 | env.put("caadar", new Primitive("caadar",69)); 122 | env.put("caaadr", new Primitive("caaadr",70)); 123 | env.put("cddaar", new Primitive("cddaar",71)); 124 | env.put("caddar", new Primitive("caddar",72)); 125 | env.put("caaddr", new Primitive("caaddr",73)); 126 | env.put("cadadr", new Primitive("cadadr",74)); 127 | env.put("cdadar", new Primitive("cdadar",75)); 128 | env.put("cdaadr", new Primitive("cdaadr",76)); 129 | env.put("cdddar", new Primitive("cdddar",77)); 130 | env.put("cddarr", new Primitive("cddaar",78)); 131 | env.put("cdaddr", new Primitive("cdaddr",79)); 132 | env.put("cadddr", new Primitive("cadddr",80)); 133 | env.put("cddddr", new Primitive("cddddr",81)); 134 | env.put("map",new Primitive("map",82)); 135 | env.put("member", new Primitive("member",83)); 136 | env.put("list-ref", new Primitive("list-ref",84)); 137 | env.put("length", new Primitive("length",85)); 138 | env.put("begin", new Primitive("begin",86)); 139 | env.put("gcd",new Primitive("gcd",87)); 140 | env.put("char?", new Primitive("char?",88)); 141 | env.put("string?", new Primitive("string?",89)); 142 | env.put("symbol?", new Primitive("symbol?",90)); 143 | env.put("for-each", new Primitive("for-each",91)); 144 | 145 | } 146 | 147 | static void skipBlanks() { 148 | // Skip past any spaces and tabs on the current line of input. 149 | // Stop at a non-blank character or end-of-line. 150 | 151 | while ( TextIO.peek() == ' ' || TextIO.peek() == '\t' || TextIO.peek() == '\n' || TextIO.peek() == '\r') 152 | TextIO.getAnyChar(); 153 | } 154 | 155 | } // end class SimpleParser3 -------------------------------------------------------------------------------- /RecuFunc.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/RecuFunc.class -------------------------------------------------------------------------------- /RecuFunc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * RecuFunc.java 3 | * 4 | * Created on December 23, 2006, 5:43 PM 5 | * 6 | * author: David Pilo 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | 30 | /** 31 | * 32 | * @author David 33 | */ 34 | public class RecuFunc { 35 | 36 | /** Creates a new instance of RecuFunc */ 37 | static public int posBuffer; 38 | static public String str; 39 | public RecuFunc() { 40 | posBuffer = 0; 41 | str = ""; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /SEBool.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/SEBool.class -------------------------------------------------------------------------------- /SEBool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SEBool.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | 30 | import java.awt.*; 31 | import java.awt.event.*; 32 | 33 | class SEBool extends Atom { 34 | String bool; 35 | 36 | SEBool(String b) { 37 | bool = b; 38 | x = 0; 39 | y = 0; 40 | } 41 | 42 | void print() { 43 | PVTSFrame.put(bool); 44 | } 45 | 46 | public SEBool copy() { 47 | return new SEBool(this.bool); 48 | } 49 | 50 | public void setTrue() { 51 | bool = "#t"; 52 | } 53 | 54 | public void setFalse() { 55 | bool = "#f"; 56 | } 57 | 58 | public int getX() { 59 | return x; 60 | } 61 | 62 | public int getY() { 63 | return y; 64 | } 65 | 66 | public String getPrintable() { 67 | return bool; 68 | } 69 | 70 | public Boolean boolValue() { 71 | if (bool.equals("#f")) 72 | return false; 73 | else 74 | return true; 75 | } 76 | 77 | 78 | public void draw(Graphics g) { 79 | g.drawString(""+ bool,x,y); 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /SEChar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/SEChar.class -------------------------------------------------------------------------------- /SEChar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SEChar.java 3 | * 4 | * Created on September 11, 2006, 11:06 PM 5 | * 6 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 7 | Copyright (C) 2007 David A. Pilo Mansion 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | Contact information: 24 | David Pilo 25 | davidpilo@gmail.com 26 | */ 27 | import java.awt.*; 28 | import java.awt.event.*; 29 | /** 30 | * 31 | * @author David Pilo 32 | */ 33 | public class SEChar extends Atom { 34 | String st; 35 | 36 | SEChar(String s) { 37 | st = s; 38 | x = 0; 39 | y = 0; 40 | } 41 | 42 | void print() { 43 | PVTSFrame.put(st); 44 | } 45 | 46 | public String getPrintable() { 47 | return st; 48 | } 49 | 50 | public String display() { 51 | String r = st.substring(2,st.length()); 52 | return r; 53 | } 54 | 55 | public SEString copy() { 56 | // TextIO.put("done SEInt copy"); 57 | return new SEString(this.st); 58 | } 59 | 60 | public int getX() { 61 | return x; 62 | } 63 | 64 | public int getY() { 65 | return y; 66 | } 67 | 68 | 69 | 70 | public String stringValue() { 71 | return st; 72 | } 73 | 74 | 75 | public void draw(Graphics g) { 76 | g.drawString(st,x,y); 77 | } 78 | 79 | } 80 | 81 | -------------------------------------------------------------------------------- /SEFloat.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/SEFloat.class -------------------------------------------------------------------------------- /SEFloat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SEFloat.java 3 | * 4 | * Created on June 28, 2006, 1:37 PM 5 | * 6 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 7 | Copyright (C) 2007 David A. Pilo Mansion 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | Contact information: 24 | David Pilo 25 | davidpilo@gmail.com 26 | */ 27 | 28 | /** 29 | * 30 | * @author David Pilo 31 | */ 32 | import java.awt.*; 33 | import java.awt.event.*; 34 | 35 | class SEFloat extends SENumber { 36 | double num; 37 | 38 | SEFloat(double n) { 39 | num = n; 40 | x = 0; 41 | y = 0; 42 | } 43 | 44 | void print() { 45 | PVTSFrame.put(num); 46 | } 47 | 48 | public String getPrintable() { 49 | return ""+num; 50 | } 51 | 52 | public SEFloat copy() { 53 | // TextIO.put("done SEInt copy"); 54 | return new SEFloat(this.num); 55 | } 56 | 57 | public int getX() { 58 | return x; 59 | } 60 | 61 | public int getY() { 62 | return y; 63 | } 64 | 65 | 66 | 67 | public double getValue() { 68 | return num; 69 | } 70 | 71 | 72 | public void draw(Graphics g) { 73 | g.drawString(""+ num,x,y); 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /SEInt.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/SEInt.class -------------------------------------------------------------------------------- /SEInt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SEInt.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | 30 | import java.awt.*; 31 | import java.awt.event.*; 32 | 33 | class SEInt extends SENumber { 34 | int num; 35 | 36 | SEInt(int n) { 37 | num = n; 38 | x = 0; 39 | y = 0; 40 | } 41 | 42 | void print() { 43 | PVTSFrame.put(num); 44 | } 45 | 46 | public String getPrintable() { 47 | return "" + num; 48 | //return "" + ((Integer)num).toString(); 49 | } 50 | 51 | public SEInt copy() { 52 | // TextIO.put("done SEInt copy"); 53 | return new SEInt(this.num); 54 | } 55 | 56 | public int getX() { 57 | return x; 58 | } 59 | 60 | public int getY() { 61 | return y; 62 | } 63 | 64 | 65 | 66 | public int getValue() { 67 | return num; 68 | } 69 | 70 | 71 | public void draw(Graphics g) { 72 | g.drawString(""+ num,x,y); 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /SEName.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/SEName.class -------------------------------------------------------------------------------- /SEName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SEName.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | import java.util.ArrayList; 30 | 31 | public class SEName { 32 | int environmentLevel; 33 | ArrayList nameAL; 34 | // String exp_name; 35 | int x, y; 36 | boolean managed; 37 | 38 | public SEName() { 39 | environmentLevel = -1; //this var should never be left unmodified. 40 | nameAL = new ArrayList(); 41 | managed = false; 42 | } 43 | public void setXY(int a, int b) { 44 | if (!managed) { 45 | x = a; 46 | y = b; 47 | } 48 | } 49 | 50 | public void setEnvironmentLevel (int i) { 51 | environmentLevel = i; 52 | } 53 | 54 | public void setX(int n) { 55 | if (!managed) { 56 | x = n; 57 | } 58 | } 59 | 60 | public boolean hasAName() { 61 | return (!nameAL.isEmpty()); 62 | } 63 | 64 | public void setY(int n) { 65 | if (!managed) { 66 | y = n; 67 | } 68 | } 69 | 70 | 71 | public void addName(String n) { 72 | if (!nameAL.contains(n)) { 73 | nameAL.add(n); 74 | } 75 | } 76 | 77 | public void removeName(String n) { 78 | if (nameAL.contains(n)) { 79 | nameAL.remove(n); 80 | } 81 | 82 | } 83 | 84 | public String getName() { 85 | String temp = ""; 86 | if (hasAName()) { 87 | if (environmentLevel != 0) 88 | temp = temp + "E"+environmentLevel+": "; 89 | else 90 | temp = temp + "GE: "; 91 | } 92 | int l; 93 | for (String st: nameAL) { 94 | temp = temp + st +","; 95 | } 96 | l = temp.length(); 97 | return temp.substring(0,l-1); 98 | } 99 | 100 | 101 | } -------------------------------------------------------------------------------- /SENumber.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/SENumber.class -------------------------------------------------------------------------------- /SENumber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SENumber.java 3 | * 4 | * Created on June 28, 2006, 1:32 PM 5 | * 6 | * author David Pilo 7 | * 8 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 9 | Copyright (C) 2007 David A. Pilo Mansion 10 | 11 | This program is free software; you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation; either version 2 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License along 22 | with this program; if not, write to the Free Software Foundation, Inc., 23 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | Contact information: 26 | David Pilo 27 | davidpilo@gmail.com 28 | */ 29 | 30 | /** 31 | * 32 | * @author david 33 | */ 34 | public abstract class SENumber extends Atom { 35 | 36 | /** Creates a new instance of SENumber */ 37 | /* public SENumber(int n) { 38 | new SEInt(n); 39 | } 40 | 41 | public SENumber(double n) { 42 | new SEFloat(n); 43 | }*/ 44 | /* public int getValue() { 45 | return this.getValue(); 46 | } */ 47 | /* public primitive getValue() { 48 | return this.getValue(); 49 | }*/ 50 | 51 | } 52 | -------------------------------------------------------------------------------- /SEString.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/SEString.class -------------------------------------------------------------------------------- /SEString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SEString.java 3 | * 4 | * Created on June 22, 2006, 1:58 PM 5 | * 6 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 7 | Copyright (C) 2007 David A. Pilo Mansion 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | Contact information: 24 | David Pilo 25 | davidpilo@gmail.com 26 | */ 27 | 28 | /** 29 | * 30 | * @author david pilo 31 | */ 32 | import java.awt.*; 33 | import java.awt.event.*; 34 | 35 | class SEString extends Atom { 36 | String st; 37 | 38 | SEString(String s) { 39 | st = "\"" + s + "\""; 40 | x = 0; 41 | y = 0; 42 | } 43 | 44 | void print() { 45 | PVTSFrame.put(st); 46 | } 47 | 48 | public String getPrintable() { 49 | return st; 50 | } 51 | 52 | public String display() { 53 | return st.substring(1,st.length()-1); 54 | } 55 | 56 | public SEString copy() { 57 | // TextIO.put("done SEInt copy"); 58 | return new SEString(this.st); 59 | } 60 | 61 | public int getX() { 62 | return x; 63 | } 64 | 65 | public int getY() { 66 | return y; 67 | } 68 | 69 | 70 | 71 | public String stringValue() { 72 | return st; 73 | } 74 | 75 | 76 | public void draw(Graphics g) { 77 | g.drawString(st,x,y); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /SESymbol.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/SESymbol.class -------------------------------------------------------------------------------- /SESymbol.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SESymbol.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | 30 | import java.awt.*; 31 | import java.awt.event.*; 32 | 33 | class SESymbol extends Atom { 34 | String symbol; 35 | 36 | SESymbol(String s) { 37 | symbol = s; 38 | x = 0; 39 | y = 0; 40 | } 41 | 42 | void print() { 43 | PVTSFrame.put(symbol); 44 | } 45 | 46 | public String getPrintable() { 47 | return symbol; 48 | } 49 | 50 | public SEBool copy() { 51 | return new SEBool(this.symbol); 52 | } 53 | 54 | public void setSymbol(String st) { 55 | symbol = st; 56 | } 57 | 58 | public String getSymbol() { 59 | return symbol; 60 | } 61 | 62 | 63 | public int getX() { 64 | return x; 65 | } 66 | 67 | public int getY() { 68 | return y; 69 | } 70 | 71 | 72 | 73 | 74 | 75 | 76 | public void draw(Graphics g) { 77 | g.drawString(""+ symbol,x,y); 78 | } 79 | 80 | } -------------------------------------------------------------------------------- /SExpression.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/SExpression.class -------------------------------------------------------------------------------- /SExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SExpression.java 3 | * 4 | * author: David Pilo 5 | * 6 | * 7 | Pilo's Visualization Tools for Scheme (PVTS). A Basic Visual Scheme Interpreter. 8 | Copyright (C) 2007 David A. Pilo Mansion 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Contact information: 25 | David Pilo 26 | davidpilo@gmail.com 27 | */ 28 | 29 | 30 | 31 | import java.awt.*; 32 | import java.awt.event.*; 33 | import java.util.*; 34 | 35 | 36 | abstract class SExpression { 37 | int x,y; 38 | 39 | SEName name_obj = new SEName(); 40 | public boolean managed = false; 41 | // abstract String getName(); 42 | // abstract void setName(String n); 43 | abstract int getX(); 44 | abstract int getY(); 45 | abstract void draw(Graphics g); 46 | abstract void print(); 47 | abstract SExpression copy(); 48 | public String toString() { return "SExpression!";} 49 | 50 | 51 | public Boolean isListCC() { 52 | return this.getClass().getName().equalsIgnoreCase("ListCC"); 53 | } 54 | 55 | public Boolean isReal() { 56 | return (this.getClass().getName().equals("SEInt") || this.getClass().getName().equals("SEFloat")); 57 | } 58 | 59 | 60 | 61 | public Boolean isProperList() { 62 | if (this.getClass().getName().equalsIgnoreCase("ListCC")) { 63 | if (((ListCC) this).isEmpty()) 64 | return true; 65 | if (!((ListCC) this).last.isDottedPair()) 66 | return true; 67 | else 68 | return false; 69 | } 70 | else 71 | return false; 72 | 73 | } 74 | 75 | public Boolean isAtom() { 76 | return (this.getClass().getName().equals("SEInt") || this.getClass().getName().equals("SEBool") || this.getClass().getName().equals("SESymbol") 77 | || this.getClass().getName().equals("Primitive") || this.getClass().getName().equals("Procedure") 78 | || this.getClass().getName().equals("SEString") || this.getClass().getName().equals("SEFloat") || this.getClass().getName().equals("SEChar")); 79 | } 80 | 81 | public Boolean isSEString() { 82 | return this.getClass().getName().equals("SEString"); 83 | } 84 | 85 | public Boolean isSEChar() { 86 | return this.getClass().getName().equals("SEChar"); 87 | } 88 | 89 | public Boolean isFunction() { 90 | return (this.getClass().getName().equals("Primitive") || this.getClass().getName().equals("Procedure") 91 | || this.getClass().getName().equals("Function")); 92 | } 93 | 94 | public Boolean isSENumber() { 95 | return (this.getClass().getName().equals("SEInt") || this.getClass().getName().equals("SEFloat")); 96 | } 97 | 98 | public static Boolean isPrimitive(String st) { 99 | return (st.equals("+") || st.equals("-") || st.equals("/") || st.equals("*") || 100 | st.equals(">") || st.equals("<") || st.equals("=") || st.equals("<=") || 101 | st.equals(">=")); 102 | } 103 | 104 | public Boolean isPrimitiveG() { 105 | return this.getClass().getName().equals("Primitive"); 106 | } 107 | 108 | public Boolean isProcedure() { 109 | return this.getClass().getName().equals("Procedure"); 110 | } 111 | 112 | public Boolean isSEFloat(){ 113 | return this.getClass().getName().equals("SEFloat"); 114 | } 115 | 116 | public Boolean isSEInt(){ 117 | return this.getClass().getName().equals("SEInt"); 118 | } 119 | 120 | public Boolean isSESymbol() { 121 | return this.getClass().getName().equalsIgnoreCase("SESymbol"); 122 | } 123 | 124 | public SEName getNameObj() { 125 | return name_obj; 126 | } 127 | 128 | 129 | 130 | public void setXY(int a, int b) { 131 | if (!managed) { 132 | x = a; 133 | y = b; 134 | } 135 | } 136 | 137 | public void setX(int n) { 138 | if (!managed) { 139 | x = n; 140 | } 141 | } 142 | 143 | public void setY(int n) { 144 | if (!managed) { 145 | y = n; 146 | } 147 | } 148 | 149 | boolean isBounded() { 150 | return name_obj.hasAName(); 151 | } 152 | 153 | 154 | 155 | } 156 | 157 | -------------------------------------------------------------------------------- /TextIO.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/TextIO.class -------------------------------------------------------------------------------- /TextIO.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | The file defines a class TextIO, which provides a simple interface 4 | to Java's standard console input and output. This class defines 5 | several static methods for reading and writing 6 | values of various type. 7 | 8 | This class will only work with standard, interactive applications. 9 | When it is used in such an application, System.out and System.in 10 | should not be used directly, since the TextIO class thinks it has 11 | exclusive control of System.out and System.in. (Actually, using 12 | System.out will probably not cause any problems, but don't use 13 | System.in.) 14 | 15 | To use this class in your program, simply include the compiled class 16 | file TextIO.class in the same directory with the class file for your 17 | main program. (If you are using a development environment such as 18 | CodeWarrior or Visual J++, you can include the source file, 19 | TextIO.java in your project.) You can then use all the public static methods 20 | from the TextIO class in your program. (In your programs, the names 21 | of the methods must be prefaced with "TextIO." For example, you should 22 | use the name TextIO.getln() rather than simply getln().) 23 | 24 | (This class is for use with my on-line introductory java textbook, 25 | which is available at http://math.hws.edu/eck/cs124/notes/index.html.) 26 | 27 | Written by: David Eck 28 | Department of Mathematics and Computer Science 29 | Hobart and William Smith Colleges 30 | Geneva, NY 14456 31 | Email: eck@hws.edu 32 | WWW: http://math.hws.edu/eck/ 33 | 34 | July 16, 1998 35 | 36 | Modified February, 2000; getChar() now skips blanks and CR's, and getAnyChar() 37 | can be used to read the next char even if it's a blank or CR. 38 | 39 | */ 40 | 41 | import java.io.*; 42 | 43 | public class TextIO { 44 | 45 | // *************************** I/O Methods ********************************* 46 | 47 | // Methods for writing the primitive types, plus type String, 48 | // to the console, with no extra spaces. 49 | // 50 | // Note that the real-number data types, float 51 | // and double, a rounded version is output that will 52 | // use at most 10 or 11 characters. If you want to 53 | // output a real number with full accuracy, use 54 | // "TextIO.put(String.valueOf(x))", for example. 55 | 56 | public static void put(int x) { put(x,0); } // Note: also handles byte and short! 57 | public static void put(long x) { put(x,0); } 58 | public static void put(double x) { put(x,0); } // Also handles float. 59 | public static void put(char x) { put(x,0); } 60 | public static void put(boolean x) { put(x,0); } 61 | public static void put(String x) { put(x,0); } 62 | 63 | 64 | // Methods for writing the primitive types, plus type String, 65 | // to the console,followed by a carriage return, with 66 | // no extra spaces. 67 | 68 | public static void putln(int x) { put(x,0); newLine(); } // Note: also handles byte and short! 69 | public static void putln(long x) { put(x,0); newLine(); } 70 | public static void putln(double x) { put(x,0); newLine(); } // Also handles float. 71 | public static void putln(char x) { put(x,0); newLine(); } 72 | public static void putln(boolean x) { put(x,0); newLine(); } 73 | public static void putln(String x) { put(x,0); newLine(); } 74 | 75 | 76 | // Methods for writing the primitive types, plus type String, 77 | // to the console, with a minimum field width of w, 78 | // and followed by a carriage return. 79 | // If output value is less than w characters, it is padded 80 | // with extra spaces in front of the value. 81 | 82 | public static void putln(int x, int w) { put(x,w); newLine(); } // Note: also handles byte and short! 83 | public static void putln(long x, int w) { put(x,w); newLine(); } 84 | public static void putln(double x, int w) { put(x,w); newLine(); } // Also handles float. 85 | public static void putln(char x, int w) { put(x,w); newLine(); } 86 | public static void putln(boolean x, int w) { put(x,w); newLine(); } 87 | public static void putln(String x, int w) { put(x,w); newLine(); } 88 | 89 | 90 | // Method for outputting a carriage return 91 | 92 | public static void putln() { newLine(); } 93 | 94 | 95 | // Methods for writing the primitive types, plus type String, 96 | // to the console, with minimum field width w. 97 | 98 | public static void put(int x, int w) { dumpString(String.valueOf(x), w); } // Note: also handles byte and short! 99 | public static void put(long x, int w) { dumpString(String.valueOf(x), w); } 100 | public static void put(double x, int w) { dumpString(realToString(x), w); } // Also handles float. 101 | public static void put(char x, int w) { dumpString(String.valueOf(x), w); } 102 | public static void put(boolean x, int w) { dumpString(String.valueOf(x), w); } 103 | public static void put(String x, int w) { dumpString(x, w); } 104 | 105 | 106 | // Methods for reading in the primitive types, plus "words" and "lines". 107 | // The "getln..." methods discard any extra input, up to and including 108 | // the next carriage return. 109 | // A "word" read by getlnWord() is any sequence of non-blank characters. 110 | // A "line" read by getlnString() or getln() is everything up to next CR; 111 | // the carriage return is not part of the returned value, but it is 112 | // read and discarded. 113 | // Note that all input methods except getAnyChar(), peek(), the ones for lines 114 | // skip past any blanks and carriage returns to find a non-blank value. 115 | // getln() can return an empty string; getChar() and getlnChar() can 116 | // return a space or a linefeed ('\n') character. 117 | // peek() allows you to look at the next character in input, without 118 | // removing it from the input stream. (Note that using this 119 | // routine might force the user to enter a line, in order to 120 | // check what the next character is.) 121 | // Acceptable boolean values are the "words": true, false, t, f, yes, 122 | // no, y, n, 0, or 1; uppercase letters are OK. 123 | // None of these can produce an error; if an error is found in input, 124 | // the user is forced to re-enter. 125 | // Available input routines are: 126 | // 127 | // getByte() getlnByte() getShort() getlnShort() 128 | // getInt() getlnInt() getLong() getlnLong() 129 | // getFloat() getlnFloat() getDouble() getlnDouble() 130 | // getChar() getlnChar() peek() getAnyChar() 131 | // getWord() getlnWord() getln() getString() getlnString() 132 | // 133 | // (getlnString is the same as getln and is only provided for consistency.) 134 | 135 | public static byte getlnByte() { byte x=getByte(); emptyBuffer(); return x; } 136 | public static short getlnShort() { short x=getShort(); emptyBuffer(); return x; } 137 | public static int getlnInt() { int x=getInt(); emptyBuffer(); return x; } 138 | public static long getlnLong() { long x=getLong(); emptyBuffer(); return x; } 139 | public static float getlnFloat() { float x=getFloat(); emptyBuffer(); return x; } 140 | public static double getlnDouble() { double x=getDouble(); emptyBuffer(); return x; } 141 | public static char getlnChar() { char x=getChar(); emptyBuffer(); return x; } 142 | public static boolean getlnBoolean() { boolean x=getBoolean(); emptyBuffer(); return x; } 143 | public static String getlnWord() { String x=getWord(); emptyBuffer(); return x; } 144 | public static String getlnString() { return getln(); } // same as getln() 145 | public static String getln() { 146 | PVTS.currentLine++; 147 | StringBuffer s = new StringBuffer(100); 148 | char ch = readChar(); 149 | while (ch != '\n') { 150 | s.append(ch); 151 | ch = readChar(); 152 | } 153 | return s.toString(); 154 | } 155 | 156 | 157 | public static byte getByte() { return (byte)readInteger(-128L,127L); } 158 | public static short getShort() { return (short)readInteger(-32768L,32767L); } 159 | public static int getInt() { return (int)readInteger((long)Integer.MIN_VALUE, (long)Integer.MAX_VALUE); } 160 | public static long getLong() { return readInteger(Long.MIN_VALUE, Long.MAX_VALUE); } 161 | 162 | // public static char getAnyChar(){ return readChar(); } 163 | public static char getAnyChar(){ char c = readChar(); 164 | if (c == '\n' && PVTS.bufferStack.size() == 2) {PVTS.currentLine ++;} return c; } 165 | public static char peek() { return lookChar(); } 166 | 167 | public static char getChar() { // skip spaces & cr's, then return next char 168 | char ch = lookChar(); 169 | while (ch == ' ' || ch == '\n') { 170 | readChar(); 171 | if (ch == '\n') 172 | dumpString("? ",0); 173 | ch = lookChar(); 174 | } 175 | return readChar(); 176 | } 177 | 178 | public static float getFloat() { 179 | float x = 0.0F; 180 | while (true) { 181 | String str = readRealString(); 182 | if (str.equals("")) { 183 | errorMessage("Illegal floating point input.", 184 | "Real number in the range " + Float.MIN_VALUE + " to " + Float.MAX_VALUE); 185 | } else { 186 | Float f = null; 187 | try { f = Float.valueOf(str); } catch (NumberFormatException e) { 188 | errorMessage("Illegal floating point input.", 189 | "Real number in the range " + Float.MIN_VALUE + " to " + Float.MAX_VALUE); 190 | continue; 191 | } 192 | if (f.isInfinite()) { 193 | errorMessage("Floating point input outside of legal range.", 194 | "Real number in the range " + Float.MIN_VALUE + " to " + Float.MAX_VALUE); 195 | continue; 196 | } 197 | x = f.floatValue(); 198 | break; 199 | } 200 | } 201 | return x; 202 | } 203 | 204 | public static double getDouble() { 205 | double x = 0.0; 206 | while (true) { 207 | String str = readRealString(); 208 | if (str.equals("")) { 209 | errorMessage("Illegal floating point input", 210 | "Real number in the range " + Double.MIN_VALUE + " to " + Double.MAX_VALUE); 211 | } else { 212 | Double f = null; 213 | try { f = Double.valueOf(str); } catch (NumberFormatException e) { 214 | errorMessage("Illegal floating point input", 215 | "Real number in the range " + Double.MIN_VALUE + " to " + Double.MAX_VALUE); 216 | continue; 217 | } 218 | if (f.isInfinite()) { 219 | errorMessage("Floating point input outside of legal range.", 220 | "Real number in the range " + Double.MIN_VALUE + " to " + Double.MAX_VALUE); 221 | continue; 222 | } 223 | x = f.doubleValue(); 224 | break; 225 | } 226 | } 227 | return x; 228 | } 229 | 230 | public static String peekWord() { 231 | String temp = getWord(); 232 | pos = pos - temp.length(); 233 | return temp; 234 | } 235 | 236 | public static String getWord() { 237 | char ch = lookChar(); 238 | while (ch == ' ' || ch == '\n' || ch == '\t') { 239 | readChar(); 240 | if (ch == '\n') 241 | dumpString("? ",0); 242 | ch = lookChar(); 243 | } 244 | StringBuffer str = new StringBuffer(50); 245 | while (ch != ')' && ch != ' ' && ch != '\n' && ch!='(' && ch!='"' 246 | && ch != '\'' && ch != '`' && ch != '{' && ch!='}' && ch!='[' 247 | && ch != ']' && ch != ';' && ch != '|') { 248 | str.append(readChar()); 249 | ch = lookChar(); 250 | } 251 | return str.toString(); 252 | } 253 | 254 | public static String getWordForSEString() { 255 | char ch = lookChar(); 256 | StringBuffer str = new StringBuffer(50); 257 | while (ch!='"') { 258 | //if (TextIO.peek() != '~') { 259 | str.append(readChar()); 260 | ch = lookChar(); 261 | } 262 | return str.toString(); 263 | } 264 | 265 | public static boolean getBoolean() { 266 | boolean ans = false; 267 | while (true) { 268 | String s = getWord(); 269 | if ( s.equalsIgnoreCase("true") || s.equalsIgnoreCase("t") || 270 | s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("y") || 271 | s.equals("1") ) { 272 | ans = true; 273 | break; 274 | } else if ( s.equalsIgnoreCase("false") || s.equalsIgnoreCase("f") || 275 | s.equalsIgnoreCase("no") || s.equalsIgnoreCase("n") || 276 | s.equals("0") ) { 277 | ans = false; 278 | break; 279 | } else 280 | errorMessage("Illegal boolean input value.", 281 | "one of: true, false, t, f, yes, no, y, n, 0, or 1"); 282 | } 283 | return ans; 284 | } 285 | 286 | // ***************** Everything beyond this point is private ******************* 287 | 288 | // ********************** Utility routines for input/output ******************** 289 | 290 | private static InputStream in = System.in; // rename standard input stream 291 | private static PrintStream out = System.out; // rename standard output stream 292 | 293 | 294 | public static String buffer = null; // one line read from input 295 | public static int pos = 0; // position of next char in input line that has 296 | // not yet been processed 297 | public static void setPos(int p) { 298 | pos = p; 299 | } 300 | 301 | public static int getPos() { 302 | return pos; 303 | } 304 | 305 | public static void fillBuffer(String st, int p) { 306 | buffer = st+"\n"+"\n"+" "+'~'; 307 | TextIO.setPos(p); 308 | //TextIO.putln(buffer); 309 | // in = st.toInputStream(); 310 | //ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes()); 311 | } 312 | 313 | private static String readRealString() { // read chars from input following syntax of real numbers 314 | StringBuffer s=new StringBuffer(50); 315 | char ch=lookChar(); 316 | while (ch == ' ' || ch == '\n') { 317 | readChar(); 318 | if (ch == '\n') 319 | dumpString("? ",0); 320 | ch = lookChar(); 321 | } 322 | if (ch == '-' || ch == '+') { 323 | s.append(readChar()); 324 | ch = lookChar(); 325 | while (ch == ' ') { 326 | readChar(); 327 | ch = lookChar(); 328 | } 329 | } 330 | while (ch >= '0' && ch <= '9') { 331 | s.append(readChar()); 332 | ch = lookChar(); 333 | } 334 | if (ch == '.') { 335 | s.append(readChar()); 336 | ch = lookChar(); 337 | while (ch >= '0' && ch <= '9') { 338 | s.append(readChar()); 339 | ch = lookChar(); 340 | } 341 | } 342 | if (ch == 'E' || ch == 'e') { 343 | s.append(readChar()); 344 | ch = lookChar(); 345 | if (ch == '-' || ch == '+') { 346 | s.append(readChar()); 347 | ch = lookChar(); 348 | } 349 | while (ch >= '0' && ch <= '9') { 350 | s.append(readChar()); 351 | ch = lookChar(); 352 | } 353 | } 354 | return s.toString(); 355 | } 356 | 357 | private static long readInteger(long min, long max) { // read long integer, limited to specified range 358 | long x=0; 359 | while (true) { 360 | StringBuffer s=new StringBuffer(34); 361 | char ch=lookChar(); 362 | while (ch == ' ' || ch == '\n') { 363 | readChar(); 364 | if (ch == '\n') 365 | dumpString("? ",0); 366 | ch = lookChar(); 367 | } 368 | if (ch == '-' || ch == '+') { 369 | s.append(readChar()); 370 | ch = lookChar(); 371 | while (ch == ' ') { 372 | readChar(); 373 | ch = lookChar(); 374 | } 375 | } 376 | while (ch >= '0' && ch <= '9') { 377 | s.append(readChar()); 378 | ch = lookChar(); 379 | } 380 | if (s.equals("")){ 381 | errorMessage("Illegal integer input.", 382 | "Integer in the range " + min + " to " + max); 383 | } else { 384 | String str = s.toString(); 385 | try { 386 | x = Long.parseLong(str); 387 | } catch (NumberFormatException e) { 388 | errorMessage("Illegal integer input.", 389 | "Integer in the range " + min + " to " + max); 390 | continue; 391 | } 392 | if (x < min || x > max) { 393 | errorMessage("Integer input outside of legal range.", 394 | "Integer in the range " + min + " to " + max); 395 | continue; 396 | } 397 | break; 398 | } 399 | } 400 | return x; 401 | } 402 | 403 | private static String realToString(double x) { 404 | // Goal is to get a reasonable representation of x in at most 405 | // 10 characters, or 11 characters if x is negative. 406 | if (Double.isNaN(x)) 407 | return "undefined"; 408 | if (Double.isInfinite(x)) 409 | if (x < 0) 410 | return "-INF"; 411 | else 412 | return "INF"; 413 | if (Math.abs(x) <= 5000000000.0 && Math.rint(x) == x) 414 | return String.valueOf( (long)x ); 415 | String s = String.valueOf(x); 416 | if (s.length() <= 10) 417 | return s; 418 | boolean neg = false; 419 | if (x < 0) { 420 | neg = true; 421 | x = -x; 422 | s = String.valueOf(x); 423 | } 424 | if (x >= 0.00005 && x <= 50000000 && (s.indexOf('E') == -1 && s.indexOf('e') == -1)) { // trim x to 10 chars max 425 | s = round(s,10); 426 | s = trimZeros(s); 427 | } else if (x > 1) { // construct exponential form with positive exponent 428 | long power = (long)Math.floor(Math.log(x)/Math.log(10)); 429 | String exp = "E" + power; 430 | int numlength = 10 - exp.length(); 431 | x = x / Math.pow(10,power); 432 | s = String.valueOf(x); 433 | s = round(s,numlength); 434 | s = trimZeros(s); 435 | s += exp; 436 | } else { // constuct exponential form 437 | long power = (long)Math.ceil(-Math.log(x)/Math.log(10)); 438 | String exp = "E-" + power; 439 | int numlength = 10 - exp.length(); 440 | x = x * Math.pow(10,power); 441 | s = String.valueOf(x); 442 | s = round(s,numlength); 443 | s = trimZeros(s); 444 | s += exp; 445 | } 446 | if (neg) 447 | return "-" + s; 448 | else 449 | return s; 450 | } 451 | 452 | private static String trimZeros(String num) { // used by realToString 453 | if (num.indexOf('.') >= 0 && num.charAt(num.length() - 1) == '0') { 454 | int i = num.length() - 1; 455 | while (num.charAt(i) == '0') 456 | i--; 457 | if (num.charAt(i) == '.') 458 | num = num.substring(0,i); 459 | else 460 | num = num.substring(0,i+1); 461 | } 462 | return num; 463 | } 464 | 465 | private static String round(String num, int length) { // used by realToString 466 | if (num.indexOf('.') < 0) 467 | return num; 468 | if (num.length() <= length) 469 | return num; 470 | if (num.charAt(length) >= '5' && num.charAt(length) != '.') { 471 | char[] temp = new char[length+1]; 472 | int ct = length; 473 | boolean rounding = true; 474 | for (int i = length-1; i >= 0; i--) { 475 | temp[ct] = num.charAt(i); 476 | if (rounding && temp[ct] != '.') { 477 | if (temp[ct] < '9') { 478 | temp[ct]++; 479 | rounding = false; 480 | } else 481 | temp[ct] = '0'; 482 | } 483 | ct--; 484 | } 485 | if (rounding) { 486 | temp[ct] = '1'; 487 | ct--; 488 | } 489 | // ct is -1 or 0 490 | return new String(temp,ct+1,length-ct); 491 | } else 492 | return num.substring(0,length); 493 | 494 | } 495 | private static void dumpString(String str, int w) { // output string to console 496 | for (int i=str.length(); i= 0x20 && (int)str.charAt(i) != 0x7F) // no control chars or delete 500 | out.print(str.charAt(i)); 501 | else if (str.charAt(i) == '\n' || str.charAt(i) == '\r') 502 | newLine(); 503 | } 504 | 505 | private static void errorMessage(String message, String expecting) { 506 | // inform user of error and force user to re-enter. 507 | newLine(); 508 | dumpString(" *** Error in input: " + message + "\n", 0); 509 | dumpString(" *** Expecting: " + expecting + "\n", 0); 510 | dumpString(" *** Discarding Input: ", 0); 511 | if (lookChar() == '\n') 512 | dumpString("(end-of-line)\n\n",0); 513 | else { 514 | while (lookChar() != '\n') 515 | out.print(readChar()); 516 | dumpString("\n\n",0); 517 | } 518 | dumpString("Please re-enter: ", 0); 519 | readChar(); // discard the end-of-line character 520 | } 521 | 522 | private static char lookChar() { // return next character from input 523 | if (buffer == null || pos > buffer.length()) 524 | fillBuffer(); 525 | if (pos == buffer.length()) 526 | return '\n'; 527 | return buffer.charAt(pos); 528 | } 529 | 530 | private static char readChar() { // return and discard next character from input 531 | char ch = lookChar(); 532 | pos++; 533 | return ch; 534 | } 535 | 536 | private static void newLine() { // output a CR to console 537 | out.println(); 538 | out.flush(); 539 | } 540 | 541 | private static boolean possibleLinefeedPending = false; 542 | 543 | private static void fillBuffer() { // Wait for user to type a line and press return, 544 | /* // and put the typed line into the buffer. 545 | StringBuffer b = new StringBuffer(); 546 | out.flush(); 547 | try { 548 | int ch = in.read(); 549 | if (ch == '\n' && possibleLinefeedPending) 550 | ch = in.read(); 551 | possibleLinefeedPending = false; 552 | while (ch != -1 && ch != '\n' && ch != '\r') { 553 | b.append((char)ch); 554 | ch = in.read(); 555 | } 556 | possibleLinefeedPending = (ch == '\r'); 557 | if (ch == -1) { 558 | System.out.println("\n*** Found an end-of-file while trying to read from standard input!"); 559 | System.out.println("*** Maybe your Java system doesn't implement standard input?"); 560 | System.out.println("*** Program will be terminated.\n"); 561 | throw new RuntimeException("End-of-file on standard input."); 562 | } 563 | } 564 | catch (IOException e) { 565 | System.out.println("Unexpected system error on input."); 566 | System.out.println("Terminating program."); 567 | System.exit(1); 568 | } 569 | buffer = b.toString(); 570 | pos = 0;*/ 571 | } 572 | 573 | private static void emptyBuffer() { // discard the rest of the current line of input 574 | buffer = null; 575 | } 576 | 577 | 578 | } // end of class TextIO 579 | -------------------------------------------------------------------------------- /dist/0.243/PVTS.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/dist/0.243/PVTS.exe -------------------------------------------------------------------------------- /dist/0.243/PVTS.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidpilo/pvts/f7dbc43f1d58835369d3322e2e1aa77057f71b54/dist/0.243/PVTS.jar --------------------------------------------------------------------------------