diff options
Diffstat (limited to 'logo/src/xlogo/kernel/grammar')
-rw-r--r-- | logo/src/xlogo/kernel/grammar/LogoException.java | 69 | ||||
-rw-r--r-- | logo/src/xlogo/kernel/grammar/LogoList.java | 93 | ||||
-rw-r--r-- | logo/src/xlogo/kernel/grammar/LogoNumber.java | 76 | ||||
-rw-r--r-- | logo/src/xlogo/kernel/grammar/LogoParser.java | 289 | ||||
-rw-r--r-- | logo/src/xlogo/kernel/grammar/LogoPrimitive.java | 74 | ||||
-rw-r--r-- | logo/src/xlogo/kernel/grammar/LogoRightDelimiter.java | 56 | ||||
-rw-r--r-- | logo/src/xlogo/kernel/grammar/LogoTree.java | 96 | ||||
-rw-r--r-- | logo/src/xlogo/kernel/grammar/LogoType.java | 129 | ||||
-rw-r--r-- | logo/src/xlogo/kernel/grammar/LogoTypeNull.java | 56 | ||||
-rw-r--r-- | logo/src/xlogo/kernel/grammar/LogoVariable.java | 68 | ||||
-rw-r--r-- | logo/src/xlogo/kernel/grammar/LogoWord.java | 68 |
11 files changed, 1074 insertions, 0 deletions
diff --git a/logo/src/xlogo/kernel/grammar/LogoException.java b/logo/src/xlogo/kernel/grammar/LogoException.java new file mode 100644 index 0000000..225a677 --- /dev/null +++ b/logo/src/xlogo/kernel/grammar/LogoException.java @@ -0,0 +1,69 @@ +/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq + * Copyright (C) 2013 Marko Zivkovic + * + * Contact Information: marko88zivkovic at gmail dot com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic + * during his Bachelor thesis at the computer science department of ETH Z�rich, + * in the year 2013 and/or during future work. + * + * It is a reengineered version of XLogo written by Lo�c Le Coq, published + * under the GPL License at http://xlogo.tuxfamily.org/ + * + * Contents of this file were initially written by Lo�c Le Coq, + * modifications, extensions, refactorings might have been applied by Marko Zivkovic + */ + +/** + * Title : XLogo + * Description : XLogo is an interpreter for the Logo + * programming language + * Licence : GPL + * + * @author Loïc Le Coq + */ +package xlogo.kernel.grammar; + +/** + * @author loic + * + */ +public class LogoException extends LogoType +{ + + private String message; + + public LogoException(String message) + { + this.message = message; + } + + public boolean isException() + { + return true; + } + + public String toString() + { + return message; + } + + @Override + public String toDebug() + { + return "(EXCEPTION) " + message; + } + +} diff --git a/logo/src/xlogo/kernel/grammar/LogoList.java b/logo/src/xlogo/kernel/grammar/LogoList.java new file mode 100644 index 0000000..1cd6ea5 --- /dev/null +++ b/logo/src/xlogo/kernel/grammar/LogoList.java @@ -0,0 +1,93 @@ +/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq + * Copyright (C) 2013 Marko Zivkovic + * + * Contact Information: marko88zivkovic at gmail dot com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic + * during his Bachelor thesis at the computer science department of ETH Z�rich, + * in the year 2013 and/or during future work. + * + * It is a reengineered version of XLogo written by Lo�c Le Coq, published + * under the GPL License at http://xlogo.tuxfamily.org/ + * + * Contents of this file were initially written by Lo�c Le Coq, + * modifications, extensions, refactorings might have been applied by Marko Zivkovic + */ + +/** + * Title : XLogo + * Description : XLogo is an interpreter for the Logo + * programming language + * Licence : GPL + * + * @author Loïc Le Coq + */ +package xlogo.kernel.grammar; + +import java.util.Vector; + +public class LogoList extends LogoType +{ + private Vector<LogoType> vector; + + LogoList(Vector<LogoType> vector) + { + this.vector = vector; + } + + LogoList() + { + vector = new Vector<LogoType>(); + } + + public boolean isList() + { + return true; + } + + public void add(LogoType type) + { + vector.add(type); + } + + public Vector<LogoType> getVector() + { + return vector; + } + + public String toString() + { + StringBuffer sb = new StringBuffer(); + sb.append("[ "); + for (int i = 0; i < vector.size(); i++) + { + sb.append(vector.get(i).toString()); + sb.append(" "); + } + sb.append("]"); + return sb.toString(); + } + + @Override + public String toDebug() + { + StringBuffer sb = new StringBuffer(); + sb.append("(LIST) "); + sb.append(toString()); + return sb.toString(); + + } + +} diff --git a/logo/src/xlogo/kernel/grammar/LogoNumber.java b/logo/src/xlogo/kernel/grammar/LogoNumber.java new file mode 100644 index 0000000..fd367bb --- /dev/null +++ b/logo/src/xlogo/kernel/grammar/LogoNumber.java @@ -0,0 +1,76 @@ +/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq + * Copyright (C) 2013 Marko Zivkovic + * + * Contact Information: marko88zivkovic at gmail dot com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic + * during his Bachelor thesis at the computer science department of ETH Z�rich, + * in the year 2013 and/or during future work. + * + * It is a reengineered version of XLogo written by Lo�c Le Coq, published + * under the GPL License at http://xlogo.tuxfamily.org/ + * + * Contents of this file were initially written by Lo�c Le Coq, + * modifications, extensions, refactorings might have been applied by Marko Zivkovic + */ + +/** + * Title : XLogo + * Description : XLogo is an interpreter for the Logo + * programming language + * Licence : GPL + * + * @author Loïc Le Coq + */ +package xlogo.kernel.grammar; + +/** + * @author loic + * + */ +public class LogoNumber extends LogoType +{ + private double value; + + LogoNumber(double value) + { + this.value = value; + } + public double getValue() + { + return value; + } + + public boolean isWord() + { + return true; + } + + public boolean isNumber() + { + return true; + } + + public String toString() + { + return String.valueOf(value); + } + + @Override + public String toDebug() + { + return "(NUMBER) " + String.valueOf(value); + } +} diff --git a/logo/src/xlogo/kernel/grammar/LogoParser.java b/logo/src/xlogo/kernel/grammar/LogoParser.java new file mode 100644 index 0000000..ccf3436 --- /dev/null +++ b/logo/src/xlogo/kernel/grammar/LogoParser.java @@ -0,0 +1,289 @@ +/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq + * Copyright (C) 2013 Marko Zivkovic + * + * Contact Information: marko88zivkovic at gmail dot com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic + * during his Bachelor thesis at the computer science department of ETH Z�rich, + * in the year 2013 and/or during future work. + * + * It is a reengineered version of XLogo written by Lo�c Le Coq, published + * under the GPL License at http://xlogo.tuxfamily.org/ + * + * Contents of this file were initially written by Lo�c Le Coq, + * modifications, extensions, refactorings might have been applied by Marko Zivkovic + */ + +/** + * Title : XLogo + * Description : XLogo is an interpreter for the Logo + * programming language + * + * @author Loïc Le Coq + */ + +package xlogo.kernel.grammar; + +import xlogo.Logo; +import xlogo.kernel.DrawPanel; +import xlogo.kernel.Primitive; +import xlogo.storage.global.GlobalConfig; + +public class LogoParser +{ + private char c; + private int cursor; + private String text; + + /** + * + * @param sr + * The String input reader + */ + public LogoParser(String text) + { + this.text = text; + cursor = 0; + while (cursor < text.length()) + { + LogoType lt = getToken(); + if (GlobalConfig.DEBUG) + System.out.println("[DEBUG] Token " + lt.toDebug() + " cursor " + cursor); + } + } + + private LogoType getToken() + { + boolean isQuotedWord = false; + boolean isVariable = false; + + StringBuffer sb = new StringBuffer(); + boolean start = false; + boolean backslash = false; + do + { + c = text.charAt(cursor); + // Skip White Spaces + if (c == ' ' || c == '\t') + { + if (start) + break; + else + cursor++; + } + else + { + if (backslash) + { + if (c == ' ') + sb.append(" "); + else if (c == '#') + sb.append("#"); + else if (c == '\\') + sb.append("\\"); + else if (c == '(') + sb.append("("); + else if (c == ')') + sb.append(")"); + else if (c == '[') + sb.append("["); + else if (c == ']') + sb.append("]"); + else if (c == 'n') + sb.append("\n"); + else + sb.append(c); + cursor++; + } + else + { + // If it's the first character, check for type + if (!start) + { + if (c == ':') + isVariable = true; + else if (c == '\"') + isQuotedWord = true; + } + if (c == '\\') + backslash = true; + + else if (c == '[') + { + if (start) + break; + else + { + cursor++; + return extractList(); + } + } + else if (c == '(') + { + if (start) + break; + } + else if (c == '*' || c == '/' || c == '+' || c == '-' || c == '|' || c == '&' || c == '=') + { + if (!isQuotedWord) + { + if (!start) + { + sb.append(c); + cursor++; + } + break; + + } + else + cursor++; + } + else if (c == ')') + return new LogoException(Logo.messages.getString("parenthese_ouvrante")); + else if (c == ']') + return new LogoException(Logo.messages.getString("error.whattodo") + " ]"); + else + { + sb.append(c); + cursor++; + } + } + start = true; + } + } while (cursor < text.length()); + if (sb.length() == 0) + return DrawPanel.nullType; + else if (isQuotedWord) + return new LogoWord(sb.substring(1)); + else if (isVariable) + return new LogoVariable(sb.substring(1)); + try + { + double d = Double.parseDouble(sb.toString()); + return new LogoNumber(d); + } + catch (NumberFormatException e) + { + int id = Primitive.isPrimitive(sb.toString()); + if (id != -1) { return new LogoPrimitive(id, sb.toString()); } + return new LogoException(Logo.messages.getString("je_ne_sais_pas") + " " + sb.toString()); + } + + } + + /** + * This method extracts a list. + * + * @return a LogoList if operation succeed, + * a LogoException otherwise + */ + + private LogoType extractList() + { + LogoList list = new LogoList(); + while (cursor < text.length()) + { + LogoType lt = getListToken(); + if (lt.isNull()) + { + return new LogoException(Logo.messages.getString("erreur_crochet")); + } + else if (lt.isRightDelimiter()) + return list; + else + { + list.add(lt); + } + } + return new LogoException(Logo.messages.getString("erreur_crochet")); + } + + private LogoType getListToken() + { + StringBuffer sb = new StringBuffer(); + boolean start = false; + boolean backslash = false; + for (int i = cursor; i < text.length(); i++) + { + cursor = i; + c = text.charAt(i); + // Skip White Spaces + if (c == ' ' || c == '\t') + { + if (start) + break; + } + else + { + if (backslash) + { + if (c == ' ') + sb.append(" "); + else if (c == '#') + sb.append("#"); + else if (c == '\\') + sb.append("\\"); + else if (c == '(') + sb.append("("); + else if (c == ')') + sb.append(")"); + else if (c == '[') + sb.append("["); + else if (c == ']') + sb.append("]"); + else if (c == 'n') + sb.append("\n"); + else + sb.append(c); + } + else + { + if (c == '\\') + { + backslash = true; + } + else if (c == '[') + { + if (start) + break; + else + { + cursor++; + return extractList(); + } + } + else if (c == ']') + { + if (start) + break; + else + { + System.out.println("coucou"); + cursor++; + return new LogoRightDelimiter(); + } + } + else + sb.append(c); + } + start = true; + } + } + if (sb.length() == 0) + return DrawPanel.nullType; + return new LogoWord(sb.toString()); + } + +} diff --git a/logo/src/xlogo/kernel/grammar/LogoPrimitive.java b/logo/src/xlogo/kernel/grammar/LogoPrimitive.java new file mode 100644 index 0000000..52044a3 --- /dev/null +++ b/logo/src/xlogo/kernel/grammar/LogoPrimitive.java @@ -0,0 +1,74 @@ +/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq + * Copyright (C) 2013 Marko Zivkovic + * + * Contact Information: marko88zivkovic at gmail dot com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic + * during his Bachelor thesis at the computer science department of ETH Z�rich, + * in the year 2013 and/or during future work. + * + * It is a reengineered version of XLogo written by Lo�c Le Coq, published + * under the GPL License at http://xlogo.tuxfamily.org/ + * + * Contents of this file were initially written by Lo�c Le Coq, + * modifications, extensions, refactorings might have been applied by Marko Zivkovic + */ + +/** + * Title : XLogo + * Description : XLogo is an interpreter for the Logo + * programming language + * Licence : GPL + * + * @author Loïc Le Coq + */ +package xlogo.kernel.grammar; + +public class LogoPrimitive extends LogoType +{ + private int id; + private String name; + + LogoPrimitive(int id, String name) + { + this.id = id; + this.name = name; + } + + public boolean isPrimitive() + { + return true; + } + + /** + * @return + * @uml.property name="id" + */ + public int getId() + { + return id; + } + + public String toString() + { + return name; + } + + @Override + public String toDebug() + { + return "(PRIMITIVE id=" + id + ") " + name; + } +} diff --git a/logo/src/xlogo/kernel/grammar/LogoRightDelimiter.java b/logo/src/xlogo/kernel/grammar/LogoRightDelimiter.java new file mode 100644 index 0000000..fb46026 --- /dev/null +++ b/logo/src/xlogo/kernel/grammar/LogoRightDelimiter.java @@ -0,0 +1,56 @@ +/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq + * Copyright (C) 2013 Marko Zivkovic + * + * Contact Information: marko88zivkovic at gmail dot com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic + * during his Bachelor thesis at the computer science department of ETH Z�rich, + * in the year 2013 and/or during future work. + * + * It is a reengineered version of XLogo written by Lo�c Le Coq, published + * under the GPL License at http://xlogo.tuxfamily.org/ + * + * Contents of this file were initially written by Lo�c Le Coq, + * modifications, extensions, refactorings might have been applied by Marko Zivkovic + */ + +/** + * Title : XLogo + * Description : XLogo is an interpreter for the Logo + * programming language + * Licence : GPL + * + * @author Loïc Le Coq + */ +package xlogo.kernel.grammar; + +/** + * @author loic + * + */ +public class LogoRightDelimiter extends LogoType +{ + public boolean isRightDelimiter() + { + return true; + } + + @Override + public String toDebug() + { + return null; + } + +} diff --git a/logo/src/xlogo/kernel/grammar/LogoTree.java b/logo/src/xlogo/kernel/grammar/LogoTree.java new file mode 100644 index 0000000..4e6b66e --- /dev/null +++ b/logo/src/xlogo/kernel/grammar/LogoTree.java @@ -0,0 +1,96 @@ +/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq + * Copyright (C) 2013 Marko Zivkovic + * + * Contact Information: marko88zivkovic at gmail dot com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic + * during his Bachelor thesis at the computer science department of ETH Z�rich, + * in the year 2013 and/or during future work. + * + * It is a reengineered version of XLogo written by Lo�c Le Coq, published + * under the GPL License at http://xlogo.tuxfamily.org/ + * + * Contents of this file were initially written by Lo�c Le Coq, + * modifications, extensions, refactorings might have been applied by Marko Zivkovic + */ + +package xlogo.kernel.grammar; + +import java.util.Vector; + +public class LogoTree +{ + private Vector<LogoTree> children; + private LogoTree parent; + private LogoType value; + private boolean isRoot = false; + private boolean isProcedure = false; + private boolean isPrimitive = false; + private boolean isLeaf = false; + + LogoTree() + { + children = new Vector<LogoTree>(); + } + + protected void setParent(LogoTree lt) + { + this.parent = lt; + } + + protected LogoTree getParent() + { + return parent; + } + + protected boolean isRoot() + { + return isRoot; + } + + protected void addChild(LogoTree child) + { + children.add(child); + } + + protected void setValue(LogoType value) + { + this.value = value; + } + + protected LogoType getValue() + { + return value; + } + + protected boolean isLeaf() + { + return isLeaf; + } + + LogoType evaluate() + { + Vector<LogoType> args = new Vector<LogoType>(); + for (int i = 0; i < children.size(); i++) + { + LogoTree child = children.get(i); + if (child.isLeaf()) + args.add(child.getValue()); + else + args.add(child.evaluate()); + } + return null; + } +} diff --git a/logo/src/xlogo/kernel/grammar/LogoType.java b/logo/src/xlogo/kernel/grammar/LogoType.java new file mode 100644 index 0000000..d407431 --- /dev/null +++ b/logo/src/xlogo/kernel/grammar/LogoType.java @@ -0,0 +1,129 @@ +/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq + * Copyright (C) 2013 Marko Zivkovic + * + * Contact Information: marko88zivkovic at gmail dot com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic + * during his Bachelor thesis at the computer science department of ETH Z�rich, + * in the year 2013 and/or during future work. + * + * It is a reengineered version of XLogo written by Lo�c Le Coq, published + * under the GPL License at http://xlogo.tuxfamily.org/ + * + * Contents of this file were initially written by Lo�c Le Coq, + * modifications, extensions, refactorings might have been applied by Marko Zivkovic + */ + +/** + * Title : XLogo + * Description : XLogo is an interpreter for the Logo + * programming language + * Licence : GPL + * + * @author Loïc Le Coq + */ + +package xlogo.kernel.grammar; + +public abstract class LogoType +{ + + /** + * If this token is a word ? + * + * @return true for a word, false otherwise + */ + public boolean isWord() + { + return false; + } + + /** + * If this token is a list? + * + * @return true for a list, false otherwise + */ + public boolean isList() + { + return false; + } + + /** + * If this token is a number? + * + * @return true for a number, false otherwise + */ + public boolean isNumber() + { + return false; + } + + /** + * If this token is a variable? + * + * @return true for a variable, false otherwise + */ + public boolean isVariable() + { + return false; + } + + /** + * If this token is a primitive? + * + * @return true for a primitive, false otherwise + */ + public boolean isPrimitive() + { + return false; + } + + /** + * If this token is a procedure? + * + * @return true for a procedure, false otherwise + */ + public boolean isProcedure() + { + return false; + } + + /** + * If this token is an exception? + * + * @return true for an exception, false otherwise + */ + public boolean isException() + { + return false; + } + + public boolean isNull() + { + return false; + } + + public boolean isRightDelimiter() + { + return false; + } + + /** + * Util for debugging + * + * @return the type and value for LogoType + */ + abstract public String toDebug(); +} diff --git a/logo/src/xlogo/kernel/grammar/LogoTypeNull.java b/logo/src/xlogo/kernel/grammar/LogoTypeNull.java new file mode 100644 index 0000000..b764063 --- /dev/null +++ b/logo/src/xlogo/kernel/grammar/LogoTypeNull.java @@ -0,0 +1,56 @@ +/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq + * Copyright (C) 2013 Marko Zivkovic + * + * Contact Information: marko88zivkovic at gmail dot com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic + * during his Bachelor thesis at the computer science department of ETH Z�rich, + * in the year 2013 and/or during future work. + * + * It is a reengineered version of XLogo written by Lo�c Le Coq, published + * under the GPL License at http://xlogo.tuxfamily.org/ + * + * Contents of this file were initially written by Lo�c Le Coq, + * modifications, extensions, refactorings might have been applied by Marko Zivkovic + */ + +/** + * Title : XLogo + * Description : XLogo is an interpreter for the Logo + * programming language + * Licence : GPL + * + * @author Loïc Le Coq + */ +package xlogo.kernel.grammar; + +/** + * @author loic + * + */ +public class LogoTypeNull extends LogoType +{ + public boolean isNull() + { + return true; + } + + @Override + public String toDebug() + { + return "(LogoTypeNull)"; + } + +} diff --git a/logo/src/xlogo/kernel/grammar/LogoVariable.java b/logo/src/xlogo/kernel/grammar/LogoVariable.java new file mode 100644 index 0000000..d2a7e91 --- /dev/null +++ b/logo/src/xlogo/kernel/grammar/LogoVariable.java @@ -0,0 +1,68 @@ +/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq + * Copyright (C) 2013 Marko Zivkovic + * + * Contact Information: marko88zivkovic at gmail dot com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic + * during his Bachelor thesis at the computer science department of ETH Z�rich, + * in the year 2013 and/or during future work. + * + * It is a reengineered version of XLogo written by Lo�c Le Coq, published + * under the GPL License at http://xlogo.tuxfamily.org/ + * + * Contents of this file were initially written by Lo�c Le Coq, + * modifications, extensions, refactorings might have been applied by Marko Zivkovic + */ + +package xlogo.kernel.grammar; + +/** + * Title : XLogo + * Description : XLogo is an interpreter for the Logo + * programming language + * Licence : GPL + * + * @author Loïc Le Coq + */ +public class LogoVariable extends LogoType +{ + String name; + + LogoVariable(String name) + { + this.name = name; + } + + public boolean isVariable() + { + return true; + } + + public String getName() + { + return name; + } + + public String toString() + { + return ":" + name; + } + + @Override + public String toDebug() + { + return "(VARIABLE) :" + name; + } +} diff --git a/logo/src/xlogo/kernel/grammar/LogoWord.java b/logo/src/xlogo/kernel/grammar/LogoWord.java new file mode 100644 index 0000000..e155180 --- /dev/null +++ b/logo/src/xlogo/kernel/grammar/LogoWord.java @@ -0,0 +1,68 @@ +/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq + * Copyright (C) 2013 Marko Zivkovic + * + * Contact Information: marko88zivkovic at gmail dot com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic + * during his Bachelor thesis at the computer science department of ETH Z�rich, + * in the year 2013 and/or during future work. + * + * It is a reengineered version of XLogo written by Lo�c Le Coq, published + * under the GPL License at http://xlogo.tuxfamily.org/ + * + * Contents of this file were initially written by Lo�c Le Coq, + * modifications, extensions, refactorings might have been applied by Marko Zivkovic + */ + +/** + * Title : XLogo + * Description : XLogo is an interpreter for the Logo + * programming language + * Licence : GPL + * + * @author Loïc Le Coq + */ +package xlogo.kernel.grammar; + +public class LogoWord extends LogoType +{ + private String value; + + LogoWord(String value) + { + this.value = value; + } + + public String getQuotedValue() + { + return "\"" + value; + } + + public String toString() + { + return value; + } + + public boolean isWord() + { + return true; + } + + @Override + public String toDebug() + { + return "(WORD) " + value; + } +} |