diff --git a/open-nars/src/com/googlecode/opennars/entity/Base.java b/open-nars/src/com/googlecode/opennars/entity/Base.java deleted file mode 100644 index 4ccd3184214b6e76be8fcd1c0250fa5bdc9ad065..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/Base.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Base.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import com.googlecode.opennars.main.Parameters; -import com.googlecode.opennars.parser.Symbols; - -/** - * Each Sentence has a list of serial numbers of a constant length. - * The input sentence gets a unique number. - * The derived sentences inherits from its parents. - */ -public class Base implements Cloneable { // make it part of TruthValue? - private static final int MAXLENGTH = Parameters.MAXMUM_LABEL_RECORD_LENGTH; - private static final String opener = Symbols.Base_opener; - private static final String closer = Symbols.Base_closer; - private static final String separator = Symbols.Base_separator; - private static final String separator0 = Symbols.Base_separator0; - - // for each base - private int length; - private long list[] = new long[MAXLENGTH]; - - // sequential number, for the whole system - private static long current = 0; - - // generate a new number --- serial number or generation time? - // called in StringParser - public Base() { - current++; - length = 1; - list[0] = current; - } - - // the first one is no shorter than the second - private Base(Base first, Base second) { - int i1, i2, j; - i1 = i2 = j = 0; - while (i2 < second.length() && j < MAXLENGTH) { - list[j] = first.list(i1); - i1++; - j++; - list[j] = second.list(i2); - i2++; - j++; - } - while (i1 < first.length() && j < MAXLENGTH) { - list[j] = first.list(i1); - i1++; - j++; - } - length = j; - } - - // try to merge two Bases, return null if have overlap - public static Base make(Base first, Base second) { - for (int i = 0; i < first.length(); i++) - for (int j = 0; j < second.length(); j++) - if (first.list(i) == second.list(j)) - return null; - if (first.length() > second.length()) - return new Base(first, second); - else - return new Base(second, first); - } - - // Initialize the machenism - // called in Center - public static void init() { - current = 0; - } - - public int length() { - return length; - } - - public long list(int i) { - return list[i]; - } - - // to check for subset - public boolean include(Base s) { - boolean result = false; - if (length >= s.length()) - for (int i = 0; i < s.length(); i++) { - result = false; - for (int j = 0; j < length; j++) - if (list[j] == s.list(i)) { - result = true; - break; - } - if (result == false) - break; - } - return result; - } - - public boolean equals(Object that) { - return ((that instanceof Base) && this.include((Base) that) && ((Base) that).include(this)); - } - - // called for update - public long latest() { - long v = list[0]; - for (int i = 1; i < length(); i++) - if (list[i] > v) - v = list[i]; - return v; - } - - // for display - public String toString() { - String buf = new String(opener + length + separator0); - for (int i = 0; i < length; i++) { - buf = buf.concat(Long.toString(list[i])); - if (i < (length - 1)) - buf = buf.concat(separator); - else - buf = buf.concat(closer); - } - return buf; - } -} diff --git a/open-nars/src/com/googlecode/opennars/entity/BudgetValue.java b/open-nars/src/com/googlecode/opennars/entity/BudgetValue.java deleted file mode 100644 index a2c5bc589b0132540752d2affa2af43e94d549fd..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/BudgetValue.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * BudgetValue.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import com.googlecode.opennars.inference.*; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.*; - -/** - * A triple of priority (current), durability (decay), and quality (long-term average). - */ -public class BudgetValue implements Cloneable { - public static final char mark = Symbols.BUDGET_VALUE_MARK; // default - public static final char separator = Symbols.VALUE_SEPARATOR; // default - protected ShortFloat priority; // short-term, first-order - protected ShortFloat durability; // short-term, second-order - protected ShortFloat quality; // long-term - private Memory memory; - protected BudgetFunctions budgetfunctions; - - /* ----- constructors ----- */ - - public BudgetValue(Memory memory) { - priority = new ShortFloat(0.01f); - durability = new ShortFloat(0.01f); - quality = new ShortFloat(0.01f); - this.memory = memory; - this.budgetfunctions = new BudgetFunctions(memory); - } - - public BudgetValue(float p, float d, float q, Memory memory) { - priority = new ShortFloat(p); - durability = new ShortFloat(d); - quality = new ShortFloat(q); - this.memory = memory; - this.budgetfunctions = new BudgetFunctions(memory); - } - - public BudgetValue(BudgetValue v, Memory memory) { // clone, not copy - priority = new ShortFloat(v.getPriority()); - durability = new ShortFloat(v.getDurability()); - quality = new ShortFloat(v.getQuality()); - this.memory = memory; - this.budgetfunctions = new BudgetFunctions(memory); - } - - public Object clone() { - return new BudgetValue(this.getPriority(), this.getDurability(), this.getQuality(), this.memory); - } - - /* ----- priority ----- */ - - public float getPriority() { - return priority.getValue(); - } - - public void setPriority(float v) { - priority.setValue(v); - } - - public void incPriority(float v) { - priority.setValue(UtilityFunctions.or(priority.getValue(), v)); - } - - public void decPriority(float v) { - priority.setValue(UtilityFunctions.and(priority.getValue(), v)); - } - - /* ----- durability ----- */ - - public float getDurability() { - return durability.getValue(); - } - - public void setDurability(float v) { - durability.setValue(v); - } - - public void incDurability(float v) { - durability.setValue(UtilityFunctions.or(durability.getValue(), v)); - } - - public void decDurability(float v) { - durability.setValue(UtilityFunctions.and(durability.getValue(), v)); - } - - /* ----- quality ----- */ - - public float getQuality() { - return quality.getValue(); - } - - public void setQuality(float v) { - quality.setValue(v); - } - - public void incQuality(float v) { - quality.setValue(UtilityFunctions.or(quality.getValue(), v)); - } - - public void decQuality(float v) { - quality.setValue(UtilityFunctions.and(quality.getValue(), v)); - } - - /* ----- utility ----- */ - - public void merge(BudgetValue that) { - this.budgetfunctions.merge(this, that); - } - - // called from Memory only - public float singleValue() { -// return (priority.getValue() + quality.getValue()) * durability.getValue() / 2.0f; - return UtilityFunctions.aveAri(priority.getValue(), durability.getValue(), quality.getValue()); - } - - public boolean aboveThreshold() { - return (singleValue() > 0.001); // to be revised to depend on how busy the system is - } - - // full output - public String toString() { - return mark + priority.toString() + separator + durability.toString() + separator + quality.toString() + mark; - } - - // short output - public String toString2() { - return mark + priority.toString2() + separator + durability.toString2() + separator + quality.toString2() + mark; - } - - /** - * @param memory the memory to set - */ - public void setMemory(Memory memory) { - this.memory = memory; - } - - /** - * @return the memory - */ - public Memory getMemory() { - return memory; - } -} diff --git a/open-nars/src/com/googlecode/opennars/entity/Concept.java b/open-nars/src/com/googlecode/opennars/entity/Concept.java deleted file mode 100644 index b32ce46573fc429b98537e042d522046511e3b7e..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/Concept.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Concept.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import java.util.*; -import java.io.*; - -import com.googlecode.opennars.inference.*; -import com.googlecode.opennars.language.*; -import com.googlecode.opennars.main.*; -import com.googlecode.opennars.operation.*; -import com.googlecode.opennars.parser.*; -import com.googlecode.opennars.storage.*; - - -/** - * A concept contains information directly related to a term, including directly and indirectly related tasks and beliefs. - * <p> - * To make sure the space will be released, no other will refer to a concept, except in a concept bag. - */ -public final class Concept extends Item { - /* Constant term as the unique ID of the concept */ - private Term term; - /* Direct Task lists (they may never be used for a Term that is not used as a Statement) */ - private ArrayList<Judgement> directBeliefs; // Judgments with the same content - private ArrayList<Goal> directGoals; // Goals that can be directly achieved - private Question directQuestion; // Question that can be directly answered - private boolean revisible = true; // truth value of judgments can be revised - /* Link bags for indirect processing (always used) */ - private ArrayList<TermLink> linkTemplates; // templates of TermLink, only in Concepts for CompoundTerms - private TaskLinkBag taskLinks; - private TermLinkBag termLinks; - - /* ---------- constructor ---------- */ - - /** - * Constructor - * @param tm A constant term corresponding to the concept - */ - public Concept(Term tm, Memory memory) { - super(memory); - term = tm; - key = tm.toString(); - directBeliefs = new ArrayList<Judgement>(); - directGoals = new ArrayList<Goal>(); - directQuestion = null; - taskLinks = new TaskLinkBag(); - termLinks = new TermLinkBag(); - if (tm instanceof CompoundTerm) { - linkTemplates = ((CompoundTerm) tm).prepareComponentLinks(getMemory()); - checkRevisibility(); - } - } - - private void checkRevisibility() { - revisible = !(term instanceof Tense); // no tense - if (revisible) - revisible = ((key.indexOf("()") < 0) && (key.indexOf("(#")) < 0); // no dependent variable - } - - /* ---------- add direct information as Tasks ---------- */ - - /** - * New task to be directly processed in a constant time, called from Memory only - * @param task The task to be processed - */ - public void directProcess(Task task) { - getMemory().currentTask = task; - Sentence sentence = task.getSentence(); - if (sentence instanceof Question) - processQuestion(task); - else if (sentence instanceof Goal) - processGoal(task); - else - processJudgment(task); - getMemory().activateConcept(this, task.getBudget()); - } - - /** - * New question to be directly answered by existing beliefs - * @param task The task to be processed - */ - private void processQuestion(Task task) { - if (directQuestion == null) - directQuestion = (Question) task.getSentence(); // remember it - for (int i = 0; i < directBeliefs.size(); i++) { - Judgement judg = directBeliefs.get(i); - getMemory().getRuletables().getMatchingRules().trySolution(directQuestion, judg, task); // look for better answer - } - } - - /** - * New judgment - * @param task The task to be processed - */ - private void processJudgment(Task task) { - Judgement judg = (Judgement) task.getSentence(); - if (revisible) - reviseTable(task, directBeliefs); - else - updateTable(task); - if (task.getPriority() > 0) { // if still valuable --- necessary??? - if (directQuestion != null) - getMemory().getRuletables().getMatchingRules().trySolution(directQuestion, judg, task); - for (int i = 0; i < directGoals.size(); i++) { - Goal goal = directGoals.get(i); - getMemory().getRuletables().getMatchingRules().trySolution(goal, judg, task); - } - addToTable(judg, directBeliefs, getMemory().getParameters().MAXMUM_BELIEF_LENGTH); - } - } - - /** - * New goal - * @param task The task to be processed - */ - private void processGoal(Task task) { - Goal goal = (Goal) task.getSentence(); - if (revisible) - reviseTable(task, directGoals); - else - updateTable(task); - for (int i = 0; i < directBeliefs.size(); i++) { - Judgement judg = directBeliefs.get(i); - getMemory().getRuletables().getMatchingRules().trySolution(goal, judg, task); - } - if (task.getPriority() > 0) { // if still valuable - addToTable(goal, directGoals, getMemory().getParameters().MAXMUM_GOALS_LENGTH); // with the feedbacks - } - decisionMaking(task); - } - - private void decisionMaking(Task task) { // add plausibility - Goal goal = (Goal) task.getSentence(); - float desire = 2 * goal.getTruth().getExpectation() - 1; - float quality = (desire < 0) ? 0 : desire; - task.setQuality(quality); - } - - // revise previous beliefs or goals - private void reviseTable(Task task, ArrayList table) { - Judgement belief; - for (int i = 0; i < table.size(); i++) { // call select() - belief = (Judgement) table.get(i); - if (belief.noOverlapping((Judgement) task.getSentence())) - getMemory().getRuletables().getMatchingRules().revision(task, belief, false); - } - } - - // to be rewritten - private void updateTable(Task task) { -// Judgement belief; -// for (int i = 0; i < directBeliefs.size(); i++) { // call select() -// belief = directBeliefs.get(i); -// if (((Judgement) task.getSentence()).getBase().latest() > belief.getBase().latest()) -// getMemory().getRuletables().getMatchingRules().update(task, belief); -// } - } - - // add the Task as a new direct Belief or Goal, remove redundant ones - // table sorted by rank - private void addToTable(Judgement newJudgement, ArrayList table, int capacity) { - float rank1 = this.budgetfunctions.rankBelief(newJudgement); // for the new belief - Base base1 = newJudgement.getBase(); - Judgement judgement2; - float rank2; - int i; - for (i = 0; i < table.size(); i++) { // go through everyone - judgement2 = (Judgement) table.get(i); - rank2 = this.budgetfunctions.rankBelief(judgement2); // previous belief - if (rank1 >= rank2) { - if (newJudgement.equivalentTo(judgement2)) - return; - table.add(i, newJudgement); - break; - } - } - if (table.size() == capacity) - table.remove(capacity - 1); - else if (i == table.size()) - table.add(newJudgement); - } - - // return a piece of Belief to be used with the task - // get the first qualified one - public Judgement getBelief(Task task) { - Sentence sentence = task.getSentence(); - Judgement belief; - for (int i = 0; i < directBeliefs.size(); i++) { - belief = directBeliefs.get(i); - if ((sentence instanceof Question) || belief.noOverlapping((Judgement) sentence)) { - return belief; - } - } - return null; - } - - /* ---------- insert relational information as Links ---------- */ - - public ArrayList<TermLink> getTermLinks() { - return linkTemplates; - } - - // insert TaskLink into the task base, called from Memory only - public void insertTaskLink(TaskLink taskLink) { - BudgetValue budget = taskLink.getBudget(); - taskLinks.putIn(taskLink); - getMemory().activateConcept(this, budget); // activate the concept - if (term instanceof CompoundTerm) - buildTermLinks(budget); - } - - private void buildTermLinks(BudgetValue budget) { - Term t; - Concept c; - TermLink cLink1, cLink2; - BudgetValue subBudget = this.budgetfunctions.distributeAmongLinks(budget, linkTemplates.size()); - if (!subBudget.aboveThreshold()) - return; - for(TermLink link : linkTemplates) { - t = link.getTarget(); - c = getMemory().getConcept(t); - cLink1 = new TermLink(t, link, subBudget, getMemory()); - insertTermLink(cLink1); // this link to that - cLink2 = new TermLink(term, link, subBudget, getMemory()); - c.insertTermLink(cLink2); // that link to this - if (t instanceof CompoundTerm) - c.buildTermLinks(subBudget); - } - } - - // insert TermLink into the Belief base, called from Memory only - public void insertTermLink(TermLink cLink) { - termLinks.putIn(cLink); - getMemory().activateConcept(this, cLink.getBudget()); - } - - /* ---------- main loop ---------- */ - - // a single step of syllogism within a concept - public void fire() { - TaskLink tLink = (TaskLink) taskLinks.takeOut(); - if (tLink == null) - return; - getMemory().currentTaskLink = tLink; - getMemory().currentBeliefLink = null; - Task task = tLink.getTargetTask(); - getMemory().currentTask = task; - if ((tLink.getType() == TermLink.TRANSFORM) && !task.isStructual()) { - getMemory().getRuletables().transformTask(task, tLink); // inference from a TaskLink and the Task --- for Product and Image - return; // cannot be used otherwise - } - TermLink bLink = (TermLink) termLinks.takeOut(tLink); // to avoid repeated syllogism - if (bLink != null) { - getMemory().currentBeliefLink = bLink; - getMemory().getRuletables().reason(tLink, bLink); - termLinks.putBack(bLink); - } - taskLinks.putBack(tLink); - } - - /* ---------- utility ---------- */ - - public Term getTerm() { // called from Memory only - return term; - } - - public String toString() { // called from concept bag - return (super.toString2() + " " + key); - } - - public float getQuality() { // re-calculate-and-set? consider syntactic complexity? - return UtilityFunctions.and(taskLinks.averagePriority(), termLinks.averagePriority()); - } - - /* ---------- reporting ---------- */ - - // display direct belief, questions, and goals - public String displayContent() { - StringBuffer buffer = new StringBuffer(); - if (directBeliefs.size() > 0) { - buffer.append(" Beliefs:\n"); - for (int i = 0; i < directBeliefs.size(); i++) - buffer.append(directBeliefs.get(i) + "\n"); - } - if (directGoals.size() > 0) { - buffer.append("\n Goals:\n"); - for (int i = 0; i < directGoals.size(); i++) - buffer.append(directGoals.get(i) + "\n"); - } - if (directQuestion != null) - buffer.append("\n Question:\n" + directQuestion + "\n"); - return buffer.toString(); - } -} - diff --git a/open-nars/src/com/googlecode/opennars/entity/Goal.java b/open-nars/src/com/googlecode/opennars/entity/Goal.java deleted file mode 100644 index 8cf4c4272455f2ed18edadf01feef3e80525e71b..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/Goal.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Goal.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import com.googlecode.opennars.language.Term; -import com.googlecode.opennars.main.Memory; - -/** - * A Goal is an event to be realized, and may conain query variables - */ -public class Goal extends Judgement { - public Goal(Term term, char punc, TruthValue t, Base b, Memory memory) { - super(term, punc, t, b, memory); - } -} - diff --git a/open-nars/src/com/googlecode/opennars/entity/Item.java b/open-nars/src/com/googlecode/opennars/entity/Item.java deleted file mode 100644 index 636d801d00dd6b56c6f98cd7ee01a6a6ce590a18..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/Item.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Item.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import com.googlecode.opennars.main.Memory; - -/** - * An item is an object that can be put into a Bag, - * and it participates in the resource competation of the system. - */ -public abstract class Item extends BudgetValue implements Cloneable { - - /** - * The key of the Item, unique in a Bag - */ - protected String key; // uniquely define an Item in a bag - - protected Item(Memory memory) { - super(memory); - } - - protected Item(BudgetValue v, Memory memory) { - super(v, memory); - } - - /** - * Get the current key - * @return Current key value - */ - public String getKey() { - return key; - } - - /** - * Set a new key value - * @param k New key value - */ - public void setKey(String k) { - key = k; - } - - /** - * Get current BudgetValue - * @return Current BudgetValue - */ - public BudgetValue getBudget() { - return this; - } - - /** - * Set new BudgetValue - * @param v new BudgetValue - */ - public void setBudget(BudgetValue v) { // is this necessary? - setPriority(v.getPriority()); - setDurability(v.getDurability()); - setQuality(v.getQuality()); - } -} diff --git a/open-nars/src/com/googlecode/opennars/entity/Judgement.java b/open-nars/src/com/googlecode/opennars/entity/Judgement.java deleted file mode 100644 index 0d632d9b699fd54282677dfc3abca486ccde9db9..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/Judgement.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Judgement.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import com.googlecode.opennars.language.Term; -import com.googlecode.opennars.main.*; - -/** - * A Judgement is an piece of new knowledge to be absorbed. - */ -public class Judgement extends Sentence { - - public Judgement(Term term, char punc, TruthValue t, Base b, Memory memory) { - content = term; - punctuation = punc; - truth = t; - base = b; - this.memory = memory; - } - - public TruthValue getTruth() { - return truth; - } - - public float getFrequency() { - return truth.getFrequency(); - } - - public float getConfidence() { - return truth.getConfidence(); - } - - public Base getBase() { - return base; - } - - boolean equivalentTo(Judgement judgement2) { - return (truth.equals(judgement2.getTruth()) && base.equals(judgement2.getBase())); // may have different key - } - - public float getExpectationDifference(Judgement that) { - return getTruth().getExpDifAbs(that.getTruth()); - } - - public float solutionQuality(Sentence sentence) { - Term problem = sentence.getContent(); - if (sentence instanceof Goal) - return truth.getExpectation(); - else if (problem.isConstant()) // "yes/no" question - return truth.getConfidence(); // by confidence - else // "what" question or goal - return truth.getExpectation() / content.getComplexity(); // by likelihood/simplicity, to be refined - } - - public boolean noOverlapping(Judgement judgement) { - Base b = Base.make(base, judgement.getBase()); - if (b == null) - return false; - memory.currentBase = b; - return true; - } -} - diff --git a/open-nars/src/com/googlecode/opennars/entity/Question.java b/open-nars/src/com/googlecode/opennars/entity/Question.java deleted file mode 100644 index aa677eb8ea739edea8258edb76676f421d208d50..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/Question.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Question.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import com.googlecode.opennars.language.Term; -import com.googlecode.opennars.main.Memory; - -/** - * A Question is a sentence without a truth value needs evaluation, and may conain query variables - */ -public class Question extends Sentence { - - public Question(Term term, char punc, Memory memory) { - content = term; - punctuation = punc; - this.memory = memory; - } -} - diff --git a/open-nars/src/com/googlecode/opennars/entity/Sentence.java b/open-nars/src/com/googlecode/opennars/entity/Sentence.java deleted file mode 100644 index 1d1d60ed3145c26f2d659f3a290d245c012cef65..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/Sentence.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Sentence.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import com.googlecode.opennars.language.*; -import com.googlecode.opennars.main.*; -import com.googlecode.opennars.parser.Symbols; - -/** - * A Sentence contains a Statement, a TruthValue, and a Base list. - *<p> - * It is used as the premises and conclusions of all inference rules. - */ -public abstract class Sentence { - protected Term content; - protected char punctuation; - protected TruthValue truth = null; - protected Base base = null; - protected boolean input = false; // whether it is an input sentence - protected Judgement bestSolution = null; // for Question and Goal - protected Memory memory; // to change things -// protected Object token; // to track information through inferences - - /** - * Make a Sentence from an input String. Called by StringParser. - * @param term The content of the sentence - * @param punc The punctuation (and therefore, type) of the sentence - * @param truth The truth value of the sentence, if it is a Judgement (or Goal) - * @param base The base of the truth value (for Judgement or Goal) - * @return the Sentence generated from the arguments - */ - public static Sentence make(Term term, char punc, TruthValue truth, Base base, Memory memory) { - if (term instanceof CompoundTerm) - ((CompoundTerm) term).renameVariables(); - switch (punc) { - case Symbols.JUDGMENT_MARK: - return new Judgement(term, punc, truth, base, memory); - case Symbols.GOAL_MARK: - return new Goal(term, punc, truth, base, memory); - case Symbols.QUESTION_MARK: - return new Question(term, punc, memory); - default: - return null; - } - } - - /** - * Make a derived Sentence. Called by memory - * @param term The content of the sentence - * @param oldS A sample sentence providing the type of the new sentence - * @param truth The truth value of the sentence, if it is a Judgement (or Goal) - * @param base The base of the truth value (for Judgement or Goal) - * @return the Sentence generated from the arguments - */ - public static Sentence make(Sentence oldS, Term term, TruthValue truth, Base base, Memory memory) { - if (term instanceof CompoundTerm) - ((CompoundTerm) term).renameVariables(); - if (oldS instanceof Question) - return new Question(term, Symbols.QUESTION_MARK, memory); - if (oldS instanceof Goal) - return new Goal(term, Symbols.GOAL_MARK, truth, base, memory); - return new Judgement(term, Symbols.JUDGMENT_MARK, truth, base, memory); - } - - public Term getContent() { - return content; - } - - public Term cloneContent() { - return (Term) content.clone(); - } - - public TruthValue getTruth() { - return null; - } - - public Base getBase() { - return null; - } - - // distinguish Judgement from Goal - public boolean isJudgment() { - return (punctuation == Symbols.JUDGMENT_MARK); - } - - public boolean isInput() { - return input; - } - - public void setInput() { - input = true; - } - - public Judgement getBestSolution() { - return bestSolution; - } - - public void setBestSolution(Judgement judg) { - bestSolution = judg; - if (input) - memory.report(judg, false); // report answer to input question - } - - // display a sentence - public String toString() { - StringBuffer s = new StringBuffer(); - s.append(content.getName()); - s.append(punctuation + " "); - if (truth != null) { - s.append(truth.toString()); - s.append(base.toString()); - } - if (bestSolution != null) - s.append("BestSolution: " + bestSolution); - - return s.toString(); - } - - // display a sentence in compact form (2 digits) - public String toString2() { - StringBuffer s = new StringBuffer(); - s.append(content.getName()); - s.append(punctuation + " "); - if (truth != null) { - s.append(truth.toString2()); - } - return s.toString(); - } - - public boolean isGoal() { - return (this.punctuation == Symbols.GOAL_MARK); - } - - public boolean isQuestion() { - return (this.punctuation == Symbols.QUESTION_MARK); - } -} diff --git a/open-nars/src/com/googlecode/opennars/entity/ShortFloat.java b/open-nars/src/com/googlecode/opennars/entity/ShortFloat.java deleted file mode 100644 index 21f4e19f9a329b873b2e83434e8e699f1e4391e4..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/ShortFloat.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * ShortFloat.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -/** - * A float value in [0, 1], with 4 digits accuracy. - */ -public class ShortFloat implements Cloneable { - - // the values are saved as short integers (-32768 to 32767, only 0 to 10000 used), - // but used as float - private short value; - - public ShortFloat(float v) { - setValue(v); - } - - // access value - public float getValue() { - return (float) (value * 0.0001); - } - - public short getShortValue() { - return value; - } - - // set new value, rounded, with validity checking - public void setValue(float v) { - if ((v < 0) || (v > 1)) - System.err.println("!!! Wrong value: " + v); - else - value = (short) (v * 10000.0 + 0.5); - } - - public boolean equals(Object that) { - return ((that instanceof ShortFloat) && (value == ((ShortFloat) that).getShortValue())); - } - - // full output - public String toString() { - if (value == 10000) - return "1.0000"; - else { - String s = String.valueOf(value); - while (s.length() < 4) - s = "0" + s; - return "0." + s; - } - } - - // output with 2 digits, rounded - public String toString2() { - String s = toString(); - if (s.length() > 4) - return s.substring(0, 4); - else - return s; - } -} diff --git a/open-nars/src/com/googlecode/opennars/entity/Task.java b/open-nars/src/com/googlecode/opennars/entity/Task.java deleted file mode 100644 index fd2943f77f7491b72cc70d205b041c9035e62b50..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/Task.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Task.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import com.googlecode.opennars.language.*; -import com.googlecode.opennars.main.Memory; - -/** - * A task to be processed. - */ -public class Task extends Item { - private Sentence sentence; - protected boolean structual = false; // whether it is based on a structual rule - - public Task(Sentence s, BudgetValue b, Memory memory) { - super(b, memory); - sentence = s; - key = sentence.toString(); - } - - public Sentence getSentence() { - return sentence; - } - - public Term getContent() { - return sentence.getContent(); - } - - public boolean isStructual() { - return structual; - } - - public void setStructual() { - structual = true; - } - - public void merge(Item that) { - ((BudgetValue) this).merge(that.getBudget()); - structual = (structual || ((Task) that).isStructual()); - } - - public String toString() { - StringBuffer s = new StringBuffer(); - s.append(super.toString()); - s.append(sentence); - return s.toString(); - } - - public String toString2() { - StringBuffer s = new StringBuffer(); - if (sentence instanceof Question) - s.append(sentence); - else - s.append(((Judgement) sentence).toString2()); - return s.toString(); - } -} - diff --git a/open-nars/src/com/googlecode/opennars/entity/TaskLink.java b/open-nars/src/com/googlecode/opennars/entity/TaskLink.java deleted file mode 100644 index 45e51f1be834317209c5ef48d9b5243b4aa8aa8d..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/TaskLink.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * TaskLink.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import java.util.*; - -import com.googlecode.opennars.language.Term; -import com.googlecode.opennars.main.*; - -/** - * Reference to a Task. - * <p> - * The reason to separate a Task and a TaskLink is that a Task can be linked from multiple Concepts, with different BudgetValue. - */ -public class TaskLink extends TermLink { - private static final int RECORD_LENGTH = Parameters.TASK_INFERENCE_RECORD_LENGTH; - private Task targetTask; // now "target" means a term !!! - private ArrayList<String> record; // remember the CompositionLinks that has been used recently - - public TaskLink(Task t, TermLink template, BudgetValue v, Memory memory) { - super(v, memory); - if (template == null) { - type = TermLink.SELF; - index = null; - } else { - type = template.getType(); - index = template.getIndices(); - } - targetTask = t; - record = new ArrayList<String>(Parameters.TASK_INFERENCE_RECORD_LENGTH); - setKey(); - key += t.getKey(); - } - - public Task getTargetTask() { - return targetTask; - } - - public ArrayList<String> getRecord() { - return record; - } - - public void merge(Item that) { - ((BudgetValue) this).merge(that.getBudget()); - ArrayList<String> v = ((TaskLink) that).getRecord(); - for (int i = 0; i < v.size(); i++) - if (record.size() <= RECORD_LENGTH) - record.add(v.get(i)); - } - - // To check whether a TaskLink can use a TermLink - // return false if they intereacted recently - // called in CompositionBag only - // move into Task ? - public boolean novel(TermLink bLink) { - Term bTerm = bLink.getTarget(); - if (bTerm.equals(targetTask.getSentence().getContent())) - return false; - String key = bLink.getKey(); - for (int i = 0; i < record.size(); i++) - if (key.equals((String) record.get(i))) - return false; - record.add(key); // add knowledge reference to record -// if (record.size() > RECORD_LENGTH) // keep a constant length --- allow repeatation -// record.remove(0); - return true; - } -} - diff --git a/open-nars/src/com/googlecode/opennars/entity/TermLink.java b/open-nars/src/com/googlecode/opennars/entity/TermLink.java deleted file mode 100644 index cc6078893b0da34ea50e8bf6eba7498816008308..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/TermLink.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * TermLink.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import com.googlecode.opennars.language.CompoundTerm; -import com.googlecode.opennars.language.Term; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A link between a compound term and a component term - * <p> - * A TermLink links the current Term to a target Term, which is - * either a component of, or compound made from, the current term. - * <p> - * Both terms are constant. - * <p> - * The index value(s) indicates the location of the component in the compound. - */ -public class TermLink extends Item { - - public static final short SELF = 0; // TaskLink only - public static final short COMPONENT = 1; - public static final short COMPOUND = 2; - public static final short COMPONENT_STATEMENT = 3; - public static final short COMPOUND_STATEMENT = 4; - public static final short COMPONENT_CONDITION = 5; - public static final short COMPOUND_CONDITION = 6; - public static final short TRANSFORM = 7; // TaskLink only - - private Term target; - protected short type; - protected short[] index; - - public TermLink(Memory memory) { - super(memory); - } - - /** - * Simplest constructor, called in CompoundTerm and Implication - * @param t target Term - * @param p link type - * @param i component index in compound - */ - public TermLink(Term t, short p, int i, Memory memory) { - super(memory); - target = t; - type = p; - index = new short[1]; - index[0] = (short) i; - setKey(); - } - - public TermLink(Term t, short p, int i, int j, Memory memory) { - super(memory); - target = t; - type = p; - index = new short[2]; - index[0] = (short) i; - index[1] = (short) j; - setKey(); - } - - public TermLink(Term t, short p, int i, int j, int k, Memory memory) { - super(memory); - target = t; - type = p; - index = new short[3]; - index[0] = (short) i; - index[1] = (short) j; - index[2] = (short) k; - setKey(); - } - - protected TermLink(BudgetValue v, Memory memory) { - super(v, memory); - } - - // the CompotionLink that is actually inserted - public TermLink(Term t, TermLink template, BudgetValue v, Memory memory) { - super(v, memory); - target = t; - type = template.getType(); - if (template.getTarget().equals(target)) - type = reverse(type); - index = template.getIndices(); - setKey(); - } - - protected void setKey() { - String at1, at2; - if (toComponent()) { - at1 = Symbols.LinkToComponent_at1; - at2 = Symbols.LinkToComponent_at2; - } else { - at1 = Symbols.LinkToCompound_at1; - at2 = Symbols.LinkToCompound_at2; - } - String in = "T" + type; - if (index != null) - for (int i = 0; i < index.length; i++) { - in += "-" + (index[i]+1); - } - key = at1 + in + at2; - if (target != null) - key += target; - } - - public Term getTarget() { - return target; - } - - public short getType() { - return type; - } - - public boolean toComponent() { - return ((type % 2) > 0); - } - - public int indexLength() { - return (index == null)? 0 : index.length; - } - - public short[] getIndices() { - return index; - } - - public short getIndex(int i) { - if ((index != null) && (i < index.length)) - return index[i]; - else - return -1; - } - - protected short reverse(short i) { - if ((i % 2) == 0) - return (short) (i - 1); - else - return (short) (i + 1); - } - - public String toString() { - return (super.toString() + " " + key); - } - - public String toString2() { - return (super.toString2() + " " + key); - } -} - diff --git a/open-nars/src/com/googlecode/opennars/entity/TruthValue.java b/open-nars/src/com/googlecode/opennars/entity/TruthValue.java deleted file mode 100644 index ecf9d719d8e787151599d1ffe2e244b10719b520..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/TruthValue.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * TruthValue.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.entity; - -import com.googlecode.opennars.language.Term; -import com.googlecode.opennars.parser.*; - -/** - * Frequency and confidence. - */ -public class TruthValue { // implements Cloneable { - public static final char DELIMITER = Symbols.TRUTH_VALUE_MARK; // default - public static final char SEPARATOR = Symbols.VALUE_SEPARATOR; // default - protected ShortFloat frequency; - protected ShortFloat confidence; - - public TruthValue(float f, float c) { - frequency = new ShortFloat(f); - confidence = new ShortFloat(c); - } - - public TruthValue(TruthValue v) { - frequency = new ShortFloat(v.getFrequency()); - confidence = new ShortFloat(v.getConfidence()); - } - - public float getFrequency() { - return frequency.getValue(); - } - - public float getConfidence() { - return confidence.getValue(); - } - - public float getExpectation() { - return (float) (confidence.getValue() * (frequency.getValue() - 0.5) + 0.5); - } - - public float getExpDifAbs(float e) { - return Math.abs(e - getExpectation()); - } - - public float getExpDifAbs(TruthValue t) { - return getExpDifAbs(t.getExpectation()); - } - - public boolean equals(Object that) { - return ((that instanceof TruthValue) - && (getFrequency() == ((TruthValue) that).getFrequency()) - && (getConfidence() == ((TruthValue) that).getConfidence())); - } - - // full output - public String toString() { - return DELIMITER + frequency.toString() + SEPARATOR + confidence.toString() + DELIMITER; - } - - // short output - public String toString2() { - return DELIMITER + frequency.toString2() + SEPARATOR + confidence.toString2() + DELIMITER; - } -} diff --git a/open-nars/src/com/googlecode/opennars/entity/package.html b/open-nars/src/com/googlecode/opennars/entity/package.html deleted file mode 100644 index ffbdf26feae18dffab1f0cb478624683dbc2e22d..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/entity/package.html +++ /dev/null @@ -1,21 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<body bgcolor="white"> - -Data entities that are independently stored - -<h2>Package Specification</h2> - -<ul> -<li>ShortFloats: BudgetValue (priority/durability/quality) and TruthValue (frequency/confidence)</li> -<li>Base: serial numbers associated to TruthVallue</li> -<li>Sentence: a Term, a TruthValue, and a Base. A Sentence can be a Judgment, a Goal, or a Question.</li> -<li>Task: a Sentence to be processed.</li> -<li>TermLink: built in pair between a compound term and a component term.</li> -<li>TaskLink: special TermLink refering to a Task, whose Term equals or directly contains the current Term.</li> -<li>Concept: labeled by a Term, contains a TaskLink bag and a TermLink bag for indirect tasks/beliefs, as well as beliefs/questions/goals directly on the Term.</li> -<li>Item: Concept, Task, or TermLink</li> -</ul> - -</body> -</html> diff --git a/open-nars/src/com/googlecode/opennars/inference/BudgetFunctions.java b/open-nars/src/com/googlecode/opennars/inference/BudgetFunctions.java deleted file mode 100644 index 1538d5712fe38ab3c898cbe3fd7681ad572b0ea5..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/inference/BudgetFunctions.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * BudgetFunctions.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.inference; - -import com.googlecode.opennars.entity.*; -import com.googlecode.opennars.language.Term; -import com.googlecode.opennars.main.*; - -/** - * Budget functions controlling the resources allocation - */ -public class BudgetFunctions extends UtilityFunctions { - - private Memory memory; - - public BudgetFunctions(Memory memory) { - this.memory = memory; - } - - /* ----------------------- Belief evaluation ----------------------- */ - - /** - * Determine the quality of a judgment by its truth value - * <p> - * Mainly decided by confidence, though binary judgment is also preferred - * @param t The truth value of a judgment - * @return The quality of the judgment, according to truth value only - */ - public float truthToQuality(TruthValue t) { - float freq = t.getFrequency(); - float conf = t.getConfidence(); - return and(conf, Math.abs(freq - 0.5f) + freq * 0.5f); - } - - /** - * Determine the rank of a judgment by its confidence and originality (base length) - * <p> - * @param judg The judgment to be ranked - * @return The rank of the judgment, according to truth value only - */ - public float rankBelief(Judgement judg) { -// TruthValue truth = judg.getTruth(); -// float quality = truthToQuality(truth); - float confidence = judg.getConfidence(); - float originality = 1.0f / (judg.getBase().length() + 1); - return or(confidence, originality); - } - - /* ----- Functions used both in direct and indirect processing of tasks ----- */ - - /** - * Evaluate the quality of a belief as a solution to a problem, then reward the belief and de-prioritize the problem - * @param problem The problem (question or goal) to be solved - * @param solution The belief as solution - * @param task The task to be immediatedly processed, or null for continued process - * @return The budget for the new task which is the belief activated, if necessary - */ - BudgetValue solutionEval(Sentence problem, Judgement solution, Task task) { - BudgetValue budget = null; - boolean feedbackToLinks = false; - if (task == null) { // called in continued processing - task = memory.currentTask; - feedbackToLinks = true; - } - boolean judgmentTask = task.getSentence().isJudgment(); - float quality; // the quality of the solution - if (problem instanceof Question) - quality = solution.solutionQuality((Question) problem); - else // problem is goal - quality = solution.getTruth().getExpectation(); - if (judgmentTask) - task.incPriority(quality); - else { - task.setPriority(Math.min(1 - quality, task.getPriority())); - budget = new BudgetValue(quality, task.getDurability(), truthToQuality(solution.getTruth()), memory); - } - if (feedbackToLinks) { - TaskLink tLink = memory.currentTaskLink; - tLink.setPriority(Math.min(1 - quality, tLink.getPriority())); - TermLink bLink = memory.currentBeliefLink; - bLink.incPriority(quality); - } - return budget; - } - - /** - * Evaluate the quality of a revision, then de-prioritize the premises - * @param tTruth The truth value of the judgment in the task - * @param bTruth The truth value of the belief - * @param truth The truth value of the conclusion of revision - * @param task The task to be immediatedly or continuely processed - * @return The budget for the new task - */ - BudgetValue revise(TruthValue tTruth, TruthValue bTruth, TruthValue truth, Task task, boolean feedbackToLinks) { - float difT = truth.getExpDifAbs(tTruth); - task.decPriority(1 - difT); - task.decDurability(1 - difT); - if (feedbackToLinks) { - TaskLink tLink = memory.currentTaskLink; - tLink.decPriority(1 - difT); - tLink.decDurability(1 - difT); - TermLink bLink = memory.currentBeliefLink; - float difB = truth.getExpDifAbs(bTruth); - bLink.decPriority(1 - difB); - bLink.decDurability(1 - difB); - } - float dif = truth.getConfidence() - Math.max(tTruth.getConfidence(), bTruth.getConfidence()); - float priority = or(dif, task.getPriority()); - float durability = or(dif, task.getDurability()); - float quality = truthToQuality(truth); - return new BudgetValue(priority, durability, quality, memory); - } - - /* ----------------------- Links ----------------------- */ - - public BudgetValue distributeAmongLinks(BudgetValue b, int n) { - float priority = (float) (b.getPriority() / (n==0 ? 1 : Math.sqrt(n))); - return new BudgetValue(priority, b.getDurability(), b.getQuality(), memory); - } - - /* ----------------------- Concept ----------------------- */ - - /** - * Activate a concept by an incoming item (Task, TaskLink, or TermLink) - * @param concept The concept - * @param budget The budget for the new item - */ - public void activate(Concept concept, BudgetValue budget) { - float quality = aveAri(concept.getQuality(), budget.getPriority()); - float oldPri = concept.getPriority(); - float priority = or(oldPri, quality); - float durability = aveAri(concept.getDurability(), budget.getDurability(), oldPri / priority); - concept.setPriority(priority); - concept.setDurability(durability); - concept.setQuality(quality); - } - - /* ---------------- Bag functions, on all Items ------------------- */ - - /** - * Decrease Priority after an item is used, called in Bag - * <p> - * After a constant time, p should become d*p. Since in this period, the item is accessed c*p times, - * each time p-q should multiple d^(1/(c*p)). - * The intuitive meaning of the parameter "forgetRate" is: after this number of times of access, - * priority 1 will become d, it is a system parameter adjustable in run time. - * - * @param budget The previous budget value - * @param forgetRate The budget for the new item - */ - public static void forget(BudgetValue budget, float forgetRate, float relativeThreshold) { - double quality = budget.getQuality() * relativeThreshold; // re-scaled quality - double p = budget.getPriority() - quality; // priority above quality - if (p > 0) - quality += p * Math.pow(budget.getDurability(), 1.0 / (forgetRate * p)); // priority Durability - budget.setPriority((float) quality); - } - - /** - * Merge an item into another one in a bag, when the two are identical except in budget values - * @param baseValue The budget value to be modified - * @param adjustValue The budget doing the adjusting - */ - public void merge(BudgetValue baseValue, BudgetValue adjustValue) { - baseValue.incPriority(adjustValue.getPriority()); - baseValue.setDurability(Math.max(baseValue.getDurability(), adjustValue.getDurability())); - baseValue.setQuality(Math.max(baseValue.getQuality(), adjustValue.getQuality())); - } - - /* ----- Task derivation in MatchingRules and SyllogisticRules ----- */ - - /** - * Forward inference result and adjustment - * @param truth The truth value of the conclusion - * @return The budget value of the conclusion - */ - BudgetValue forward(TruthValue truth) { - return budgetInference(truthToQuality(truth), 1); - } - - // backward inference result and adjustment - public BudgetValue backward(TruthValue truth) { - return budgetInference(truthToQuality(truth), 1); - } - - public BudgetValue backwardWeak(TruthValue truth) { - return budgetInference(w2c(1) * truthToQuality(truth), 1); - } - - /* ----- Task derivation in CompositionalRules and StructuralRules ----- */ - - // forward inference with CompoundTerm conclusion and adjustment - public BudgetValue compoundForward(TruthValue truth, Term content) { - return budgetInference(truthToQuality(truth), content.getComplexity()); - } - - public BudgetValue compoundBackward(Term content) { - return budgetInference(1, content.getComplexity()); - } - - public BudgetValue compoundBackwardWeak(Term content) { - return budgetInference(w2c(1), content.getComplexity()); - } - - /* ----- common function for all inference ----- */ - - private BudgetValue budgetInference(float qual, int complexity) { - TaskLink tLink = memory.currentTaskLink; - TermLink bLink = memory.currentBeliefLink; - float priority = tLink.getPriority(); - float durability = tLink.getDurability(); - float quality = (float) (qual / Math.sqrt(complexity)); - if (bLink != null) { - priority = aveAri(priority, bLink.getPriority()); - durability = aveAri(durability, bLink.getDurability()); - bLink.incPriority(quality); - } - return new BudgetValue(and(priority, quality), and(durability, quality), quality, memory); - } -} diff --git a/open-nars/src/com/googlecode/opennars/inference/CompositionalRules.java b/open-nars/src/com/googlecode/opennars/inference/CompositionalRules.java deleted file mode 100644 index 0a6b77b05eabdef8c8d8b4b710abe7601b6a49be..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/inference/CompositionalRules.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * CompositionalRules.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.inference; - -import com.googlecode.opennars.entity.*; -import com.googlecode.opennars.language.*; -import com.googlecode.opennars.main.*; -import com.googlecode.opennars.parser.*; - -/** - * Compound term composition and decomposition rules, with two premises. - * <p> - * Forward inference only, except the last rule (abdDepOuter) can also be used backward. - */ -public class CompositionalRules { - - private Memory memory; - private BudgetFunctions budgetfunctions; - - public CompositionalRules(Memory memory) { - this.memory = memory; - this.budgetfunctions = new BudgetFunctions(memory); - } - - /* -------------------- intersections and differences -------------------- */ - - /** - * {<S ==> M>, <P ==> M>} |- {<(S|P) ==> M>, <(S&P) ==> M>, <(S-P) ==> M>, <(P-S) ==> M>} - * - * @param sentence The first premise - * @param belief The second premise - * @param index The location of the shared term - */ - void composeCompound(Sentence sentence, Judgement belief, int index) { - if (!sentence.isJudgment()) - return; // forward only - Statement content1 = (Statement) sentence.getContent(); - Statement content2 = (Statement) belief.getContent(); - if (content1.getClass() != content2.getClass()) - return; - if (content1.getTemporalOrder() != content2.getTemporalOrder()) - return; - Term component1, component2; - component1 = content1.componentAt(1 - index); - component2 = content2.componentAt(1 - index); - Term component = content1.componentAt(index); - if ((component1 instanceof CompoundTerm) && ((CompoundTerm) component1).containAllComponents(component2)) { - decomposeCompound((CompoundTerm) component1, component2, component, index, true); - return; - } else if ((component2 instanceof CompoundTerm) && ((CompoundTerm) component2).containAllComponents(component1)) { - decomposeCompound((CompoundTerm) component2, component1, component, index, false); - return; - } - Term t1 = null; - Term t2 = null; - Term t3 = null; - Term t4 = null; - TruthValue v1 = sentence.getTruth(); - TruthValue v2 = belief.getTruth(); - if (index == 0) { - if (content1 instanceof Inheritance) { - t1 = IntersectionInt.make(component1, component2, this.memory); - t2 = IntersectionExt.make(component1, component2, this.memory); - t3 = DifferenceExt.make(component1, component2, this.memory); - t4 = DifferenceExt.make(component2, component1, this.memory); - } else if (content1 instanceof Implication) { - t1 = Disjunction.make(component1, component2, this.memory); - t2 = Conjunction.make(component1, component2, this.memory); - t3 = Conjunction.make(component1, Negation.make(component2, this.memory), this.memory); - t4 = Conjunction.make(component2, Negation.make(component1, this.memory), this.memory); - } - processComposed(content1, component, t1, TruthFunctions.union(v1, v2)); - processComposed(content1, component, t2, TruthFunctions.intersection(v1, v2)); - processComposed(content1, component, t3, TruthFunctions.difference(v1, v2)); - processComposed(content1, component, t4, TruthFunctions.difference(v2, v1)); - if (content1.isConstant()) - introVarDepOuter(content1, content2, index); - } else { - if (content1 instanceof Inheritance) { - t1 = IntersectionExt.make(component1, component2, this.memory); - t2 = IntersectionInt.make(component1, component2, this.memory); - t3 = DifferenceInt.make(component1, component2, this.memory); - t4 = DifferenceInt.make(component2, component1, this.memory); - } else if (content1 instanceof Implication) { - t1 = Conjunction.make(component1, component2, this.memory); - t2 = Disjunction.make(component1, component2, this.memory); - t3 = Disjunction.make(component1, Negation.make(component2, this.memory), this.memory); - t4 = Disjunction.make(component2, Negation.make(component1, this.memory), this.memory); - } - processComposed(content1, t1, component, TruthFunctions.union(v1, v2)); - processComposed(content1, t2, component, TruthFunctions.intersection(v1, v2)); - processComposed(content1, t3, component, TruthFunctions.difference(v1, v2)); - processComposed(content1, t4, component, TruthFunctions.difference(v2, v1)); - if (content1.isConstant()) - introVarDepOuter(content1, content2, index); - } - } - - /** - * Finish composing compound term - * @param statement Type of the content - * @param subject Subject of content - * @param predicate Predicate of content - * @param truth TruthValue of the content - */ - private void processComposed(Statement statement, Term subject, Term predicate, TruthValue truth) { - if ((subject == null) || (predicate == null)) - return; - Term content = Statement.make(statement, subject, predicate, this.memory); - if ((content == null) || content.equals(statement) || content.equals(this.memory.currentBelief.getContent())) - return; - BudgetValue budget = this.budgetfunctions.compoundForward(truth, content); - this.memory.doublePremiseTask(budget, content, truth); - } - - /** - * {<(S|P) ==> M>, <P ==> M>} |- <S ==> M> - * @param compound The compound term to be decomposed - * @param component The part of the compound to be removed - * @param term1 The other term in the content - * @param index The location of the shared term: 0 for subject, 1 for predicate - * @param compoundTask Whether the compound comes from the task - */ - private void decomposeCompound(CompoundTerm compound, Term component, Term term1, int index, boolean compoundTask) { - Term term2 = CompoundTerm.reduceComponents(compound, component, this.memory); - if (term2 == null) - return; - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - Judgement belief = this.memory.currentBelief; - Statement oldContent = (Statement) task.getContent(); - TruthValue v1, v2; - if (compoundTask) { - v1 = sentence.getTruth(); - v2 = belief.getTruth(); - } else { - v1 = belief.getTruth(); - v2 = sentence.getTruth(); - } - TruthValue truth = null; - Term content; - if (index == 0) { - content = Statement.make(oldContent, term1, term2, this.memory); - if (content == null) - return; - if (oldContent instanceof Inheritance) { - if (compound instanceof IntersectionExt) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if (compound instanceof IntersectionInt) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } else if ((compound instanceof SetInt) && (component instanceof SetInt)) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if ((compound instanceof SetExt) && (component instanceof SetExt)) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } else if (compound instanceof DifferenceExt) { - if (compound.componentAt(0).equals(component)) { - truth = TruthFunctions.reduceDisjunction(v2, v1); - } else { - truth = TruthFunctions.reduceConjunctionNeg(v1, v2); - } - } - } else if (oldContent instanceof Implication) { - if (compound instanceof Conjunction) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if (compound instanceof Disjunction) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } - } - } else { - content = Statement.make(oldContent, term2, term1, this.memory); - if (content == null) - return; - if (oldContent instanceof Inheritance) { - if (compound instanceof IntersectionInt) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if (compound instanceof IntersectionExt) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } else if ((compound instanceof SetExt) && (component instanceof SetExt)) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if ((compound instanceof SetInt) && (component instanceof SetInt)) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } else if (compound instanceof DifferenceInt) { - if (compound.componentAt(1).equals(component)) { - truth = TruthFunctions.reduceDisjunction(v2, v1); - } else { - truth = TruthFunctions.reduceConjunctionNeg(v1, v2); - } - } - } else if (oldContent instanceof Implication) { - if (compound instanceof Disjunction) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if (compound instanceof Conjunction) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } - } - } - BudgetValue budget = this.budgetfunctions.compoundForward(truth, content); - this.memory.doublePremiseTask(budget, content, truth); - } - - /** - * {(||, S, P), P} |- S - * @param compound The compound term to be decomposed - * @param component The part of the compound to be removed - * @param compoundTask Whether the compound comes from the task - */ - void decomposeStatement(CompoundTerm compound, Term component, boolean compoundTask) { - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - if (!sentence.isJudgment()) - return; - Judgement belief = this.memory.currentBelief; - Term content = CompoundTerm.reduceComponents(compound, component, this.memory); - if (content == null) - return; - TruthValue v1, v2; - if (compoundTask) { - v1 = sentence.getTruth(); - v2 = belief.getTruth(); - } else { - v1 = belief.getTruth(); - v2 = sentence.getTruth(); - } - TruthValue truth = null; - if (compound instanceof Conjunction) { - if (sentence instanceof Goal) { - if (compoundTask) - truth = TruthFunctions.reduceDisjunction(v1, v2); - else - return; - } else if (sentence instanceof Judgement) - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if (compound instanceof Disjunction) { - if (sentence instanceof Goal) { - if (compoundTask) - truth = TruthFunctions.reduceConjunction(v1, v2); - else - return; - } else if (sentence instanceof Judgement) - truth = TruthFunctions.reduceDisjunction(v1, v2); - } else - return; - BudgetValue budget = this.budgetfunctions.compoundForward(truth, content); - this.memory.doublePremiseTask(budget, content, truth); - } - - /* ---------------- dependent variable and conjunction ---------------- */ - - /** - * {<M --> S>, <M --> P>} |- (&&, <#x() --> S>, <#x() --> P>> - * @param premise1 The first premise <M --> P> - * @param premise2 The second premise <M --> P> - * @param index The location of the shared term: 0 for subject, 1 for predicate - */ - private Conjunction introVarDep(Statement premise1, Statement premise2, int index) { - Statement state1, state2; - Variable v1 = new Variable(Symbols.VARIABLE_TAG + "0()"); - Variable v2 = new Variable(Symbols.VARIABLE_TAG + "0()"); - if (index == 0) { - state1 = Statement.make(premise1, v1, premise1.getPredicate(), this.memory); - state2 = Statement.make(premise2, v2, premise2.getPredicate(), this.memory); - } else { - state1 = Statement.make(premise1, premise1.getSubject(), v1, this.memory); - state2 = Statement.make(premise2, premise2.getSubject(), v2, this.memory); - } - Conjunction content = (Conjunction) Conjunction.make(state1, state2, this.memory); - return content; - } - - /** - * Introduce a dependent variable in an outer-layer conjunction - * @param premise1 The first premise <M --> S> - * @param premise2 The second premise <M --> P> - * @param index The location of the shared term: 0 for subject, 1 for predicate - */ - private void introVarDepOuter(Statement premise1, Statement premise2, int index) { - Term content = introVarDep(premise1, premise2, index); - TruthValue v1 = this.memory.currentTask.getSentence().getTruth(); - TruthValue v2 = this.memory.currentBelief.getTruth(); - TruthValue truth = TruthFunctions.intersection(v1, v2); - BudgetValue budget = this.budgetfunctions.compoundForward(truth, content); - this.memory.doublePremiseTask(budget, content, truth); - } - - /** - * Introduce a dependent variable in an inner-layer conjunction - * @param compound The compound containing the first premise - * @param component The first premise <M --> S> - * @param premise The second premise <M --> P> - */ - void introVarDepInner(CompoundTerm compound, Term component, Term premise) { - if (!(component instanceof Statement) || !(component.getClass() == premise.getClass())) - return; - Statement premise1 = (Statement) premise; - Statement premise2 = (Statement) component; - int index; - if (premise1.getSubject().equals(premise2.getSubject())) - index = 0; - else if (premise1.getPredicate().equals(premise2.getPredicate())) - index = 1; - else - return; - Term innerContent = introVarDep(premise1, premise2, index); - if (innerContent == null) - return; - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - Judgement belief = this.memory.currentBelief; - Term content = task.getContent(); - if (compound instanceof Implication) - content = Statement.make((Statement) content, compound.componentAt(0), innerContent, this.memory); - else if (compound instanceof Conjunction) - content = CompoundTerm.replaceComponent(compound, component, innerContent, this.memory); - TruthValue truth = null; - if (sentence instanceof Goal) - truth = TruthFunctions.intersection(belief.getTruth(), sentence.getTruth()); // to be revised - else if (sentence instanceof Judgement) - truth = TruthFunctions.intersection(belief.getTruth(), sentence.getTruth()); - else - return; // don't do it for questions - BudgetValue budget = this.budgetfunctions.compoundForward(truth, content); - this.memory.doublePremiseTask(budget, content, truth); - } - - /** - * {(&&, <#x() --> S>, <#x() --> P>>, <M --> P>} |- <M --> S> - * @param compound The compound term to be decomposed - * @param component The part of the compound to be removed - * @param compoundTask Whether the compound comes from the task - */ - void abdVarDepOuter(CompoundTerm compound, Term component, boolean compoundTask) { - Term content = CompoundTerm.reduceComponents(compound, component, this.memory); - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - Judgement belief = this.memory.currentBelief; - TruthValue v1 = sentence.getTruth(); - TruthValue v2 = belief.getTruth(); - TruthValue truth = null; - BudgetValue budget; - if (sentence instanceof Question) - budget = (compoundTask ? this.budgetfunctions.backward(v2) : this.budgetfunctions.backwardWeak(v2)); - else { - if (sentence instanceof Goal) - truth = (compoundTask ? TruthFunctions.desireStrong(v1, v2) : TruthFunctions.desireWeak(v1, v2)); - else - truth = (compoundTask ? TruthFunctions.existAnalogy(v1, v2) : TruthFunctions.existAnalogy(v2, v1)); - budget = this.budgetfunctions.compoundForward(truth, content); - } - this.memory.doublePremiseTask(budget, content, truth); - } -} diff --git a/open-nars/src/com/googlecode/opennars/inference/MatchingRules.java b/open-nars/src/com/googlecode/opennars/inference/MatchingRules.java deleted file mode 100644 index 0942515533a921439436e925cee08d9c5b846764..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/inference/MatchingRules.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * MatchingRules.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.inference; - -import com.googlecode.opennars.entity.*; -import com.googlecode.opennars.language.*; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.*; - -/** - * Directly process a task by a belief, with only two Terms in both - */ -public class MatchingRules { - - private Memory memory; - private BudgetFunctions budgetfunctions; - - public MatchingRules(Memory memory) { - this.memory = memory; - this.budgetfunctions = new BudgetFunctions(memory); - } - - /* -------------------- same contents -------------------- */ - - // the task and belief match each other - // forward inference only - // called only for Figure 0 of syllogism, in ThreeTermRules - public void match(Task task, Judgement belief) { - Sentence sentence = task.getSentence(); - if (sentence.isJudgment()) - revision(task, belief, true); - else - trySolution(sentence, belief, null); - } - - // to be rewritten - public void update(Task newBelief, Judgement oldBelief) { -// Base label = Base.make(newBelief.getBase(), oldBelief.getBase()); -// if ((label == null) || (label.length() == 0)) -// return; -// Task updatedNewBelief = (Task) newBelief.clone(); -// Task updatedOldBelief = (Task) oldBelief.clone(); -// Term content = oldBelief.getContent(); -// Term toPast = Past.make(content); -// updatedOldBelief.setContent(toPast); -// updatedNewBelief.setBase(label); -// TruthValue truth = TruthFunctions.revision(newBelief.getTruth(), oldBelief.getTruth()); -// float confidence = truth.getConfidence(); -// updatedNewBelief.setConfidence(confidence); -// BudgetValue usage = this.budgetfunctions.update(newBelief, oldBelief); -// updatedNewBelief.setBudget(usage); -// this.memory.derivedTask(updatedNewBelief); -// this.memory.derivedTask(updatedOldBelief); - } - - // called from Concept (direct) and match (indirect) - public void revision(Task task, Judgement belief, boolean feedbackToLinks) { - Judgement judgement = (Judgement) task.getSentence(); - TruthValue tTruth = judgement.getTruth(); - TruthValue bTruth = belief.getTruth(); - TruthValue truth = TruthFunctions.revision(tTruth, bTruth); - BudgetValue budget = this.budgetfunctions.revise(tTruth, bTruth, truth, task, feedbackToLinks); - Term content = judgement.getContent(); - this.memory.doublePremiseTask(budget, content, truth); - } - - /** - * Check if a Judgement provide a better answer to a Question - * @param task The task to be processed - */ - public void trySolution(Sentence problem, Judgement belief, Task task) { - Judgement oldBest = problem.getBestSolution(); - if (betterSolution(belief, oldBest, problem)) { - problem.setBestSolution(belief); - BudgetValue budget = this.budgetfunctions.solutionEval(problem, belief, task); - if (budget != null) - this.memory.activatedTask(budget, belief, problem.isInput()); - } - } - - // s1 is a better answer to q than s2 is - private boolean betterSolution(Judgement newSol, Judgement oldSol, Sentence problem) { - if (oldSol == null) - return true; - else - return (newSol.solutionQuality(problem) > oldSol.solutionQuality(problem)); - } - - /* -------------------- same terms, difference relations -------------------- */ - - // the task and belief match each other reversely - // forward inference only - // called only for Figure 5 of syllogism - public void matchReverse() { - Task task = this.memory.currentTask; - Judgement belief = this.memory.currentBelief; - if (task.getContent().getTemporalOrder() != CompoundTerm.temporalReverse(belief.getContent().getTemporalOrder())) - return; - Sentence sentence = task.getSentence(); - if (sentence.isJudgment()) - inferToSym((Judgement) sentence, belief); - else - conversion(); - } - - // Inheritance matches Similarity - // forward inference only - // called from ThreeTermRules only - public void matchAsymSym(Sentence asym, Sentence sym, int figure) { // (Task task, Sentence belief, int order, boolean inhSim) { - CompoundTerm.TemporalOrder order1 = asym.getContent().getTemporalOrder(); - CompoundTerm.TemporalOrder order2 = sym.getContent().getTemporalOrder(); - CompoundTerm.TemporalOrder order = CompoundTerm.temporalInferenceWithFigure(order1, order2, figure); - if (order == CompoundTerm.TemporalOrder.UNSURE) - return; - if (this.memory.currentTask.getSentence().isJudgment()) - inferToAsym((Judgement) asym, (Judgement) sym, order); - else { - convertRelation(); - } - } - - /* -------------------- two-premise inference rules -------------------- */ - - /** - * Produce Similarity/Equivalence from a pire of reversed Inheritance/Implication - * @param judgement1 The first premise - * @param judgement2 The second premise - */ - private void inferToSym(Judgement judgement1, Judgement judgement2) { - Statement s1 = (Statement) judgement1.getContent(); - Statement s2 = (Statement) judgement2.getContent(); - Term t1 = s1.getSubject(); - Term t2 = s1.getPredicate(); - Term content; - if (s1 instanceof Inheritance) - content = Similarity.make(t1, t2, this.memory); - else if (s1 instanceof ImplicationAfter) - content = EquivalenceAfter.make(t1, t2, this.memory); - else if (s1 instanceof ImplicationBefore) - content = EquivalenceAfter.make(t2, t1, this.memory); - else - content = Equivalence.make(t1, t2, this.memory); - TruthValue value1 = judgement1.getTruth(); - TruthValue value2 = judgement2.getTruth(); - TruthValue truth = TruthFunctions.intersection(value1, value2); - BudgetValue budget = this.budgetfunctions.forward(truth); - this.memory.doublePremiseTask(budget, content, truth); - } - - /** - * Produce an Inheritance/Implication from a Similarity/Equivalence and a reversed Inheritance/Implication - * @param asym The asymmetric premise - * @param sym The symmetric premise - */ - private void inferToAsym(Judgement asym, Judgement sym, CompoundTerm.TemporalOrder order) { - Statement statement = (Statement) asym.getContent(); - Term sub = statement.getPredicate(); - Term pre = statement.getSubject(); - Statement content = Statement.make(statement, sub, pre, order, this.memory); - TruthValue truth = TruthFunctions.reduceConjunction(sym.getTruth(), asym.getTruth()); - BudgetValue budget = this.budgetfunctions.forward(truth); - this.memory.doublePremiseTask(budget, content, truth); - } - - /* -------------------- one-premise inference rules -------------------- */ - - /** - * Produce an Inheritance/Implication from a reversed Inheritance/Implication - */ - private void conversion() { - TruthValue truth = TruthFunctions.conversion(this.memory.currentBelief.getTruth()); - BudgetValue budget = this.budgetfunctions.forward(truth); - this.memory.singlePremiseTask(truth, budget); - } - - // switch between Inheritance/Implication and Similarity/Equivalence - private void convertRelation() { - TruthValue truth = this.memory.currentBelief.getTruth(); - if (((Statement) this.memory.currentTask.getContent()).isCommutative()) - truth = TruthFunctions.implied(truth); - else - truth = TruthFunctions.implying(truth); - BudgetValue budget = this.budgetfunctions.forward(truth); - this.memory.singlePremiseTask(truth, budget); - } -} diff --git a/open-nars/src/com/googlecode/opennars/inference/RuleTables.java b/open-nars/src/com/googlecode/opennars/inference/RuleTables.java deleted file mode 100644 index a34caefb02c17f3d50f162180f222f833c59bec0..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/inference/RuleTables.java +++ /dev/null @@ -1,440 +0,0 @@ -/* - * RuleTables.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.inference; - -import com.googlecode.opennars.entity.*; -import com.googlecode.opennars.language.*; -import com.googlecode.opennars.main.Memory; - -/** - * Table of inference rules, indexed by the CompositionLinks for the task and the belief. - * Used for indirective processing of a task - */ -public class RuleTables { - - private Memory memory; - - private SyllogisticRules syllogisticrules; - private StructuralRules structuralrules; - private MatchingRules matchingrules; - private CompositionalRules compositionalrules; - - public RuleTables(Memory memory) { - this.memory = memory; - this.syllogisticrules = new SyllogisticRules(memory); - this.structuralrules = new StructuralRules(memory); - this.matchingrules = new MatchingRules(memory); - this.compositionalrules = new CompositionalRules(memory); - } - - public MatchingRules getMatchingRules() { - return this.matchingrules; - } - - /* ----- inferences with two composition links ----- */ - - public void reason(TaskLink tLink, TermLink bLink) { - Task task = memory.currentTask; - Term taskTerm = (Term) task.getContent().clone(); // cloning for substitution - Term beliefTerm = (Term) bLink.getTarget().clone(); // cloning for substitution - Concept beliefConcept = memory.termToConcept(beliefTerm); - Judgement belief = null; - if (beliefConcept != null) - belief = beliefConcept.getBelief(task); - memory.currentBelief = belief; // may be null - if ((belief != null) && (Variable.findSubstitute(Variable.VarType.QUERY, taskTerm, beliefTerm) != null)) - matchingrules.match(task, belief); - short tIndex = tLink.getIndex(0); - short bIndex = bLink.getIndex(0); - switch(tLink.getType()) { - case TermLink.SELF: - switch(bLink.getType()) { - case TermLink.COMPONENT: - compoundAndSelf((CompoundTerm) taskTerm, beliefTerm, true); - break; - case TermLink.COMPOUND: - compoundAndSelf((CompoundTerm) beliefTerm, taskTerm, false); - break; - case TermLink.COMPONENT_STATEMENT: // detachment - if (belief != null) - syllogisticrules.detachment((Statement) taskTerm, null, true, bIndex); - break; - case TermLink.COMPOUND_STATEMENT: // detachment - if (belief != null) - syllogisticrules.detachment((Statement) beliefTerm, null, false, bIndex); //task, beliefTerm); - break; - case TermLink.COMPONENT_CONDITION: - if (belief != null) - syllogisticrules.conditionalDedInd((Implication) taskTerm, bIndex, beliefTerm, tIndex); - break; - case TermLink.COMPOUND_CONDITION: - if (belief != null) - syllogisticrules.conditionalDedInd((Implication) beliefTerm, bIndex, taskTerm, tIndex); - break; - default: - } - break; - case TermLink.COMPOUND: - switch(bLink.getType()) { - case TermLink.COMPOUND: - compoundAndCompound((CompoundTerm) taskTerm, tIndex, (CompoundTerm) beliefTerm, bIndex); - break; - case TermLink.COMPOUND_STATEMENT: - compoundAndStatement((CompoundTerm) taskTerm, tIndex, (Statement) beliefTerm, bIndex, beliefTerm); - break; - default: - } - break; - case TermLink.COMPOUND_STATEMENT: - switch(bLink.getType()) { - case TermLink.COMPONENT: - componentAndStatement((CompoundTerm) memory.currentTerm, bIndex, (Statement) taskTerm, tIndex); - break; - case TermLink.COMPOUND: - compoundAndStatement((CompoundTerm) beliefTerm, bIndex, (Statement) taskTerm, tIndex, beliefTerm); - break; - case TermLink.COMPOUND_STATEMENT: - if (belief != null) - syllogisms(tLink, bLink, taskTerm, beliefTerm); - break; - case TermLink.COMPOUND_CONDITION: - if (belief != null) - conditionalDedIndWithVar((Implication) beliefTerm, bIndex, (Statement) taskTerm, tIndex); - break; - default: - } - break; - case TermLink.COMPOUND_CONDITION: - switch(bLink.getType()) { - case TermLink.COMPOUND_STATEMENT: - if (belief != null) - conditionalDedIndWithVar((Implication) taskTerm, tIndex, (Statement) beliefTerm, bIndex); - break; - default: - } - break; - default: - // to be revised to cover all types - } - } - - /* ----- syllogistic inferences ----- */ - - /** - * Meta-table of syllogistic rules, indexed by the content classes of the sentence and the belief - */ - private void syllogisms(TaskLink tLink, TermLink bLink, Term taskTerm, Term beliefTerm) { - Sentence sentence = memory.currentTask.getSentence(); - Judgement belief = memory.currentBelief; - int figure; - if (taskTerm instanceof Inheritance) { - if (beliefTerm instanceof Inheritance) { - figure = indexToFigure(tLink, bLink); - asymmetricAsymmetric(sentence, belief, figure); - } else if (beliefTerm instanceof Similarity) { - figure = indexToFigure(tLink, bLink); - asymmetricSymmetric(sentence, belief, figure); - } else - detachmentWithVar((Statement) beliefTerm, false, bLink.getIndex(0), (Statement) taskTerm, belief); - } else if (taskTerm instanceof Similarity) { - if (beliefTerm instanceof Inheritance) { - figure = indexToFigure(bLink, tLink); - asymmetricSymmetric(belief, sentence, figure); - } else if (beliefTerm instanceof Similarity) { - figure = indexToFigure(bLink, tLink); - symmetricSymmetric(belief, sentence, figure); - } - } else if (taskTerm instanceof Implication) { - if (beliefTerm instanceof Implication) { - figure = indexToFigure(tLink, bLink); - asymmetricAsymmetric(sentence, belief, figure); - } else if (beliefTerm instanceof Equivalence) { - figure = indexToFigure(tLink, bLink); - asymmetricSymmetric(sentence, belief, figure); - } else if (beliefTerm instanceof Inheritance) - detachmentWithVar((Statement) taskTerm, true, tLink.getIndex(0), (Statement) beliefTerm, belief); - // or intro 2nd ind var - } else if (taskTerm instanceof Equivalence) { - if (beliefTerm instanceof Implication) { - figure = indexToFigure(bLink, tLink); - asymmetricSymmetric(belief, sentence, figure); - } else if (beliefTerm instanceof Equivalence) { - figure = indexToFigure(bLink, tLink); - symmetricSymmetric(belief, sentence, figure); - } else if (beliefTerm instanceof Inheritance) - detachmentWithVar((Statement) taskTerm, true, tLink.getIndex(0), (Statement) beliefTerm, belief); - } - } - - private int indexToFigure(TermLink link1, TermLink link2) { - return (link1.getIndex(0) + 1) * 10 + (link2.getIndex(0) + 1); // valid value: 11, 12, 21, 22 - } - - /** - * Syllogistic rules whose both premises are on the same asymmetric relation - */ - private void asymmetricAsymmetric(Sentence sentence, Judgement belief, int figure) { - Statement s1 = (Statement) sentence.cloneContent(); - Statement s2 = (Statement) belief.cloneContent(); - Term t1, t2; - switch (figure) { - case 11: // induction - if (Variable.unify(Variable.VarType.INDEPENDENT, s1.getSubject(), s2.getSubject(), s1, s2)) { - t1 = s2.getPredicate(); - t2 = s1.getPredicate(); - syllogisticrules.abdIndCom(t1, t2, sentence, belief, figure); - compositionalrules.composeCompound(sentence, belief, 0); - } - break; - case 12: // deduction - if (Variable.unify(Variable.VarType.INDEPENDENT, s1.getSubject(), s2.getPredicate(), s1, s2)) { - t1 = s2.getSubject(); - t2 = s1.getPredicate(); - if (Variable.unify(Variable.VarType.QUERY, t1, t2, s1, s2)) - matchingrules.matchReverse(); - else - syllogisticrules.dedExe(t1, t2, sentence, belief); - } - break; - case 21: // exemplification - if (Variable.unify(Variable.VarType.INDEPENDENT, s1.getPredicate(), s2.getSubject(), s1, s2)) { - t1 = s1.getSubject(); - t2 = s2.getPredicate(); - if (Variable.unify(Variable.VarType.QUERY, t1, t2, s1, s2)) - matchingrules.matchReverse(); - else - syllogisticrules.dedExe(t1, t2, sentence, belief); - } - break; - case 22: // abduction - if (Variable.unify(Variable.VarType.INDEPENDENT, s1.getPredicate(), s2.getPredicate(), s1, s2)) { - t1 = s1.getSubject(); - t2 = s2.getSubject(); - if (! syllogisticrules.conditionalAbd(t1, t2, s1, s2)) { // if conditional abduction, skip the following - syllogisticrules.abdIndCom(t1, t2, sentence, belief, figure); - compositionalrules.composeCompound(sentence, belief, 1); - } - } - break; - default: - } - } - - /** - * Syllogistic rules whose first premise is on an asymmetric relation, and the second on a symmetric relation - */ - private void asymmetricSymmetric(Sentence asym, Sentence sym, int figure) { - Statement asymSt = (Statement) asym.cloneContent(); - Statement symSt = (Statement) sym.cloneContent(); - Term t1, t2; - switch (figure) { - case 11: - if (Variable.unify(Variable.VarType.INDEPENDENT, asymSt.getSubject(), symSt.getSubject(), asymSt, symSt)) { - t1 = asymSt.getPredicate(); - t2 = symSt.getPredicate(); - if (Variable.unify(Variable.VarType.QUERY, t1, t2, asymSt, symSt)) - matchingrules.matchAsymSym(asym, sym, figure); //task, belief, order1 - order2, false); - else - syllogisticrules.analogy(t2, t1, asym, sym, figure); - } - break; - case 12: - if (Variable.unify(Variable.VarType.INDEPENDENT, asymSt.getSubject(), symSt.getPredicate(), asymSt, symSt)) { - t1 = asymSt.getPredicate(); - t2 = symSt.getSubject(); - if (Variable.unify(Variable.VarType.QUERY, t1, t2, asymSt, symSt)) - matchingrules.matchAsymSym(asym, sym, figure); //task, belief, order1 - order2, false); - else - syllogisticrules.analogy(t2, t1, asym, sym, figure); - } - break; - case 21: - if (Variable.unify(Variable.VarType.INDEPENDENT, asymSt.getPredicate(), symSt.getSubject(), asymSt, symSt)) { - t1 = asymSt.getSubject(); - t2 = symSt.getPredicate(); - if (Variable.unify(Variable.VarType.QUERY, t1, t2, asymSt, symSt)) - matchingrules.matchAsymSym(asym, sym, figure); //task, belief, order1 - order2, false); - else - syllogisticrules.analogy(t1, t2, asym, sym, figure); - } - break; - case 22: - if (Variable.unify(Variable.VarType.INDEPENDENT, asymSt.getPredicate(), symSt.getPredicate(), asymSt, symSt)) { - t1 = asymSt.getSubject(); - t2 = symSt.getSubject(); - if (Variable.unify(Variable.VarType.QUERY, t1, t2, asymSt, symSt)) - matchingrules.matchAsymSym(asym, sym, figure); //task, belief, order1 - order2, false); - else - syllogisticrules.analogy(t1, t2, asym, sym, figure); - } - break; - } - } - - /** - * Syllogistic rules whose both premises are on the same symmetric relation - */ - private void symmetricSymmetric(Judgement belief, Sentence sentence, int figure) { - Statement s1 = (Statement) belief.cloneContent(); - Statement s2 = (Statement) sentence.cloneContent(); - switch (figure) { - case 11: - if (Variable.unify(Variable.VarType.INDEPENDENT, s1.getSubject(), s2.getSubject(), s1, s2)) - syllogisticrules.resemblance(s1.getPredicate(), s2.getPredicate(), belief, sentence, figure); - break; - case 12: - if (Variable.unify(Variable.VarType.INDEPENDENT, s1.getSubject(), s2.getPredicate(), s1, s2)) - syllogisticrules.resemblance(s1.getPredicate(), s2.getSubject(), belief, sentence, figure); - break; - case 21: - if (Variable.unify(Variable.VarType.INDEPENDENT, s1.getPredicate(), s2.getSubject(), s1, s2)) - syllogisticrules.resemblance(s1.getSubject(), s2.getPredicate(), belief, sentence, figure); - break; - case 22: - if (Variable.unify(Variable.VarType.INDEPENDENT, s1.getPredicate(), s2.getPredicate(), s1, s2)) - syllogisticrules.resemblance(s1.getSubject(), s2.getSubject(), belief, sentence, figure); - break; - } - } - - /* ----- conditional inferences ----- */ - - private void detachmentWithVar(Statement statement, boolean compoundTask, int index, CompoundTerm compound, Sentence belief) { - Term component = statement.componentAt(index); - Term inh = (compound instanceof Tense) ? compound.componentAt(0) : compound; - if ((component instanceof Inheritance) && (belief != null)) { - if (component.isConstant()) - syllogisticrules.detachment(statement, compound, compoundTask, index); - else if (Variable.unify(Variable.VarType.INDEPENDENT, component, inh, statement, compound)) - syllogisticrules.detachment(statement, compound, compoundTask, index); - else if ((statement instanceof Implication) && (memory.currentTask.getSentence().isJudgment())) { - syllogisticrules.introVarIndInner(statement, statement.getPredicate(), inh); // tense??? - compositionalrules.introVarDepInner(statement, statement.getPredicate(), inh); // tense??? - } - } - } - - private void conditionalDedIndWithVar(Implication conditional, short index, Statement statement, short side) { - CompoundTerm condition = (CompoundTerm) conditional.getSubject(); - Term component = condition.componentAt(index); - Term component2 = null; - if (statement instanceof Inheritance) - component2 = statement; - else if (statement instanceof Implication) - component2 = statement.componentAt(side); - if ((component2 != null) && Variable.unify(Variable.VarType.INDEPENDENT, component, component2, conditional, statement)) - syllogisticrules.conditionalDedInd(conditional, index, statement, -1); - } - - /* ----- structural inferences ----- */ - - private void compoundAndSelf(CompoundTerm compound, Term component, boolean compoundTask) { - if ((compound instanceof Conjunction) || (compound instanceof Disjunction)) { - if (memory.currentBelief != null) - compositionalrules.decomposeStatement(compound, component, compoundTask); - else if (compound.containComponent(component)) - structuralrules.structuralCompound(compound, component, compoundTask); - } else if ((compound instanceof Negation) && !memory.currentTask.isStructual()) { - if (compoundTask) - structuralrules.transformNegation(((Negation) compound).componentAt(0)); - else - structuralrules.transformNegation(compound); - } - } - - private void compoundAndCompound(CompoundTerm taskTerm, int tIndex, CompoundTerm beliefTerm, int bIndex) { - if (taskTerm.getClass() == beliefTerm.getClass()) { - if (taskTerm.size() > beliefTerm.size()) - compoundAndSelf(taskTerm, beliefTerm, true); - else if (taskTerm.size() < beliefTerm.size()) - compoundAndSelf(beliefTerm, taskTerm, false); - } - } - - private void compoundAndStatement(CompoundTerm compound, short index, Statement statement, short side, Term beliefTerm) { - Term component = compound.componentAt(index); - Task task = memory.currentTask; - if (component.getClass() == statement.getClass()) { - if ((compound instanceof Conjunction) && (memory.currentBelief != null)) { - if (Variable.unify(Variable.VarType.DEPENDENT, component, statement, compound, statement)) - compositionalrules.abdVarDepOuter(compound, component, statement.equals(beliefTerm)); - else if (task.getSentence().isJudgment()) { - syllogisticrules.introVarIndInner(compound, component, statement); - compositionalrules.introVarDepInner(compound, component, statement); - } - } - } else { - if (compound instanceof Tense) { - if (component instanceof Inheritance) - detachmentWithVar(statement, statement.equals(beliefTerm), side, compound, memory.currentBelief); - else { - Sentence belief = memory.currentBelief; - if (belief != null) - syllogisticrules.detachment(statement, compound, statement.equals(beliefTerm), side); - } - } else if (!task.isStructual() && task.getSentence().isJudgment()) { - if (statement instanceof Inheritance) { - structuralrules.structuralCompose1(compound, index, statement); - if (!(compound instanceof SetExt) && !(compound instanceof SetInt)) - structuralrules.structuralCompose2(compound, index, statement, side); // {A --> B, A @ (A&C)} |- (A&C) --> (B&C) - } else if (statement instanceof Similarity) - structuralrules.structuralCompose2(compound, index, statement, side); // {A <-> B, A @ (A&C)} |- (A&C) <-> (B&C) - } - } - } - - private void componentAndStatement(CompoundTerm compound, short index, Statement statement, short side) { - if (!memory.currentTask.isStructual()) { - if (statement instanceof Inheritance) { - structuralrules.structuralDecompose1(compound, index, statement, side); - if (!(compound instanceof SetExt) && !(compound instanceof SetInt)) - structuralrules.structuralDecompose2(statement); // {(C-B) --> (C-A), A @ (C-A)} |- A --> B - else - structuralrules.transformSetRelation(compound, statement, side); - } else if (statement instanceof Similarity) { - structuralrules.structuralDecompose2(statement); // {(C-B) --> (C-A), A @ (C-A)} |- A --> B - if ((compound instanceof SetExt) || (compound instanceof SetInt)) - structuralrules.transformSetRelation(compound, statement, side); - } else if ((statement instanceof Implication) && (compound instanceof Negation)) - structuralrules.contraposition(statement); - } - } - - /* ----- inference with one composition link ----- */ - - public void transformTask(Task task, TaskLink tLink) { // move to StructuralRules??? - CompoundTerm content = (CompoundTerm) task.getContent().clone(); - short[] indices = tLink.getIndices(); - Term inh = null; - if (indices.length == 2) { - inh = content; - } else if (indices.length == 3) { - if ((content instanceof Implication) && (content.componentAt(0) instanceof Conjunction)) - inh = ((CompoundTerm) content.componentAt(0)).componentAt(indices[0]); - else - inh = content.componentAt(indices[0]); - } - if (inh instanceof Inheritance) - structuralrules.transformProductImage((Inheritance)inh, content, indices, task); - } - -} diff --git a/open-nars/src/com/googlecode/opennars/inference/StructuralRules.java b/open-nars/src/com/googlecode/opennars/inference/StructuralRules.java deleted file mode 100644 index 607061a1e9df82328ebb02c7845bb311a80e4b06..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/inference/StructuralRules.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * StructuralRules.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.inference; - -import java.util.*; - -import com.googlecode.opennars.entity.*; -import com.googlecode.opennars.language.*; -import com.googlecode.opennars.main.*; -import com.googlecode.opennars.parser.*; - - -/** - * Forward inference rules involving compound terms. - * Input premises are one sentence and one BeliefLink. - */ -public class StructuralRules { - - private Memory memory; - private BudgetFunctions budgetfunctions; - - public StructuralRules(Memory memory) { - this.memory = memory; - this.budgetfunctions = new BudgetFunctions(memory); - } - - /* -------------------- transform between compounds and components -------------------- */ - - /** - * {<A --> B>} |- <(A&C) --> (B&C)> - * @param compound The compound term - * @param index The location of the indicated term in the compound - * @param statement The premise - * @param side The location of the indicated term in the premise - */ - void structuralCompose2(CompoundTerm compound, short index, Statement statement, short side) { - Term sub = statement.getSubject(); - Term pred = statement.getPredicate(); - ArrayList<Term> components = compound.cloneComponents(); - if (((side == 0) && components.contains(pred)) || ((side == 1) && components.contains(sub))) - return; // both terms in compound - if (side == 0) { - sub = compound; - components.set(index, pred); - pred = CompoundTerm.make(compound, components, this.memory); - } else { - components.set(index, sub); - sub = CompoundTerm.make(compound, components, this.memory); - pred = compound; - } - if ((sub == null) || (pred == null)) - return; - Term content; - if (switchOrder(compound, index)) - content = Statement.make(statement, pred, sub, this.memory); // {A --> B, A @ (C-A)} |- (C-B) --> (C-A) - else - content = Statement.make(statement, sub, pred, this.memory); // the other cases - if (content == null) - return; - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) { - budget = this.budgetfunctions.compoundBackwardWeak(content); - } else { - if (compound.size() > 1) { - if (sentence.isJudgment()) - truth = TruthFunctions.implying(truth); - else // Goal - truth = TruthFunctions.implied(truth); - } - budget = this.budgetfunctions.compoundForward(truth, content); - } - this.memory.singlePremiseTask(budget, content, truth); - } - - /** - * {<(A&C) --> (B&C)>} |- <A --> B> - * @param statement The premise - */ - void structuralDecompose2(Statement statement) { - Term subj = statement.getSubject(); - Term pred = statement.getPredicate(); - if (subj.getClass() != pred.getClass()) - return; - CompoundTerm sub = (CompoundTerm) subj; - CompoundTerm pre = (CompoundTerm) pred; - if (sub.size() != pre.size()) - return; - int index = -1; - Term t1, t2; - for (int i = 0; i < sub.size(); i++) { - t1 = sub.componentAt(i); - t2 = pre.componentAt(i); - if (!t1.equals(t2)) { - if (index < 0) - index = i; - else - return; - } - } - t1 = sub.componentAt(index); - t2 = pre.componentAt(index); - Term content; - if (switchOrder(sub, (short) index)) { - // System.out.println("Switch order: " + t1.toString() + " " + t2.toString()); - content = Statement.make(statement, t2, t1, this.memory); - // System.out.println(content); - } - else { - // System.out.println("No switch: " + t1.toString() + " " + t2.toString()); - content = Statement.make(statement, t1, t2, this.memory); - // System.out.println(content); - } - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) { - budget = this.budgetfunctions.compoundBackward(content); - } else { - if (sub.size() > 1) { - if (sentence.isJudgment()) - truth = TruthFunctions.implied(truth); - else // Goal - truth = TruthFunctions.implying(truth); - } - budget = this.budgetfunctions.compoundForward(truth, content); - } - this.memory.singlePremiseTask(budget, content, truth); - } - - private boolean switchOrder(CompoundTerm compound, short index) { - return ((((compound instanceof DifferenceExt) || (compound instanceof DifferenceInt)) && (index == 1)) || - ((compound instanceof ImageExt) && (index != ((ImageExt) compound).getRelationIndex())) || - ((compound instanceof ImageInt) && (index != ((ImageInt) compound).getRelationIndex()))); - } - - /** - * {<A --> B>} |- <A --> (B&C)> - * @param compound The compound term - * @param index The location of the indicated term in the compound - * @param statement The premise - */ - void structuralCompose1(CompoundTerm compound, short index, Statement statement) { - if (!this.memory.currentTask.getSentence().isJudgment()) - return; - Term component = compound.componentAt(index); - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - Term subj = statement.getSubject(); - Term pred = statement.getPredicate(); - if (component.equals(subj)) { - if (compound instanceof IntersectionExt) // {A --> B, A @ (A&C)} |- (A&C) --> B - structuralStatement(compound, pred, TruthFunctions.implying(truth)); - else if (compound instanceof IntersectionInt) // {A --> B, A @ (A|C)} |- (A|C) --> B - structuralStatement(compound, pred, TruthFunctions.implied(truth)); - else if ((compound instanceof DifferenceExt) && (index == 0)) // {A --> B, A @ (A-C)} |- (A-C) --> B - structuralStatement(compound, pred, TruthFunctions.implying(truth)); - else if (compound instanceof DifferenceInt) - if (index == 0) // {A --> B, A @ (A~C)} |- (A~C) --> B - structuralStatement(compound, pred, TruthFunctions.implied(truth)); - else // {A --> B, A @ (C~A)} |- (C~A) --> B - structuralStatement(compound, pred, TruthFunctions.negImply(truth)); - } else if (component.equals(pred)) { - if (compound instanceof IntersectionExt) // {B --> A, A @ (A&C)} |- B --> (A&C) - structuralStatement(subj, compound, TruthFunctions.implied(truth)); - else if (compound instanceof IntersectionInt) // {B --> A, A @ (A|C)} |- B --> (A|C) - structuralStatement(subj, compound, TruthFunctions.implying(truth)); - else if (compound instanceof DifferenceExt) - if (index == 0) // {B --> A, A @ (A-C)} |- B --> (A-C) - structuralStatement(subj, compound, TruthFunctions.implied(truth)); - else // {B --> A, A @ (C-A)} |- B --> (C-A) - structuralStatement(subj, compound, TruthFunctions.negImply(truth)); - else if ((compound instanceof DifferenceInt) && (index == 0)) // {B --> A, A @ (A~C)} |- B --> (A~C) - structuralStatement(subj, compound, TruthFunctions.implying(truth)); - } - } - - /** - * {<(A&C) --> B>} |- <A --> B> - * @param compound The compound term - * @param index The location of the indicated term in the compound - * @param statement The premise - * @param side The location of the indicated term in the premise - */ - void structuralDecompose1(CompoundTerm compound, short index, Statement statement, short side) { - if (!this.memory.currentTask.getSentence().isJudgment()) - return; - Term component = compound.componentAt(index); - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - Term subj = statement.getSubject(); - Term pred = statement.getPredicate(); - if (compound.equals(subj)) { - if (compound instanceof IntersectionExt) // {(A&C) --> B, A @ (A&C)} |- A --> B - structuralStatement(component, pred, TruthFunctions.implied(truth)); - else if (compound instanceof IntersectionInt) // {(A|C) --> B, A @ (A|C)} |- A --> B - structuralStatement(component, pred, TruthFunctions.implying(truth)); - else if ((compound instanceof DifferenceExt) && (index == 0)) // {(A-C) --> B, A @ (A-C)} |- A --> B - structuralStatement(component, pred, TruthFunctions.implied(truth)); - else if (compound instanceof DifferenceInt) - if (index == 0) // {(A~C) --> B, A @ (A~C)} |- A --> B - structuralStatement(component, pred, TruthFunctions.implying(truth)); - else // {(C~A) --> B, A @ (C~A)} |- A --> B - structuralStatement(component, pred, TruthFunctions.negImply(truth)); - } else if (compound.equals(pred)) { - if (compound instanceof IntersectionExt) // {B --> (A&C), A @ (A&C)} |- B --> A - structuralStatement(subj, component, TruthFunctions.implying(truth)); - else if (compound instanceof IntersectionInt) // {B --> (A&C), A @ (A&C)} |- B --> A - structuralStatement(subj, component, TruthFunctions.implied(truth)); - else if (compound instanceof DifferenceExt) - if (index == 0) // {B --> (A-C), A @ (A-C)} |- B --> A - structuralStatement(subj, component, TruthFunctions.implying(truth)); - else // {B --> (C-A), A @ (C-A)} |- B --> A - structuralStatement(subj, component, TruthFunctions.negImply(truth)); - else if ((compound instanceof DifferenceInt) && (index == 0)) // {B --> (A~C), A @ (A~C)} |- B --> A - structuralStatement(subj, component, TruthFunctions.implied(truth)); - } - } - - /** - * Common final operations of the above two methods - * @param subject The subject of the new task - * @param predicate The predicate of the new task - * @param truth The truth value of the new task - */ - private void structuralStatement(Term subject, Term predicate, TruthValue truth) { // Inheritance only? - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - Term content = Statement.make((Statement) task.getContent(), subject, predicate, this.memory); - if (content == null) - return; - BudgetValue budget = this.budgetfunctions.compoundForward(truth, content); -// if (sentence instanceof Question) -// budget = this.budgetfunctions.compoundBackward(content); -// else -// budget = this.budgetfunctions.compoundForward(truth, content); - this.memory.singlePremiseTask(budget, content, truth); - } - - /* -------------------- set transform -------------------- */ - - /** - * {<S --> {P}>} |- <S <-> {P}> - * @param compound The set compound - * @param statement The premise - * @param side The location of the indicated term in the premise - */ - void transformSetRelation(CompoundTerm compound, Statement statement, short side) { - if (compound.size() > 1) - return; - if (statement instanceof Inheritance) - if (((compound instanceof SetExt) && (side == 0)) || ((compound instanceof SetInt) && (side == 1))) - return; - Term sub = statement.getSubject(); - Term pre = statement.getPredicate(); - Term content; - if (statement instanceof Inheritance) { - content = Similarity.make(sub, pre, this.memory); - } else { - if (((compound instanceof SetExt) && (side == 0)) || ((compound instanceof SetInt) && (side == 1))) - content = Inheritance.make(pre, sub, this.memory); - else - content = Inheritance.make(sub, pre, this.memory); - } - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) - budget = this.budgetfunctions.compoundBackward(content); - else - budget = this.budgetfunctions.compoundForward(truth, content); - this.memory.singlePremiseTask(budget, content, truth); - } - - /* -------------------- products and images transform -------------------- */ - - void transformProductImage(Inheritance inh, CompoundTerm oldContent, short[] indices, Task task) { - Term subject = null; - Term predicate = null; - short index = indices[indices.length - 1]; - short side = indices[indices.length - 2]; - CompoundTerm comp = (CompoundTerm) inh.componentAt(side); - if (comp instanceof Product) { - if (side == 0) { // Product as subject - subject = comp.componentAt(index); - predicate = ImageExt.make((Product) comp, inh.getPredicate(), index, this.memory); - } else { - subject = ImageInt.make((Product) comp, inh.getSubject(), index, this.memory); - predicate = comp.componentAt(index); - } - } else if ((comp instanceof ImageExt) && (side == 1)) { // ImageExt as predicate - if (index == ((ImageExt) comp).getRelationIndex()) { - subject = Product.make(comp, inh.getSubject(), index, this.memory); - predicate = comp.componentAt(index); - } else { - subject = comp.componentAt(index); - predicate = ImageExt.make((ImageExt) comp, inh.getSubject(), index, this.memory); - } - } else if ((comp instanceof ImageInt) && (side == 0)) { // ImageInt as subject - if (index == ((ImageInt) comp).getRelationIndex()) { - subject = comp.componentAt(index); - predicate = Product.make(comp, inh.getPredicate(), index, this.memory); - } else { - subject = ImageInt.make((ImageInt) comp, inh.getPredicate(), index, this.memory); - predicate = comp.componentAt(index); - } - } else // if ((subject == null) || (predicate == null)) - return; - Inheritance newInh = Inheritance.make(subject, predicate, this.memory); - Term content = null; - if (indices.length == 2) - content = newInh; - else { - ArrayList<Term> componentList; - if ((oldContent instanceof Implication) && (oldContent.componentAt(0) instanceof Conjunction)) { - componentList = ((CompoundTerm) oldContent.componentAt(0)).cloneComponents(); - componentList.set(indices[0], newInh); - Term newCond = Conjunction.make(componentList, this.memory); - content = Implication.make(newCond, ((Statement) oldContent).getPredicate(), this.memory); - } else - componentList = oldContent.cloneComponents(); - componentList.set(indices[0], newInh); - if (oldContent instanceof Conjunction) - content = Conjunction.make(componentList, this.memory); - else if ((oldContent instanceof Implication) || (oldContent instanceof Equivalence)) - content = Statement.make((Statement) oldContent, componentList.get(0), componentList.get(1), this.memory); - } - if (content == null) - return; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) - budget = this.budgetfunctions.compoundBackward(content); - else - budget = this.budgetfunctions.compoundForward(truth, content); - this.memory.singlePremiseTask(budget, content, truth); - } - - /* --------------- Disjunction and Conjunction transform --------------- */ - - /** - * {(&&, A, B)} |- A - * @param compound The premise - * @param component The recognized component in the premise - * @param compoundTask Whether the compound comes from the task - */ - void structuralCompound(CompoundTerm compound, Term component, boolean compoundTask) { - Term content = (compoundTask ? component : compound); - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) { - budget = this.budgetfunctions.compoundBackward(content); - } else { - if ((sentence.isJudgment()) == (compoundTask == (compound instanceof Conjunction))) - truth = TruthFunctions.implying(truth); - else - truth = TruthFunctions.implied(truth); - budget = this.budgetfunctions.compoundForward(sentence.getTruth(), content); - } - this.memory.singlePremiseTask(budget, content, truth); - } - - /* --------------- Negation related rules --------------- */ - - /** - * {A} |- (--, A) - * @param content The premise - */ - void transformNegation(Term content) { - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - if (sentence instanceof Judgement) - truth = TruthFunctions.negation(truth); - BudgetValue budget; - if (sentence instanceof Question) - budget = this.budgetfunctions.compoundBackward(content); - else - budget = this.budgetfunctions.compoundForward(truth, content); - this.memory.singlePremiseTask(budget, content, truth); - } - - /** - * {<A ==> B>} |- <(--B) ==> (--A)> - * @param statement The premise - */ - void contraposition(Statement statement) { - Term subj = statement.getSubject(); - Term pred = statement.getPredicate(); - Term content = Statement.make(statement, Negation.make(pred, this.memory), Negation.make(subj, this.memory), CompoundTerm.temporalReverse(statement.getTemporalOrder()), this.memory); - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) { - if (content instanceof Implication) - budget = this.budgetfunctions.compoundBackwardWeak(content); - else - budget = this.budgetfunctions.compoundBackward(content); - } else { - if (content instanceof Implication) - truth = TruthFunctions.contraposition(truth); - budget = this.budgetfunctions.compoundForward(truth, content); - } - this.memory.singlePremiseTask(budget, content, truth); - } -} diff --git a/open-nars/src/com/googlecode/opennars/inference/SyllogisticRules.java b/open-nars/src/com/googlecode/opennars/inference/SyllogisticRules.java deleted file mode 100644 index 28258358a034403642994bb20eafe446107dea3f..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/inference/SyllogisticRules.java +++ /dev/null @@ -1,512 +0,0 @@ -/* - * SyllogisticRules.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.inference; - -import java.util.*; - -import com.googlecode.opennars.entity.*; -import com.googlecode.opennars.language.*; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.*; - - -/** - * Syllogisms: Inference rules based on the transitivity of the relation. - */ -public class SyllogisticRules { - - private Memory memory; - private BudgetFunctions budgetfunctions; - - public SyllogisticRules(Memory memory) { - this.memory = memory; - this.budgetfunctions = new BudgetFunctions(memory); - } - - /* --------------- rules used in both first-order inference and higher-order inference --------------- */ - - /** - * {<S ==> M>, <M ==> P>} |- {<S ==> P>, <P ==> S>} - * @param term1 Subject of the first new task - * @param term2 Predicate of the first new task - * @param sentence The first premise - * @param belief The second premise - */ - void dedExe(Term term1, Term term2, Sentence sentence, Judgement belief) { - if (Statement.invalidStatement(term1, term2)) - return; - CompoundTerm.TemporalOrder order1 = sentence.getContent().getTemporalOrder(); - CompoundTerm.TemporalOrder order2 = belief.getContent().getTemporalOrder(); - CompoundTerm.TemporalOrder order = CompoundTerm.temporalInference(order1, order2); - if (order == CompoundTerm.TemporalOrder.UNSURE) - return; - Statement content1 = Statement.make((Statement) sentence.getContent(), term1, term2, order, this.memory); - Statement content2 = Statement.make((Statement) sentence.getContent(), term2, term1, CompoundTerm.temporalReverse(order), this.memory); - TruthValue value1 = sentence.getTruth(); - TruthValue value2 = belief.getTruth(); - TruthValue truth1 = null; - TruthValue truth2 = null; - BudgetValue budget1, budget2; - Task task = this.memory.currentTask; - if (sentence instanceof Question) { - budget1 = this.budgetfunctions.backwardWeak(value2); - budget2 = this.budgetfunctions.backwardWeak(value2); - } else { - if (sentence instanceof Goal) { - truth1 = TruthFunctions.desireWeak(value1, value2); - truth2 = TruthFunctions.desireWeak(value1, value2); - } else { - truth1 = TruthFunctions.deduction(value1, value2); - truth2 = TruthFunctions.exemplification(value1, value2); - } - budget1 = this.budgetfunctions.forward(truth1); - budget2 = this.budgetfunctions.forward(truth2); - } - this.memory.doublePremiseTask(budget1, content1, truth1); - this.memory.doublePremiseTask(budget2, content2, truth2); - } - - /** - * {<M ==> S>, <M ==> P>} |- {<S ==> P>, <P ==> S>, <S <=> P>} - * @param term1 Subject of the first new task - * @param term2 Predicate of the first new task - * @param sentence The first premise - * @param belief The second premise - * @param figure Locations of the shared term in premises - */ - void abdIndCom(Term term1, Term term2, Sentence sentence, Judgement belief, int figure) { - if (Statement.invalidStatement(term1, term2)) - return; - Statement st1 = (Statement) sentence.getContent(); - Statement st2 = (Statement) belief.getContent(); - CompoundTerm.TemporalOrder order1 = st1.getTemporalOrder(); - CompoundTerm.TemporalOrder order2 = st2.getTemporalOrder(); - CompoundTerm.TemporalOrder order; - if (figure == 11) - order = CompoundTerm.temporalInference(order1, CompoundTerm.temporalReverse(order2)); - else - order = CompoundTerm.temporalInference(CompoundTerm.temporalReverse(order1), order2); - if (order == CompoundTerm.TemporalOrder.UNSURE) - return; - Statement statement1 = Statement.make(st1, term1, term2, order, this.memory); - Statement statement2 = Statement.make(st1, term2, term1, CompoundTerm.temporalReverse(order), this.memory); - Statement statement3 = Statement.makeSym(st1, term1, term2, order, this.memory); - TruthValue truth1 = null; - TruthValue truth2 = null; - TruthValue truth3 = null; - BudgetValue budget1, budget2, budget3; - TruthValue value1 = sentence.getTruth(); - TruthValue value2 = belief.getTruth(); - if (sentence instanceof Question) { - budget1 = this.budgetfunctions.backward(value2); - budget2 = this.budgetfunctions.backwardWeak(value2); - budget3 = this.budgetfunctions.backward(value2); - } else { - if (sentence instanceof Goal) { - truth1 = TruthFunctions.desireStrong(value1, value2); - truth2 = TruthFunctions.desireWeak(value2, value1); - truth3 = TruthFunctions.desireStrong(value1, value2); - } else { - truth1 = TruthFunctions.abduction(value1, value2); - truth2 = TruthFunctions.abduction(value2, value1); - truth3 = TruthFunctions.comparison(value1, value2); - } - budget1 = this.budgetfunctions.forward(truth1); - budget2 = this.budgetfunctions.forward(truth2); - budget3 = this.budgetfunctions.forward(truth3); - } - this.memory.doublePremiseTask(budget1, statement1, truth1); - this.memory.doublePremiseTask(budget2, statement2, truth2); - this.memory.doublePremiseTask(budget3, statement3, truth3); - if (statement1.isConstant()) { - this.memory.doublePremiseTask(budget1, introVarInd(statement1, st2, st1, figure), truth1); - this.memory.doublePremiseTask(budget2, introVarInd(statement2, st1, st2, figure), truth2); - this.memory.doublePremiseTask(budget3, introVarInd(statement3, st1, st2, figure), truth3); - } - } - - /** - * {<S ==> P>, <M <=> P>} |- <S ==> P> - * @param term1 Subject of the new task - * @param term2 Predicate of the new task - * @param asym The asymmetric premise - * @param sym The symmetric premise - * @param figure Locations of the shared term in premises - */ - void analogy(Term term1, Term term2, Sentence asym, Sentence sym, int figure) { - if (Statement.invalidStatement(term1, term2)) - return; - Statement asymSt = (Statement) asym.getContent(); - Statement symSt = (Statement) sym.getContent(); - CompoundTerm.TemporalOrder order1 = asymSt.getTemporalOrder(); - CompoundTerm.TemporalOrder order2 = symSt.getTemporalOrder(); - CompoundTerm.TemporalOrder order; - switch (figure) { - case 11: - case 12: - order = CompoundTerm.temporalInferenceWithFigure(order2, order1, figure); - break; - case 21: - case 22: - order = CompoundTerm.temporalInferenceWithFigure(order1, order2, figure); - break; - default: - return; - } - if (order == CompoundTerm.TemporalOrder.UNSURE) - return; - Term content = Statement.make(asymSt, term1, term2, order, this.memory); - TruthValue truth = null; - BudgetValue budget; - Sentence sentence = this.memory.currentTask.getSentence(); - CompoundTerm taskTerm = (CompoundTerm) sentence.getContent(); - if (sentence instanceof Question) { - if (taskTerm.isCommutative()) - budget = this.budgetfunctions.backwardWeak(asym.getTruth()); - else - budget = this.budgetfunctions.backward(sym.getTruth()); - } else { - if (sentence instanceof Goal) { - if (taskTerm.isCommutative()) - truth = TruthFunctions.desireWeak(asym.getTruth(), sym.getTruth()); - else - truth = TruthFunctions.desireStrong(asym.getTruth(), sym.getTruth()); - } else - truth = TruthFunctions.analogy(asym.getTruth(), sym.getTruth()); - budget = this.budgetfunctions.forward(truth); - } - this.memory.doublePremiseTask(budget, content, truth); - } - - /** - * {<S <=> M>, <M <=> P>} |- <S <=> P> - * @param term1 Subject of the new task - * @param term2 Predicate of the new task - * @param belief The first premise - * @param sentence The second premise - * @param figure Locations of the shared term in premises - */ - void resemblance(Term term1, Term term2, Judgement belief, Sentence sentence, int figure) { - if (Statement.invalidStatement(term1, term2)) - return; - Statement st1 = (Statement) belief.getContent(); - Statement st2 = (Statement) sentence.getContent(); - CompoundTerm.TemporalOrder order1 = st1.getTemporalOrder(); - CompoundTerm.TemporalOrder order2 = st2.getTemporalOrder(); - CompoundTerm.TemporalOrder order = CompoundTerm.temporalInferenceWithFigure(order1, order2, figure); - if (order == CompoundTerm.TemporalOrder.UNSURE) - return; - Term statement = Statement.make(st1, term1, term2, order, this.memory); - TruthValue truth = null; - BudgetValue budget; - Task task = this.memory.currentTask; - if (sentence instanceof Question) { - budget = this.budgetfunctions.backward(belief.getTruth()); - } else { - if (sentence instanceof Goal) - truth = TruthFunctions.desireStrong(sentence.getTruth(), belief.getTruth()); - else - truth = TruthFunctions.resemblance(belief.getTruth(), sentence.getTruth()); - budget = this.budgetfunctions.forward(truth); - } - this.memory.doublePremiseTask(budget, statement, truth); - } - - /* --------------- rules used only in conditional inference --------------- */ - - /** - * {<S ==> P>, S} |- P - * @param statement The premise statement - * @param compound The compound containing the shared component, can be null - * @param compoundTask Whether the component comes in the task - * @param side The location of the shared term in the statement - */ - void detachment(Statement statement, CompoundTerm compound, boolean compoundTask, int side) { - if (!(statement instanceof Implication) && !(statement instanceof Equivalence)) // necessary? - return; - Sentence sentence = this.memory.currentTask.getSentence(); - Judgement belief = this.memory.currentBelief; - TruthValue value1, value2; - if (compoundTask) { - value2 = sentence.getTruth(); - value1 = belief.getTruth(); - } else { - value1 = sentence.getTruth(); - value2 = belief.getTruth(); - } - TruthValue truth = null; - BudgetValue budget; - if (sentence instanceof Question) { - if (statement instanceof Equivalence) - budget = this.budgetfunctions.backward(belief.getTruth()); - else if (side == 0) - budget = this.budgetfunctions.backwardWeak(belief.getTruth()); - else - budget = this.budgetfunctions.backward(belief.getTruth()); - } else { - if (sentence instanceof Goal) { - if (statement instanceof Equivalence) - truth = TruthFunctions.desireStrong(value1, value2); - else if (side == 0) - truth = TruthFunctions.desireInd(value1, value2); - else - truth = TruthFunctions.desireDed(value1, value2); - } else { - if (statement instanceof Equivalence) - truth = TruthFunctions.analogy(value1, value2); - else if (side == 0) - truth = TruthFunctions.deduction(value1, value2); - else - truth = TruthFunctions.abduction(value1, value2); - } - budget = this.budgetfunctions.forward(truth); - } - Term content = statement.componentAt(1 - side); - if (!content.isConstant()) - return; - if ((compound != null) && (compound instanceof Tense)){ - CompoundTerm.TemporalOrder order1 = compound.getTemporalOrder(); - CompoundTerm.TemporalOrder order2 = statement.getTemporalOrder(); - CompoundTerm.TemporalOrder order; - if (side == 0) - order = CompoundTerm.temporalInference(order1, order2); - else - order = CompoundTerm.temporalInference(order1, CompoundTerm.temporalReverse(order2)); - if (order == CompoundTerm.TemporalOrder.UNSURE) -// order = order1; - return; - content = Tense.make(content, order, this.memory); - } - this.memory.doublePremiseTask(budget, content, truth); - } - - /** - * {<(&&, S1, S2) ==> P>, <M ==> S1>} |- <(&&, M, S2) ==> P> - * @param premise1 The conditional premise - * @param index The location of the shared term in the condition of premise1 - * @param premise2 The premise which, or part of which, appears in the condition of premise1 - * @param side The location of the shared term in premise2: 0 for subject, 1 for predicate, -1 for the whole term - */ - void conditionalDedInd(Implication premise1, short index, Term premise2, int side) { - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - Judgement belief = this.memory.currentBelief; - Conjunction oldCondition = (Conjunction) premise1.getSubject(); - CompoundTerm.TemporalOrder order1 = premise1.getTemporalOrder(); - CompoundTerm.TemporalOrder order2 = premise2.getTemporalOrder(); - boolean deduction = (side != 0); - if (!(order1 == order2)) // to be refined to cover tense - if (!(deduction && ((side == -1) || (index == 0)))) // don't replace middle conditions - return; - Term newComponent = null; - if (side == 0) - newComponent = ((Statement) premise2).getPredicate(); - else if (side == 1) - newComponent = ((Statement) premise2).getSubject(); - Term newCondition = CompoundTerm.replaceComponent(oldCondition, index, newComponent, this.memory); - Term content = Statement.make(premise1, newCondition, premise1.getPredicate(), order1, this.memory); - if (content == null) - return; - TruthValue value1 = sentence.getTruth(); - TruthValue value2 = belief.getTruth(); - TruthValue truth = null; - BudgetValue budget; - boolean conditionalTask = (Variable.findSubstitute(Variable.VarType.INDEPENDENT, premise2, belief.getContent()) != null); - if (sentence instanceof Question) { - budget = this.budgetfunctions.backwardWeak(value2); - } else { - if (sentence instanceof Goal) { - if (conditionalTask) - truth = TruthFunctions.desireWeak(value1, value2); - else if (deduction) - truth = TruthFunctions.desireInd(value1, value2); - else - truth = TruthFunctions.desireDed(value1, value2); - budget = this.budgetfunctions.forward(truth); - } else { - if (deduction) - truth = TruthFunctions.deduction(value1, value2); - else if (conditionalTask) - truth = TruthFunctions.induction(value2, value1); - else - truth = TruthFunctions.induction(value1, value2); - } - budget = this.budgetfunctions.forward(truth); - } - this.memory.doublePremiseTask(budget, content, truth); - } - - /** - * {<(&&, S1, S2) ==> P>, <(&&, S1, S3) ==> P>} |- <S2 ==> S3> - * @param cond1 The condition of the first premise - * @param cond2 The condition of the second premise - * @param st1 The first premise - * @param st2 The second premise - * @return Whether there are derived tasks - */ - boolean conditionalAbd(Term cond1, Term cond2, Statement st1, Statement st2) { - if (!(st1 instanceof Implication) || !(st2 instanceof Implication)) - return false; - if (!(cond1 instanceof Conjunction) && !(cond2 instanceof Conjunction)) - return false; - CompoundTerm.TemporalOrder order1 = st1.getTemporalOrder(); - CompoundTerm.TemporalOrder order2 = st2.getTemporalOrder(); - if (order1 != CompoundTerm.temporalReverse(order2)) - return false; - Term term1 = null; - Term term2 = null; - if (cond1 instanceof Conjunction) { - term1 = CompoundTerm.reduceComponents((Conjunction) cond1, cond2, this.memory); - } - if (cond2 instanceof Conjunction) { - term2 = CompoundTerm.reduceComponents((Conjunction) cond2, cond1, this.memory); - } - if ((term1 == null) && (term2 == null)) - return false; - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - Judgement belief = this.memory.currentBelief; - TruthValue value1 = sentence.getTruth(); - TruthValue value2 = belief.getTruth(); - boolean keepOrder = (Variable.findSubstitute(Variable.VarType.INDEPENDENT, st1, task.getContent()) != null); - Term content; - TruthValue truth = null; - BudgetValue budget; - if (term1 != null) { - if (term2 != null) - content = Statement.make(st2, term2, term1, order2, this.memory); - else - content = term1; - if (sentence instanceof Question) { - budget = this.budgetfunctions.backwardWeak(value2); - } else { - if (sentence instanceof Goal) { - if (keepOrder) - truth = TruthFunctions.desireDed(value1, value2); - else - truth = TruthFunctions.desireInd(value1, value2); - } else - truth = TruthFunctions.abduction(value2, value1); - budget = this.budgetfunctions.forward(truth); - } - this.memory.doublePremiseTask(budget, content, truth); - } - if (term2 != null) { - if (term1 != null) - content = Statement.make(st1, term1, term2, order1, this.memory); - else - content = term2; - if (sentence instanceof Question) { - budget = this.budgetfunctions.backwardWeak(value2); - } else { - if (sentence instanceof Goal) { - if (keepOrder) - truth = TruthFunctions.desireDed(value1, value2); - else - truth = TruthFunctions.desireInd(value1, value2); - } else - truth = TruthFunctions.abduction(value1, value2); - budget = this.budgetfunctions.forward(truth); - } - this.memory.doublePremiseTask(budget, content, truth); - } - return true; - } - - /* --------------- rules used for independent variable introduction --------------- */ - - /** - * {<C ==> <M --> P>>, <M --> S>} |- <(&&,C,<#x --> S>) ==> <#x --> P>> - * @param compound The compound statement: Implication or Conjunction - * @param component The component to be used as a premise in internal induction - * @param premise The second premise, directly used in internal induction - */ - void introVarIndInner(CompoundTerm compound, Term component, Term premise) { - Task task = this.memory.currentTask; - Sentence sentence = task.getSentence(); - if (!sentence.isJudgment()) - return; - if (!(component instanceof Statement)) - return; - if (component.getClass() != premise.getClass()) - return; - Variable v1 = new Variable(Symbols.VARIABLE_TAG + "0"); - Variable v2 = new Variable(Symbols.VARIABLE_TAG + "0"); - Statement premise1 = (Statement) premise; - Statement premise2 = (Statement) component; - CompoundTerm.TemporalOrder order1 = premise1.getTemporalOrder(); - CompoundTerm.TemporalOrder order2 = premise2.getTemporalOrder(); - if (order1 != CompoundTerm.temporalReverse(order2)) - return; - int figure; - if (premise1.getSubject().equals(premise2.getSubject())) - figure = 11; - else if (premise1.getPredicate().equals(premise2.getPredicate())) - figure = 22; - else - return; - Statement innerContent = introVarInd(null, premise1, premise2, figure); - if (innerContent == null) - return; - Sentence belief = this.memory.currentBelief; - Term content; - if (compound instanceof Implication) { - content = Statement.make((Statement) compound, compound.componentAt(0), innerContent, this.memory); - } else if (compound instanceof Conjunction) { - content = CompoundTerm.replaceComponent(compound, component, innerContent, this.memory); - } else - return; - TruthValue truth; - if (premise.equals(sentence.getContent())) - truth = TruthFunctions.abduction(sentence.getTruth(), belief.getTruth()); - else - truth = TruthFunctions.abduction(belief.getTruth(), sentence.getTruth()); - BudgetValue budget = this.budgetfunctions.forward(truth); - this.memory.doublePremiseTask(budget, content, truth); - } - - /** - * {<M --> S>, <M --> P>} |- <<#x --> S> ==> <#x --> P>> - * @param temp The template for the new task <S --> P> - * @param premise1 The first premise <M --> P> - * @param premise2 The second premise <M --> P> - * @param figure The figure indicating the location of the shared term - */ - private Statement introVarInd(Statement temp, Statement premise1, Statement premise2, int figure) { - Statement state1, state2; - Variable v1 = new Variable(Symbols.VARIABLE_TAG + "0"); - Variable v2 = new Variable(Symbols.VARIABLE_TAG + "0"); - if (figure == 11) { - state1 = Statement.make(premise1, v1, premise1.getPredicate(), this.memory); - state2 = Statement.make(premise2, v2, premise2.getPredicate(), this.memory); - } else { - state1 = Statement.make(premise1, premise1.getSubject(), v1, this.memory); - state2 = Statement.make(premise2, premise2.getSubject(), v2, this.memory); - } - Statement content; - if ((temp == null) || !temp.isCommutative()) - content = Implication.make(state1, state2, this.memory); - else - content = Equivalence.make(state1, state2, this.memory); - return content; - } -} diff --git a/open-nars/src/com/googlecode/opennars/inference/TruthFunctions.java b/open-nars/src/com/googlecode/opennars/inference/TruthFunctions.java deleted file mode 100644 index 63fe480cce39c49b466418a72aa95b90b7adde1b..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/inference/TruthFunctions.java +++ /dev/null @@ -1,369 +0,0 @@ -/* - * TruthFunctions.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.inference; - -import com.googlecode.opennars.entity.TruthValue; - -/** - * All truth value functions used in inference rules - */ -public final class TruthFunctions extends UtilityFunctions { - - /* ----- Single Argument Functions, called in MatchingRules and StructuralRules ----- */ - - /** - * {A} |- (--A) - * @param v1 Truth value of the premise - * @return Truth value of the conclusion - */ - static TruthValue negation(TruthValue v1) { - float f = 1 - v1.getFrequency(); - float c = v1.getConfidence(); - return new TruthValue(f, c); - } - - /** - * {<A ==> B>} |- <B ==> A> - * @param v1 Truth value of the premise - * @return Truth value of the conclusion - */ - static TruthValue conversion(TruthValue v1) { - float f1 = v1.getFrequency(); - float c1 = v1.getConfidence(); - float w = and(f1, c1); - float c = w2c(w); - return new TruthValue(1, c); - } - - /** - * {<A ==> B>} |- <(--, B) ==> (--, A)> - * @param v1 Truth value of the premise - * @return Truth value of the conclusion - */ - static TruthValue contraposition(TruthValue v1) { - float f1 = v1.getFrequency(); - float c1 = v1.getConfidence(); - float w = and(1-f1, c1); - float c = w2c(w); - return new TruthValue(0, c); - } - - /** - * {<A ==> B>, A} |- B - * @param v1 Truth value of the premise - * @return Truth value of the conclusion - */ - static TruthValue implying(TruthValue v1) { - float f1 = v1.getFrequency(); - float c1 = v1.getConfidence(); - float c = and(f1, c1); - return new TruthValue(f1, c); - } - - /** - * {<A ==> B>, B} |- A - * @param v1 Truth value of the premise - * @return Truth value of the conclusion - */ - static TruthValue implied(TruthValue v1) { - float f1 = v1.getFrequency(); - float c1 = v1.getConfidence(); - float c = w2c(c1); - return new TruthValue(f1, c); - } - - /** - * {<A ==> (--, B)>, A} |- B - * @param v1 Truth value of the premise - * @return Truth value of the conclusion - */ - static TruthValue negImply(TruthValue v1) { - return negation(implying(v1)); - } - - /* -------------------- called in MatchingRules -------------------- */ - - /** - * {<S ==> P>, <S ==> P>} |- <S ==> P> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue revision(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float w1 = c1 / (1 - c1); - float w2 = c2 / (1 - c2); - float f = (w1 * f1 + w2 * f2) / (w1 + w2); - float c = (w1 + w2) / (w1 + w2 + 1); - return new TruthValue(f, c); - } - - /* -------------------- called in SyllogisticRules -------------------- */ - - /** - * {<S ==> M>, <M ==> P>} |- <S ==> P> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue deduction(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float f = and(f1, f2); - float c = and(c1, c2, f); - return new TruthValue(f, c); - } - - /** - * {<S ==> M>, <P ==> M>} |- <S ==> P> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue abduction(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float w = and(f2, c1, c2); - float c = w2c(w); - return new TruthValue(f1, c); - } - - /** - * {<M ==> S>, <M ==> P>} |- <S ==> P> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue induction(TruthValue v1, TruthValue v2) { - return abduction(v2, v1); - } - - /** - * {<M ==> S>, <P ==> M>} |- <S ==> P> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue exemplification(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float w = and(f1, f2, c1, c2); - float c = w2c(w); - return new TruthValue(1, c); - } - - /** - * {<M ==> S>, <M ==> P>} |- <S <=> P> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue comparison(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float f0 = or(f1, f2); - float f = (f0 == 0) ? 0 : (and(f1, f2) / f0) ; - float w = and(f0, c1, c2); - float c = w2c(w); - return new TruthValue(f, c); - } - - /** - * {<S ==> M>, <M <=> P>} |- <S ==> P> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue analogy(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float f = and(f1, f2); - float c0 = and(f2, c2); - float c = and(c1, c0, c0); - return new TruthValue(f, c); - } - - /** - * {<S <=> M>, <M <=> P>} |- <S <=> P> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue resemblance(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float f = and(f1, f2); - float c = and(c1, c2, or(f1, f2)); - return new TruthValue(f, c); - } - - // -------------------- desire rules -------------------- // - - // strong backword inference on goals - // called in SyllogisticRules and HighOrderRules - static TruthValue desireStrong(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float f = and(f1, f2); - float c = and(c1, c2, f2); - return new TruthValue(f, c); - } - - // weak backword inference on goals - // called in SyllogisticRules and HighOrderRules - static TruthValue desireWeak(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float f = and(f1, f2); - float c = and(c1, c2, f2, w2c(1.0f)); - return new TruthValue(f, c); - } - - // strong backword inference on goals - // called in HighOrderRules only - static TruthValue desireDed(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float f = and(f1, f2); - float c = and(f, c1, c2); - return new TruthValue(f, c); - } - - // called in HighOrderRules only - static TruthValue desireInd(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float w = and(f2, c1, c2); - float c = w2c(w); - return new TruthValue(f1, c); - } - - /* -------------------- called in CompositionalRules -------------------- */ - - /** - * {<M --> S>, <M <-> P>} |- <M --> (S|P)> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue union(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float f = or(f1, f2); - float c = or(and(f1, c1), and(f2, c2)) + and(1 - f1, 1 - f2, c1, c2); - return new TruthValue(f, c); - } - - /** - * {<M --> S>, <M <-> P>} |- <M --> (S&P)> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue intersection(TruthValue v1, TruthValue v2) { - float f1 = v1.getFrequency(); - float f2 = v2.getFrequency(); - float c1 = v1.getConfidence(); - float c2 = v2.getConfidence(); - float f = and(f1, f2); - float c = or(and(1 - f1, c1), and(1 - f2, c2)) + and(f1, f2, c1, c2); - return new TruthValue(f, c); - } - - /** - * {<M --> S>, <M <-> P>} |- <M --> (S-P)> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue difference(TruthValue v1, TruthValue v2) { - TruthValue v0 = negation(v2); - return intersection(v1, v0); - } - - /** - * {(||, A, B), (--, B)} |- A - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue reduceDisjunction(TruthValue v1, TruthValue v2) { - TruthValue v0 = intersection(v1, negation(v2)); - return implying(v0); - } - - /** - * {(--, (&&, A, B)), B} |- (--, A) - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue reduceConjunction(TruthValue v1, TruthValue v2) { - TruthValue v0 = intersection(negation(v1), v2); - return negation(implying(v0)); - } - - /** - * {(--, (&&, A, (--, B))), (--, B)} |- (--, A) - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue reduceConjunctionNeg(TruthValue v1, TruthValue v2) { - return reduceConjunction(v1, negation(v2)); - } - - /** - * {(&&, <#x() ==> M>, <#x() ==> P>), S ==> M} |- <S ==> P> - * @param v1 Truth value of the first premise - * @param v2 Truth value of the second premise - * @return Truth value of the conclusion - */ - static TruthValue existAnalogy(TruthValue v1, TruthValue v2) { - return abduction(v1, v2); - } -} diff --git a/open-nars/src/com/googlecode/opennars/inference/UtilityFunctions.java b/open-nars/src/com/googlecode/opennars/inference/UtilityFunctions.java deleted file mode 100644 index ef3075af7a100ae755408fc825d00a73deafef96..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/inference/UtilityFunctions.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * UtilityFunctions.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.inference; - -import com.googlecode.opennars.main.Parameters; - -/** - * Common functions on real numbers in [0,1]. - */ -public class UtilityFunctions { - - // arithmetic average - public static float aveAri(float... arr) { - float sum = 0; - for(int i=0; i<arr.length; i++) - sum += arr[i]; - return sum / arr.length; - } - - public static float or(float... arr) { - float product = 1; - for(int i=0; i<arr.length; i++) - product *= (1 - arr[i]); - return 1 - product; - } - - public static float and(float... arr) { - float product = 1; - for(int i=0; i<arr.length; i++) - product *= arr[i]; - return product; - } - - // weight to confidence - public static float w2c(float v) { - return v / (v + Parameters.NEAR_FUTURE); - } -} - diff --git a/open-nars/src/com/googlecode/opennars/inference/package.html b/open-nars/src/com/googlecode/opennars/inference/package.html deleted file mode 100644 index 95e3f329d6c7cde84007e0da90daa4e8706d645e..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/inference/package.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<body bgcolor="white"> - -The inference rules and control functions - -<h2>Package Specification</h2> - -Every task is processed in two stages: -<ol> -<li>Direct processing by matching, in the concept corresponding to the content, in one step. It happens when the task is inserted into memory.</li> -<li>Indirect processing by reasoning, in related concepts and unlimited steps. It happens in each inference cycle.</li> -</ol> -The transmission from (1) to (2) corresponds to "decision making". -<p> -Inference between premises with no shared term can only happen in task buffer, between tasks based on common evidence. -<p> -In matching, the new task is compared with all existing direct Tasks in that Concept, to carry out: -<ul> -<li>revision: between judgments on non-overlapping evidence</li> -<li>update: between judgments</li> -<li>satisfy: between a Judgment and a Question/Goal</li> -<li>merge: between items of the same type and base</li> -</ul> -<p> -In reasoning, there are two basic types: -<ol> -<li>Between a Task and a TermLink (syntatic information)</li> -<li>Between a Task and a Belief obtained by following a TermLink (semantic information).</li> -</ol> -In each case, there may be multiple applicable rules, which will be applied in parallel. For each rule, each conclusion is formed in three stages, to determine (1) the content (as a Term), (2) the truth-value or desire-value, and (3) the budget-value, in that order. -<p> -In the system, forward inference (the task is a Judgment) and backward inference (the task is a Question or Goal) are mostly isomorphic to each other, so that the inference rules produce clonclusions with the same content for different types of tasks. However, there are exceptions. For example, backward inference does not generate more complex terms. -</body> -</html> diff --git a/open-nars/src/com/googlecode/opennars/language/BooleanLiteral.java b/open-nars/src/com/googlecode/opennars/language/BooleanLiteral.java deleted file mode 100644 index b2c6c61db862cdd2e05b35febf29b326dc6b57fe..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/BooleanLiteral.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.googlecode.opennars.language; - -public class BooleanLiteral extends Literal { - - private boolean truthval; - - public BooleanLiteral(String name) { - super(name); - this.truthval = Boolean.parseBoolean(name); - } - - public BooleanLiteral(boolean tv) { - super(Boolean.toString(tv)); - this.truthval = tv; - } - -} diff --git a/open-nars/src/com/googlecode/opennars/language/CompoundTerm.java b/open-nars/src/com/googlecode/opennars/language/CompoundTerm.java deleted file mode 100644 index 0aac00e31b6f1bec60f8deac89b5470ee4012a8b..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/CompoundTerm.java +++ /dev/null @@ -1,638 +0,0 @@ -/* - * CompoundTerm.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A Term with internal structure - * <p> - * Formed by a term operator with one or more component Terms. - * <p> - * This abstract class contains default methods for all CompoundTerms. - */ -public abstract class CompoundTerm extends Term { - - /** - * list of (direct) components - */ - protected ArrayList<Term> components; - - /** - * list of open variables in the compound - */ - protected ArrayList<Variable> openVariables; // always necessary? - - /** - * list of closed variables in the compound - */ - protected ArrayList<Variable> closedVariables; // remove??? - - /** - * syntactic complexity of the compound, which is the sum of those of its components plus 1 - */ - protected short complexity; - - - // abstract methods - public abstract Object clone(); - public abstract String operator(); - - /* ----- object builders, called from subclasses ----- */ - - /** - * default constructor - */ - public CompoundTerm() {} - - /** - * constructor called from subclasses constructors to clone the fields - */ - protected CompoundTerm(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - name = n; - components = cs; - openVariables = open; - closedVariables = closed; - complexity = i; - } - - /** - * constructor called from subclasses constructors to initialize the fields - */ - protected CompoundTerm(String n, ArrayList<Term> arg) { - components = arg; - calcComplexity(); - markVariables(); // set in components, not in this - name = makeName(); - } - - /** - * the complexity of the term is the sum of those of the components plus 1 - */ - private void calcComplexity() { - Term t; - complexity = 1; - for (int i = 0; i < components.size(); i++) { - t = components.get(i); - complexity += t.getComplexity(); - } - } - - /** - * check CompoundTerm operator symbol - * @return if the given String is an operator symbol - * @param s The String to be checked - */ - public static boolean isOperator(String s, Memory memory) { - if (s.length() == 1) - return (s.equals(Symbols.INTERSECTION_EXT_OPERATOR) || - s.equals(Symbols.INTERSECTION_INT_OPERATOR) || - s.equals(Symbols.DIFFERENCE_EXT_OPERATOR) || - s.equals(Symbols.DIFFERENCE_INT_OPERATOR) || - s.equals(Symbols.PRODUCT_OPERATOR) || - s.equals(Symbols.IMAGE_EXT_OPERATOR) || - s.equals(Symbols.IMAGE_INT_OPERATOR)); - if (s.length() == 2) - return (s.equals(Symbols.NEGATION_OPERATOR) || - s.equals(Symbols.DISJUNCTION_OPERATOR) || - s.equals(Symbols.CONJUNCTION_OPERATOR) || - s.equals(Symbols.SEQUENCE_OPERATOR) || - s.equals(Symbols.PARALLEL_OPERATOR) || - s.equals(Symbols.PAST_OPERATOR) || - s.equals(Symbols.PRESENT_OPERATOR) || - s.equals(Symbols.FUTURE_OPERATOR)); - return isBuiltInOperator(s, memory); // s.length() > 2 - } - - public static Term make(String op, ArrayList arg, Memory memory) { - if (op.length() == 1) { - if (op.equals(Symbols.INTERSECTION_EXT_OPERATOR)) - return IntersectionExt.make(arg, memory); - if (op.equals(Symbols.INTERSECTION_INT_OPERATOR)) - return IntersectionInt.make(arg, memory); - if (op.equals(Symbols.DIFFERENCE_EXT_OPERATOR)) - return DifferenceExt.make(arg, memory); - if (op.equals(Symbols.DIFFERENCE_INT_OPERATOR)) - return DifferenceInt.make(arg, memory); - if (op.equals(Symbols.PRODUCT_OPERATOR)) - return Product.make(arg, memory); - if (op.equals(Symbols.IMAGE_EXT_OPERATOR)) - return ImageExt.make(arg, memory); - if (op.equals(Symbols.IMAGE_INT_OPERATOR)) - return ImageInt.make(arg, memory); - } - if (op.length() == 2) { - if (op.equals(Symbols.NEGATION_OPERATOR)) - return Negation.make(arg, memory); - if (op.equals(Symbols.DISJUNCTION_OPERATOR)) - return Disjunction.make(arg, memory); - if (op.equals(Symbols.CONJUNCTION_OPERATOR)) - return Conjunction.make(arg, memory); - if (op.equals(Symbols.SEQUENCE_OPERATOR)) - return ConjunctionSequence.make(arg, memory); - if (op.equals(Symbols.PARALLEL_OPERATOR)) - return ConjunctionSequence.make(arg, memory); - if (op.equals(Symbols.FUTURE_OPERATOR)) - return TenseFuture.make(arg, memory); - if (op.equals(Symbols.PRESENT_OPERATOR)) - return TensePresent.make(arg, memory); - if (op.equals(Symbols.PAST_OPERATOR)) - return TensePast.make(arg, memory); - } - if (isBuiltInOperator(op, memory)) { - // t = Operator.make(op, arg); - Term sub = Product.make(arg, memory); - Term pre = memory.nameToOperator(op); - return Inheritance.make(sub, pre, memory); - } - return null; - } - - /** - * check built-in operator name - * @return if the given String is an operator name - * @param s The String to be checked - */ - private static boolean isBuiltInOperator(String s, Memory memory) { - return (s.charAt(0) == Symbols.OPERATOR_TAG) && (memory.nameToOperator(s) != null); - } - - public static Term make(CompoundTerm compound, ArrayList<Term> components, Memory memory) { - if (compound instanceof SetExt) - return SetExt.make(components, memory); - if (compound instanceof SetInt) - return SetInt.make(components, memory); - if (compound instanceof IntersectionExt) - return IntersectionExt.make(components, memory); - if (compound instanceof IntersectionInt) - return IntersectionInt.make(components, memory); - if (compound instanceof DifferenceExt) - return DifferenceExt.make(components, memory); - if (compound instanceof DifferenceInt) - return DifferenceInt.make(components, memory); - if (compound instanceof Product) - return Product.make(components, memory); - if (compound instanceof ImageExt) - return ImageExt.make(components, ((ImageExt) compound).getRelationIndex(), memory); - if (compound instanceof ImageInt) - return ImageInt.make(components, ((ImageInt) compound).getRelationIndex(), memory); - if (compound instanceof Disjunction) - return Disjunction.make(components, memory); - if (compound instanceof ConjunctionSequence) - return ConjunctionSequence.make(components, memory); - if (compound instanceof ConjunctionParallel) - return ConjunctionParallel.make(components, memory); - if (compound instanceof Conjunction) - return Conjunction.make(components, memory); - return null; - } - - /* ----- utilities for name ----- */ - - /** - * default method to make the name of the current term from existing fields - * @return the name of the term - */ - protected String makeName() { - return makeCompoundName(operator(), components); - } - - /** - * default method to make the name of a compound term from given fields - * @param op the term operator - * @param arg the list of components - * @return the name of the term - */ - protected static String makeCompoundName(String op, ArrayList<Term> arg) { - StringBuffer name = new StringBuffer(); - name.append(Symbols.COMPOUND_TERM_OPENER); // also show closed variables??? - name.append(op); - for (int i = 0; i < arg.size(); i++) { - name.append(Symbols.ARGUMENT_SEPARATOR); - name.append(arg.get(i).getName()); - } - name.append(Symbols.COMPOUND_TERM_CLOSER); - return name.toString(); - } - - /** - * make the name of an ExtensionSet or IntensionSet - * @param opener the set opener - * @param closer the set closer - * @param arg the list of components - * @return the name of the term - */ - protected static String makeSetName(char opener, ArrayList<Term> arg, char closer) { - StringBuffer name = new StringBuffer(); - name.append(opener); - name.append(arg.get(0).toString()); - for (int i = 1; i < arg.size(); i++) { - name.append(Symbols.ARGUMENT_SEPARATOR); - name.append(arg.get(i).getName()); - } - name.append(closer); - return name.toString(); - } - - /** - * default method to make the name of an image term from given fields - * @param op the term operator - * @param arg the list of components - * @param relationIndex the location of the place holder - * @return the name of the term - */ - protected static String makeImageName(String op, ArrayList<Term> arg, int relationIndex) { - StringBuffer name = new StringBuffer(); - name.append(Symbols.COMPOUND_TERM_OPENER); - name.append(op); - name.append(Symbols.ARGUMENT_SEPARATOR); - name.append(arg.get(relationIndex).getName()); - for (int i = 0; i < arg.size(); i++) { - name.append(Symbols.ARGUMENT_SEPARATOR); - if (i == relationIndex) - name.append(Symbols.IMAGE_PLACE_HOLDER); - else - name.append(arg.get(i).getName()); - } - name.append(Symbols.COMPOUND_TERM_CLOSER); - return name.toString(); - } - - /** - * skip all variable names to produce stable sorting order among components, not for display - * @return the constant part of the term name - */ - public String getConstantName() { - StringBuffer s = new StringBuffer(); - s.append(Symbols.COMPOUND_TERM_OPENER); - s.append(operator()); - s.append(Symbols.ARGUMENT_SEPARATOR); - for (int i = 0; i < components.size(); i++) { - s.append(components.get(i).getConstantName()); - s.append(Symbols.ARGUMENT_SEPARATOR); - } - s.append(Symbols.COMPOUND_TERM_CLOSER); - return s.toString(); - } - - /* ----- utilities for other fields ----- */ - - /** - * report the term's syntactic complexity - * @return the comlexity value - */ - public int getComplexity() { - return complexity; - } - - /** - * check if the term contains free variable - * @return if the term is a constant - */ - public boolean isConstant() { - return (openVariables == null); - } - - /** - * check if the order of the components matters - * <p> - * commutative CompoundTerms: Sets, Intersections; - * communative Statements: Similarity, Equivalence; - * communative CompoundStatements: Disjunction, Conjunction - * @return if the term is a communitive - */ - public boolean isCommutative() { - return false; - } - - /** - * build a component list from two terms - * @param t1 the first component - * @param t2 the second component - * @return the component list - */ - protected static ArrayList<Term> argumentsToList(Term t1, Term t2) { - ArrayList<Term> list = new ArrayList<Term>(2); - list.add(t1); - list.add(t2); - return list; - } - - /* ----- extend Collection methods to component list ----- */ - - /** - * get the number of components - * @return the size of the component list - */ - public int size() { - return components.size(); - } - - /** - * get a component by index - * @param i index of the component - * @return the component - */ - public Term componentAt(int i) { - return components.get(i); - } - - public ArrayList<Term> getComponents() { - return components; - } - - public ArrayList<Term> cloneComponents() { - return (ArrayList<Term>) cloneList(components); - } - - /** - * deep clone an array list - * @return an identical and separate copy of the list - */ - public static ArrayList cloneList(ArrayList original) { - if (original == null) - return null; - ArrayList arr = new ArrayList(original.size()); - for (int i = 0; i < original.size(); i++) - arr.add(((Term) original.get(i)).clone()); - return arr; - } - - public boolean containComponent(Term t) { - return components.contains(t); - } - - public boolean containAllComponents(Term t) { - if (getClass() == t.getClass()) - return components.containsAll(((CompoundTerm) t).getComponents()); - else - return components.contains(t); - } - - /* ----- clone/modify methods ----- */ - - public static Term reduceComponents(CompoundTerm t1, Term t2, Memory memory) { - boolean done; - ArrayList<Term> list = t1.cloneComponents(); - if (t1.getClass() == t2.getClass()) - done = list.removeAll(((CompoundTerm) t2).getComponents()); - else - done = list.remove(t2); - return (done ? make(t1, list, memory) : null); - } - - public static Term replaceComponent(CompoundTerm compound, int index, Term t, Memory memory) { - ArrayList<Term> list = compound.cloneComponents(); - if (t == null) - list.remove(index); - else if (compound.getClass() != t.getClass()) - list.set(index, t); - else { - ArrayList<Term> list2 = ((CompoundTerm)t).cloneComponents(); - for (int i = 0; i < list2.size(); i++) - list.add(index + i, list2.get(i)); - } - if (compound.isCommutative()) - Collections.sort(list); - return make(compound, list, memory); - } - - public static Term replaceComponent(CompoundTerm compound, Term oldComponent, Term newComponent, Memory memory) { - ArrayList<Term> list = compound.cloneComponents(); - int index = list.indexOf(oldComponent); - list.remove(index); - if (compound.getClass() != newComponent.getClass()) - list.add(index, newComponent); - else { - ArrayList<Term> list2 = ((CompoundTerm)newComponent).cloneComponents(); - for (int i = 0; i < list2.size(); i++) - list.add(index + i, list2.get(i)); - } - if (compound.isCommutative()) - Collections.sort(list); - return make(compound, list, memory); - } - - /* ----- variable-related utilities ----- */ - - /** - * get the OpenVariables list - * @return the open variables list - */ - public ArrayList<Variable> getOpenVariables() { - return openVariables; - } - - /** - * register open and closed variables in a CompoundTerm - * <p> - * an open variable only appears in one components, while a closed variable appears in multiple components - */ - private void markVariables() { // not recursive - openVariables = new ArrayList<Variable>(); - ArrayList<Variable> closedVariables = new ArrayList<Variable>(); // local variable - ArrayList<Variable> list; - for (Term term : components) { - if ((term instanceof Variable) && (((Variable) term).getType() != Variable.VarType.ANONYMOUS)) { - openVariables.add((Variable) term); - } else if (term instanceof CompoundTerm) { - list = ((CompoundTerm) term).getOpenVariables(); - if (list != null) { - for (Variable var : list) { - if (var.getType() == Variable.VarType.QUERY) - openVariables.add(var); - else { - int i = openVariables.indexOf(var); - if (i >= 0) { // assume a (independent/dependent) variable appears exactly twice - var.setScope(this); - openVariables.get(i).setScope(this); - openVariables.remove(i); - closedVariables.add(var); - } else - openVariables.add(var); - } - } - } - } - } - if (openVariables.size() == 0) // { - openVariables = null; - } - - // only called from Sentence - public void renameVariables() { - renameVariables(new HashMap<String, String>()); - } - - /** - * Recursively rename variables by their appearing order in the CompoundTerm - * <p> - * Since each occurance of a variable is processed exactly ones, there will be no confusion between new names and old names. - * @param varMap the mapping built so far - */ - protected void renameVariables(HashMap<String, String> varMap) { - String oldName, newName; - for (Term t : components) { - if ((t instanceof Variable) && (((Variable) t).getType() != Variable.VarType.ANONYMOUS)) { - oldName = ((Variable) t).getSimpleName(); - newName = varMap.get(oldName); - if (newName == null) { - newName = makeVarName(varMap.size(), (Variable) t); - varMap.put(oldName, newName); - } - ((Variable) t).setName(newName); -// } else if ((t instanceof CompoundTerm) && !(t.isConstant())) { - } else if (t instanceof CompoundTerm) { - ((CompoundTerm) t).renameVariables(varMap); - } - } - name = makeName(); // type-specific - } - - /** - * sequentially generate new variable names - * @param size the current size of the variable list - * @param v the variable to be renamed - * @return a new variable name - */ - private String makeVarName(int size, Variable v) { - StringBuffer s = new StringBuffer(); - Variable.VarType type = v.getType(); - if (type == Variable.VarType.QUERY) - s.append(Symbols.QUERY_VARIABLE_TAG); - else - s.append(Symbols.VARIABLE_TAG); - s.append(size + 1); - return s.toString(); - } - - public void substituteComponent(HashMap<String,Term> subs, boolean first) { - Term t1, t2; - String varName; - for (int i = 0; i < size(); i++) { - t1 = componentAt(i); - if (t1 instanceof Variable) { // simple Variable - varName = ((Variable) t1).getVarName(first); // name of the variable used in the mapping - t2 = subs.get(varName); // new Term if exist - if (t2 != null) { - components.set(i, t2); - } - } else if (t1 instanceof CompoundTerm) { // compound - ((CompoundTerm) t1).substituteComponent(subs, first); // apply substitute to a clone - } - } - markVariables(); // variable status may be changed, so need to re-do this - name = makeName(); - } - - /* ----- link CompoundTerm and its components ----- */ - - /** - * build CompositionalLinks to constant components and subcomponents - * <p> - * The compound type determines the link type; the component type determines whether to build the link. - */ - public ArrayList<TermLink> prepareComponentLinks(Memory memory) { - ArrayList<TermLink> componentLinks = new ArrayList<TermLink>(); - short type = (this instanceof Statement) ? TermLink.COMPOUND_STATEMENT : TermLink.COMPOUND; // default - prepareComponentLinks(componentLinks, type, this, memory); - return componentLinks; - } - - protected void prepareComponentLinks(ArrayList<TermLink> componentLinks, short type, CompoundTerm term, Memory memory) { - Term t1, t2, t3; - for (int i = 0; i < term.size(); i++) { // first level components - t1 = term.componentAt(i); - if (t1.isConstant()) // first level - componentLinks.add(new TermLink(t1, type, i, memory)); - if ((this instanceof Implication) && (i == 0) && (t1 instanceof Conjunction)) { - ((CompoundTerm) t1).prepareComponentLinks(componentLinks, TermLink.COMPOUND_CONDITION, (CompoundTerm) t1, memory); - } else if (t1 instanceof CompoundTerm) { - for (int j = 0; j < ((CompoundTerm) t1).size(); j++) { - t2 = ((CompoundTerm) t1).componentAt(j); - if (t2.isConstant()) { // second level - if ((t1 instanceof Product) || (t1 instanceof ImageExt) || (t1 instanceof ImageInt)) - componentLinks.add(new TermLink(t2, TermLink.TRANSFORM, i, j, memory)); - else - componentLinks.add(new TermLink(t2, type, i, j, memory)); - } - if ((t2 instanceof Product) || (t2 instanceof ImageExt) || (t2 instanceof ImageInt)) { - for (int k = 0; k < ((CompoundTerm) t2).size(); k++) { - t3 = ((CompoundTerm) t2).componentAt(k); - if (t3.isConstant()) { // third level - componentLinks.add(new TermLink(t3, TermLink.TRANSFORM, i, j, k, memory)); - } - } - } - } - } - } - } - - - /* ---------- temporal order among components ---------- */ - - public enum TemporalOrder { BEFORE, WHEN, AFTER, NONE, UNSURE } - - public static TemporalOrder temporalInference(TemporalOrder t1, TemporalOrder t2) { - if ((t1 == TemporalOrder.UNSURE) || (t2 == TemporalOrder.UNSURE)) - return TemporalOrder.UNSURE; - if (t1 == TemporalOrder.NONE) - return t2; - if (t2 == TemporalOrder.NONE) - return t1; - if (t1 == TemporalOrder.WHEN) - return t2; - if (t2 == TemporalOrder.WHEN) - return t1; - if (t1 == t2) - return t1; - return TemporalOrder.UNSURE; - } - - public static TemporalOrder temporalReverse(TemporalOrder t1) { - if (t1 == TemporalOrder.BEFORE) - return TemporalOrder.AFTER; - if (t1 == TemporalOrder.AFTER) - return TemporalOrder.BEFORE; - return t1; - } - - public static TemporalOrder temporalInferenceWithFigure(TemporalOrder order1, TemporalOrder order2, int figure) { - switch (figure) { - case 11: - return temporalInference(temporalReverse(order1), order2); - case 12: - return temporalInference(temporalReverse(order1), temporalReverse(order2)); - case 21: - return temporalInference(order1, order2); - case 22: - return temporalInference(order1, temporalReverse(order2)); - default: - return TemporalOrder.UNSURE; - } - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/Conjunction.java b/open-nars/src/com/googlecode/opennars/language/Conjunction.java deleted file mode 100644 index 398cf54c3daf5a9b399dfe68fcc741c19474bd36..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Conjunction.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Conjunction.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.inference.*; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.*; - -/** - * Conjunction of statements - */ -public class Conjunction extends CompoundTerm { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected Conjunction(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - protected Conjunction(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a Conjunction - */ - public Object clone() { - return new Conjunction(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param term1 The first compoment - * @param term2 The second compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term term1, Term term2, Memory memory) { - TreeSet set; - if (term1 instanceof Conjunction) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - if (term2 instanceof Conjunction) - set.addAll(((CompoundTerm) term2).cloneComponents()); // (&,(&,P,Q),(&,R,S)) = (&,P,Q,R,S) - else - set.add((Term) term2.clone()); // (&,(&,P,Q),R) = (&,P,Q,R) - } else if (term2 instanceof Conjunction) { - set = new TreeSet(((CompoundTerm) term2).cloneComponents()); - set.add((Term) term1.clone()); // (&,R,(&,P,Q)) = (&,P,Q,R) - } else { - set = new TreeSet(); - set.add(term1); // valid solution??? - set.add(term2); -// set.add((Term) term1.clone()); -// set.add((Term) term2.clone()); - } - return make(set, memory); - } - - /** - * Try to make a new compound from a list of components. Called by StringParser. - * @return the Term generated from the arguments - * @param argList the list of arguments - */ - public static Term make(ArrayList<Term> argList, Memory memory) { - TreeSet<Term> set = new TreeSet<Term>(argList); // sort/merge arguments - return make(set, memory); - } - - /** - * Try to make a new compound from a set of components. Called by the public make methods. - * @param set a set of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(TreeSet<Term> set, Memory memory) { - if (set.isEmpty()) - return null; // special case: no component - if (set.size() == 1) - return set.first(); // special case: single component - ArrayList<Term> argument = new ArrayList<Term>(set); - String name = makeCompoundName(Symbols.CONJUNCTION_OPERATOR, argument); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new Conjunction(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.CONJUNCTION_OPERATOR; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - public boolean isCommutative() { - return true; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/ConjunctionParallel.java b/open-nars/src/com/googlecode/opennars/language/ConjunctionParallel.java deleted file mode 100644 index 1af046891af47e64322a0a7bf2054e0672ac08a8..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/ConjunctionParallel.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * ConjunctionParallel.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.inference.*; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.*; - -/** - * A parallel conjunction of Statements. - */ -public class ConjunctionParallel extends Conjunction { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected ConjunctionParallel(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - protected ConjunctionParallel(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a Conjunction - */ - public Object clone() { - return new ConjunctionParallel(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param term1 The first compoment - * @param term2 The second compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term term1, Term term2, Memory memory) { - TreeSet set; - if (term1 instanceof ConjunctionParallel) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - if (term2 instanceof ConjunctionParallel) - set.addAll(((CompoundTerm) term2).cloneComponents()); // (&,(&,P,Q),(&,R,S)) = (&,P,Q,R,S) - else - set.add((Term) term2.clone()); // (&,(&,P,Q),R) = (&,P,Q,R) - } else if (term2 instanceof ConjunctionParallel) { - set = new TreeSet(((CompoundTerm) term2).cloneComponents()); - set.add((Term) term1.clone()); // (&,R,(&,P,Q)) = (&,P,Q,R) - } else { - set = new TreeSet(); - set.add(term1); // valid solution??? - set.add(term2); - } - return make(set, memory); - } - - /** - * Try to make a new compound from a list of components. Called by StringParser. - * @return the Term generated from the arguments - * @param argList the list of arguments - */ - public static Term make(ArrayList<Term> argList, Memory memory) { - TreeSet<Term> set = new TreeSet<Term>(argList); // sort/merge arguments - return make(set, memory); - } - - /** - * Try to make a new compound from a set of components. Called by the public make methods. - * @param set a set of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(TreeSet<Term> set, Memory memory) { - if (set.isEmpty()) - return null; // special case: no component - if (set.size() == 1) - return set.first(); // special case: single component - ArrayList<Term> argument = new ArrayList<Term>(set); - String name = makeCompoundName(Symbols.CONJUNCTION_OPERATOR, argument); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new ConjunctionParallel(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.PARALLEL_OPERATOR; - } - - public CompoundTerm.TemporalOrder getTemporalOrder() { - return CompoundTerm.TemporalOrder.WHEN; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/ConjunctionSequence.java b/open-nars/src/com/googlecode/opennars/language/ConjunctionSequence.java deleted file mode 100644 index 7b971e4913e80055bb058aba6215592e4a2d2df0..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/ConjunctionSequence.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * ConjunctionSequence.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.inference.*; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.*; - -/** - * A sequential conjunction of Statements. - */ -public class ConjunctionSequence extends Conjunction { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private ConjunctionSequence(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private ConjunctionSequence(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a Conjunction - */ - public Object clone() { - return new ConjunctionSequence(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from a list of components. Called by StringParser. - * @param argument the list of arguments - * @return the Term generated from the arguments - */ - public static Term make(ArrayList<Term> argument, Memory memory) { - if (argument.size() == 1) - return argument.get(0); - String name = makeCompoundName(Symbols.PRODUCT_OPERATOR, argument); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new ConjunctionSequence(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.SEQUENCE_OPERATOR; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - public boolean isCommutative() { - return false; - } - - public CompoundTerm.TemporalOrder getTemporalOrder() { - return CompoundTerm.TemporalOrder.AFTER; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/DifferenceExt.java b/open-nars/src/com/googlecode/opennars/language/DifferenceExt.java deleted file mode 100644 index 59fecd68d14c99c17ae1e5a07de649c402f4cb80..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/DifferenceExt.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * DifferenceExt.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A compound term whose extension is the difference of the extensions of its components - */ -public class DifferenceExt extends CompoundTerm { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private DifferenceExt(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private DifferenceExt(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a DifferenceExt - */ - public Object clone() { - return new DifferenceExt(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new DifferenceExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argList The list of components - */ - public static Term make(ArrayList<Term> argList, Memory memory) { - if (argList.size() == 1) // special case from CompoundTerm.reduceComponent - return argList.get(0); - if (argList.size() != 2) - return null; - String name = makeCompoundName(Symbols.DIFFERENCE_EXT_OPERATOR, argList); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new DifferenceExt(name, argList); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param t1 The first compoment - * @param t2 The second compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term t1, Term t2, Memory memory) { - if (t1.equals(t2)) - return null; - if ((t1 instanceof SetExt) && (t2 instanceof SetExt)) { - TreeSet set = new TreeSet(((CompoundTerm) t1).cloneComponents()); - set.removeAll(((CompoundTerm) t2).cloneComponents()); // set difference - return SetExt.make(set, memory); - } - ArrayList<Term> list = argumentsToList(t1, t2); - return make(list, memory); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.DIFFERENCE_EXT_OPERATOR; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/DifferenceInt.java b/open-nars/src/com/googlecode/opennars/language/DifferenceInt.java deleted file mode 100644 index acace500c7c9ff05b167affb3bc878e74e5988d4..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/DifferenceInt.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * DifferenceInt.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A compound term whose extension is the difference of the intensions of its components - */ -public class DifferenceInt extends CompoundTerm { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private DifferenceInt(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private DifferenceInt(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a DifferenceInt - */ - public Object clone() { - return new DifferenceInt(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new DifferenceExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argList The list of components - */ - public static Term make(ArrayList<Term> argList, Memory memory) { - if (argList.size() == 1) // special case from CompoundTerm.reduceComponent - return argList.get(0); - if (argList.size() != 2) - return null; - String name = makeCompoundName(Symbols.DIFFERENCE_INT_OPERATOR, argList); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new DifferenceInt(name, argList); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param t1 The first compoment - * @param t2 The second compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term t1, Term t2, Memory memory) { - if (t1.equals(t2)) - return null; - if ((t1 instanceof SetInt) && (t2 instanceof SetInt)) { - TreeSet set = new TreeSet(((CompoundTerm) t1).cloneComponents()); - set.removeAll(((CompoundTerm) t2).cloneComponents()); // set difference - return SetInt.make(set, memory); - } - ArrayList<Term> list = argumentsToList(t1, t2); - return make(list, memory); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.DIFFERENCE_INT_OPERATOR; - } -} - - diff --git a/open-nars/src/com/googlecode/opennars/language/Disjunction.java b/open-nars/src/com/googlecode/opennars/language/Disjunction.java deleted file mode 100644 index 387f977c71a93e8df1d614663e0a7c389ba7a88b..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Disjunction.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Disjunction.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.inference.*; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.*; - -/** - * A disjunction of Statements. - */ -public class Disjunction extends CompoundTerm { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private Disjunction(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private Disjunction(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a Disjunction - */ - public Object clone() { - return new Disjunction(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new Disjunction from two components. Called by the inference rules. - * @param term1 The first compoment - * @param term2 The first compoment - * @return A Disjunction generated or a Term it reduced to - */ - public static Term make(Term term1, Term term2, Memory memory) { - TreeSet set; - if (term1 instanceof Disjunction) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - if (term2 instanceof Disjunction) - set.addAll(((CompoundTerm) term2).cloneComponents()); // (&,(&,P,Q),(&,R,S)) = (&,P,Q,R,S) - else - set.add((Term) term2.clone()); // (&,(&,P,Q),R) = (&,P,Q,R) - } else if (term2 instanceof Disjunction) { - set = new TreeSet(((CompoundTerm) term2).cloneComponents()); - set.add((Term) term1.clone()); // (&,R,(&,P,Q)) = (&,P,Q,R) - } else { - set = new TreeSet(); - set.add((Term) term1.clone()); - set.add((Term) term2.clone()); - } - return make(set, memory); - } - - /** - * Try to make a new IntersectionExt. Called by StringParser. - * @param argList a list of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(ArrayList<Term> argList, Memory memory) { - TreeSet<Term> set = new TreeSet<Term>(argList); // sort/merge arguments - return make(set, memory); - } - - /** - * Try to make a new Disjunction from a set of components. Called by the public make methods. - * @param set a set of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(TreeSet<Term> set, Memory memory) { - if (set.size() == 1) - return set.first(); // special case: single component - ArrayList<Term> argument = new ArrayList<Term>(set); - String name = makeCompoundName(Symbols.DISJUNCTION_OPERATOR, argument); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new Disjunction(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.DISJUNCTION_OPERATOR; - } - - /** - * Conjunction is communitative. - * @return true for communitative - */ - public boolean isCommutative() { - return true; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/Equivalence.java b/open-nars/src/com/googlecode/opennars/language/Equivalence.java deleted file mode 100644 index e63106bfefa087b42d2559b89cd25a68007ca7e3..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Equivalence.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Equivalence.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A Statement about an Equivalence relation. - */ -public class Equivalence extends Statement { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected Equivalence(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - protected Equivalence(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a Similarity - */ - public Object clone() { - return new Equivalence(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Equivalence make(Term subject, Term predicate, Memory memory) { - if (invalidStatement(subject, predicate)) - return null; - if (subject.compareTo(predicate) > 0) - return make(predicate, subject, memory); - String name = makeStatementName(subject, Symbols.EQUIVALENCE_RELATION, predicate); - Term t = memory.nameToListedTerm(name); - if (t != null) - return (Equivalence) t; - ArrayList<Term> argument = argumentsToList(subject, predicate); - return new Equivalence(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.EQUIVALENCE_RELATION; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - public boolean isCommutative() { - return true; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/EquivalenceAfter.java b/open-nars/src/com/googlecode/opennars/language/EquivalenceAfter.java deleted file mode 100644 index c9d008d53b94128b4feb5821bef4325c53e0493a..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/EquivalenceAfter.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * EquivalenceAfter.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * Temporal Implication relation, predicate after subject. - */ -public class EquivalenceAfter extends Equivalence { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - public EquivalenceAfter(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private EquivalenceAfter(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a Similarity - */ - public Object clone() { - return new EquivalenceAfter(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static EquivalenceAfter make(Term subject, Term predicate, Memory memory) { - if (invalidStatement(subject, predicate)) - return null; - String name = makeStatementName(subject, Symbols.EQUIVALENCE_RELATION, predicate); - Term t = memory.nameToListedTerm(name); - if (t != null) - return (EquivalenceAfter) t; - ArrayList<Term> argument = argumentsToList(subject, predicate); - return new EquivalenceAfter(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.EQUIVALENCE_AFTER_RELATION; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - public boolean isCommutative() { - return false; - } - - public CompoundTerm.TemporalOrder getTemporalOrder() { - return CompoundTerm.TemporalOrder.AFTER; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/EquivalenceWhen.java b/open-nars/src/com/googlecode/opennars/language/EquivalenceWhen.java deleted file mode 100644 index a6853db83ed2f5ebf5c56fa4ae8e65ea9a305c3f..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/EquivalenceWhen.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * EquivalenceWhen.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * Temporal Equivalence relation, concurrent. - * - */ -public class EquivalenceWhen extends Equivalence { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - public EquivalenceWhen(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private EquivalenceWhen(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a Similarity - */ - public Object clone() { - return new EquivalenceWhen(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static EquivalenceWhen make(Term subject, Term predicate, Memory memory) { - if (invalidStatement(subject, predicate)) - return null; - if (subject.compareTo(predicate) > 0) - return make(predicate, subject, memory); - String name = makeStatementName(subject, Symbols.EQUIVALENCE_RELATION, predicate); - Term t = memory.nameToListedTerm(name); - if (t != null) - return (EquivalenceWhen) t; - ArrayList<Term> argument = argumentsToList(subject, predicate); - return new EquivalenceWhen(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.EQUIVALENCE_WHEN_RELATION; - } - - public CompoundTerm.TemporalOrder getTemporalOrder() { - return CompoundTerm.TemporalOrder.WHEN; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/ImageExt.java b/open-nars/src/com/googlecode/opennars/language/ImageExt.java deleted file mode 100644 index 5cd342cb20676faefb1f59f88f2d51a842e70cd7..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/ImageExt.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * ImageExt.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * An extension image. - * <p> - * B --> (/,P,A,_)) iff (*,A,B) --> P - * <p> - * Internally, it is actually (/,A,P)_1, with an index. - */ -public class ImageExt extends CompoundTerm { - - /** - * The index of relation in the component list. - */ - private short relationIndex; - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - * @param index The index of relation in the component list - */ - private ImageExt(String n, ArrayList<Term> arg, short index) { - super(n, arg); - relationIndex = index; - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param complexity syntactic complexity of the compound - * @param n The name of the term - * @param index The index of relation in the component list - */ - private ImageExt(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short complexity, short index) { - super(n, cs, open, closed, complexity); - relationIndex = index; - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into an ImageExt - */ - public Object clone() { - return new ImageExt(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity, relationIndex); - } - - /** - * Try to make a new ImageExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argList The list of components - */ - public static Term make(ArrayList<Term> argList, Memory memory) { - if (argList.size() < 3) - return null; - Term t; - Term relation = argList.get(0); - ArrayList<Term> argument = new ArrayList<Term>(); - int index = 0; - for (int j = 1; j < argList.size(); j++) { - if (argList.get(j).getName().charAt(0) == Symbols.IMAGE_PLACE_HOLDER) { - index = j-1; - argument.add(relation); - } else - argument.add(argList.get(j)); - } - return make(argument, (short) index, memory); - } - - /** - * Try to make an Image from a Product and a relation. Called by the inference rules. - * @param product The product - * @param relation The relation - * @param index The index of the place-holder - * @return A compound generated or a term it reduced to - */ - public static Term make(Product product, Term relation, short index, Memory memory) { - if (relation instanceof Product) { - Product p2 = (Product) relation; - if ((product.size() == 2) && (p2.size() == 2)) { - if ((index == 0) && product.componentAt(1).equals(p2.componentAt(1))) // (/,_,(*,a,b),b) is reduced to a - return p2.componentAt(0); - if ((index == 1) && product.componentAt(0).equals(p2.componentAt(0))) // (/,(*,a,b),a,_) is reduced to b - return p2.componentAt(1); - } - } - ArrayList<Term> argument = product.cloneComponents(); - argument.set(index, relation); - return make(argument, index, memory); - } - - /** - * Try to make an Image from an existing Image and a component. Called by the inference rules. - * @param oldImage The existing Image - * @param component The component to be added into the component list - * @param index The index of the place-holder in the new Image - * @return A compound generated or a term it reduced to - */ - public static Term make(ImageExt oldImage, Term component, short index, Memory memory) { - ArrayList<Term> argList = oldImage.cloneComponents(); - int oldIndex = oldImage.getRelationIndex(); - Term relation = argList.get(oldIndex); - argList.set(oldIndex, component); - argList.set(index, relation); - return make(argList, index, memory); - } - - /** - * Try to make a new compound from a set of components. Called by the public make methods. - * @param argument The argument list - * @return the Term generated from the arguments - */ - public static Term make(ArrayList<Term> argument, short index, Memory memory) { - String name = makeImageName(Symbols.IMAGE_EXT_OPERATOR, argument, index); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new ImageExt(name, argument, index); - } - - /** - * get the index of the relation in the component list - * @return the index of relation - */ - public short getRelationIndex() { - return relationIndex; - } - - /** - * override the default in making the name of the current term from existing fields - * @return the name of the term - */ - public String makeName() { - return makeImageName(Symbols.IMAGE_EXT_OPERATOR, components, relationIndex); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.IMAGE_EXT_OPERATOR; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/ImageInt.java b/open-nars/src/com/googlecode/opennars/language/ImageInt.java deleted file mode 100644 index 3e40977b6f84d1bf5839b197ac8217e320492527..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/ImageInt.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * ImageInt.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * An intension image. - * <p> - * (\,P,A,_)) --> B iff P --> (*,A,B) - * <p> - * Internally, it is actually (\,A,P)_1, with an index. - */ -public class ImageInt extends CompoundTerm { - - /** - * The index of relation in the component list. - */ - private short relationIndex; - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - * @param index The index of relation in the component list - */ - private ImageInt(String n, ArrayList<Term> arg, short index) { - super(n, arg); - relationIndex = index; - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param complexity syntactic complexity of the compound - * @param n The name of the term - * @param index The index of relation in the component list - */ - private ImageInt(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short complexity, short index) { - super(n, cs, open, closed, complexity); - relationIndex = index; - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into an ImageInt - */ - public Object clone() { - return new ImageInt(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity, relationIndex); - } - - /** - * Try to make a new ImageExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argList The list of components - */ - public static Term make(ArrayList<Term> argList, Memory memory) { - if (argList.size() < 3) - return null; - Term t; - Term relation = argList.get(0); - ArrayList<Term> argument = new ArrayList<Term>(); - int index = 0; - for (int j = 1; j < argList.size(); j++) { - if (argList.get(j).getName().charAt(0) == Symbols.IMAGE_PLACE_HOLDER) { - index = j-1; - argument.add(relation); - } else - argument.add(argList.get(j)); - } - return make(argument, (short) index, memory); - } - - /** - * Try to make an Image from a Product and a relation. Called by the inference rules. - * @param product The product - * @param relation The relation - * @param index The index of the place-holder - * @return A compound generated or a term it reduced to - */ - public static Term make(Product product, Term relation, short index, Memory memory) { - if (relation instanceof Product) { - Product p2 = (Product) relation; - if ((product.size() == 2) && (p2.size() == 2)) { - if ((index == 0) && product.componentAt(1).equals(p2.componentAt(1))) // (\,_,(*,a,b),b) is reduced to a - return p2.componentAt(0); - if ((index == 1) && product.componentAt(0).equals(p2.componentAt(0))) // (\,(*,a,b),a,_) is reduced to b - return p2.componentAt(1); - } - } - ArrayList<Term> argument = product.cloneComponents(); - argument.set(index, relation); - return make(argument, index, memory); - } - - /** - * Try to make an Image from an existing Image and a component. Called by the inference rules. - * @param oldImage The existing Image - * @param component The component to be added into the component list - * @param index The index of the place-holder in the new Image - * @return A compound generated or a term it reduced to - */ - public static Term make(ImageInt oldImage, Term component, short index, Memory memory) { - ArrayList<Term> argList = oldImage.cloneComponents(); - int oldIndex = oldImage.getRelationIndex(); - Term relation = argList.get(oldIndex); - argList.set(oldIndex, component); - argList.set(index, relation); - return make(argList, index, memory); - } - - /** - * Try to make a new compound from a set of components. Called by the public make methods. - * @param argument The argument list - * @return the Term generated from the arguments - */ - public static Term make(ArrayList<Term> argument, short index, Memory memory) { - String name = makeImageName(Symbols.IMAGE_INT_OPERATOR, argument, index); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new ImageInt(name, argument, index); - } - - /** - * get the index of the relation in the component list - * @return the index of relation - */ - public short getRelationIndex() { - return relationIndex; - } - - /** - * override the default in making the name of the current term from existing fields - * @return the name of the term - */ - public String makeName() { - return makeImageName(Symbols.IMAGE_INT_OPERATOR, components, relationIndex); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.IMAGE_INT_OPERATOR; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/Implication.java b/open-nars/src/com/googlecode/opennars/language/Implication.java deleted file mode 100644 index 0e69a326a1977fa781774c09ef62ce68e9d3e23c..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Implication.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Implication.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A Statement about an Inheritance relation. - */ -public class Implication extends Statement { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected Implication(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - protected Implication(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a SetExt - */ - public Object clone() { - return new Implication(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or a term it reduced to - */ - public static Implication make(Term subject, Term predicate, Memory memory) { // to be extended to check if subject is Conjunction - if (invalidStatement(subject, predicate)) - return null; - String name = makeStatementName(subject, Symbols.IMPLICATION_RELATION, predicate); - Term t = memory.nameToListedTerm(name); - if (t != null) - return (Implication) t; - if (predicate instanceof Implication) { - Term oldCondition = ((Implication) predicate).getSubject(); - Term newCondition = Conjunction.make(subject, oldCondition, memory); - return make(newCondition, ((Implication) predicate).getPredicate(), memory); - } else { - ArrayList<Term> argument = argumentsToList(subject, predicate); - return new Implication(name, argument); - } - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.IMPLICATION_RELATION; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/ImplicationAfter.java b/open-nars/src/com/googlecode/opennars/language/ImplicationAfter.java deleted file mode 100644 index d3cde1818ee016fd553bdb1baf8511e243970ae0..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/ImplicationAfter.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * ImplicationAfter.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * Temporal Implication relation, predicate after subject. - */ -public class ImplicationAfter extends Implication { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private ImplicationAfter(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private ImplicationAfter(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a SetExt - */ - public Object clone() { - return new ImplicationAfter(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or a term it reduced to - */ - public static ImplicationAfter make(Term subject, Term predicate, Memory memory) { // to be extended to check if subject is Conjunction - if (invalidStatement(subject, predicate)) - return null; - String name = makeStatementName(subject, Symbols.IMPLICATION_AFTER_RELATION, predicate); - Term t = memory.nameToListedTerm(name); - if (t != null) - return (ImplicationAfter) t; - if (predicate instanceof ImplicationAfter) { - Term oldCondition = ((ImplicationAfter) predicate).getSubject(); - Term newCondition = ConjunctionSequence.make(subject, oldCondition, memory); - return make(newCondition, ((ImplicationAfter) predicate).getPredicate(), memory); - } else { - ArrayList<Term> argument = argumentsToList(subject, predicate); - return new ImplicationAfter(name, argument); - } - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.IMPLICATION_AFTER_RELATION; - } - - // overwrite default - public CompoundTerm.TemporalOrder getTemporalOrder() { - return CompoundTerm.TemporalOrder.AFTER; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/ImplicationBefore.java b/open-nars/src/com/googlecode/opennars/language/ImplicationBefore.java deleted file mode 100644 index d93d182943892df3511bf99a25be525075693eba..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/ImplicationBefore.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * ImplicationBefore.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * Temporal Implication relation, predicate before subject. - */ -public class ImplicationBefore extends Implication { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private ImplicationBefore(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private ImplicationBefore(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a SetExt - */ - public Object clone() { - return new ImplicationBefore(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or a term it reduced to - */ - public static ImplicationBefore make(Term subject, Term predicate, Memory memory) { // to be extended to check if subject is Conjunction - if (invalidStatement(subject, predicate)) - return null; - String name = makeStatementName(subject, Symbols.IMPLICATION_BEFORE_RELATION, predicate); - Term t = memory.nameToListedTerm(name); - if (t != null) - return (ImplicationBefore) t; - if (predicate instanceof ImplicationBefore) { - Term oldCondition = ((ImplicationBefore) predicate).getSubject(); - Term newCondition = ConjunctionSequence.make(oldCondition, subject, memory); - return make(newCondition, ((ImplicationBefore) predicate).getPredicate(), memory); - } else { - ArrayList<Term> argument = argumentsToList(subject, predicate); - return new ImplicationBefore(name, argument); - } - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.IMPLICATION_BEFORE_RELATION; - } - - // overwrite default - public CompoundTerm.TemporalOrder getTemporalOrder() { - return CompoundTerm.TemporalOrder.BEFORE; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/ImplicationWhen.java b/open-nars/src/com/googlecode/opennars/language/ImplicationWhen.java deleted file mode 100644 index 2ebffa4a12a9563369f9cd1117dc305e93ea23a3..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/ImplicationWhen.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * ImplicationWhen.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * Temporal Implication relation, concurrent. - */ - -public class ImplicationWhen extends Implication { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected ImplicationWhen(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - protected ImplicationWhen(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a SetExt - */ - public Object clone() { - return new ImplicationWhen(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or a term it reduced to - */ - public static ImplicationWhen make(Term subject, Term predicate, Memory memory) { // to be extended to check if subject is Conjunction - if (invalidStatement(subject, predicate)) - return null; - String name = makeStatementName(subject, Symbols.IMPLICATION_RELATION, predicate); - Term t = memory.nameToListedTerm(name); - if (t != null) - return (ImplicationWhen) t; - if (predicate instanceof ImplicationWhen) { - Term oldCondition = ((ImplicationWhen) predicate).getSubject(); - Term newCondition = ConjunctionParallel.make(subject, oldCondition, memory); - return make(newCondition, ((ImplicationWhen) predicate).getPredicate(), memory); - } else { - ArrayList<Term> argument = argumentsToList(subject, predicate); - return new ImplicationWhen(name, argument); - } - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.IMPLICATION_WHEN_RELATION; - } - - public CompoundTerm.TemporalOrder getTemporalOrder() { - return CompoundTerm.TemporalOrder.WHEN; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/Inheritance.java b/open-nars/src/com/googlecode/opennars/language/Inheritance.java deleted file mode 100644 index 93a1d2e86f39161daa6da810851469cc3bd1a980..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Inheritance.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Inheritance.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A Statement about an Inheritance relation. - */ -public class Inheritance extends Statement { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private Inheritance(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private Inheritance(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a SetExt - */ - public Object clone() { - return new Inheritance(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Inheritance make(Term subject, Term predicate, Memory memory) { - if (invalidStatement(subject, predicate)) - return null; - String name = makeStatementName(subject, Symbols.INHERITANCE_RELATION, predicate); - Term t = memory.nameToListedTerm(name); - if (t != null) - return (Inheritance) t; - ArrayList<Term> argument = argumentsToList(subject, predicate); - return new Inheritance(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.INHERITANCE_RELATION; - } -} - diff --git a/open-nars/src/com/googlecode/opennars/language/Instance.java b/open-nars/src/com/googlecode/opennars/language/Instance.java deleted file mode 100644 index 99b718322e310ed904c7611b7af355c7cdb4804b..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Instance.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Instance.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import com.googlecode.opennars.main.Memory; - -/** - * A Statement about an Instance relation, which is used only in Narsese for I/O, - * and translated into Inheritance for internal use. - */ -public abstract class Instance extends Statement { - - /** - * Try to make a new compound from two components. Called by the inference rules. - * <p> - * A {-- B becomes {A} --> B - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Statement make(Term subject, Term predicate, Memory memory) { - return Inheritance.make(SetExt.make(subject, memory), predicate, memory); - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/InstanceProperty.java b/open-nars/src/com/googlecode/opennars/language/InstanceProperty.java deleted file mode 100644 index fc871b588c79f96c032dad6d2333ae1d140b6d89..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/InstanceProperty.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * InstanceProperty.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import com.googlecode.opennars.main.Memory; - -/** - * A Statement about an InstanceProperty relation, which is used only in Narsese for I/O, - * and translated into Inheritance for internal use. - */ -public abstract class InstanceProperty extends Statement { - - /** - * Try to make a new compound from two components. Called by the inference rules. - * <p> - * A {-] B becomes {A} --> [B] - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Statement make(Term subject, Term predicate, Memory memory) { - return Inheritance.make(SetExt.make(subject, memory), SetInt.make(predicate, memory), memory); - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/IntersectionExt.java b/open-nars/src/com/googlecode/opennars/language/IntersectionExt.java deleted file mode 100644 index 30c3d8b694feb8cfb77c074e669e18e312585c33..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/IntersectionExt.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * IntersectionExt.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A compound term whose extension is the intersection of the extensions of its components - */ -public class IntersectionExt extends CompoundTerm { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private IntersectionExt(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private IntersectionExt(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a IntersectionExt - */ - public Object clone() { - return new IntersectionExt(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param term1 The first compoment - * @param term2 The first compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term term1, Term term2, Memory memory) { - TreeSet set; - if ((term1 instanceof SetInt) && (term2 instanceof SetInt)) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - set.addAll(((CompoundTerm) term2).cloneComponents()); // set union - return SetInt.make(set, memory); - } - if ((term1 instanceof SetExt) && (term2 instanceof SetExt)) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - set.retainAll(((CompoundTerm) term2).cloneComponents()); // set intersection - return SetExt.make(set, memory); - } - if (term1 instanceof IntersectionExt) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - if (term2 instanceof IntersectionExt) - set.addAll(((CompoundTerm) term2).cloneComponents()); // (&,(&,P,Q),(&,R,S)) = (&,P,Q,R,S) - else - set.add((Term) term2.clone()); // (&,(&,P,Q),R) = (&,P,Q,R) - } else if (term2 instanceof IntersectionExt) { - set = new TreeSet(((CompoundTerm) term2).cloneComponents()); - set.add((Term) term1.clone()); // (&,R,(&,P,Q)) = (&,P,Q,R) - } else { - set = new TreeSet(); - set.add((Term) term1.clone()); - set.add((Term) term2.clone()); - } - return make(set, memory); - } - - /** - * Try to make a new IntersectionExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argList The list of components - */ - public static Term make(ArrayList<Term> argList, Memory memory) { - TreeSet<Term> set = new TreeSet<Term>(argList); // sort/merge arguments - return make(set, memory); - } - - /** - * Try to make a new compound from a set of components. Called by the public make methods. - * @param set a set of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(TreeSet<Term> set, Memory memory) { - if (set.size() == 1) - return set.first(); // special case: single component - ArrayList<Term> argument = new ArrayList<Term>(set); - String name = makeCompoundName(Symbols.INTERSECTION_EXT_OPERATOR, argument); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new IntersectionExt(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.INTERSECTION_EXT_OPERATOR; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - public boolean isCommutative() { - return true; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/IntersectionInt.java b/open-nars/src/com/googlecode/opennars/language/IntersectionInt.java deleted file mode 100644 index bc13e5d7d20a6bd47d962f882b167f3ce79f2d54..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/IntersectionInt.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * IntersectionInt.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A compound term whose intension is the intersection of the extensions of its components - */ -public class IntersectionInt extends CompoundTerm { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private IntersectionInt(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private IntersectionInt(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a Conjunction - */ - public Object clone() { - return new IntersectionInt(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param term1 The first compoment - * @param term2 The first compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term term1, Term term2, Memory memory) { - TreeSet set; - if ((term1 instanceof SetExt) && (term2 instanceof SetExt)) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - set.addAll(((CompoundTerm) term2).cloneComponents()); // set union - return SetExt.make(set, memory); - } - if ((term1 instanceof SetInt) && (term2 instanceof SetInt)) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - set.retainAll(((CompoundTerm) term2).cloneComponents()); // set intersection - return SetInt.make(set, memory); - } - if (term1 instanceof IntersectionInt) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - if (term2 instanceof IntersectionInt) - set.addAll(((CompoundTerm) term2).cloneComponents()); // (|,(|,P,Q),(|,R,S)) = (|,P,Q,R,S) - else - set.add((Term) term2.clone()); // (|,(|,P,Q),R) = (|,P,Q,R) - } else if (term2 instanceof IntersectionInt) { - set = new TreeSet(((CompoundTerm) term2).cloneComponents()); - set.add((Term) term1.clone()); // (|,R,(|,P,Q)) = (|,P,Q,R) - } else { - set = new TreeSet(); - set.add((Term) term1.clone()); - set.add((Term) term2.clone()); - } - return make(set, memory); - } - - /** - * Try to make a new IntersectionExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argList The list of components - */ - public static Term make(ArrayList<Term> argList, Memory memory) { - TreeSet<Term> set = new TreeSet<Term>(argList); // sort/merge arguments - return make(set, memory); - } - - /** - * Try to make a new compound from a set of components. Called by the public make methods. - * @param set a set of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(TreeSet<Term> set, Memory memory) { - if (set.size() == 1) - return set.first(); // special case: single component - ArrayList<Term> argument = new ArrayList<Term>(set); - String name = makeCompoundName(Symbols.INTERSECTION_INT_OPERATOR, argument); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new IntersectionInt(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.INTERSECTION_INT_OPERATOR; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - public boolean isCommutative() { - return true; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/Literal.java b/open-nars/src/com/googlecode/opennars/language/Literal.java deleted file mode 100644 index e9cee1d45cfe33ea3a073caa808550b64132da07..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Literal.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.googlecode.opennars.language; - -public class Literal extends Term { - - public Literal() { - } - - public Literal(String name) { - super(name); - } - -} diff --git a/open-nars/src/com/googlecode/opennars/language/Negation.java b/open-nars/src/com/googlecode/opennars/language/Negation.java deleted file mode 100644 index 81e9ffbdd13531f75f9f1c562109dd8246bec44b..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Negation.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Negation.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A negation of a Statement. - */ -public class Negation extends CompoundTerm { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private Negation(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private Negation(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a SetExt - */ - public Object clone() { - return new Negation(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a Negation of one component. Called by the inference rules. - * @param t The compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term t, Memory memory) { - if (t instanceof Negation) - return (Term) ((CompoundTerm) t).cloneComponents().get(0); // (--,(--,P)) = P - ArrayList<Term> argument = new ArrayList<Term>(); - argument.add(t); - return make(argument, memory); - } - - /** - * Try to make a new SetExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argument The list of components - */ - public static Term make(ArrayList<Term> argument, Memory memory) { - if (argument.size() != 1) - return null; - String name = makeCompoundName(Symbols.NEGATION_OPERATOR, argument); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new Negation(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.NEGATION_OPERATOR; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/NumericLiteral.java b/open-nars/src/com/googlecode/opennars/language/NumericLiteral.java deleted file mode 100644 index 5fcf5a706637e86e4e7ca9df7b89a7665899bb41..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/NumericLiteral.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.googlecode.opennars.language; - -public class NumericLiteral extends Literal { - - public enum TYPE { - INTEGER, - DOUBLE; - }; - - private double num; - private TYPE type; - - public NumericLiteral(String name) { - super(name); - this.num = Double.parseDouble(name); - } - - public NumericLiteral(int num) { - super(Integer.toString(num)); - this.num = num; - this.type = TYPE.INTEGER; - } - - public NumericLiteral(double num) { - super(Double.toString(num)); - this.num = num; - this.type = TYPE.DOUBLE; - } - - public TYPE getType() { - return type; - } - -} diff --git a/open-nars/src/com/googlecode/opennars/language/Product.java b/open-nars/src/com/googlecode/opennars/language/Product.java deleted file mode 100644 index dcd51a5d7b203968cb3c5fc109ebd86f32c90b38..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Product.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Product.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A Product is a sequence of terms. - */ -public class Product extends CompoundTerm { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private Product(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param complexity syntactic complexity of the compound - * @param n The name of the term - */ - private Product(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short complexity) { - super(n, cs, open, closed, complexity); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into an ImageExt - */ - public Object clone() { - return new Product(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound. Called by StringParser. - * @return the Term generated from the arguments - * @param argument The list of components - */ - public static Term make(ArrayList<Term> argument, Memory memory) { - if (argument.size() < 2) - return null; - String name = makeCompoundName(Symbols.PRODUCT_OPERATOR, argument); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new Product(name, argument); - } - - /** - * Try to make a Product from an ImageExt/ImageInt and a component. Called by the inference rules. - * @param image The existing Image - * @param component The component to be added into the component list - * @param index The index of the place-holder in the new Image -- optional parameter - * @return A compound generated or a term it reduced to - */ - // for both - public static Term make(CompoundTerm image, Term component, int index, Memory memory) { - ArrayList<Term> argument = image.cloneComponents(); - argument.set(index, component); - return make(argument, memory); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.PRODUCT_OPERATOR; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/Property.java b/open-nars/src/com/googlecode/opennars/language/Property.java deleted file mode 100644 index d5997c8d5da2b777a95d2674bb047a5b22d8e427..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Property.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Property.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import com.googlecode.opennars.main.Memory; - -/** - * A Statement about a Property relation, which is used only in Narsese for I/O, - * and translated into Inheritance for internal use. - */ -public abstract class Property extends Statement { - - /** - * Try to make a new compound from two components. Called by the inference rules. - * <p> - * A --] B becomes A --> [B] - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Statement make(Term subject, Term predicate, Memory memory) { - return Inheritance.make(subject, SetInt.make(predicate, memory), memory); - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/SetExt.java b/open-nars/src/com/googlecode/opennars/language/SetExt.java deleted file mode 100644 index 2c42c6843a5eed2902f12ee444652aeeca713202..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/SetExt.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SetExt.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * An extensionally defined set, which contains one or more instances defining the Term. - */ -public class SetExt extends CompoundTerm { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private SetExt(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private SetExt(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a SetExt - */ - public Object clone() { - return new SetExt(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new set from one component. Called by the inference rules. - * @param t The compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term t, Memory memory) { - TreeSet<Term> set = new TreeSet<Term>(); - set.add(t); - return make(set, memory); - } - - /** - * Try to make a new SetExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argList The list of components - */ - public static Term make(ArrayList<Term> argList, Memory memory) { - TreeSet<Term> set = new TreeSet<Term>(argList); // sort/merge arguments - return make(set, memory); - } - - /** - * Try to make a new compound from a set of components. Called by the public make methods. - * @param set a set of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(TreeSet<Term> set, Memory memory) { - if (set.isEmpty()) - return null; - ArrayList<Term> argument = new ArrayList<Term>(set); - String name = makeSetName(Symbols.SET_EXT_OPENER, argument, Symbols.SET_EXT_CLOSER); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new SetExt(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return "" + Symbols.SET_EXT_OPENER; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - public boolean isCommutative() { - return true; - } - - /** - * Make a String representation of the set, override the default. - * @return true for communitative - */ - public String makeName() { - return makeSetName(Symbols.SET_EXT_OPENER, components, Symbols.SET_EXT_CLOSER); - } -} - diff --git a/open-nars/src/com/googlecode/opennars/language/SetInt.java b/open-nars/src/com/googlecode/opennars/language/SetInt.java deleted file mode 100644 index c7d3554d55e0dd68e0abcbb3c9dbf4c94530c317..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/SetInt.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SetInt.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * An intensionally defined set, which contains one or more instances defining the Term. - */ -public class SetInt extends CompoundTerm { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private SetInt(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private SetInt(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a SetInt - */ - public Object clone() { - return new SetInt(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new set from one component. Called by the inference rules. - * @param t The compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term t, Memory memory) { - TreeSet<Term> set = new TreeSet<Term>(); - set.add(t); - return make(set, memory); - } - - /** - * Try to make a new SetExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argList The list of components - */ - public static Term make(ArrayList<Term> argList, Memory memory) { - TreeSet<Term> set = new TreeSet<Term>(argList); // sort/merge arguments - return make(set, memory); - } - - /** - * Try to make a new compound from a set of components. Called by the public make methods. - * @param set a set of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(TreeSet<Term> set, Memory memory) { - if (set.isEmpty()) - return null; - ArrayList<Term> argument = new ArrayList<Term>(set); - String name = makeSetName(Symbols.SET_INT_OPENER, argument, Symbols.SET_INT_CLOSER); - Term t = memory.nameToListedTerm(name); - return (t != null) ? t : new SetInt(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return "" + Symbols.SET_INT_OPENER; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - public boolean isCommutative() { - return true; - } - - /** - * Make a String representation of the set, override the default. - * @return true for communitative - */ - public String makeName() { - return makeSetName(Symbols.SET_INT_OPENER, components, Symbols.SET_INT_CLOSER); - } -} - diff --git a/open-nars/src/com/googlecode/opennars/language/Similarity.java b/open-nars/src/com/googlecode/opennars/language/Similarity.java deleted file mode 100644 index 8c0f9a98cc0092b4ff8d345931ba280d60e4c537..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Similarity.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Similarity.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.entity.TermLink; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; - -/** - * A Statement about a Similarity relation. - */ -public class Similarity extends Statement { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private Similarity(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private Similarity(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a Similarity - */ - public Object clone() { - return new Similarity(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Similarity make(Term subject, Term predicate, Memory memory) { - if (invalidStatement(subject, predicate)) - return null; - if (subject.compareTo(predicate) > 0) - return make(predicate, subject, memory); - String name = makeStatementName(subject, Symbols.SIMILARITY_RELATION, predicate); - Term t = memory.nameToListedTerm(name); - if (t != null) - return (Similarity) t; - ArrayList<Term> argument = argumentsToList(subject, predicate); - return new Similarity(name, argument); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.SIMILARITY_RELATION; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - public boolean isCommutative() { - return true; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/Statement.java b/open-nars/src/com/googlecode/opennars/language/Statement.java deleted file mode 100644 index 9709b6f268bac8da4eb8fedda9546c99bb4b6206..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Statement.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Statement.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.*; - -/** - * A statement is a compound term, consisting of a subject, a predicate, - * and a relation symbol in between. It can be of either first-order or higher-order. - */ -public abstract class Statement extends CompoundTerm { - - /** - * default constructor - */ - protected Statement() {} - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected Statement(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - protected Statement(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * Make a Statement from String, called by StringParser - * @param relation The relation String - * @param subject The first component - * @param predicate The second component - * @return The Statement built - */ - public static Statement make(String relation, Term subject, Term predicate, Memory memory) { - if (invalidStatement(subject, predicate)) - return null; - if (relation.equals(Symbols.INHERITANCE_RELATION)) - return Inheritance.make(subject, predicate, memory); - if (relation.equals(Symbols.SIMILARITY_RELATION)) - return Similarity.make(subject, predicate, memory); - if (relation.equals(Symbols.INSTANCE_RELATION)) - return Instance.make(subject, predicate, memory); - if (relation.equals(Symbols.PROPERTY_RELATION)) - return Property.make(subject, predicate, memory); - if (relation.equals(Symbols.INSTANCE_PROPERTY_RELATION)) - return InstanceProperty.make(subject, predicate, memory); - if (relation.equals(Symbols.IMPLICATION_RELATION)) - return Implication.make(subject, predicate, memory); - if (relation.equals(Symbols.EQUIVALENCE_RELATION)) - return Equivalence.make(subject, predicate, memory); - if (relation.equals(Symbols.IMPLICATION_AFTER_RELATION)) - return ImplicationAfter.make(subject, predicate, memory); - if (relation.equals(Symbols.IMPLICATION_WHEN_RELATION)) - return ImplicationWhen.make(subject, predicate, memory); - if (relation.equals(Symbols.IMPLICATION_BEFORE_RELATION)) - return ImplicationBefore.make(subject, predicate, memory); - if (relation.equals(Symbols.EQUIVALENCE_AFTER_RELATION)) - return EquivalenceAfter.make(subject, predicate, memory); - if (relation.equals(Symbols.EQUIVALENCE_WHEN_RELATION)) - return EquivalenceWhen.make(subject, predicate, memory); - return null; - } - - /** - * Make a Statement from given components, called by the rules - * @return The Statement built - * @param sub The first component - * @param pred The second component - * @param statement A sample statement providing the class type - */ - public static Statement make(Statement statement, Term sub, Term pred, Memory memory) { - if (statement instanceof Inheritance) - return Inheritance.make(sub, pred, memory); - if (statement instanceof Similarity) - return Similarity.make(sub, pred, memory); - if (statement instanceof ImplicationBefore) - return ImplicationBefore.make(sub, pred, memory); - if (statement instanceof ImplicationWhen) - return ImplicationWhen.make(sub, pred, memory); - if (statement instanceof ImplicationAfter) - return ImplicationAfter.make(sub, pred, memory); - if (statement instanceof Implication) - return Implication.make(sub, pred, memory); - if (statement instanceof EquivalenceWhen) - return EquivalenceWhen.make(sub, pred, memory); - if (statement instanceof EquivalenceAfter) - return EquivalenceAfter.make(sub, pred, memory); - if (statement instanceof Equivalence) - return Equivalence.make(sub, pred, memory); - return null; - } - - /** - * Make a Statement from given components and temporal information, called by the rules - * @param statement A sample statement providing the class type - * @param sub The first component - * @param pred The second component - * @param order The temporal order of the statement - * @return The Statement built - */ - public static Statement make(Statement statement, Term sub, Term pred, CompoundTerm.TemporalOrder order, Memory memory) { - if (order == CompoundTerm.TemporalOrder.UNSURE) - return null; - if (order == CompoundTerm.TemporalOrder.NONE) - return make(statement, sub, pred, memory); - if (order == CompoundTerm.TemporalOrder.AFTER) { - if (statement instanceof Implication) - return ImplicationAfter.make(sub, pred, memory); - if (statement instanceof Equivalence) - return EquivalenceAfter.make(sub, pred, memory); - return null; - } - if (order == CompoundTerm.TemporalOrder.WHEN) { - if (statement instanceof Implication) - return ImplicationWhen.make(sub, pred, memory); - if (statement instanceof Equivalence) - return EquivalenceWhen.make(sub, pred, memory); - return null; - } - if (order == CompoundTerm.TemporalOrder.BEFORE) { - if (statement instanceof Implication) - return ImplicationBefore.make(sub, pred, memory); - if (statement instanceof Equivalence) - return EquivalenceAfter.make(pred, sub, memory); - return null; - } - return null; - } - - /** - * Make a symmetric Statement from given components and temporal information, called by the rules - * @param statement A sample asymmetric statement providing the class type - * @param sub The first component - * @param pred The second component - * @param order The temporal order of the statement - * @return The Statement built - */ - public static Statement makeSym(Statement statement, Term sub, Term pred, CompoundTerm.TemporalOrder order, Memory memory) { - if (order == CompoundTerm.TemporalOrder.UNSURE) - return null; - if (order == CompoundTerm.TemporalOrder.NONE) { - if (statement instanceof Inheritance) - return Similarity.make(sub, pred, memory); - if (statement instanceof Implication) - return Equivalence.make(sub, pred, memory); - return null; - } - if (order == CompoundTerm.TemporalOrder.AFTER) { - if (statement instanceof Implication) - return EquivalenceAfter.make(sub, pred, memory); - return null; - } - if (order == CompoundTerm.TemporalOrder.WHEN) { - if (statement instanceof Implication) - return EquivalenceWhen.make(sub, pred, memory); - return null; - } - if (order == CompoundTerm.TemporalOrder.BEFORE) { - if (statement instanceof Implication) - return EquivalenceAfter.make(pred, sub, memory); - return null; - } - return null; - } - - /** - * check Statement relation symbol - * @return if the given String is a relation symbol - * @param s0 The String to be checked - */ - public static boolean isRelation(String s0) { - String s = s0.trim(); - if (s.length() != 3) - return false; - return (s.equals(Symbols.INHERITANCE_RELATION) || - s.equals(Symbols.SIMILARITY_RELATION) || - s.equals(Symbols.INSTANCE_RELATION) || - s.equals(Symbols.PROPERTY_RELATION) || - s.equals(Symbols.INSTANCE_PROPERTY_RELATION) || - s.equals(Symbols.IMPLICATION_RELATION) || - s.equals(Symbols.EQUIVALENCE_RELATION) || - s.equals(Symbols.IMPLICATION_AFTER_RELATION) || - s.equals(Symbols.IMPLICATION_WHEN_RELATION) || - s.equals(Symbols.IMPLICATION_BEFORE_RELATION) || - s.equals(Symbols.EQUIVALENCE_WHEN_RELATION) || - s.equals(Symbols.EQUIVALENCE_AFTER_RELATION) ); - } - - /** - * override the default in making the name of the current term from existing fields - * @return the name of the term - */ - protected String makeName() { - return makeStatementName(getSubject(), operator(), getPredicate()); - } - - /** - * default method to make the name of an image term from given fields - * @param subject the first component - * @param predicate the second component - * @param relation the relation operator - * @return the name of the term - */ - protected static String makeStatementName(Term subject, String relation, Term predicate) { - StringBuffer name = new StringBuffer(); - name.append(Symbols.STATEMENT_OPENER); - name.append(subject.getName()); - name.append(' ' + relation + ' '); - name.append(predicate.getName()); - name.append(Symbols.STATEMENT_CLOSER); - return name.toString(); - } - - /** - * check the validity of a potential Statement. - * <p> - * Minimum requirement: the two terms cannot be the same. To be strengthened. - * @param subject the first component - * @param predicate the second component - * @return Whether the Statement is invalid - */ - public static boolean invalidStatement(Term subject, Term predicate) { - if (subject.equals(predicate)) - return true; - if ((subject instanceof CompoundTerm) && ((CompoundTerm) subject).containComponent(predicate)) - return true; - if ((predicate instanceof CompoundTerm) && ((CompoundTerm) predicate).containComponent(subject)) - return true; - return false; - } - - /** - * Return the first component of the statement - * @return The first component - */ - public Term getSubject() { - return components.get(0); - } - - /** - * Return the second component of the statement - * @return The second component - */ - public Term getPredicate() { - return components.get(1); - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/StringLiteral.java b/open-nars/src/com/googlecode/opennars/language/StringLiteral.java deleted file mode 100644 index e881f5b6ada4026557ed5c2e3d4f7826d29bf64e..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/StringLiteral.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.googlecode.opennars.language; - -public class StringLiteral extends Literal { - - public StringLiteral(String string_) { - super(string_); - } - -} diff --git a/open-nars/src/com/googlecode/opennars/language/Tense.java b/open-nars/src/com/googlecode/opennars/language/Tense.java deleted file mode 100644 index 63da1898e608bb3deff5be9d4dcfe6951b119544..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Tense.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Tense.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.main.Memory; - -/** - * Term with temporal relation with "now" - */ -public abstract class Tense extends CompoundTerm { - - protected Tense(String n, ArrayList<Term> arg) { - super(n, arg); - } - - protected Tense(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - public static Term make(Term content, CompoundTerm.TemporalOrder order, Memory memory) { - switch (order) { - case AFTER: - return TenseFuture.make(content, memory); - case WHEN: - return TensePresent.make(content, memory); - case BEFORE: - return TensePast.make(content, memory); - default: - return content; - } - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/TenseFuture.java b/open-nars/src/com/googlecode/opennars/language/TenseFuture.java deleted file mode 100644 index f8ac936daadec759c4aeeabc08b373d11ef615bd..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/TenseFuture.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * TenseFuture.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.*; - -/** - * Future tense of a Statement. - */ -public class TenseFuture extends Tense { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private TenseFuture(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private TenseFuture(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a SetExt - */ - public Object clone() { - return new TenseFuture(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound. Called by StringParser. - * @return the Term generated from the arguments - * @param argument The list of components - */ - public static Term make(ArrayList<Term> argument, Memory memory) { - if (argument.size() != 1) - return null; - Term t = argument.get(0); - if (t instanceof TenseFuture) - return t; - if (t instanceof TensePast) - return null; - if (t instanceof TensePresent) - t = ((CompoundTerm) t).componentAt(0); - String name = makeCompoundName(Symbols.FUTURE_OPERATOR, argument); - t = memory.nameToListedTerm(name); - return (t != null) ? t : new TenseFuture(name, argument); - } - - /** - * Try to make a compound of one component. Called by the inference rules. - * @param t The compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term t, Memory memory) { - ArrayList<Term> argument = new ArrayList<Term>(); - argument.add(t); - return make(argument, memory); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.FUTURE_OPERATOR; - } - - public CompoundTerm.TemporalOrder getTemporalOrder() { - return CompoundTerm.TemporalOrder.AFTER; - } -} \ No newline at end of file diff --git a/open-nars/src/com/googlecode/opennars/language/TensePast.java b/open-nars/src/com/googlecode/opennars/language/TensePast.java deleted file mode 100644 index 48c6cd1e41f04d139f5c086552b8871bb3d9cd45..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/TensePast.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * TensePast.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.*; - -/** - * Past tense of a Statement. - */ -public class TensePast extends Tense { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private TensePast(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private TensePast(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a SetExt - */ - public Object clone() { - return new TensePast(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound. Called by StringParser. - * @return the Term generated from the arguments - * @param argument The list of components - */ - public static Term make(ArrayList<Term> argument, Memory memory) { - if (argument.size() != 1) - return null; - Term t = argument.get(0); - if (t instanceof TensePast) - return t; - if (t instanceof TenseFuture) - return null; - if (t instanceof TensePresent) - t = ((CompoundTerm) t).componentAt(0); - String name = makeCompoundName(Symbols.PAST_OPERATOR, argument); - t = memory.nameToListedTerm(name); - return (t != null) ? t : new TensePast(name, argument); - } - - /** - * Try to make a compound of one component. Called by the inference rules. - * @param t The compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term t, Memory memory) { - ArrayList<Term> argument = new ArrayList<Term>(); - argument.add(t); - return make(argument, memory); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.PAST_OPERATOR; - } - - public CompoundTerm.TemporalOrder getTemporalOrder() { - return CompoundTerm.TemporalOrder.BEFORE; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/TensePresent.java b/open-nars/src/com/googlecode/opennars/language/TensePresent.java deleted file mode 100644 index 038f926399b4693999966fc665d40982fb707605..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/TensePresent.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * TensePresent.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.*; - -/** - * Present tense of a Statement. - */ -public class TensePresent extends Tense { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private TensePresent(String n, ArrayList<Term> arg) { - super(n, arg); - } - - /** - * constructor with full values, called by clone - * @param cs component list - * @param open open variable list - * @param closed closed variable list - * @param i syntactic complexity of the compound - * @param n The name of the term - */ - private TensePresent(String n, ArrayList<Term> cs, ArrayList<Variable> open, ArrayList<Variable> closed, short i) { - super(n, cs, open, closed, i); - } - - /** - * override the cloning methed in Object - * @return A new object, to be casted into a SetExt - */ - public Object clone() { - return new TensePresent(name, (ArrayList<Term>) cloneList(components), - (ArrayList<Variable>) cloneList(openVariables), (ArrayList<Variable>) cloneList(closedVariables), complexity); - } - - /** - * Try to make a new compound. Called by StringParser. - * @return the Term generated from the arguments - * @param argument The list of components - */ - public static Term make(ArrayList<Term> argument, Memory memory) { - if (argument.size() != 1) - return null; - Term t = argument.get(0); - if ((t instanceof TensePresent) || (t instanceof TensePast) || (t instanceof TenseFuture)) - return t; - String name = makeCompoundName(Symbols.PRESENT_OPERATOR, argument); - t = memory.nameToListedTerm(name); - return (t != null) ? t : new TensePresent(name, argument); - } - - /** - * Try to make a compound of one component. Called by the inference rules. - * @param t The compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term t, Memory memory) { - ArrayList<Term> argument = new ArrayList<Term>(); - argument.add(t); - return make(argument, memory); - } - - /** - * get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.PRESENT_OPERATOR; - } - - public CompoundTerm.TemporalOrder getTemporalOrder() { - return CompoundTerm.TemporalOrder.WHEN; - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/Term.java b/open-nars/src/com/googlecode/opennars/language/Term.java deleted file mode 100644 index 96e4e33337818c3d18273904d746917d182a16cd..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Term.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Term.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.inference.SyllogisticRules; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.Symbols; -import com.googlecode.opennars.parser.TermVisitor; - -/** - * Term is the basic component of Narsese, and the object of processing in NARS. - * <p> - * A Term may or may not have an associated Concept containing relations with other Terms. It - * is not linked in the Term, because a Concept may be forgot, while the Term exists. - */ -public class Term implements Cloneable, Comparable<Term> { - /** - * A Term is identified uniquely by its name, a sequence of characters in a given alphabet. - */ - protected String name; // name of the term, an ASCII string (can be changed to Unicode) - - /** - * Default constructor - */ - protected Term() {} - - /** - * Constructor with a given name - * @param name A String as the name of the Term - */ - public Term(String name) { - this.name = name; - } - - /** - * The same as getName, used in display. - * @return The name of the term as a String - */ - public final String toString() { - return name; - } - - /** - * Reporting the name of the current Term. - * @return The name of the term as a String - */ - public String getName() { - return name; - } - - /** - * Default, to be overrided in variable Terms. - * @return The name of the term as a String - */ - public String getConstantName() { - return name; - } - - /** - * Make a new Term with the same name. - * @return The new Term - */ - public Object clone() { - return new Term(name); - } - - /** - * Equal terms have identical name, though not necessarily the same reference. - * @return Whether the two Terms are equal - * @param that The Term to be compared with the current Term - */ - public boolean equals(Object that) { - return (that instanceof Term) && getName().equals(((Term) that).getName()); - } - - /** - * The default complexity, for constant automic Term, is 1. - * @return The conplexity of the term, an integer - */ - public int getComplexity() { - return 1; - } - - /** - * Check the relative order of two Terms. - * @param that The Term to be compared with the current Term - * @return The same as compareTo as defined on Strings when the constant parts are compared - */ - public final int compareTo(Term that) { - int i = this.getConstantName().compareTo(that.getConstantName()); // based on the constant part first - return (i != 0) ? i : this.getName().compareTo(that.getName()); - } - - /** - * Check whether the current Term can name a Concept. - * @return a Term is constant by default - */ - public boolean isConstant() { - return true; - } - - public CompoundTerm.TemporalOrder getTemporalOrder() { - return CompoundTerm.TemporalOrder.NONE; - } - - public final boolean containQueryVariable() { // to be revised - return (name.indexOf(Symbols.QUERY_VARIABLE_TAG) >= 0); - } - - /** - * Accept a visitor - * @param <R> Return type - * @param <A> Argument type - * @param v Visitor - * @param arg Argument - * @return an instance of the return type - */ - public <R,A> R accept(TermVisitor<R,A> v, A arg) { - return v.visit(this, arg); - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/URIRef.java b/open-nars/src/com/googlecode/opennars/language/URIRef.java deleted file mode 100644 index f88b24aaa177705053cbbafca2cbc4a1b5851927..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/URIRef.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.googlecode.opennars.language; - -import java.net.URI; - -public class URIRef extends Term { - - private URI uri; - - public URIRef(URI uri2) { - super(uri2.toString().trim()); - uri = uri2; - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.language.Term#getConstantName() - */ - @Override - public String getConstantName() { - return uri.toString().trim(); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.language.Term#getName() - */ - @Override - public String getName() { - return uri.toString().trim(); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.language.Term#clone() - */ - @Override - public Object clone() { - return new URIRef(uri); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/language/Variable.java b/open-nars/src/com/googlecode/opennars/language/Variable.java deleted file mode 100644 index 35f2eb2ba1a7c2d2587891b4f218636ded3a1c6d..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/Variable.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Variable.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.language; - -import java.util.*; - -import com.googlecode.opennars.parser.Symbols; - -/** - * A variable term. - */ -public class Variable extends Term { - public enum VarType { INDEPENDENT, DEPENDENT, ANONYMOUS, QUERY } - - private CompoundTerm scope; - private VarType type; - - public Variable() { - super(); - } - - public Variable(String s) { - name = s; - scope = null; - char prefix = s.charAt(0); - if (prefix == Symbols.QUERY_VARIABLE_TAG) - type = VarType.QUERY; - else if (s.length() == 1) - type = VarType.ANONYMOUS; - else if (s.charAt(s.length()-1) == Symbols.COMPOUND_TERM_CLOSER) { - type = VarType.DEPENDENT; - int i = s.indexOf(Symbols.COMPOUND_TERM_OPENER); - name = s.substring(0, i); // ignore the dependency list - } else - type = VarType.INDEPENDENT; - } - - private Variable(String n, CompoundTerm s, VarType t) { - name = n; - scope = s; - type = t; - } - - /** - * Make a new Variable with the same name and type. - * @return The new Variable - */ - public Object clone() { - return new Variable(name, scope, type); - } - - // overwrite default, to be omitted in sorting - public String getConstantName() { - return ("" + Symbols.VARIABLE_TAG); - } - - /** - * Rename a variable temporally to distinguish it from variables in other Terms - * @param first Whether it is the first term - * @return The new name - */ - public String getVarName(boolean first) { - if (first) - return Symbols.VARIABLE_TAG + "1" + name; - else - return Symbols.VARIABLE_TAG + "2" + name; - } - - public void setName(String n) { - name = n; - } - - public CompoundTerm getScope() { - return scope; - } - - public void setScope(CompoundTerm s) { - scope = s; - } - - public VarType getType() { - return type; - } - - public void setType(VarType t) { - type = t; - } - - public boolean equals(Object that) { - return (that instanceof Variable) && name.equals(((Variable) that).getSimpleName()); - } - - public String getSimpleName() { - return name; - } - - public String getName() { - if (type != VarType.DEPENDENT) - return name; - else { - StringBuffer buffer = new StringBuffer(name + "("); - if (scope != null) { - ArrayList<Variable> dependency = scope.getOpenVariables(); - if (dependency != null) { - for (Variable v : dependency) - if (v.getType() == VarType.INDEPENDENT) - buffer.append(v.toString()); - } - } - buffer.append(")"); - return buffer.toString(); - } - } - - public boolean isConstant() { - return false; // overridding default - } - - // move to RuleTable? the last two arguments must be clones - /** - * To unify two Terms, then apply the substitution to the two compounds - * @param type The type of Variable to be unified - * @param t1 The first Term to be unified - * @param t2 The second Term to be unified - * @param compound1 The first compound to be substituted - * @param compound2 The second compound to be substituted - * @return Whether a unification has been succeeded - */ - public static boolean unify(VarType type, Term t1, Term t2, Term compound1, Term compound2) { - if (t1.isConstant() && t1.equals(t2)) // to constant Terms are unified if equals - return true; - if (!(compound1 instanceof CompoundTerm) || !(compound2 instanceof CompoundTerm)) - return false; - HashMap<String,Term> substitute = findSubstitute(type, t1, t2, new HashMap<String,Term>()); // find substitution - if (substitute == null) // not unifiable - return false; - if (!substitute.isEmpty()) { - ((CompoundTerm) compound1).substituteComponent(substitute, true); // apply the substitution to the first compound - ((CompoundTerm) compound2).substituteComponent(substitute, false); // apply the substitution to the second compound - } - return true; - } - - - public static HashMap<String,Term> findSubstitute(VarType type, Term term1, Term term2) { - return findSubstitute(type, term1, term2, new HashMap<String,Term>()); - } - - /** - * To find a substitution that can unify two Terms without changing them - * @param type The type of Variable to be substituted - * @param term1 The first Term to be unified - * @param term2 The second Term to be unified - * @param subs The substitution formed so far - * @return The substitution that unifies the two Terms - */ - private static HashMap<String,Term> findSubstitute(VarType type, Term term1, Term term2, HashMap<String,Term> subs) { - Term oldValue, t1, t2; - if (term1.equals(term2)) // for constant, also shortcut for variable and compound - return subs; - if ((term1 instanceof Variable) && (((Variable) term1).getType() == type)) // the first Term is a unifiable Variable - return findSubstituteVar(type, (Variable) term1, term2, subs, true); - if ((term2 instanceof Variable) && (((Variable) term2).getType() == type)) // the second Term is a unifiable Variable - return findSubstituteVar(type, (Variable) term2, term1, subs, false); - if (term1 instanceof CompoundTerm) { - if (!term1.getClass().equals(term2.getClass())) // two compounds must be of the same type to be unified - return null; - if (!(((CompoundTerm) term1).size() == ((CompoundTerm) term2).size())) // two compounds must be of the same size, too - return null; - for (int i = 0; i < ((CompoundTerm) term1).size(); i++) { // recursively unify components - t1 = ((CompoundTerm) term1).componentAt(i); - t2 = ((CompoundTerm) term2).componentAt(i); - HashMap<String,Term> newSubs = findSubstitute(type, t1, t2, subs); - if (newSubs == null) // fails in one component means no substitution - return null; - subs.putAll(newSubs); // put new mappings into the table - } - return subs; // solve: <x,x,2> and <y,3,y> - } - return null; - } - - /** - * To find a substitution that can unify a Vriable and a Term - * @param type The type of Variable to be substituted - * @param var The Variable to be unified - * @param term The Term to be unified - * @param subs The substitution formed so far - * @param first If it is the first Term in unify - * @return The substitution that unifies the two Terms, as "name-term" pairs - */ - private static HashMap<String,Term> findSubstituteVar(VarType type, Variable var, Term term, HashMap<String,Term> subs, boolean first) { - String name1 = var.getVarName(first); // make a prefixed name for the avriable - Term oldTerm = subs.get(name1); // check if a mapping for that name exist - if (oldTerm != null) { // processed variable - if (first) - return findSubstitute(type, oldTerm, term, subs); - else - return findSubstitute(type, term, oldTerm, subs); - } else { // novel variable - if (term instanceof Variable) { // the other is also a variable - String name2 = ((Variable) term).getVarName(!first); - oldTerm = subs.get(name2); - if (oldTerm != null) { // if the other has a substitute - if (first) - return findSubstitute(type, var, oldTerm, subs); - else - return findSubstitute(type, oldTerm, var, subs); - } - } - subs.put(name1, term); // check dependency for dependent variable!!! - return subs; - } - } -} diff --git a/open-nars/src/com/googlecode/opennars/language/package.html b/open-nars/src/com/googlecode/opennars/language/package.html deleted file mode 100644 index 4fb4628b371d496d1e8ff4076b32be12470040df..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/language/package.html +++ /dev/null @@ -1,71 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<body bgcolor="white"> - -Terms in Narsese, a formal language - -<h2>Package Specification</h2> - -NARS 4.3 implements the following formal language, Narsese. -<pre> - <sentence> ::= <judgment> - | <question> - | <goal> - <judgment> ::= <statement> <truth-value> - <question> ::= <statement> - <goal> ::= <statement> <desire-value> - <statement> ::= <<term> <relation> <term>> - | <compound-statement> - | <term> - <term> ::= <word> - | <variable> - | <compound-term> - | <statement> - <relation> ::= --> - | <-> - | {-- - | --] - | {-] - | ==> - | <=> - | =/> - | =\> - | </> - <compound-statement> ::= (-- <statement>) - | (|| <statement> <statement><sup>+</sup>) - | (&& <statement> <statement><sup>+</sup>) - | (&/ <statement> <statement><sup>+</sup>) - | (/> <statement>) - | (\> <statement>) - <compound-term> ::= {<term><sup>+</sup>} - | [<term><sup>+</sup>] - | (& <term> <term><sup>+</sup>) - | (| <term> <term><sup>+</sup>) - | (- <term> <term>) - | (~ <term> <term>) - | (* <term> <term><sup>+</sup>) - | (/ <term><sup>+</sup> _ <term><sup>*</sup>) - | (\ <term><sup>+</sup> _ <term><sup>*</sup>) - <variable> ::= <dependent-var> - | <independent-var> - | <query-var> - <dependent-var> ::= #<word>(<independent-var><sup>*</sup>) - <independent-var> ::= #<word> - <query-var> ::= ?<word> - <word> : string in an alphabet - <truth-value> : a pair of real numbers in [0, 1] x (0, 1) - <desire-value> : a pair of real numbers in [0, 1] x (0, 1) -</pre> - -Major methods in the term classes: -<ul> -<li>constructors</li> -<li>get and set</li> -<li>clone, compare, and unify</li> -<li>create and access corresponding concept</li> -<li>structural operation in compound</li> -<li>class-specific inference</li> -</ul> - -</body> -</html> diff --git a/open-nars/src/com/googlecode/opennars/main/Memory.java b/open-nars/src/com/googlecode/opennars/main/Memory.java deleted file mode 100644 index 5c73d4de15952729dd9bafe1caee251724edc3cc..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/main/Memory.java +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Memory.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.main; - -import java.util.*; - -import com.googlecode.opennars.entity.*; -import com.googlecode.opennars.inference.*; -import com.googlecode.opennars.language.*; -import com.googlecode.opennars.operation.Operator; -import com.googlecode.opennars.parser.*; -import com.googlecode.opennars.parser.narsese.NarseseParser; -import com.googlecode.opennars.storage.*; - -/** - * The memory of the system. - */ -public class Memory extends Observable { - - private Parameters parameters; - private RuleTables ruletables; - public BudgetFunctions budgetfunctions; - - /* ---------- all members have limited space ---------- */ - - /** - * Concept bag. Containing all Concepts of the system. - */ - private ConceptBag concepts; - - /** - * Operators (built-in terms) table. Accessed by name. - */ - private HashMap<String, Operator> operators; - - // There is no global Term table, which may ask for unlimited space. - - /** - * List of inference newTasks, to be processed in the next working cycle. - */ - private ArrayList<Task> newTasks; - - /** - * New tasks to be processed in the near future. - */ - private TaskBag taskBuffer; - - /* ---------- global variables used to reduce method arguments ---------- */ - - /** - * Shortcut to the selected Term. - */ - public Term currentTerm; - - /** - * Shortcut to the selected TaskLink. - */ - public TaskLink currentTaskLink; - - /** - * Shortcut to the selected Task. - */ - public Task currentTask; - - /** - * Shortcut to the selected TermLink. - */ - public TermLink currentBeliefLink; - - /** - * Shortcut to the selected belief (Sentence). - */ - public Judgement currentBelief; - - public Base currentBase; - - /* ---------- initialization ---------- */ - - /** - * Initialize a new memory by creating all members. - * <p> - * Called in Center.reset only - */ - public Memory() { - init(); - ruletables = new RuleTables(this); - budgetfunctions = new BudgetFunctions(this); - } - - public void reset() { - init(); - } - - private void init() { - concepts = new ConceptBag(); // initially empty - newTasks = new ArrayList<Task>(); // initially empty - taskBuffer = new TaskBag(); // initially empty - operators = Operator.setOperators(); // with operators created - parameters = new Parameters(); - } - - /* ---------- access utilities ---------- */ - - /** - * Get a Term for a given name of a Concept or Operator, called in StringParser and the make methods of compound terms. - * @param name the name of a concept or operator - * @return a Term or null (if no Concept/Operator has this name) - */ - public Term nameToListedTerm(String name) { - Concept concept = concepts.get(name); - if (concept != null) - return concept.getTerm(); // Concept associated Term - return operators.get(name); - } - - /** - * Check if a string is an operator name, called in StringParser only. - * @param name the name of a possible operator - * @return the corresponding operator or null - */ - public Operator nameToOperator(String name) { - return operators.get(name); - } - - /** - * Add a new operator with the given name - * @param op the operator - * @param name the operator's name. Should begin with ^. - */ - public void addOperatorWithName(Operator op, String name) { - operators.put(name, op); - } - - /** - * Remove the operator with the given name - * @param name the operator's name - */ - public void removeOperatorWithName(String name) { - operators.remove(operators.get(name)); - } - - /** - * Return the parameters of this reasoner - * @return the parameters - */ - public Parameters getParameters() { - return parameters; - } - - /** - * Return an ArrayList of the Concepts this reasoner knows about - * @return the concepts - */ - public ArrayList<Concept> getAllConcepts() { - return this.concepts.getAllContents(); - } - - public HashMap<String,Concept> getConceptMap() { - return this.concepts.getNameTable(); - } - - public Task getCurrentTask() { - return this.currentTask; - } - - /** - * Return an ArrayList of the Tasks this reasoner is working on - * @return the tasks - */ - public ArrayList<Task> getAllTasks() { - return this.taskBuffer.getAllContents(); - } - - /** - * @return the ruletables - */ - public RuleTables getRuletables() { - return ruletables; - } - - /** - * Get an existing Concept for a given name, called from Term and ConceptWindow. - * @param name the name of a concept - * @return a Concept or null - */ - public Concept nameToConcept(String name) { - return concepts.get(name); - } - - /** - * Get an existing Concept for a given Term. - * @param term The Term naming a concept - * @return a Concept or null - */ - public Concept termToConcept(Term term) { - return nameToConcept(term.getName()); - } - - /** - * Get the Concept associated to a Term, or creat it. - * @param term indicating the concept - * @return an existing Concept, or a new one - */ - public Concept getConcept(Term term) { - String n = term.getName(); - Concept concept = concepts.get(n); - if (concept == null) - concept = new Concept(term, this); // the only place to make a new Concept - return concept; - } - - /** - * Adjust the activation level of a Concept or Operator, called in Concept only. - * @param c the concept to be adusted - * @param b the new BudgetValue - */ - public void activateConcept(Concept c, BudgetValue b) { - BudgetValue budget; - if (concepts.contains(c)) { // listed Concept - concepts.pickOut(c.getKey()); - this.budgetfunctions.activate(c, b); - concepts.putBack(c); - } else { // new Concept - this.budgetfunctions.activate(c, b); - concepts.putIn(c); - } - } - - /* ---------- new task entries ---------- */ - - // There are three types of new tasks: (1) input, (2) derived, (3) activated - // They are all added into the newTasks list, to be processed in the next cycle. - // Some of them are reported and/or logged. - - /** - * Input task comes from the InputWindow. - * @param str the input line - */ - public void inputStringWithParser(String str, Parser parser) throws InvalidInputException { - Task task = parser.parseTask(str, this); // the only place to call StringParser - if (task != null) { - if (task.aboveThreshold()) { // set a threshold? - report(task.getSentence(), true); // report input - newTasks.add(task); // wait to be processed in the next cycle - } - } - } - - /** - * Input task from some source - * @param task the task to add - */ - public void inputTask(Task task) { - if (task != null) { - if (task.aboveThreshold()) { // set a threshold? - report(task.getSentence(), true); // report input - newTasks.add(task); // wait to be processed in the next cycle - } - } - } - - /** - * Derived task comes from the inference rules. - * @param task the derived task - */ - private void derivedTask(Task task) { - if (task.aboveThreshold()) { - float budget = task.getBudget().singleValue(); - float minSilent = parameters.SILENT_LEVEL / 100.0f; - if (budget > minSilent) - report(task.getSentence(), false); // report significient derived Tasks - newTasks.add(task); - } - } - - /** - * Reporting executed task, called from Concept.directOperation. - * @param task the executed task - */ - public void executedTask(Task task) { // called by the inference rules - float budget = task.getBudget().singleValue(); - float minSilent = parameters.SILENT_LEVEL / 100.0f; - if (budget > minSilent) - report(task.getSentence(), false); - } - - /** - * Activated task comes from MatchingRules. - * @param budget The budget value of the new Task - * @param sentence The content of the new Task - * @param isInput Whether the question is input - */ - public void activatedTask(BudgetValue budget, Sentence sentence, boolean isInput) { - Task task = new Task(sentence, budget, this); - newTasks.add(task); - } - - /* --------------- new task building --------------- */ - - /** - * Shared final operations by all double-premise rules, called from the rules except StructuralRules - * @param budget The budget value of the new task - * @param content The content of the new task - * @param truth The truth value of the new task - */ - public void doublePremiseTask(BudgetValue budget, Term content, TruthValue truth) { - Sentence newSentence = Sentence.make(currentTask.getSentence(), content, truth, this.currentBase, this); - Task newTask = new Task(newSentence, budget, this); - derivedTask(newTask); - } - - /** - * Shared final operations by all single-premise rules, called in StructuralRules - * @param budget The budget value of the new task - * @param content The content of the new task - * @param truth The truth value of the new task - */ - public void singlePremiseTask(BudgetValue budget, Term content, TruthValue truth) { - Sentence sentence = currentTask.getSentence(); - Sentence newSentence = Sentence.make(sentence, content, truth, sentence.getBase(), this); - Task newTask = new Task(newSentence, budget, this); - newTask.setStructual(); - derivedTask(newTask); - } - - /** - * Shared final operations by all single-premise rules, called in MatchingRules - * @param budget The budget value of the new task - * @param truth The truth value of the new task - */ - public void singlePremiseTask(TruthValue truth, BudgetValue budget) { - Term content = this.currentTask.getContent(); - Base base = this.currentBelief.getBase(); - Sentence newJudgment = Sentence.make(content, Symbols.JUDGMENT_MARK, truth, base, this); - Task newTask = new Task(newJudgment, budget, this); - newTask.setStructual(); - derivedTask(newTask); - } - - /* ---------- system working cycle ---------- */ - - /** - * An atomic working cycle of the system. Called from Center only. - */ - public void cycle() { - processTask(); // tune relative frequency? - processConcept(); // use this order to check the new result - } - - /** - * Process the newTasks accumulated in the previous cycle, accept input ones - * and those that corresponding to existing concepts, plus one from the buffer. - */ - private void processTask() { - Task task; - int counter = newTasks.size(); // don't include new tasks produced in the current cycle - while (counter-- > 0) { // process the newTasks of the previous cycle - task = (Task) newTasks.remove(0); - if (task.getSentence().isInput() || (termToConcept(task.getContent()) != null)) // new input or existing concept - immediateProcess(task); // immediate process - else - taskBuffer.putIn(task); // postponed process - } - task = (Task) taskBuffer.takeOut(); // select a task from taskBuffer - if (task != null) - immediateProcess(task); // immediate process - } - - /** - * Select a concept to fire. - */ - private void processConcept() { - Concept currentConcept = (Concept) concepts.takeOut(); - if (currentConcept != null) { - currentTerm = currentConcept.getTerm(); - concepts.putBack(currentConcept); // current Concept remains in the bag all the time - currentConcept.fire(); // a working cycle - } - } - - /* ---------- task / belief insertion ---------- */ - - /** - * Imediate processing of a new task - * @param task the task to be accepted - */ - private void immediateProcess(Task task) { - Term content = task.getContent(); - if (content.isConstant()) { // does not creat concept for Query? - Concept c = getConcept(content); - c.directProcess(task); - } - if (task.aboveThreshold()) - continuedProcess(task, content); - } - - /** - * Link to a new task from all relevant concepts for distributed processing. - * @param task The task to be linked - * @param content The content of the task - */ - private void continuedProcess(Task task, Term content) { - TaskLink tLink; - Concept c1 = null; // local Concept - BudgetValue budget = task.getBudget(); - if (content.isConstant()) { - c1 = getConcept(content); - tLink = new TaskLink(task, null, budget, this); // link type SELF - c1.insertTaskLink(tLink); - } - if (content instanceof CompoundTerm) { - Term component; // component term - Concept c2; // component concept - TermLink cLink1, cLink2; // a pair of compound/component links - ArrayList<TermLink> cLinks; // link list - cLinks = (c1 != null) ? c1.getTermLinks() : ((CompoundTerm) content).prepareComponentLinks(this); // use saved - short[] indices; - BudgetValue subBudget = this.budgetfunctions.distributeAmongLinks(budget, cLinks.size()); - if (!subBudget.aboveThreshold()) - return; - for (TermLink cLink0 : cLinks) { - component = cLink0.getTarget(); - c2 = getConcept(component); - if (!(task.isStructual() && (cLink0.getType() == TermLink.TRANSFORM))) { - tLink = new TaskLink(task, cLink0, subBudget, this); - c2.insertTaskLink(tLink); // component link to task - } - } - } - } - - /* ---------- report ---------- */ - - /** - * Display selected task. - * @param sentence the sentence to be displayed - * @param input whether the task is input - */ - public void report(Sentence sentence, boolean input) { - this.setChanged(); - notifyObservers(sentence); - } -} diff --git a/open-nars/src/com/googlecode/opennars/main/Parameters.java b/open-nars/src/com/googlecode/opennars/main/Parameters.java deleted file mode 100644 index 2657b700a1e315b22b29da0dd1a0e4e6ce1b3d42..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/main/Parameters.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Parameters.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.main; - -/** - * Collected system parameters. To be modified before compiling. - */ -public class Parameters { - - /* ---------- initial values of run-time adjustable parameters ---------- */ - - /** Concept decay rate, in [1, 99]. */ - public static final int CONCEPT_DEFAULT_FORGETTING_CYCLE = 3; - /** TaskLink decay rate, in [1, 99]. */ - public static final int TASK_DEFAULT_FORGETTING_CYCLE = 10; - /** CompositionLink decay rate, in [1, 99]. */ - public static final int BELIEF_DEFAULT_FORGETTING_CYCLE = 50; - - /** Silent threshold for task reporting, in [0, 100]. */ - public int SILENT_LEVEL = 100; - - /* ---------- parameters fixed after compiling --- logical ---------- */ - - /** Horizon, the amount of evidence coming in the near future. */ - public static final int NEAR_FUTURE = 1; // or 2, can be float - - /** Default confidence of input judgment. */ - public float DEFAULT_JUDGMENT_CONFIDENCE = (float) 0.9; // ? - - /* Default priority and durability of input judgment */ - public final float DEFAULT_JUDGMENT_PRIORITY = (float) 0.8; - public final float DEFAULT_JUDGMENT_DURABILITY = (float) 0.8; - public final float DEFAULT_GOAL_PRIORITY = (float) 0.9; - public final float DEFAULT_GOAL_DURABILITY = (float) 0.7; - public final float DEFAULT_QUESTION_PRIORITY = (float) 0.9; - public final float DEFAULT_QUESTION_DURABILITY = (float) 0.7; - -// public final float TASK_FOR_NEW_CONCEPT_DISCOUNT = (float) 0.2; // ? - - // belief component priority rate - public final float DEFAULT_COMPONENT_PRIORITY_RATE = (float) 0.7; - - /** - * Level granularity in Bag, two digits - */ - public static final int BAG_LEVEL = 100; - /** - * Level separation in Bag, one digit, both for display (run-time adjustable) and management (fixed) - */ - public static final int BAG_THRESHOLD = 10; - - /* ---------- parameters fixed after compiling --- time management ---------- */ - - // time distribution - public static final int COLD_TASK_DELAY_STEPS = 10; // ? - - // decay rate, within 100 - public static final int NEW_TASK_DEFAULT_FORGETTING_CYCLE = 1; // ? - - // quality updating rate - public static final float DEFAULT_QUALITY_UPDATE_RATE = (float) 0.01; // percent of updating - - // maximum bLinks tried for each tLink (to avoid repeated inference) - public static final int MAX_TAKE_OUT_K_LINK = 10; - - // maximum belief tried for each task (to avoid overlapping evidence) - public static final int MAX_TAKE_OUT_BELIEF = 5; - - /* ---------- parameters fixed after compiling --- space management ---------- */ - - // bag size - public static final int CONCEPT_BAG_SIZE = 1000; // vocabulary? - public static final int TASK_BUFFER_SIZE = 20; // "7+-2"? - public static final int TASK_BAG_SIZE = 20; // ? - public static final int BELIEF_BAG_SIZE = 100; // ? - - // other storage size - public static final int MAXMUM_LABEL_RECORD_LENGTH = 16; // should be pow(2,n) - public static final int TASK_INFERENCE_RECORD_LENGTH = 20; // ? - public static final int MAXMUM_BELIEF_LENGTH = 8; // duplicate links - public static final int MAXMUM_GOALS_LENGTH = 5; // duplicate links - - public static final float LOAD_FACTOR = 0.5f; // bag hashtable parameter -} diff --git a/open-nars/src/com/googlecode/opennars/main/Reasoner.java b/open-nars/src/com/googlecode/opennars/main/Reasoner.java deleted file mode 100644 index 99cda6a075b232d66c2027a8c5861aadffc96ec4..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/main/Reasoner.java +++ /dev/null @@ -1,249 +0,0 @@ -/** - * - */ -package com.googlecode.opennars.main; - -import java.util.ArrayList; -import java.util.Observable; -import java.util.Observer; - -import com.googlecode.opennars.entity.BudgetValue; -import com.googlecode.opennars.entity.Concept; -import com.googlecode.opennars.entity.Sentence; -import com.googlecode.opennars.entity.Task; -import com.googlecode.opennars.operation.Operator; -import com.googlecode.opennars.parser.InvalidInputException; -import com.googlecode.opennars.parser.Parser; -import com.googlecode.opennars.parser.narsese.NarseseParser; - -/** - * The Reasoner class implements a threaded NARS reasoner. - * @author jgeldart - * - */ -public class Reasoner extends Observable implements Observer, Runnable { - - private Thread thread; - private Memory memory; - private Parser parser; - private ArrayList<Task> inputQueue; - - /** - * Create a new reasoner using default settings - */ - public Reasoner() { - parser = new NarseseParser(); - memory = new Memory(); - memory.addObserver(this); - inputQueue = new ArrayList<Task>(); - } - - /** - * Creates a new reasoner with the given string parser - * @param parser - */ - public Reasoner(Parser parser) { - this(); - this.parser = parser; - } - - /** - * Start the reasoner thread - */ - public void start() { - if(thread == null) { - thread = new Thread(this); - thread.start(); - } - } - - /** - * Stop the reasoner thread - */ - public void stop() { - thread = null; - } - - /** - * Perform a single reasoning step - */ - public void step() { - try { - Task task = this.getTask(); - if(task != null) - memory.inputTask(task); - memory.cycle(); - } catch (Exception e) { - if(e instanceof InvalidInputException) { - this.hasChanged(); - this.notifyObservers(e); - } - else { - //System.err.println(e.toString()); - e.printStackTrace(); - } - } - } - - /** - * Reset the reasoner back to 'factory defaults' - */ - public void reset() { - memory.reset(); - } - - /* ----- communicating ----- */ - - /** - * Tell the reasoner a sentence string which is parsed using the chosen parser - * @param sent the sentence - */ - public synchronized void tellSentenceString(String sent) { - try { - Task task = parser.parseTask(sent, memory); - inputQueue.add(task); - } - catch (InvalidInputException e) { - this.setChanged(); - this.notifyObservers(e); - } - } - - /** - * Tell the reasoner a task - * @param task the task - */ - public synchronized void tellTask(Task task) { - inputQueue.add(task); - } - - /** - * Tell the reasoner a sentence with the given budget for working with it - * @param sent the sentence - * @param budget the budget - */ - public synchronized void tellSentence(Sentence sent, BudgetValue budget) { - Task task = new Task(sent, budget, memory); - inputQueue.add(task); - } - - /** - * Tell the reasoner a sentence with the given priority, durability and quality needed - * to allocate resources to the task - * @param sent the sentence - * @param priority the priority - * @param durability the durability - * @param quality the quality - */ - public synchronized void tellSentence(Sentence sent, float priority, float durability, float quality) { - Task task = new Task(sent, new BudgetValue(priority, durability, quality, memory), memory); - inputQueue.add(task); - } - - private synchronized Task getTask() { - try { - return inputQueue.remove(0); - } - catch (IndexOutOfBoundsException e) { - return null; - } - } - - /* ----- setters and getters ----- */ - - /** - * Get the memory - */ - public Memory getMemory() { - return memory; - } - - /** - * Returns the parser used to parse sentence strings - * @return the parser - */ - public Parser getParser() { - return parser; - } - - /** - * Set the parser used to parse sentence strings - * @param parser the parser - */ - public void setParser(Parser parser) { - this.parser = parser; - } - - /** - * Get the reasoner's parameters - * @return the parameters - */ - public Parameters getParameters() { - return memory.getParameters(); - } - - /** - * Get all the concepts this reasoner currently knows about - * @return the concepts - */ - public ArrayList<Concept> getConcepts() { - return memory.getAllConcepts(); - } - - /** - * Get all the tasks this reasoner currently knows about - * @return the tasks - */ - public ArrayList<Task> getTasks() { - return memory.getAllTasks(); - } - - /** - * Get the current reasoning task - * @return the task - */ - public Task getCurrentTask() { - return memory.getCurrentTask(); - } - - /** - * Fetch the operator with the given name - * @param name the operator's name - * @return the operator - */ - public Operator getOperatorWithName(String name) { - return memory.nameToOperator(name); - } - - /** - * Add the operator with the given name - * @param op the operator - * @param name the name - */ - public void addOperatorWithName(Operator op, String name) { - memory.addOperatorWithName(op, name); - } - - /* ------ internals ------ */ - - /* (non-Javadoc) - * @see java.util.Observer#update(java.util.Observable, java.lang.Object) - */ - public void update(Observable o, Object arg) { - this.setChanged(); - this.notifyObservers(arg); - } - - public void run() { - Thread thisThread = Thread.currentThread(); - while(thread == thisThread) { - try { - Thread.sleep(10); - } catch (InterruptedException e) { - - } - step(); - } - } - -} diff --git a/open-nars/src/com/googlecode/opennars/main/package.html b/open-nars/src/com/googlecode/opennars/main/package.html deleted file mode 100644 index e2da9b9a4a7d0ca465462dede2e9eb7d766be9f8..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/main/package.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<body bgcolor="white"> - -Top-level classes of the system - -<h2>Package Specification</h2> - -This package contains the top classes of the system. -<p> -<tt>NARS</tt> defines the application and applet. When NARS runs as an applet, it is for demonstration only, and certain functionalities are blocked. -<p> -<tt>Parameters</tt> collects all system parameters, which can be edited before compiling. -<p> -<tt>Memory</tt> maintains the work space of the system, including -<ul> -<li>a bag of concept,</li> -<li>a look-up table of all built-in operators,</li> -<li>a queue for new results to be processed in each cycle,</li> -<li>a task buffer for new results to be processed in the future.</li> -</ul> -Each of the above occupies constant space. -<p> -Memory and all of its variables are static, so each is unique, and can be referred by name anywhere in the system. - -</body> -</html> diff --git a/open-nars/src/com/googlecode/opennars/operation/GoTo.java b/open-nars/src/com/googlecode/opennars/operation/GoTo.java deleted file mode 100644 index d222204ad7faeca87182182508e799ce13f67948..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/operation/GoTo.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * GoTo.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.operation; - -import java.io.*; - -import com.googlecode.opennars.entity.Task; - -/** - * A class used in testing only. - */ -public class GoTo extends Operator { - public GoTo(String name) { - super(name); - } - - public Object execute(Task task) { - System.out.println("EXECUTE in " + name + " " + task); - return null; - } -} - diff --git a/open-nars/src/com/googlecode/opennars/operation/Open.java b/open-nars/src/com/googlecode/opennars/operation/Open.java deleted file mode 100644 index b6f7bbb5020b7997f6033dbb923def3057baa4e6..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/operation/Open.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Open.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.operation; - -import java.io.*; - -import com.googlecode.opennars.entity.Task; - -/** - * A class used in testing only. - */ -public class Open extends Operator { - public Open(String name) { - super(name); - } - - public Object execute(Task task) { - System.out.println("EXECUTE in " + name + " " + task); - return null; - } -} - - diff --git a/open-nars/src/com/googlecode/opennars/operation/Operator.java b/open-nars/src/com/googlecode/opennars/operation/Operator.java deleted file mode 100644 index 0a394b3842bff45e44e1881a3bfefda0660e5a4d..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/operation/Operator.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Operator.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.operation; - -import java.util.*; -import java.io.*; - -import com.googlecode.opennars.entity.Task; -import com.googlecode.opennars.language.Term; - -/** - * An individual operator that can be execute by the system. - * The only file to modify when adding a new operator into NARS - */ -public abstract class Operator extends Term { - public Operator(String name) { - super(name); - } - - // required method for every operation - public abstract Object execute(Task task); - - // register the operators in the memory - // the only method to modify when adding a new operator into NARS - // an operator should contain at least two characters after "^"" - public static HashMap<String, Operator> setOperators() { - HashMap<String, Operator> table = new HashMap<String, Operator>(); - table.put("^go-to", new GoTo("^go-to")); - table.put("^pick", new Pick("^pick")); - table.put("^open", new Open("^open")); - return table; - } -} - diff --git a/open-nars/src/com/googlecode/opennars/operation/Pick.java b/open-nars/src/com/googlecode/opennars/operation/Pick.java deleted file mode 100644 index fc2c6eaa90e46bfb12362d42aea5561dbcfeec29..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/operation/Pick.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Pick.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.operation; - -import java.io.*; - -import com.googlecode.opennars.entity.Task; - -/** - * A class used in testing only. - */ -public class Pick extends Operator { - public Pick(String name) { - super(name); - } - - public Object execute(Task task) { - System.out.println("EXECUTE in " + name + " " + task); - return null; - } -} diff --git a/open-nars/src/com/googlecode/opennars/operation/package.html b/open-nars/src/com/googlecode/opennars/operation/package.html deleted file mode 100644 index 903b31203a9da4310d4412a2c4cb432c81c6dee0..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/operation/package.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<body bgcolor="white"> - -Built-in operators - -<h2>Package Specification</h2> - -The built-in operator classes are all subclasses of <tt>Operator</tt>, which extends <tt>Term</tt>. -<p> -Each built-in operator must implement a method <tt>execute</tt>, which takes a Task as argument. -<p> -All built-in operators are registered in class <tt>Operator</tt>. - -</body> -</html> diff --git a/open-nars/src/com/googlecode/opennars/overview.html b/open-nars/src/com/googlecode/opennars/overview.html deleted file mode 100644 index 8dbb004da0ae960b0adb15b5ded96c5728325eaf..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/overview.html +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> - <head>NARS</head> - <body bgcolor="white"> - - NARS overview - - <h2>Package Specification</h2> - - The code for distribution is in <tt>NARS.jar</tt>, which works both as an application (full mode) and an applet - (demo mode, with simplified display). - - </body> -</html> diff --git a/open-nars/src/com/googlecode/opennars/parser/InvalidInputException.java b/open-nars/src/com/googlecode/opennars/parser/InvalidInputException.java deleted file mode 100644 index 6b3aa5f2ed9f6c7d20a1c43f6df804c17525d429..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/InvalidInputException.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.googlecode.opennars.parser; - -/** - * An input exception from a NARS parser. - * @author jgeldart - * - */ -public class InvalidInputException extends Exception { - - /** - * Autogenerated serial code - */ - private static final long serialVersionUID = 325617403436238787L; - - public InvalidInputException() { - super("Unknown input error"); - } - - public InvalidInputException(String message) { - super(message); - } - - public InvalidInputException(Throwable cause) { - super(cause); - } - - public InvalidInputException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/Parser.java b/open-nars/src/com/googlecode/opennars/parser/Parser.java deleted file mode 100644 index 6df85085dee9b9f8008fc969c125dd1f2d7d4abb..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/Parser.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.googlecode.opennars.parser; - -import java.util.List; - -import com.googlecode.opennars.entity.Sentence; -import com.googlecode.opennars.entity.Task; -import com.googlecode.opennars.main.Memory; - -public abstract class Parser extends Symbols { - - /** - * Parses a given string into a (single) task. - * @param buffer the single-line input String - * @param memory the memory object doing the parsing - * @return an input Task, or null if the input line cannot be parsed into a Task - * @throws InvalidInputException - */ - public abstract Task parseTask(String input, Memory memory) throws InvalidInputException; - - /** - * Parses a given string into a (list of) tasks. - * @param input - * @param memory - * @return a list of input Tasks, or an empty list if the input line cannot be parsed into a Task - * @throws InvalidInputException - */ - public abstract List<Task> parseTasks(String input, Memory memory) throws InvalidInputException; - - /** - * Serialises the sentence to this parser's format - * @param task - * @param memory - * @return a string containing the serialised task - */ - public abstract String serialiseSentence(Sentence task, Memory memory); - - public abstract String serialiseSentences(List<Sentence> tasks, Memory memory); -} \ No newline at end of file diff --git a/open-nars/src/com/googlecode/opennars/parser/Symbols.java b/open-nars/src/com/googlecode/opennars/parser/Symbols.java deleted file mode 100644 index ecfca3c4f43c3777ae363a54707cfe1a6fed3333..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/Symbols.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Symbols.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.parser; - -import java.awt.*; - -/** - * The ASCII symbols used in I/O. - */ -public class Symbols { - - // sentence delimitors - public static final char JUDGMENT_MARK = '.'; - public static final char QUESTION_MARK = '?'; - public static final char GOAL_MARK = '!'; - - // numerical value delimitors - // must be different from the Term opener/closer pairs - public static final char BUDGET_VALUE_MARK = '$'; - public static final char TRUTH_VALUE_MARK = '%'; - public static final char VALUE_SEPARATOR = ';'; - - // special Term name prefix - public static final char VARIABLE_TAG = '#'; - public static final char QUERY_VARIABLE_TAG = '?'; - public static final char OPERATOR_TAG = '^'; - - // CompountTerm delimitors - // must use 4 different pairs, see CompoundTerm/fromString. - public static final char COMPOUND_TERM_OPENER = '('; - public static final char COMPOUND_TERM_CLOSER = ')'; - public static final char STATEMENT_OPENER = '<'; - public static final char STATEMENT_CLOSER = '>'; - public static final char SET_EXT_OPENER = '{'; - public static final char SET_EXT_CLOSER = '}'; - public static final char SET_INT_OPENER = '['; - public static final char SET_INT_CLOSER = ']'; - - public static final char ARGUMENT_SEPARATOR = ','; - public static final char IMAGE_PLACE_HOLDER = '_'; - - // CompountTerm operators - // length = 1 - public static final String INTERSECTION_EXT_OPERATOR = "&"; - public static final String INTERSECTION_INT_OPERATOR = "|"; - public static final String DIFFERENCE_EXT_OPERATOR = "-"; - public static final String DIFFERENCE_INT_OPERATOR = "~"; - public static final String PRODUCT_OPERATOR = "*"; - public static final String IMAGE_EXT_OPERATOR = "/"; - public static final String IMAGE_INT_OPERATOR = "\\"; - - // CompoundStatement operators - // length = 2 - public static final String NEGATION_OPERATOR = "--"; - public static final String DISJUNCTION_OPERATOR = "||"; - public static final String CONJUNCTION_OPERATOR = "&&"; - public static final String SEQUENCE_OPERATOR = "&/"; - public static final String PARALLEL_OPERATOR = "&|"; - public static final String FUTURE_OPERATOR = "/>"; - public static final String PRESENT_OPERATOR = "|>"; - public static final String PAST_OPERATOR = "\\>"; - - // built-in relations - // length = 3 - public static final String INHERITANCE_RELATION = "-->"; - public static final String SIMILARITY_RELATION = "<->"; - public static final String INSTANCE_RELATION = "{--"; - public static final String PROPERTY_RELATION = "--]"; - public static final String INSTANCE_PROPERTY_RELATION = "{-]"; - public static final String IMPLICATION_RELATION = "==>"; - public static final String EQUIVALENCE_RELATION = "<=>"; - public static final String IMPLICATION_AFTER_RELATION = "=/>"; - public static final String IMPLICATION_BEFORE_RELATION = "=\\>"; - public static final String IMPLICATION_WHEN_RELATION = "=|>"; - public static final String EQUIVALENCE_AFTER_RELATION = "</>"; - public static final String EQUIVALENCE_WHEN_RELATION = "<|>"; - - // Base, display only - public static final String Base_opener = " {"; - public static final String Base_closer = "} "; - public static final String Base_separator = ";"; - public static final String Base_separator0 = ": "; - - // TermLink type, display only - public static final String LinkToComponent_at1 = " @("; - public static final String LinkToComponent_at2 = ") _ "; - public static final String LinkToCompound_at1 = " _ @("; - public static final String LinkToCompound_at2 = ") "; -} diff --git a/open-nars/src/com/googlecode/opennars/parser/TermVisitor.java b/open-nars/src/com/googlecode/opennars/parser/TermVisitor.java deleted file mode 100644 index 4ca3a8c80100394a4e4e6d45899cece506515230..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/TermVisitor.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.googlecode.opennars.parser; - -import com.googlecode.opennars.language.*; - -/** - * A visitor interface for terms in NARS to make it easier to serialise things - * @author jgeldart - * - * @param <R> The return type of this visitor - * @param <A> The argument type - */ -public interface TermVisitor<R, A> { - - R visit(BooleanLiteral p, A arg); - R visit(Conjunction p, A arg); - R visit(ConjunctionParallel p, A arg); - R visit(ConjunctionSequence p, A arg); - R visit(DifferenceExt p, A arg); - R visit(DifferenceInt p, A arg); - R visit(Disjunction p, A arg); - R visit(Equivalence p, A arg); - R visit(EquivalenceAfter p, A arg); - R visit(EquivalenceWhen p, A arg); - R visit(ImageExt p, A arg); - R visit(ImageInt p, A arg); - R visit(Implication p, A arg); - R visit(ImplicationAfter p, A arg); - R visit(ImplicationBefore p, A arg); - R visit(Inheritance p, A arg); - R visit(Instance p, A arg); - R visit(InstanceProperty p, A arg); - R visit(IntersectionExt p, A arg); - R visit(IntersectionInt p, A arg); - R visit(Negation p, A arg); - R visit(NumericLiteral p, A arg); - R visit(Product p, A arg); - R visit(Property p, A arg); - R visit(SetExt p, A arg); - R visit(SetInt p, A arg); - R visit(Similarity p, A arg); - R visit(TenseFuture p, A arg); - R visit(TensePast p, A arg); - R visit(TensePresent p, A arg); - R visit(StringLiteral p, A arg); - R visit(URIRef p, A arg); - R visit(Variable p, A arg); - R visit(Term p, A arg); - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan.cf b/open-nars/src/com/googlecode/opennars/parser/loan/Loan.cf deleted file mode 100644 index 83aa2b951582ca9c3dc531455d21d6ccfd0ec473..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan.cf +++ /dev/null @@ -1,98 +0,0 @@ --- LOAN, Non-Axiomatic Ontology Language, grammar --- Copyright (c) 2008 Joe Geldart - -entrypoints Document, Sentence ; - -DocBR. Document ::= BaseRule [Sentence] ; -Doc. Document ::= [Sentence] ; - -BaseR. BaseRule ::= "@base" URILit "." ; -- The base URI for the document - -[]. [Sentence] ::= ; -(:). [Sentence] ::= Sentence [Sentence] ; - -SentPrefix. Sentence ::= "@prefix" NSPrefix URILit "." ; -- Declares a namespace prefix to be a certain URI -SentImport. Sentence ::= "@import" URILit "." ; -- Imports a given URL -SentDelay. Sentence ::= "@delay" Integer "." ; -- Waits for a given number of cycles before continuing -SentOp. Sentence ::= "@operator" URIRef "." ; -- Declares URI to be an operator (currently unused) - -SentJudge. Sentence ::= Stm TruthValue Budget "." ; -- A judgement with a given truth-value -SentQuest. Sentence ::= Stm "?" Budget; -- A question -SentGoal. Sentence ::= Stm TruthValue Budget"!" ; -- A goal with a given utility - -BudgetE. Budget ::= ; -BudgetP. Budget ::= "@budget" "(" Double ")" ; -BudgetPD. Budget ::= "@budget" "(" Double ";" Double ")" ; - -StmImpl. Stm ::= Stm "==>" Stm1 ; -- Implication -StmEquiv. Stm ::= Stm "<=>" Stm1 ; -- Equivalence -StmImpPred. Stm ::= Stm "=/>" Stm1 ; -- Predictive implication -StmImpRet. Stm ::= Stm "=\\>" Stm1 ; -- Retrospective implication -StmImpConc. Stm ::= Stm "=|>" Stm1 ; -- Concurrent implication -StmEqvPred. Stm ::= Stm "</>" Stm1 ; -- Predictive equivalence -StmEqvConc. Stm ::= Stm "<|>" Stm1 ; -- Concurrent equivalence -StmConj. Stm1 ::= Stm1 "&&" Stm2 ; -- Conjunction -StmDisj. Stm1 ::= Stm1 "||" Stm2 ; -- Disjunction -StmPar. Stm1 ::= Stm1 ";" Stm2 ; -- Parallel conjunction -StmSeq. Stm1 ::= Stm1 "," Stm2 ; -- Sequential conjunction -StmNot. Stm2 ::= "not" Stm3 ; -- Negation -StmPst. Stm2 ::= "past" Stm3 ; -- Past-tense operator -StmPres. Stm2 ::= "present" Stm3 ; -- Present-tense operator -StmFut. Stm2 ::= "future" Stm3 ; -- Future-tense operator -StmInher. Stm3 ::= Term "-->" Term ; -- Inheritance -StmSim. Stm3 ::= Term "<->" Term ; -- Similarity -StmInst. Stm3 ::= Term "}->" Term ; -- Instance -StmProp. Stm3 ::= Term "--[" Term ; -- Property -StmInPp. Stm3 ::= Term "}-[" Term ; -- Instance-Property -StmOp. Stm3 ::= Term "(" [Term] ")" ; -- Operation -StmTrm. Stm3 ::= Term ; -- Bare term (name) - -coercions Stm 3 ; - -TrmExInt. Term ::= Term "&" Term1 ; -- Extensional intersection -TrmInInt. Term ::= Term "|" Term1 ; -- Intensional intersection -TrmExDif. Term1 ::= Term1 "-" Term2 ; -- Extensional difference -TrmInDif. Term1 ::= Term1 "~" Term2 ; -- Intensional difference ---TrmProd. Term2 ::= Term2 "*" Term3 ; -- Product ---TrmProd. Term2 ::= [Prod] ; -TrmExImg. Term2 ::= Term "(" [Term] "/" [Term] ")" ; -- Extensional image -TrmInImg. Term2 ::= Term "(" [Term] "\\" [Term] ")" ; -- Intensional image -TrmExSet. Term3 ::= "{" [Term] "}" ; -- Extensional set -TrmInSet. Term3 ::= "[" [Term] "]" ; -- Intensional set -TrmProd. Term3 ::= "(" [Term] ")" ; -TrmLit. Term3 ::= Literal ; -- Literal -TrmStm. Term3 ::= "(" Stm ")" ; -- Statement - -coercions Term 3 ; - -separator Term "," ; - --- Literals - -token URILit '<' (char - ["<>\"{}|\\`"])* '>' ; -- A URI literal token - -separator Ident "," ; - -URIFul. URIRef ::= URILit ; -- A full URI reference (possibly relative) -URICur. URIRef ::= NSPrefix Ident ; -- A CURIE - -LitQVar. Literal ::= "?" Ident ; -- A query variable with name -LitQVarAn. Literal ::= "?" ; -- An anonymous query variable -LitSVarD. Literal ::= "#" Ident "(" [Ident] ")" ; -- A dependent statement variable -LitSVarI. Literal ::= "#" Ident ; -- An independent statement variable -LitURI. Literal ::= URIRef ; -- A URI reference literal -LitInt. Literal ::= Integer ; -- An integer literal -LitDbl. Literal ::= Double ; -- A double literal -LitString. Literal ::= String ; -- A string literal -LitTrue. Literal ::= "true" ; -- A true boolean -LitFalse. Literal ::= "false" ; -- A false boolean - -NSPrefix1. NSPrefix ::= Ident ":" ; -- A namespace prefix -NSPrefix2. NSPrefix ::= ":" ; -- The default namespace prefix - -TruthE. TruthValue ::= ; -- The default truth value -TruthF. TruthValue ::= "%" Double "%" ; -- Frequency only -TruthFC. TruthValue ::= "%" Double ";" Double "%" ; -- A full truth value - -comment "{---" "---}" ; -- Comments similar to Haskell -comment "---" ; diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan.pdf b/open-nars/src/com/googlecode/opennars/parser/loan/Loan.pdf deleted file mode 100644 index 81a11e0b5bf1dcbe502aed6f83e32b56d51e5222..0000000000000000000000000000000000000000 Binary files a/open-nars/src/com/googlecode/opennars/parser/loan/Loan.pdf and /dev/null differ diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/AbstractVisitor.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/AbstractVisitor.java deleted file mode 100644 index 2f38106782a146eb9d8779cd4c1dcb298e51ddf2..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/AbstractVisitor.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan; -import com.googlecode.opennars.parser.loan.Loan.Absyn.*; -/** BNFC-Generated Abstract Visitor */ -public class AbstractVisitor<R,A> implements AllVisitor<R,A> { -/* Document */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.Doc p, A arg) { return visitDefault(p, arg); } - public R visitDefault(com.googlecode.opennars.parser.loan.Loan.Absyn.Document p, A arg) { - throw new IllegalArgumentException(this.getClass().getName() + ": " + p); - } -/* BaseRule */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR p, A arg) { return visitDefault(p, arg); } - public R visitDefault(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule p, A arg) { - throw new IllegalArgumentException(this.getClass().getName() + ": " + p); - } -/* Sentence */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal p, A arg) { return visitDefault(p, arg); } - public R visitDefault(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence p, A arg) { - throw new IllegalArgumentException(this.getClass().getName() + ": " + p); - } -/* Budget */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD p, A arg) { return visitDefault(p, arg); } - public R visitDefault(com.googlecode.opennars.parser.loan.Loan.Absyn.Budget p, A arg) { - throw new IllegalArgumentException(this.getClass().getName() + ": " + p); - } -/* Stm */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc p, A arg) { return visitDefault(p, arg); } - - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq p, A arg) { return visitDefault(p, arg); } - - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut p, A arg) { return visitDefault(p, arg); } - - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm p, A arg) { return visitDefault(p, arg); } - - public R visitDefault(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p, A arg) { - throw new IllegalArgumentException(this.getClass().getName() + ": " + p); - } -/* Term */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt p, A arg) { return visitDefault(p, arg); } - - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif p, A arg) { return visitDefault(p, arg); } - - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg p, A arg) { return visitDefault(p, arg); } - - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm p, A arg) { return visitDefault(p, arg); } - - public R visitDefault(com.googlecode.opennars.parser.loan.Loan.Absyn.Term p, A arg) { - throw new IllegalArgumentException(this.getClass().getName() + ": " + p); - } -/* URIRef */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URICur p, A arg) { return visitDefault(p, arg); } - public R visitDefault(com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef p, A arg) { - throw new IllegalArgumentException(this.getClass().getName() + ": " + p); - } -/* Literal */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitString p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse p, A arg) { return visitDefault(p, arg); } - public R visitDefault(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal p, A arg) { - throw new IllegalArgumentException(this.getClass().getName() + ": " + p); - } -/* NSPrefix */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1 p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2 p, A arg) { return visitDefault(p, arg); } - public R visitDefault(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix p, A arg) { - throw new IllegalArgumentException(this.getClass().getName() + ": " + p); - } -/* TruthValue */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF p, A arg) { return visitDefault(p, arg); } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC p, A arg) { return visitDefault(p, arg); } - public R visitDefault(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue p, A arg) { - throw new IllegalArgumentException(this.getClass().getName() + ": " + p); - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BaseR.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BaseR.java deleted file mode 100644 index 7bca6f48b933cf5237b76ca68f80e59a12111f01..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BaseR.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class BaseR extends BaseRule { - public final String urilit_; - - public BaseR(String p1) { urilit_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR) { - com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR x = (com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR)o; - return this.urilit_.equals(x.urilit_); - } - return false; - } - - public int hashCode() { - return this.urilit_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BaseRule.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BaseRule.java deleted file mode 100644 index e6c49b76026e46bceb545aac27d7f7281b835ca6..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BaseRule.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public abstract class BaseRule implements java.io.Serializable { - public abstract <R,A> R accept(BaseRule.Visitor<R,A> v, A arg); - public interface Visitor <R,A> { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR p, A arg); - - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Budget.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Budget.java deleted file mode 100644 index 2fae415b140288d5802199a885362f10fc7a0a88..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Budget.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public abstract class Budget implements java.io.Serializable { - public abstract <R,A> R accept(Budget.Visitor<R,A> v, A arg); - public interface Visitor <R,A> { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD p, A arg); - - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BudgetE.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BudgetE.java deleted file mode 100644 index 0ee824a62af59bb9538343e751e0bf8f299bb6eb..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BudgetE.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class BudgetE extends Budget { - - public BudgetE() { } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Budget.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE) { - return true; - } - return false; - } - - public int hashCode() { - return 37; - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BudgetP.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BudgetP.java deleted file mode 100644 index 6739602c9ae385ec0c09cdbb2bfce8e42c61f4c5..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BudgetP.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class BudgetP extends Budget { - public final Double double_; - - public BudgetP(Double p1) { double_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Budget.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP) { - com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP x = (com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP)o; - return this.double_.equals(x.double_); - } - return false; - } - - public int hashCode() { - return this.double_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BudgetPD.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BudgetPD.java deleted file mode 100644 index 9e0234faf3574291b372a0a08efb03cccdc9c4b7..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/BudgetPD.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class BudgetPD extends Budget { - public final Double double_1, double_2; - - public BudgetPD(Double p1, Double p2) { double_1 = p1; double_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Budget.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD) { - com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD x = (com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD)o; - return this.double_1.equals(x.double_1) && this.double_2.equals(x.double_2); - } - return false; - } - - public int hashCode() { - return 37*(this.double_1.hashCode())+this.double_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Doc.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Doc.java deleted file mode 100644 index c9b22d1dd46bbcd61418a6364481b4171686eebd..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Doc.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class Doc extends Document { - public final ListSentence listsentence_; - - public Doc(ListSentence p1) { listsentence_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Document.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.Doc) { - com.googlecode.opennars.parser.loan.Loan.Absyn.Doc x = (com.googlecode.opennars.parser.loan.Loan.Absyn.Doc)o; - return this.listsentence_.equals(x.listsentence_); - } - return false; - } - - public int hashCode() { - return this.listsentence_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/DocBR.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/DocBR.java deleted file mode 100644 index 8a135bb93da51c84b19b34d803c51e804669f7c2..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/DocBR.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class DocBR extends Document { - public final BaseRule baserule_; - public final ListSentence listsentence_; - - public DocBR(BaseRule p1, ListSentence p2) { baserule_ = p1; listsentence_ = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Document.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR) { - com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR x = (com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR)o; - return this.baserule_.equals(x.baserule_) && this.listsentence_.equals(x.listsentence_); - } - return false; - } - - public int hashCode() { - return 37*(this.baserule_.hashCode())+this.listsentence_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Document.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Document.java deleted file mode 100644 index 0d84c9e49f47ef14845bec905ee1782ffea7b28b..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Document.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public abstract class Document implements java.io.Serializable { - public abstract <R,A> R accept(Document.Visitor<R,A> v, A arg); - public interface Visitor <R,A> { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.Doc p, A arg); - - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/ListIdent.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/ListIdent.java deleted file mode 100644 index e0c6d6d74d996b1e20b2506560ee72a96928bb6b..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/ListIdent.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class ListIdent extends java.util.LinkedList<String> { -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/ListSentence.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/ListSentence.java deleted file mode 100644 index 18bff3cad3cc941db8be717da7918edf1a4657fa..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/ListSentence.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class ListSentence extends java.util.LinkedList<Sentence> { -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/ListTerm.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/ListTerm.java deleted file mode 100644 index 78cd90fd5cd0a7bfc95e139e69fd483163fe5ab1..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/ListTerm.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class ListTerm extends java.util.LinkedList<Term> { -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitDbl.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitDbl.java deleted file mode 100644 index f992d21166b2552f46db60b36391daf3bdd1c9b9..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitDbl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class LitDbl extends Literal { - public final Double double_; - - public LitDbl(Double p1) { double_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl) { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl x = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl)o; - return this.double_.equals(x.double_); - } - return false; - } - - public int hashCode() { - return this.double_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitFalse.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitFalse.java deleted file mode 100644 index 3871bbaf0bb57ebaa5bb06de092f8455c067f65c..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitFalse.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class LitFalse extends Literal { - - public LitFalse() { } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse) { - return true; - } - return false; - } - - public int hashCode() { - return 37; - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitInt.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitInt.java deleted file mode 100644 index 155892ad1d00606f8cb3a1ca5d4fb5e9266824a9..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitInt.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class LitInt extends Literal { - public final Integer integer_; - - public LitInt(Integer p1) { integer_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt) { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt x = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt)o; - return this.integer_.equals(x.integer_); - } - return false; - } - - public int hashCode() { - return this.integer_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitQVar.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitQVar.java deleted file mode 100644 index 162a00a2de68d60653c48bcee35b7c978b15ebf5..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitQVar.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class LitQVar extends Literal { - public final String ident_; - - public LitQVar(String p1) { ident_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar) { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar x = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar)o; - return this.ident_.equals(x.ident_); - } - return false; - } - - public int hashCode() { - return this.ident_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitQVarAn.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitQVarAn.java deleted file mode 100644 index 80854bb8f71308c611cc78dfd2c84ce5ed571fe0..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitQVarAn.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class LitQVarAn extends Literal { - - public LitQVarAn() { } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn) { - return true; - } - return false; - } - - public int hashCode() { - return 37; - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitSVarD.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitSVarD.java deleted file mode 100644 index 9d561e0889fd7ab64472822acc3b107313b76982..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitSVarD.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class LitSVarD extends Literal { - public final String ident_; - public final ListIdent listident_; - - public LitSVarD(String p1, ListIdent p2) { ident_ = p1; listident_ = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD) { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD x = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD)o; - return this.ident_.equals(x.ident_) && this.listident_.equals(x.listident_); - } - return false; - } - - public int hashCode() { - return 37*(this.ident_.hashCode())+this.listident_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitSVarI.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitSVarI.java deleted file mode 100644 index 6782024edd3b8a3b95c870e77ad086a2e3d88900..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitSVarI.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class LitSVarI extends Literal { - public final String ident_; - - public LitSVarI(String p1) { ident_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI) { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI x = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI)o; - return this.ident_.equals(x.ident_); - } - return false; - } - - public int hashCode() { - return this.ident_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitString.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitString.java deleted file mode 100644 index eb30f17720dd0c65fdee92e46d3acc08941f7f9b..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitString.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class LitString extends Literal { - public final String string_; - - public LitString(String p1) { string_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitString) { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitString x = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitString)o; - return this.string_.equals(x.string_); - } - return false; - } - - public int hashCode() { - return this.string_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitTrue.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitTrue.java deleted file mode 100644 index 5ebbb93c898b5bbb30e102360eb079991c0bb0cb..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitTrue.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class LitTrue extends Literal { - - public LitTrue() { } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue) { - return true; - } - return false; - } - - public int hashCode() { - return 37; - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitURI.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitURI.java deleted file mode 100644 index c0fa8e94d95c37c82961fdbd7d1e2edc1f3ef48f..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/LitURI.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class LitURI extends Literal { - public final URIRef uriref_; - - public LitURI(URIRef p1) { uriref_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI) { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI x = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI)o; - return this.uriref_.equals(x.uriref_); - } - return false; - } - - public int hashCode() { - return this.uriref_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Literal.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Literal.java deleted file mode 100644 index 847570134bd7348632ec5c555f5c2b35e31b6332..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Literal.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public abstract class Literal implements java.io.Serializable { - public abstract <R,A> R accept(Literal.Visitor<R,A> v, A arg); - public interface Visitor <R,A> { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitString p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse p, A arg); - - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/NSPrefix.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/NSPrefix.java deleted file mode 100644 index cf6c96b0cb0f3f1de765e23f0608cf8a1aa88633..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/NSPrefix.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public abstract class NSPrefix implements java.io.Serializable { - public abstract <R,A> R accept(NSPrefix.Visitor<R,A> v, A arg); - public interface Visitor <R,A> { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1 p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2 p, A arg); - - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/NSPrefix1.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/NSPrefix1.java deleted file mode 100644 index 7835025cf168aa5948e7bb292920199d407694ef..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/NSPrefix1.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class NSPrefix1 extends NSPrefix { - public final String ident_; - - public NSPrefix1(String p1) { ident_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1) { - com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1 x = (com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1)o; - return this.ident_.equals(x.ident_); - } - return false; - } - - public int hashCode() { - return this.ident_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/NSPrefix2.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/NSPrefix2.java deleted file mode 100644 index 3ce2a9bd301922b1a4f6a9a59bb76c0c2023141f..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/NSPrefix2.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class NSPrefix2 extends NSPrefix { - - public NSPrefix2() { } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2) { - return true; - } - return false; - } - - public int hashCode() { - return 37; - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentDelay.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentDelay.java deleted file mode 100644 index 9456e9aa4b691f6ac19f9cacb35eba67cfe57aa4..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentDelay.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class SentDelay extends Sentence { - public final Integer integer_; - - public SentDelay(Integer p1) { integer_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay) { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay x = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay)o; - return this.integer_.equals(x.integer_); - } - return false; - } - - public int hashCode() { - return this.integer_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentGoal.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentGoal.java deleted file mode 100644 index 92e434b3a4bb505c2a738b466cb4cf7ba934f9af..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentGoal.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class SentGoal extends Sentence { - public final Stm stm_; - public final TruthValue truthvalue_; - public final Budget budget_; - - public SentGoal(Stm p1, TruthValue p2, Budget p3) { stm_ = p1; truthvalue_ = p2; budget_ = p3; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal) { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal x = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal)o; - return this.stm_.equals(x.stm_) && this.truthvalue_.equals(x.truthvalue_) && this.budget_.equals(x.budget_); - } - return false; - } - - public int hashCode() { - return 37*(37*(this.stm_.hashCode())+this.truthvalue_.hashCode())+this.budget_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentImport.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentImport.java deleted file mode 100644 index 856658ac99daaadb2caf90265b9ffbf9d2dcaa5d..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentImport.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class SentImport extends Sentence { - public final String urilit_; - - public SentImport(String p1) { urilit_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport) { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport x = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport)o; - return this.urilit_.equals(x.urilit_); - } - return false; - } - - public int hashCode() { - return this.urilit_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentJudge.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentJudge.java deleted file mode 100644 index 01ed541c58074a3acc5f0212a975aec0e6e10a10..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentJudge.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class SentJudge extends Sentence { - public final Stm stm_; - public final TruthValue truthvalue_; - public final Budget budget_; - - public SentJudge(Stm p1, TruthValue p2, Budget p3) { stm_ = p1; truthvalue_ = p2; budget_ = p3; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge) { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge x = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge)o; - return this.stm_.equals(x.stm_) && this.truthvalue_.equals(x.truthvalue_) && this.budget_.equals(x.budget_); - } - return false; - } - - public int hashCode() { - return 37*(37*(this.stm_.hashCode())+this.truthvalue_.hashCode())+this.budget_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentOp.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentOp.java deleted file mode 100644 index 6aad34ce2646c50c2d7b68b8675d9e2dc11d104d..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentOp.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class SentOp extends Sentence { - public final URIRef uriref_; - - public SentOp(URIRef p1) { uriref_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp) { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp x = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp)o; - return this.uriref_.equals(x.uriref_); - } - return false; - } - - public int hashCode() { - return this.uriref_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentPrefix.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentPrefix.java deleted file mode 100644 index dfd20e86b41dd11bcb17768b724d8fae14bdc604..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentPrefix.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class SentPrefix extends Sentence { - public final NSPrefix nsprefix_; - public final String urilit_; - - public SentPrefix(NSPrefix p1, String p2) { nsprefix_ = p1; urilit_ = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix) { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix x = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix)o; - return this.nsprefix_.equals(x.nsprefix_) && this.urilit_.equals(x.urilit_); - } - return false; - } - - public int hashCode() { - return 37*(this.nsprefix_.hashCode())+this.urilit_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentQuest.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentQuest.java deleted file mode 100644 index 129db24bee69f7dd081c516fb633e29df893e5e3..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/SentQuest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class SentQuest extends Sentence { - public final Stm stm_; - public final Budget budget_; - - public SentQuest(Stm p1, Budget p2) { stm_ = p1; budget_ = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest) { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest x = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest)o; - return this.stm_.equals(x.stm_) && this.budget_.equals(x.budget_); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_.hashCode())+this.budget_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Sentence.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Sentence.java deleted file mode 100644 index 044f903112a42c00b56da1461af75272802a55e8..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Sentence.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public abstract class Sentence implements java.io.Serializable { - public abstract <R,A> R accept(Sentence.Visitor<R,A> v, A arg); - public interface Visitor <R,A> { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal p, A arg); - - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Stm.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Stm.java deleted file mode 100644 index 317da4345321552f5ffa36af95292e63625ce0c4..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Stm.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public abstract class Stm implements java.io.Serializable { - public abstract <R,A> R accept(Stm.Visitor<R,A> v, A arg); - public interface Visitor <R,A> { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm p, A arg); - - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmConj.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmConj.java deleted file mode 100644 index 28f2a2fd3f77b25149ac564836ae94a920200a70..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmConj.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmConj extends Stm { - public final Stm stm_1, stm_2; - - public StmConj(Stm p1, Stm p2) { stm_1 = p1; stm_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj)o; - return this.stm_1.equals(x.stm_1) && this.stm_2.equals(x.stm_2); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_1.hashCode())+this.stm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmDisj.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmDisj.java deleted file mode 100644 index b67ef97565c955a9a4bc1a053c13e832987135c0..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmDisj.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmDisj extends Stm { - public final Stm stm_1, stm_2; - - public StmDisj(Stm p1, Stm p2) { stm_1 = p1; stm_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj)o; - return this.stm_1.equals(x.stm_1) && this.stm_2.equals(x.stm_2); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_1.hashCode())+this.stm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmEquiv.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmEquiv.java deleted file mode 100644 index c328f67f58358040bb7d6bf5f2791ce437c3ce9c..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmEquiv.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmEquiv extends Stm { - public final Stm stm_1, stm_2; - - public StmEquiv(Stm p1, Stm p2) { stm_1 = p1; stm_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv)o; - return this.stm_1.equals(x.stm_1) && this.stm_2.equals(x.stm_2); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_1.hashCode())+this.stm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmEqvConc.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmEqvConc.java deleted file mode 100644 index e15e79d796d308d50b2e2a0d851806a0e21d61de..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmEqvConc.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmEqvConc extends Stm { - public final Stm stm_1, stm_2; - - public StmEqvConc(Stm p1, Stm p2) { stm_1 = p1; stm_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc)o; - return this.stm_1.equals(x.stm_1) && this.stm_2.equals(x.stm_2); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_1.hashCode())+this.stm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmEqvPred.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmEqvPred.java deleted file mode 100644 index e2a6582ead451ed662b3917af0f69be76543b2bc..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmEqvPred.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmEqvPred extends Stm { - public final Stm stm_1, stm_2; - - public StmEqvPred(Stm p1, Stm p2) { stm_1 = p1; stm_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred)o; - return this.stm_1.equals(x.stm_1) && this.stm_2.equals(x.stm_2); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_1.hashCode())+this.stm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmFut.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmFut.java deleted file mode 100644 index 8c024d80e6ceffe492e3588cf29485b9187062c5..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmFut.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmFut extends Stm { - public final Stm stm_; - - public StmFut(Stm p1) { stm_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut)o; - return this.stm_.equals(x.stm_); - } - return false; - } - - public int hashCode() { - return this.stm_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpConc.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpConc.java deleted file mode 100644 index 1c9d97a3a06502144c4bc55cff9aae18637a35d0..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpConc.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmImpConc extends Stm { - public final Stm stm_1, stm_2; - - public StmImpConc(Stm p1, Stm p2) { stm_1 = p1; stm_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc)o; - return this.stm_1.equals(x.stm_1) && this.stm_2.equals(x.stm_2); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_1.hashCode())+this.stm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpPred.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpPred.java deleted file mode 100644 index 5d79058a6b8b3edc5fae98ef125f764770e02137..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpPred.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmImpPred extends Stm { - public final Stm stm_1, stm_2; - - public StmImpPred(Stm p1, Stm p2) { stm_1 = p1; stm_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred)o; - return this.stm_1.equals(x.stm_1) && this.stm_2.equals(x.stm_2); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_1.hashCode())+this.stm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpRet.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpRet.java deleted file mode 100644 index b073a91da18131e1f39c16da064685c0ccd84380..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpRet.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmImpRet extends Stm { - public final Stm stm_1, stm_2; - - public StmImpRet(Stm p1, Stm p2) { stm_1 = p1; stm_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet)o; - return this.stm_1.equals(x.stm_1) && this.stm_2.equals(x.stm_2); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_1.hashCode())+this.stm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpl.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpl.java deleted file mode 100644 index b4f8fa1afa70a5203281896631dd7c8892214d2f..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmImpl extends Stm { - public final Stm stm_1, stm_2; - - public StmImpl(Stm p1, Stm p2) { stm_1 = p1; stm_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl)o; - return this.stm_1.equals(x.stm_1) && this.stm_2.equals(x.stm_2); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_1.hashCode())+this.stm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmInPp.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmInPp.java deleted file mode 100644 index 9f4fea738a5a00314334685dafe089a1caae669d..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmInPp.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmInPp extends Stm { - public final Term term_1, term_2; - - public StmInPp(Term p1, Term p2) { term_1 = p1; term_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp)o; - return this.term_1.equals(x.term_1) && this.term_2.equals(x.term_2); - } - return false; - } - - public int hashCode() { - return 37*(this.term_1.hashCode())+this.term_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmInher.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmInher.java deleted file mode 100644 index e31ba046c8749df5deab3f103041ce97f58cb87b..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmInher.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmInher extends Stm { - public final Term term_1, term_2; - - public StmInher(Term p1, Term p2) { term_1 = p1; term_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher)o; - return this.term_1.equals(x.term_1) && this.term_2.equals(x.term_2); - } - return false; - } - - public int hashCode() { - return 37*(this.term_1.hashCode())+this.term_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmInst.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmInst.java deleted file mode 100644 index 98b1e777b1c4e85a4533a5fb022095d968355c70..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmInst.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmInst extends Stm { - public final Term term_1, term_2; - - public StmInst(Term p1, Term p2) { term_1 = p1; term_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst)o; - return this.term_1.equals(x.term_1) && this.term_2.equals(x.term_2); - } - return false; - } - - public int hashCode() { - return 37*(this.term_1.hashCode())+this.term_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmNot.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmNot.java deleted file mode 100644 index 319ea6c1982520078f54eb714063ce5f1c16d533..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmNot.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmNot extends Stm { - public final Stm stm_; - - public StmNot(Stm p1) { stm_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot)o; - return this.stm_.equals(x.stm_); - } - return false; - } - - public int hashCode() { - return this.stm_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmOp.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmOp.java deleted file mode 100644 index cbaf68a40ecc1304bbf0fbb3973d36d5303fe522..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmOp.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmOp extends Stm { - public final Term term_; - public final ListTerm listterm_; - - public StmOp(Term p1, ListTerm p2) { term_ = p1; listterm_ = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp)o; - return this.term_.equals(x.term_) && this.listterm_.equals(x.listterm_); - } - return false; - } - - public int hashCode() { - return 37*(this.term_.hashCode())+this.listterm_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmPar.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmPar.java deleted file mode 100644 index 1f456403d47c2ef5fd26620c68acda2f2c5e7152..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmPar.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmPar extends Stm { - public final Stm stm_1, stm_2; - - public StmPar(Stm p1, Stm p2) { stm_1 = p1; stm_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar)o; - return this.stm_1.equals(x.stm_1) && this.stm_2.equals(x.stm_2); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_1.hashCode())+this.stm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmPres.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmPres.java deleted file mode 100644 index fa5ccb776f0a47f1bc813c8c2804efd699be099d..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmPres.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmPres extends Stm { - public final Stm stm_; - - public StmPres(Stm p1) { stm_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres)o; - return this.stm_.equals(x.stm_); - } - return false; - } - - public int hashCode() { - return this.stm_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmProp.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmProp.java deleted file mode 100644 index 3e028a3987dcb2adeb2271534463e3d8afcbf5ff..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmProp.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmProp extends Stm { - public final Term term_1, term_2; - - public StmProp(Term p1, Term p2) { term_1 = p1; term_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp)o; - return this.term_1.equals(x.term_1) && this.term_2.equals(x.term_2); - } - return false; - } - - public int hashCode() { - return 37*(this.term_1.hashCode())+this.term_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmPst.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmPst.java deleted file mode 100644 index 8edb148d00948864b76f33988117524c4195f27d..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmPst.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmPst extends Stm { - public final Stm stm_; - - public StmPst(Stm p1) { stm_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst)o; - return this.stm_.equals(x.stm_); - } - return false; - } - - public int hashCode() { - return this.stm_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmSeq.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmSeq.java deleted file mode 100644 index 55e1f8fd40abd63c1d299df1594ef81a01c2d35e..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmSeq.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmSeq extends Stm { - public final Stm stm_1, stm_2; - - public StmSeq(Stm p1, Stm p2) { stm_1 = p1; stm_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq)o; - return this.stm_1.equals(x.stm_1) && this.stm_2.equals(x.stm_2); - } - return false; - } - - public int hashCode() { - return 37*(this.stm_1.hashCode())+this.stm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmSim.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmSim.java deleted file mode 100644 index 38f04c6aff09a1dfdc42706b4363e415b2daf673..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmSim.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmSim extends Stm { - public final Term term_1, term_2; - - public StmSim(Term p1, Term p2) { term_1 = p1; term_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim)o; - return this.term_1.equals(x.term_1) && this.term_2.equals(x.term_2); - } - return false; - } - - public int hashCode() { - return 37*(this.term_1.hashCode())+this.term_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmTrm.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmTrm.java deleted file mode 100644 index f0adea0895e9de85fe0cf23e8188bfac9ea40093..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/StmTrm.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class StmTrm extends Stm { - public final Term term_; - - public StmTrm(Term p1) { term_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm) { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm x = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm)o; - return this.term_.equals(x.term_); - } - return false; - } - - public int hashCode() { - return this.term_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Term.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Term.java deleted file mode 100644 index 2385b09a75558fe6c863ea5d37bcd1d30cff42ac..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/Term.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public abstract class Term implements java.io.Serializable { - public abstract <R,A> R accept(Term.Visitor<R,A> v, A arg); - public interface Visitor <R,A> { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm p, A arg); - - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExDif.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExDif.java deleted file mode 100644 index baacfce036824cb1dd1e98978183ecf6c1886915..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExDif.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TrmExDif extends Term { - public final Term term_1, term_2; - - public TrmExDif(Term p1, Term p2) { term_1 = p1; term_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif)o; - return this.term_1.equals(x.term_1) && this.term_2.equals(x.term_2); - } - return false; - } - - public int hashCode() { - return 37*(this.term_1.hashCode())+this.term_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExImg.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExImg.java deleted file mode 100644 index 18f1049d9b49e4892abb027fd4dd08cc6f923c75..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExImg.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TrmExImg extends Term { - public final Term term_; - public final ListTerm listterm_1, listterm_2; - - public TrmExImg(Term p1, ListTerm p2, ListTerm p3) { term_ = p1; listterm_1 = p2; listterm_2 = p3; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg)o; - return this.term_.equals(x.term_) && this.listterm_1.equals(x.listterm_1) && this.listterm_2.equals(x.listterm_2); - } - return false; - } - - public int hashCode() { - return 37*(37*(this.term_.hashCode())+this.listterm_1.hashCode())+this.listterm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExInt.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExInt.java deleted file mode 100644 index b761a7175b7104e0a66afa6bee34066184778240..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExInt.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TrmExInt extends Term { - public final Term term_1, term_2; - - public TrmExInt(Term p1, Term p2) { term_1 = p1; term_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt)o; - return this.term_1.equals(x.term_1) && this.term_2.equals(x.term_2); - } - return false; - } - - public int hashCode() { - return 37*(this.term_1.hashCode())+this.term_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExSet.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExSet.java deleted file mode 100644 index db98430670fb5e53182479edd7696ee307d03b58..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmExSet.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TrmExSet extends Term { - public final ListTerm listterm_; - - public TrmExSet(ListTerm p1) { listterm_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet)o; - return this.listterm_.equals(x.listterm_); - } - return false; - } - - public int hashCode() { - return this.listterm_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInDif.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInDif.java deleted file mode 100644 index 21e646d50075aaef739480d561b561bd821f7049..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInDif.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TrmInDif extends Term { - public final Term term_1, term_2; - - public TrmInDif(Term p1, Term p2) { term_1 = p1; term_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif)o; - return this.term_1.equals(x.term_1) && this.term_2.equals(x.term_2); - } - return false; - } - - public int hashCode() { - return 37*(this.term_1.hashCode())+this.term_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInImg.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInImg.java deleted file mode 100644 index 5169b6aa549cd68754233cdaf8495a40aab47cc8..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInImg.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TrmInImg extends Term { - public final Term term_; - public final ListTerm listterm_1, listterm_2; - - public TrmInImg(Term p1, ListTerm p2, ListTerm p3) { term_ = p1; listterm_1 = p2; listterm_2 = p3; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg)o; - return this.term_.equals(x.term_) && this.listterm_1.equals(x.listterm_1) && this.listterm_2.equals(x.listterm_2); - } - return false; - } - - public int hashCode() { - return 37*(37*(this.term_.hashCode())+this.listterm_1.hashCode())+this.listterm_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInInt.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInInt.java deleted file mode 100644 index e59aa00bbb1d60a5f3b645cd6957a7039521a02b..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInInt.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TrmInInt extends Term { - public final Term term_1, term_2; - - public TrmInInt(Term p1, Term p2) { term_1 = p1; term_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt)o; - return this.term_1.equals(x.term_1) && this.term_2.equals(x.term_2); - } - return false; - } - - public int hashCode() { - return 37*(this.term_1.hashCode())+this.term_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInSet.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInSet.java deleted file mode 100644 index 7d44432356af4a9729f5eb21efc6701ab02afb2e..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmInSet.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TrmInSet extends Term { - public final ListTerm listterm_; - - public TrmInSet(ListTerm p1) { listterm_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet)o; - return this.listterm_.equals(x.listterm_); - } - return false; - } - - public int hashCode() { - return this.listterm_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmLit.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmLit.java deleted file mode 100644 index 4ba0328e9a9177205b226362f72ccf3108e55c68..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmLit.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TrmLit extends Term { - public final Literal literal_; - - public TrmLit(Literal p1) { literal_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit)o; - return this.literal_.equals(x.literal_); - } - return false; - } - - public int hashCode() { - return this.literal_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmProd.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmProd.java deleted file mode 100644 index 963b6fa9454211df208b8cab0fc6871a3e6d9d64..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmProd.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TrmProd extends Term { - public final ListTerm listterm_; - - public TrmProd(ListTerm p1) { listterm_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd)o; - return this.listterm_.equals(x.listterm_); - } - return false; - } - - public int hashCode() { - return this.listterm_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmStm.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmStm.java deleted file mode 100644 index ffbb1976b5a461bdbba8607c1055c27e055c3c06..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TrmStm.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TrmStm extends Term { - public final Stm stm_; - - public TrmStm(Stm p1) { stm_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm)o; - return this.stm_.equals(x.stm_); - } - return false; - } - - public int hashCode() { - return this.stm_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthE.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthE.java deleted file mode 100644 index ded9a852ec21b9b6f80b9669345c892c82fd02fb..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthE.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TruthE extends TruthValue { - - public TruthE() { } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE) { - return true; - } - return false; - } - - public int hashCode() { - return 37; - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthF.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthF.java deleted file mode 100644 index 14333d2474c927638aa0a7998b3e6c07f4725d7a..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthF.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TruthF extends TruthValue { - public final Double double_; - - public TruthF(Double p1) { double_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF)o; - return this.double_.equals(x.double_); - } - return false; - } - - public int hashCode() { - return this.double_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthFC.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthFC.java deleted file mode 100644 index 1af27e51662354cf8073f5b1f4b42a250bc6bf20..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthFC.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class TruthFC extends TruthValue { - public final Double double_1, double_2; - - public TruthFC(Double p1, Double p2) { double_1 = p1; double_2 = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC x = (com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC)o; - return this.double_1.equals(x.double_1) && this.double_2.equals(x.double_2); - } - return false; - } - - public int hashCode() { - return 37*(this.double_1.hashCode())+this.double_2.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthValue.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthValue.java deleted file mode 100644 index 951454f40648f1d1689fb29b535966e3b00264ce..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/TruthValue.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public abstract class TruthValue implements java.io.Serializable { - public abstract <R,A> R accept(TruthValue.Visitor<R,A> v, A arg); - public interface Visitor <R,A> { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC p, A arg); - - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/URICur.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/URICur.java deleted file mode 100644 index aa175d25e94ea3282e2a4ed45218bb84ad7cb5c2..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/URICur.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class URICur extends URIRef { - public final NSPrefix nsprefix_; - public final String ident_; - - public URICur(NSPrefix p1, String p2) { nsprefix_ = p1; ident_ = p2; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.URICur) { - com.googlecode.opennars.parser.loan.Loan.Absyn.URICur x = (com.googlecode.opennars.parser.loan.Loan.Absyn.URICur)o; - return this.nsprefix_.equals(x.nsprefix_) && this.ident_.equals(x.ident_); - } - return false; - } - - public int hashCode() { - return 37*(this.nsprefix_.hashCode())+this.ident_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/URIFul.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/URIFul.java deleted file mode 100644 index 21a9e055604c01f87a1f4330037b46fa6504e21f..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/URIFul.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public class URIFul extends URIRef { - public final String urilit_; - - public URIFul(String p1) { urilit_ = p1; } - - public <R,A> R accept(com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef.Visitor<R,A> v, A arg) { return v.visit(this, arg); } - - public boolean equals(Object o) { - if (this == o) return true; - if (o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul) { - com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul x = (com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul)o; - return this.urilit_.equals(x.urilit_); - } - return false; - } - - public int hashCode() { - return this.urilit_.hashCode(); - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/URIRef.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/URIRef.java deleted file mode 100644 index 4df8f5cb9a8942e2bc84b09fb3e1e5602fad34e6..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Absyn/URIRef.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan.Absyn; // Java Package generated by the BNF Converter. - -public abstract class URIRef implements java.io.Serializable { - public abstract <R,A> R accept(URIRef.Visitor<R,A> v, A arg); - public interface Visitor <R,A> { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul p, A arg); - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URICur p, A arg); - - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/AllVisitor.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/AllVisitor.java deleted file mode 100644 index 4875d542f520f91f59cfd4c1374dbe110b1df10a..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/AllVisitor.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan; - -import com.googlecode.opennars.parser.loan.Loan.Absyn.*; - -/** BNFC-Generated All Visitor */ -public interface AllVisitor<R,A> extends - com.googlecode.opennars.parser.loan.Loan.Absyn.Document.Visitor<R,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule.Visitor<R,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence.Visitor<R,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.Budget.Visitor<R,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<R,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<R,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef.Visitor<R,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<R,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix.Visitor<R,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue.Visitor<R,A> -{} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/ComposVisitor.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/ComposVisitor.java deleted file mode 100644 index 0d724af767a79de0b1f496805bc0eeed9a2e27e3..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/ComposVisitor.java +++ /dev/null @@ -1,476 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan; -import com.googlecode.opennars.parser.loan.Loan.Absyn.*; -/** BNFC-Generated Composition Visitor -*/ - -public class ComposVisitor<A> implements - com.googlecode.opennars.parser.loan.Loan.Absyn.Document.Visitor<com.googlecode.opennars.parser.loan.Loan.Absyn.Document,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule.Visitor<com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence.Visitor<com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.Budget.Visitor<com.googlecode.opennars.parser.loan.Loan.Absyn.Budget,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm.Visitor<com.googlecode.opennars.parser.loan.Loan.Absyn.Stm,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.Term.Visitor<com.googlecode.opennars.parser.loan.Loan.Absyn.Term,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef.Visitor<com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal.Visitor<com.googlecode.opennars.parser.loan.Loan.Absyn.Literal,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix.Visitor<com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix,A>, - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue.Visitor<com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue,A> -{ -/* Document */ - public Document visit(com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR p, A arg) - { - BaseRule baserule_ = p.baserule_.accept(this, arg); - ListSentence listsentence_ = new ListSentence(); - for (Sentence x : p.listsentence_) { - listsentence_.add(x.accept(this,arg)); - } - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR(baserule_, listsentence_); - } - public Document visit(com.googlecode.opennars.parser.loan.Loan.Absyn.Doc p, A arg) - { - ListSentence listsentence_ = new ListSentence(); - for (Sentence x : p.listsentence_) { - listsentence_.add(x.accept(this,arg)); - } - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.Doc(listsentence_); - } - -/* BaseRule */ - public BaseRule visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR p, A arg) - { - String urilit_ = p.urilit_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR(urilit_); - } - -/* Sentence */ - public Sentence visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix p, A arg) - { - NSPrefix nsprefix_ = p.nsprefix_.accept(this, arg); - String urilit_ = p.urilit_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix(nsprefix_, urilit_); - } - public Sentence visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport p, A arg) - { - String urilit_ = p.urilit_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport(urilit_); - } - public Sentence visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay p, A arg) - { - Integer integer_ = p.integer_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay(integer_); - } - public Sentence visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp p, A arg) - { - URIRef uriref_ = p.uriref_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp(uriref_); - } - public Sentence visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge p, A arg) - { - Stm stm_ = p.stm_.accept(this, arg); - TruthValue truthvalue_ = p.truthvalue_.accept(this, arg); - Budget budget_ = p.budget_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge(stm_, truthvalue_, budget_); - } - public Sentence visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest p, A arg) - { - Stm stm_ = p.stm_.accept(this, arg); - Budget budget_ = p.budget_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest(stm_, budget_); - } - public Sentence visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal p, A arg) - { - Stm stm_ = p.stm_.accept(this, arg); - TruthValue truthvalue_ = p.truthvalue_.accept(this, arg); - Budget budget_ = p.budget_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal(stm_, truthvalue_, budget_); - } - -/* Budget */ - public Budget visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE p, A arg) - { - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE(); - } - public Budget visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP p, A arg) - { - Double double_ = p.double_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP(double_); - } - public Budget visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD p, A arg) - { - Double double_1 = p.double_1; - Double double_2 = p.double_2; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD(double_1, double_2); - } - -/* Stm */ - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl p, A arg) - { - Stm stm_1 = p.stm_1.accept(this, arg); - Stm stm_2 = p.stm_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl(stm_1, stm_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv p, A arg) - { - Stm stm_1 = p.stm_1.accept(this, arg); - Stm stm_2 = p.stm_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv(stm_1, stm_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred p, A arg) - { - Stm stm_1 = p.stm_1.accept(this, arg); - Stm stm_2 = p.stm_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred(stm_1, stm_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet p, A arg) - { - Stm stm_1 = p.stm_1.accept(this, arg); - Stm stm_2 = p.stm_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet(stm_1, stm_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc p, A arg) - { - Stm stm_1 = p.stm_1.accept(this, arg); - Stm stm_2 = p.stm_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc(stm_1, stm_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred p, A arg) - { - Stm stm_1 = p.stm_1.accept(this, arg); - Stm stm_2 = p.stm_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred(stm_1, stm_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc p, A arg) - { - Stm stm_1 = p.stm_1.accept(this, arg); - Stm stm_2 = p.stm_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc(stm_1, stm_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj p, A arg) - { - Stm stm_1 = p.stm_1.accept(this, arg); - Stm stm_2 = p.stm_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj(stm_1, stm_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj p, A arg) - { - Stm stm_1 = p.stm_1.accept(this, arg); - Stm stm_2 = p.stm_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj(stm_1, stm_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar p, A arg) - { - Stm stm_1 = p.stm_1.accept(this, arg); - Stm stm_2 = p.stm_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar(stm_1, stm_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq p, A arg) - { - Stm stm_1 = p.stm_1.accept(this, arg); - Stm stm_2 = p.stm_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq(stm_1, stm_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot p, A arg) - { - Stm stm_ = p.stm_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot(stm_); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst p, A arg) - { - Stm stm_ = p.stm_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst(stm_); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres p, A arg) - { - Stm stm_ = p.stm_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres(stm_); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut p, A arg) - { - Stm stm_ = p.stm_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut(stm_); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher p, A arg) - { - Term term_1 = p.term_1.accept(this, arg); - Term term_2 = p.term_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher(term_1, term_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim p, A arg) - { - Term term_1 = p.term_1.accept(this, arg); - Term term_2 = p.term_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim(term_1, term_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst p, A arg) - { - Term term_1 = p.term_1.accept(this, arg); - Term term_2 = p.term_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst(term_1, term_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp p, A arg) - { - Term term_1 = p.term_1.accept(this, arg); - Term term_2 = p.term_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp(term_1, term_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp p, A arg) - { - Term term_1 = p.term_1.accept(this, arg); - Term term_2 = p.term_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp(term_1, term_2); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp p, A arg) - { - Term term_ = p.term_.accept(this, arg); - ListTerm listterm_ = new ListTerm(); - for (Term x : p.listterm_) { - listterm_.add(x.accept(this,arg)); - } - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp(term_, listterm_); - } - public Stm visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm p, A arg) - { - Term term_ = p.term_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm(term_); - } - -/* Term */ - public Term visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt p, A arg) - { - Term term_1 = p.term_1.accept(this, arg); - Term term_2 = p.term_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt(term_1, term_2); - } - public Term visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt p, A arg) - { - Term term_1 = p.term_1.accept(this, arg); - Term term_2 = p.term_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt(term_1, term_2); - } - public Term visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif p, A arg) - { - Term term_1 = p.term_1.accept(this, arg); - Term term_2 = p.term_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif(term_1, term_2); - } - public Term visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif p, A arg) - { - Term term_1 = p.term_1.accept(this, arg); - Term term_2 = p.term_2.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif(term_1, term_2); - } - public Term visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg p, A arg) - { - Term term_ = p.term_.accept(this, arg); - ListTerm listterm_1 = new ListTerm(); - for (Term x : p.listterm_1) { - listterm_1.add(x.accept(this,arg)); - } - ListTerm listterm_2 = new ListTerm(); - for (Term x : p.listterm_2) { - listterm_2.add(x.accept(this,arg)); - } - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg(term_, listterm_1, listterm_2); - } - public Term visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg p, A arg) - { - Term term_ = p.term_.accept(this, arg); - ListTerm listterm_1 = new ListTerm(); - for (Term x : p.listterm_1) { - listterm_1.add(x.accept(this,arg)); - } - ListTerm listterm_2 = new ListTerm(); - for (Term x : p.listterm_2) { - listterm_2.add(x.accept(this,arg)); - } - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg(term_, listterm_1, listterm_2); - } - public Term visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet p, A arg) - { - ListTerm listterm_ = new ListTerm(); - for (Term x : p.listterm_) { - listterm_.add(x.accept(this,arg)); - } - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet(listterm_); - } - public Term visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet p, A arg) - { - ListTerm listterm_ = new ListTerm(); - for (Term x : p.listterm_) { - listterm_.add(x.accept(this,arg)); - } - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet(listterm_); - } - public Term visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd p, A arg) - { - ListTerm listterm_ = new ListTerm(); - for (Term x : p.listterm_) { - listterm_.add(x.accept(this,arg)); - } - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd(listterm_); - } - public Term visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit p, A arg) - { - Literal literal_ = p.literal_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit(literal_); - } - public Term visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm p, A arg) - { - Stm stm_ = p.stm_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm(stm_); - } - -/* URIRef */ - public URIRef visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul p, A arg) - { - String urilit_ = p.urilit_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul(urilit_); - } - public URIRef visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URICur p, A arg) - { - NSPrefix nsprefix_ = p.nsprefix_.accept(this, arg); - String ident_ = p.ident_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.URICur(nsprefix_, ident_); - } - -/* Literal */ - public Literal visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar p, A arg) - { - String ident_ = p.ident_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar(ident_); - } - public Literal visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn p, A arg) - { - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn(); - } - public Literal visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD p, A arg) - { - String ident_ = p.ident_; - ListIdent listident_ = p.listident_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD(ident_, listident_); - } - public Literal visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI p, A arg) - { - String ident_ = p.ident_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI(ident_); - } - public Literal visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI p, A arg) - { - URIRef uriref_ = p.uriref_.accept(this, arg); - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI(uriref_); - } - public Literal visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt p, A arg) - { - Integer integer_ = p.integer_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt(integer_); - } - public Literal visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl p, A arg) - { - Double double_ = p.double_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl(double_); - } - public Literal visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitString p, A arg) - { - String string_ = p.string_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.LitString(string_); - } - public Literal visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue p, A arg) - { - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue(); - } - public Literal visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse p, A arg) - { - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse(); - } - -/* NSPrefix */ - public NSPrefix visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1 p, A arg) - { - String ident_ = p.ident_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1(ident_); - } - public NSPrefix visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2 p, A arg) - { - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2(); - } - -/* TruthValue */ - public TruthValue visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE p, A arg) - { - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE(); - } - public TruthValue visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF p, A arg) - { - Double double_ = p.double_; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF(double_); - } - public TruthValue visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC p, A arg) - { - Double double_1 = p.double_1; - Double double_2 = p.double_2; - - return new com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC(double_1, double_2); - } - -} \ No newline at end of file diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/FoldVisitor.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/FoldVisitor.java deleted file mode 100644 index 30368d80dc5aedfbac7db8ded638a90392d14abe..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/FoldVisitor.java +++ /dev/null @@ -1,379 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan; - -import com.googlecode.opennars.parser.loan.Loan.Absyn.*; -import java.util.Collections; -import java.util.List; -import java.util.ArrayList; - -/** BNFC-Generated Fold Visitor */ -public abstract class FoldVisitor<R,A> implements AllVisitor<R,A> { - public abstract R leaf(A arg); - public abstract R combine(R x, R y, A arg); - -/* Document */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR p, A arg) { - R r = leaf(arg); - r = combine(p.baserule_.accept(this, arg), r, arg); - for (Sentence x : p.listsentence_) { - r = combine(x.accept(this,arg), r, arg); - } - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.Doc p, A arg) { - R r = leaf(arg); - for (Sentence x : p.listsentence_) { - r = combine(x.accept(this,arg), r, arg); - } - return r; - } - -/* BaseRule */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR p, A arg) { - R r = leaf(arg); - return r; - } - -/* Sentence */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix p, A arg) { - R r = leaf(arg); - r = combine(p.nsprefix_.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp p, A arg) { - R r = leaf(arg); - r = combine(p.uriref_.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge p, A arg) { - R r = leaf(arg); - r = combine(p.stm_.accept(this, arg), r, arg); - r = combine(p.truthvalue_.accept(this, arg), r, arg); - r = combine(p.budget_.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest p, A arg) { - R r = leaf(arg); - r = combine(p.stm_.accept(this, arg), r, arg); - r = combine(p.budget_.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal p, A arg) { - R r = leaf(arg); - r = combine(p.stm_.accept(this, arg), r, arg); - r = combine(p.truthvalue_.accept(this, arg), r, arg); - r = combine(p.budget_.accept(this, arg), r, arg); - return r; - } - -/* Budget */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD p, A arg) { - R r = leaf(arg); - return r; - } - -/* Stm */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl p, A arg) { - R r = leaf(arg); - r = combine(p.stm_1.accept(this, arg), r, arg); - r = combine(p.stm_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv p, A arg) { - R r = leaf(arg); - r = combine(p.stm_1.accept(this, arg), r, arg); - r = combine(p.stm_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred p, A arg) { - R r = leaf(arg); - r = combine(p.stm_1.accept(this, arg), r, arg); - r = combine(p.stm_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet p, A arg) { - R r = leaf(arg); - r = combine(p.stm_1.accept(this, arg), r, arg); - r = combine(p.stm_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc p, A arg) { - R r = leaf(arg); - r = combine(p.stm_1.accept(this, arg), r, arg); - r = combine(p.stm_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred p, A arg) { - R r = leaf(arg); - r = combine(p.stm_1.accept(this, arg), r, arg); - r = combine(p.stm_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc p, A arg) { - R r = leaf(arg); - r = combine(p.stm_1.accept(this, arg), r, arg); - r = combine(p.stm_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj p, A arg) { - R r = leaf(arg); - r = combine(p.stm_1.accept(this, arg), r, arg); - r = combine(p.stm_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj p, A arg) { - R r = leaf(arg); - r = combine(p.stm_1.accept(this, arg), r, arg); - r = combine(p.stm_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar p, A arg) { - R r = leaf(arg); - r = combine(p.stm_1.accept(this, arg), r, arg); - r = combine(p.stm_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq p, A arg) { - R r = leaf(arg); - r = combine(p.stm_1.accept(this, arg), r, arg); - r = combine(p.stm_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot p, A arg) { - R r = leaf(arg); - r = combine(p.stm_.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst p, A arg) { - R r = leaf(arg); - r = combine(p.stm_.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres p, A arg) { - R r = leaf(arg); - r = combine(p.stm_.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut p, A arg) { - R r = leaf(arg); - r = combine(p.stm_.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher p, A arg) { - R r = leaf(arg); - r = combine(p.term_1.accept(this, arg), r, arg); - r = combine(p.term_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim p, A arg) { - R r = leaf(arg); - r = combine(p.term_1.accept(this, arg), r, arg); - r = combine(p.term_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst p, A arg) { - R r = leaf(arg); - r = combine(p.term_1.accept(this, arg), r, arg); - r = combine(p.term_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp p, A arg) { - R r = leaf(arg); - r = combine(p.term_1.accept(this, arg), r, arg); - r = combine(p.term_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp p, A arg) { - R r = leaf(arg); - r = combine(p.term_1.accept(this, arg), r, arg); - r = combine(p.term_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp p, A arg) { - R r = leaf(arg); - r = combine(p.term_.accept(this, arg), r, arg); - for (Term x : p.listterm_) { - r = combine(x.accept(this,arg), r, arg); - } - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm p, A arg) { - R r = leaf(arg); - r = combine(p.term_.accept(this, arg), r, arg); - return r; - } - -/* Term */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt p, A arg) { - R r = leaf(arg); - r = combine(p.term_1.accept(this, arg), r, arg); - r = combine(p.term_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt p, A arg) { - R r = leaf(arg); - r = combine(p.term_1.accept(this, arg), r, arg); - r = combine(p.term_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif p, A arg) { - R r = leaf(arg); - r = combine(p.term_1.accept(this, arg), r, arg); - r = combine(p.term_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif p, A arg) { - R r = leaf(arg); - r = combine(p.term_1.accept(this, arg), r, arg); - r = combine(p.term_2.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg p, A arg) { - R r = leaf(arg); - r = combine(p.term_.accept(this, arg), r, arg); - for (Term x : p.listterm_1) { - r = combine(x.accept(this,arg), r, arg); - } - for (Term x : p.listterm_2) { - r = combine(x.accept(this,arg), r, arg); - } - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg p, A arg) { - R r = leaf(arg); - r = combine(p.term_.accept(this, arg), r, arg); - for (Term x : p.listterm_1) { - r = combine(x.accept(this,arg), r, arg); - } - for (Term x : p.listterm_2) { - r = combine(x.accept(this,arg), r, arg); - } - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet p, A arg) { - R r = leaf(arg); - for (Term x : p.listterm_) { - r = combine(x.accept(this,arg), r, arg); - } - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet p, A arg) { - R r = leaf(arg); - for (Term x : p.listterm_) { - r = combine(x.accept(this,arg), r, arg); - } - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd p, A arg) { - R r = leaf(arg); - for (Term x : p.listterm_) { - r = combine(x.accept(this,arg), r, arg); - } - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit p, A arg) { - R r = leaf(arg); - r = combine(p.literal_.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm p, A arg) { - R r = leaf(arg); - r = combine(p.stm_.accept(this, arg), r, arg); - return r; - } - -/* URIRef */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URICur p, A arg) { - R r = leaf(arg); - r = combine(p.nsprefix_.accept(this, arg), r, arg); - return r; - } - -/* Literal */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI p, A arg) { - R r = leaf(arg); - r = combine(p.uriref_.accept(this, arg), r, arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitString p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse p, A arg) { - R r = leaf(arg); - return r; - } - -/* NSPrefix */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1 p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2 p, A arg) { - R r = leaf(arg); - return r; - } - -/* TruthValue */ - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF p, A arg) { - R r = leaf(arg); - return r; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC p, A arg) { - R r = leaf(arg); - return r; - } - - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Loan.cup b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Loan.cup deleted file mode 100644 index 64cbfcb8cc37689fec2a75cc63f09521f6b9efa6..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Loan.cup +++ /dev/null @@ -1,202 +0,0 @@ -// -*- Java -*- This Cup file was machine-generated by BNFC -package com.googlecode.opennars.parser.loan.Loan; - -parser code {: - public com.googlecode.opennars.parser.loan.Loan.Absyn.Document pDocument() throws Exception - { - java_cup.runtime.Symbol res = parse(); - return (com.googlecode.opennars.parser.loan.Loan.Absyn.Document) res.value; - } - -public <B,A extends java.util.LinkedList<? super B>> A cons_(B x, A xs) { xs.addFirst(x); return xs; } - -public void syntax_error(java_cup.runtime.Symbol cur_token) -{ - report_error("Syntax Error, trying to recover and continue parse...", cur_token); -} - -public void unrecovered_syntax_error(java_cup.runtime.Symbol cur_token) throws java.lang.Exception -{ - throw new Exception("Unrecoverable Syntax Error"); -} - -:} - -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Document Document; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule BaseRule; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence ListSentence; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence Sentence; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Budget Budget; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Stm Stm; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Stm Stm1; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Stm Stm2; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Stm Stm3; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Term Term; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Term Term1; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Term Term2; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Term Term3; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm ListTerm; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent ListIdent; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef URIRef; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.Literal Literal; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix NSPrefix; -nonterminal com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue TruthValue; - -terminal _SYMB_0; // @base -terminal _SYMB_1; // . -terminal _SYMB_2; // @prefix -terminal _SYMB_3; // @import -terminal _SYMB_4; // @delay -terminal _SYMB_5; // @operator -terminal _SYMB_6; // ? -terminal _SYMB_7; // ! -terminal _SYMB_8; // @budget -terminal _SYMB_9; // ( -terminal _SYMB_10; // ) -terminal _SYMB_11; // ; -terminal _SYMB_12; // ==> -terminal _SYMB_13; // <=> -terminal _SYMB_14; // =/> -terminal _SYMB_15; // =\> -terminal _SYMB_16; // =|> -terminal _SYMB_17; // </> -terminal _SYMB_18; // <|> -terminal _SYMB_19; // && -terminal _SYMB_20; // || -terminal _SYMB_21; // , -terminal _SYMB_22; // --> -terminal _SYMB_23; // <-> -terminal _SYMB_24; // }-> -terminal _SYMB_25; // --[ -terminal _SYMB_26; // }-[ -terminal _SYMB_27; // & -terminal _SYMB_28; // | -terminal _SYMB_29; // - -terminal _SYMB_30; // ~ -terminal _SYMB_31; // / -terminal _SYMB_32; // \ -terminal _SYMB_33; // { -terminal _SYMB_34; // } -terminal _SYMB_35; // [ -terminal _SYMB_36; // ] -terminal _SYMB_37; // # -terminal _SYMB_38; // : -terminal _SYMB_39; // % -terminal _SYMB_40; // false -terminal _SYMB_41; // future -terminal _SYMB_42; // not -terminal _SYMB_43; // past -terminal _SYMB_44; // present -terminal _SYMB_45; // true - -terminal String _STRING_; - -terminal Integer _INTEGER_; -terminal Double _DOUBLE_; -terminal String _IDENT_; - -terminal String URILit; - - -start with Document; - - -Document ::= BaseRule:p_1 ListSentence:p_2 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR(p_1,p_2); :} - | ListSentence:p_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.Doc(p_1); :} -; -BaseRule ::= _SYMB_0 URILit:p_2 _SYMB_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR(p_2); :} -; -ListSentence ::= /* empty */ {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence(); :} - | ListSentence:p_1 Sentence:p_2 {: RESULT = p_1; p_1.addLast(p_2); :} -; -Sentence ::= _SYMB_2 NSPrefix:p_2 URILit:p_3 _SYMB_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix(p_2,p_3); :} - | _SYMB_3 URILit:p_2 _SYMB_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport(p_2); :} - | _SYMB_4 _INTEGER_:p_2 _SYMB_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay(p_2); :} - | _SYMB_5 URIRef:p_2 _SYMB_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp(p_2); :} - | Stm:p_1 TruthValue:p_2 Budget:p_3 _SYMB_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge(p_1,p_2,p_3); :} - | Stm:p_1 _SYMB_6 Budget:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest(p_1,p_3); :} - | Stm:p_1 TruthValue:p_2 Budget:p_3 _SYMB_7 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal(p_1,p_2,p_3); :} -; -Budget ::= /* empty */ {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE(); :} - | _SYMB_8 _SYMB_9 _DOUBLE_:p_3 _SYMB_10 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP(p_3); :} - | _SYMB_8 _SYMB_9 _DOUBLE_:p_3 _SYMB_11 _DOUBLE_:p_5 _SYMB_10 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD(p_3,p_5); :} -; -Stm ::= Stm:p_1 _SYMB_12 Stm1:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl(p_1,p_3); :} - | Stm:p_1 _SYMB_13 Stm1:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv(p_1,p_3); :} - | Stm:p_1 _SYMB_14 Stm1:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred(p_1,p_3); :} - | Stm:p_1 _SYMB_15 Stm1:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet(p_1,p_3); :} - | Stm:p_1 _SYMB_16 Stm1:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc(p_1,p_3); :} - | Stm:p_1 _SYMB_17 Stm1:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred(p_1,p_3); :} - | Stm:p_1 _SYMB_18 Stm1:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc(p_1,p_3); :} - | Stm1:p_1 {: RESULT = p_1; :} -; -Stm1 ::= Stm1:p_1 _SYMB_19 Stm2:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj(p_1,p_3); :} - | Stm1:p_1 _SYMB_20 Stm2:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj(p_1,p_3); :} - | Stm1:p_1 _SYMB_11 Stm2:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar(p_1,p_3); :} - | Stm1:p_1 _SYMB_21 Stm2:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq(p_1,p_3); :} - | Stm2:p_1 {: RESULT = p_1; :} -; -Stm2 ::= _SYMB_42 Stm3:p_2 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot(p_2); :} - | _SYMB_43 Stm3:p_2 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst(p_2); :} - | _SYMB_44 Stm3:p_2 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres(p_2); :} - | _SYMB_41 Stm3:p_2 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut(p_2); :} - | Stm3:p_1 {: RESULT = p_1; :} -; -Stm3 ::= Term:p_1 _SYMB_22 Term:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher(p_1,p_3); :} - | Term:p_1 _SYMB_23 Term:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim(p_1,p_3); :} - | Term:p_1 _SYMB_24 Term:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst(p_1,p_3); :} - | Term:p_1 _SYMB_25 Term:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp(p_1,p_3); :} - | Term:p_1 _SYMB_26 Term:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp(p_1,p_3); :} - | Term:p_1 _SYMB_9 ListTerm:p_3 _SYMB_10 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp(p_1,p_3); :} - | Term:p_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm(p_1); :} - | _SYMB_9 Stm:p_2 _SYMB_10 {: RESULT = p_2; :} -; -Term ::= Term:p_1 _SYMB_27 Term1:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt(p_1,p_3); :} - | Term:p_1 _SYMB_28 Term1:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt(p_1,p_3); :} - | Term1:p_1 {: RESULT = p_1; :} -; -Term1 ::= Term1:p_1 _SYMB_29 Term2:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif(p_1,p_3); :} - | Term1:p_1 _SYMB_30 Term2:p_3 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif(p_1,p_3); :} - | Term2:p_1 {: RESULT = p_1; :} -; -Term2 ::= Term:p_1 _SYMB_9 ListTerm:p_3 _SYMB_31 ListTerm:p_5 _SYMB_10 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg(p_1,p_3,p_5); :} - | Term:p_1 _SYMB_9 ListTerm:p_3 _SYMB_32 ListTerm:p_5 _SYMB_10 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg(p_1,p_3,p_5); :} - | Term3:p_1 {: RESULT = p_1; :} -; -Term3 ::= _SYMB_33 ListTerm:p_2 _SYMB_34 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet(p_2); :} - | _SYMB_35 ListTerm:p_2 _SYMB_36 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet(p_2); :} - | _SYMB_9 ListTerm:p_2 _SYMB_10 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd(p_2); :} - | Literal:p_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit(p_1); :} - | _SYMB_9 Stm:p_2 _SYMB_10 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm(p_2); :} - | _SYMB_9 Term:p_2 _SYMB_10 {: RESULT = p_2; :} -; -ListTerm ::= /* empty */ {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm(); :} - | Term:p_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm(); RESULT.addLast(p_1); :} - | Term:p_1 _SYMB_21 ListTerm:p_3 {: RESULT = p_3; p_3.addFirst(p_1); :} -; -ListIdent ::= /* empty */ {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent(); :} - | _IDENT_:p_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent(); RESULT.addLast(p_1); :} - | _IDENT_:p_1 _SYMB_21 ListIdent:p_3 {: RESULT = p_3; p_3.addFirst(p_1); :} -; -URIRef ::= URILit:p_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul(p_1); :} - | NSPrefix:p_1 _IDENT_:p_2 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.URICur(p_1,p_2); :} -; -Literal ::= _SYMB_6 _IDENT_:p_2 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar(p_2); :} - | _SYMB_6 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn(); :} - | _SYMB_37 _IDENT_:p_2 _SYMB_9 ListIdent:p_4 _SYMB_10 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD(p_2,p_4); :} - | _SYMB_37 _IDENT_:p_2 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI(p_2); :} - | URIRef:p_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI(p_1); :} - | _INTEGER_:p_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt(p_1); :} - | _DOUBLE_:p_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl(p_1); :} - | _STRING_:p_1 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitString(p_1); :} - | _SYMB_45 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue(); :} - | _SYMB_40 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse(); :} -; -NSPrefix ::= _IDENT_:p_1 _SYMB_38 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1(p_1); :} - | _SYMB_38 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2(); :} -; -TruthValue ::= /* empty */ {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE(); :} - | _SYMB_39 _DOUBLE_:p_2 _SYMB_39 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF(p_2); :} - | _SYMB_39 _DOUBLE_:p_2 _SYMB_11 _DOUBLE_:p_4 _SYMB_39 {: RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC(p_2,p_4); :} -; - diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/PrettyPrinter.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/PrettyPrinter.java deleted file mode 100644 index bdb7a6528f36f7e28868facac97c6ba8842dec09..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/PrettyPrinter.java +++ /dev/null @@ -1,1571 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan; -import com.googlecode.opennars.parser.loan.Loan.Absyn.*; - -public class PrettyPrinter -{ - //For certain applications increasing the initial size of the buffer may improve performance. - private static final int INITIAL_BUFFER_SIZE = 128; - //You may wish to change the parentheses used in precedence. - private static final String _L_PAREN = new String("("); - private static final String _R_PAREN = new String(")"); - - private static boolean inAtRule = false; - //You may wish to change render - private static void render(String s) - { - if (s.equals("{")) - { - //buf_.append("\n"); - //indent(); - buf_.append(s); - //_n_ = _n_ + 2; - //buf_.append("\n"); - //indent(); - } - else if (s.equals("(") || s.equals("[")) - buf_.append(s); - else if (s.equals(")") || s.equals("]")) - { - //backup(); - trim(); - buf_.append(s); - //buf_.append(" "); - } - else if (s.equals("}")) - { - //_n_ = _n_ - 2; - //backup(); - //backup(); - buf_.append(s); - //buf_.append("\n"); - //indent(); - } - else if (s.equals(",")) - { - //backup(); - buf_.append(s); - buf_.append(" "); - } - else if (s.equals(";")) - { - //backup(); - buf_.append(s); - buf_.append(" "); - //buf_.append("\n"); - //indent(); - } - else if (s.equals(":")) { - if(!inAtRule) trim(); - buf_.append(s); - if(inAtRule) buf_.append(" "); - } - else if (s.equals(".") && inAtRule) { - trim(); - inAtRule = false; - buf_.append(s); - } - else if (s.equals("")) return; - else if (s.equals("&") || s.equals("&&") || s.equals("%") - || s.equals("|") || s.equals("||") || s.equals("-") || s.equals("~") || s.equals("/") - || s.equals("\\") || s.equals("-->") || s.equals("<->") || s.equals("}->") - || s.equals("--[") || s.equals("}-[") || s.equals("==>") || s.equals("<=>") - || s.equals("=/>") || s.equals("=\\>") || s.equals("=|>") || s.equals("<|>") - || s.equals("</>")) { - trim(); - buf_.append(" "); - buf_.append(s); - buf_.append(" "); - } - else if (s.equals("not") || s.equals("future") || s.equals("present") || s.equals("past") - || s.equals("@budget")) { - buf_.append(s); - buf_.append(" "); - } - else if (s.equals("@base") || s.equals("@import") || s.equals("@prefix") || s.equals("@operator") - || s.equals("@delay")) { - buf_.append(s); - buf_.append(" "); - inAtRule = true; - } - else - { - buf_.append(s); - // buf_.append(" "); - } - } - - - // print and show methods are defined for each category. - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.Document foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.Document foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.Budget foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.Budget foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.Term foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.Term foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String print(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue foo) - { - pp(foo, 0); - trim(); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - public static String show(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue foo) - { - sh(foo); - String temp = buf_.toString(); - buf_.delete(0,buf_.length()); - return temp; - } - /*** You shouldn't need to change anything beyond this point. ***/ - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.Document foo, int _i_) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR _docbr = (com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_docbr.baserule_, 0); - pp(_docbr.listsentence_, 0); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.Doc) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Doc _doc = (com.googlecode.opennars.parser.loan.Loan.Absyn.Doc) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_doc.listsentence_, 0); - if (_i_ > 0) render(_R_PAREN); - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule foo, int _i_) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR _baser = (com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR) foo; - if (_i_ > 0) render(_L_PAREN); - render("@base"); - pp(_baser.urilit_, 0); - render("."); - if (_i_ > 0) render(_R_PAREN); - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence foo, int _i_) - { - for (java.util.Iterator<Sentence> it = foo.iterator(); it.hasNext();) - { - pp(it.next(), 0); - if (it.hasNext()) { - render(""); - } else { - render(""); - } - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence foo, int _i_) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix _sentprefix = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix) foo; - if (_i_ > 0) render(_L_PAREN); - render("@prefix"); - pp(_sentprefix.nsprefix_, 0); - pp(_sentprefix.urilit_, 0); - render("."); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport _sentimport = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport) foo; - if (_i_ > 0) render(_L_PAREN); - render("@import"); - pp(_sentimport.urilit_, 0); - render("."); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay _sentdelay = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay) foo; - if (_i_ > 0) render(_L_PAREN); - render("@delay"); - pp(_sentdelay.integer_, 0); - render("."); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp _sentop = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp) foo; - if (_i_ > 0) render(_L_PAREN); - render("@operator"); - pp(_sentop.uriref_, 0); - render("."); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge _sentjudge = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_sentjudge.stm_, 0); - pp(_sentjudge.truthvalue_, 0); - pp(_sentjudge.budget_, 0); - render("."); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest _sentquest = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_sentquest.stm_, 0); - render("?"); - pp(_sentquest.budget_, 0); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal _sentgoal = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_sentgoal.stm_, 0); - pp(_sentgoal.truthvalue_, 0); - pp(_sentgoal.budget_, 0); - render("!"); - if (_i_ > 0) render(_R_PAREN); - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.Budget foo, int _i_) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE _budgete = (com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE) foo; - if (_i_ > 0) render(_L_PAREN); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP _budgetp = (com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP) foo; - if (_i_ > 0) render(_L_PAREN); - render("@budget"); - render("("); - pp(_budgetp.double_, 0); - render(")"); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD _budgetpd = (com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD) foo; - if (_i_ > 0) render(_L_PAREN); - render("@budget"); - render("("); - pp(_budgetpd.double_1, 0); - render(";"); - pp(_budgetpd.double_2, 0); - render(")"); - if (_i_ > 0) render(_R_PAREN); - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm foo, int _i_) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl _stmimpl = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_stmimpl.stm_1, 0); - render("==>"); - pp(_stmimpl.stm_2, 1); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv _stmequiv = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_stmequiv.stm_1, 0); - render("<=>"); - pp(_stmequiv.stm_2, 1); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred _stmimppred = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_stmimppred.stm_1, 0); - render("=/>"); - pp(_stmimppred.stm_2, 1); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet _stmimpret = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_stmimpret.stm_1, 0); - render("=\\>"); - pp(_stmimpret.stm_2, 1); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc _stmimpconc = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_stmimpconc.stm_1, 0); - render("=|>"); - pp(_stmimpconc.stm_2, 1); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred _stmeqvpred = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_stmeqvpred.stm_1, 0); - render("</>"); - pp(_stmeqvpred.stm_2, 1); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc _stmeqvconc = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_stmeqvconc.stm_1, 0); - render("<|>"); - pp(_stmeqvconc.stm_2, 1); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj _stmconj = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj) foo; - if (_i_ > 1) render(_L_PAREN); - pp(_stmconj.stm_1, 1); - render("&&"); - pp(_stmconj.stm_2, 2); - if (_i_ > 1) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj _stmdisj = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj) foo; - if (_i_ > 1) render(_L_PAREN); - pp(_stmdisj.stm_1, 1); - render("||"); - pp(_stmdisj.stm_2, 2); - if (_i_ > 1) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar _stmpar = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar) foo; - if (_i_ > 1) render(_L_PAREN); - pp(_stmpar.stm_1, 1); - render(";"); - pp(_stmpar.stm_2, 2); - if (_i_ > 1) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq _stmseq = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq) foo; - if (_i_ > 1) render(_L_PAREN); - pp(_stmseq.stm_1, 1); - render(","); - pp(_stmseq.stm_2, 2); - if (_i_ > 1) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot _stmnot = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot) foo; - if (_i_ > 2) render(_L_PAREN); - render("not"); - pp(_stmnot.stm_, 3); - if (_i_ > 2) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst _stmpst = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst) foo; - if (_i_ > 2) render(_L_PAREN); - render("past"); - pp(_stmpst.stm_, 3); - if (_i_ > 2) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres _stmpres = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres) foo; - if (_i_ > 2) render(_L_PAREN); - render("present"); - pp(_stmpres.stm_, 3); - if (_i_ > 2) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut _stmfut = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut) foo; - if (_i_ > 2) render(_L_PAREN); - render("future"); - pp(_stmfut.stm_, 3); - if (_i_ > 2) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher _stminher = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher) foo; - if (_i_ > 3) render(_L_PAREN); - pp(_stminher.term_1, 0); - render("-->"); - pp(_stminher.term_2, 0); - if (_i_ > 3) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim _stmsim = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim) foo; - if (_i_ > 3) render(_L_PAREN); - pp(_stmsim.term_1, 0); - render("<->"); - pp(_stmsim.term_2, 0); - if (_i_ > 3) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst _stminst = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst) foo; - if (_i_ > 3) render(_L_PAREN); - pp(_stminst.term_1, 0); - render("}->"); - pp(_stminst.term_2, 0); - if (_i_ > 3) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp _stmprop = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp) foo; - if (_i_ > 3) render(_L_PAREN); - pp(_stmprop.term_1, 0); - render("--["); - pp(_stmprop.term_2, 0); - if (_i_ > 3) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp _stminpp = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp) foo; - if (_i_ > 3) render(_L_PAREN); - pp(_stminpp.term_1, 0); - render("}-["); - pp(_stminpp.term_2, 0); - if (_i_ > 3) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp _stmop = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp) foo; - if (_i_ > 3) render(_L_PAREN); - pp(_stmop.term_, 0); - render("("); - pp(_stmop.listterm_, 0); - render(")"); - if (_i_ > 3) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm _stmtrm = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm) foo; - if (_i_ > 3) render(_L_PAREN); - pp(_stmtrm.term_, 0); - if (_i_ > 3) render(_R_PAREN); - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.Term foo, int _i_) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt _trmexint = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_trmexint.term_1, 0); - render("&"); - pp(_trmexint.term_2, 1); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt _trminint = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_trminint.term_1, 0); - render("|"); - pp(_trminint.term_2, 1); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif _trmexdif = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif) foo; - if (_i_ > 1) render(_L_PAREN); - pp(_trmexdif.term_1, 1); - render("-"); - pp(_trmexdif.term_2, 2); - if (_i_ > 1) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif _trmindif = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif) foo; - if (_i_ > 1) render(_L_PAREN); - pp(_trmindif.term_1, 1); - render("~"); - pp(_trmindif.term_2, 2); - if (_i_ > 1) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg _trmeximg = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg) foo; - if (_i_ > 2) render(_L_PAREN); - pp(_trmeximg.term_, 0); - render("("); - pp(_trmeximg.listterm_1, 0); - render("/"); - pp(_trmeximg.listterm_2, 0); - render(")"); - if (_i_ > 2) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg _trminimg = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg) foo; - if (_i_ > 2) render(_L_PAREN); - pp(_trminimg.term_, 0); - render("("); - pp(_trminimg.listterm_1, 0); - render("\\"); - pp(_trminimg.listterm_2, 0); - render(")"); - if (_i_ > 2) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet _trmexset = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet) foo; - if (_i_ > 3) render(_L_PAREN); - render("{"); - pp(_trmexset.listterm_, 0); - render("}"); - if (_i_ > 3) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet _trminset = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet) foo; - if (_i_ > 3) render(_L_PAREN); - render("["); - pp(_trminset.listterm_, 0); - render("]"); - if (_i_ > 3) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd _trmprod = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd) foo; - if (_i_ > 3) render(_L_PAREN); - render("("); - pp(_trmprod.listterm_, 0); - render(")"); - if (_i_ > 3) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit _trmlit = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit) foo; - if (_i_ > 3) render(_L_PAREN); - pp(_trmlit.literal_, 0); - if (_i_ > 3) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm _trmstm = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm) foo; - if (_i_ > 3) render(_L_PAREN); - render("("); - pp(_trmstm.stm_, 0); - render(")"); - if (_i_ > 3) render(_R_PAREN); - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm foo, int _i_) - { - for (java.util.Iterator<Term> it = foo.iterator(); it.hasNext();) - { - pp(it.next(), 0); - if (it.hasNext()) { - render(","); - } else { - render(""); - } - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent foo, int _i_) - { - for (java.util.Iterator<String> it = foo.iterator(); it.hasNext();) - { - pp(it.next(), 0); - if (it.hasNext()) { - render(","); - } else { - render(""); - } - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef foo, int _i_) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul _uriful = (com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_uriful.urilit_, 0); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.URICur) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.URICur _uricur = (com.googlecode.opennars.parser.loan.Loan.Absyn.URICur) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_uricur.nsprefix_, 0); - pp(_uricur.ident_, 0); - if (_i_ > 0) render(_R_PAREN); - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal foo, int _i_) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar _litqvar = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar) foo; - if (_i_ > 0) render(_L_PAREN); - render("?"); - pp(_litqvar.ident_, 0); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn _litqvaran = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn) foo; - if (_i_ > 0) render(_L_PAREN); - render("?"); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD _litsvard = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD) foo; - if (_i_ > 0) render(_L_PAREN); - render("#"); - pp(_litsvard.ident_, 0); - render("("); - pp(_litsvard.listident_, 0); - render(")"); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI _litsvari = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI) foo; - if (_i_ > 0) render(_L_PAREN); - render("#"); - pp(_litsvari.ident_, 0); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI _lituri = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_lituri.uriref_, 0); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt _litint = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_litint.integer_, 0); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl _litdbl = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_litdbl.double_, 0); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitString) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitString _litstring = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitString) foo; - if (_i_ > 0) render(_L_PAREN); - printQuoted(_litstring.string_); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue _littrue = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue) foo; - if (_i_ > 0) render(_L_PAREN); - render("true"); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse _litfalse = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse) foo; - if (_i_ > 0) render(_L_PAREN); - render("false"); - if (_i_ > 0) render(_R_PAREN); - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix foo, int _i_) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1 _nsprefix1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1) foo; - if (_i_ > 0) render(_L_PAREN); - pp(_nsprefix1.ident_, 0); - render(":"); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2 _nsprefix2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2) foo; - if (_i_ > 0) render(_L_PAREN); - render(":"); - if (_i_ > 0) render(_R_PAREN); - } - } - - private static void pp(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue foo, int _i_) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE _truthe = (com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE) foo; - if (_i_ > 0) render(_L_PAREN); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF _truthf = (com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF) foo; - if (_i_ > 0) render(_L_PAREN); - render("%"); - pp(_truthf.double_, 0); - render("%"); - if (_i_ > 0) render(_R_PAREN); - } - else if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC _truthfc = (com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC) foo; - if (_i_ > 0) render(_L_PAREN); - render("%"); - pp(_truthfc.double_1, 0); - render(";"); - pp(_truthfc.double_2, 0); - render("%"); - if (_i_ > 0) render(_R_PAREN); - } - } - - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.Document foo) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR _docbr = (com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR) foo; - render("("); - render("DocBR"); - sh(_docbr.baserule_); - render("["); - sh(_docbr.listsentence_); - render("]"); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.Doc) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Doc _doc = (com.googlecode.opennars.parser.loan.Loan.Absyn.Doc) foo; - render("("); - render("Doc"); - render("["); - sh(_doc.listsentence_); - render("]"); - render(")"); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule foo) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR _baser = (com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR) foo; - render("("); - render("BaseR"); - sh(_baser.urilit_); - render(")"); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence foo) - { - for (java.util.Iterator<Sentence> it = foo.iterator(); it.hasNext();) - { - sh(it.next()); - if (it.hasNext()) - render(","); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence foo) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix _sentprefix = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix) foo; - render("("); - render("SentPrefix"); - sh(_sentprefix.nsprefix_); - sh(_sentprefix.urilit_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport _sentimport = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport) foo; - render("("); - render("SentImport"); - sh(_sentimport.urilit_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay _sentdelay = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay) foo; - render("("); - render("SentDelay"); - sh(_sentdelay.integer_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp _sentop = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp) foo; - render("("); - render("SentOp"); - sh(_sentop.uriref_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge _sentjudge = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge) foo; - render("("); - render("SentJudge"); - sh(_sentjudge.stm_); - sh(_sentjudge.truthvalue_); - sh(_sentjudge.budget_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest _sentquest = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest) foo; - render("("); - render("SentQuest"); - sh(_sentquest.stm_); - sh(_sentquest.budget_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal _sentgoal = (com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal) foo; - render("("); - render("SentGoal"); - sh(_sentgoal.stm_); - sh(_sentgoal.truthvalue_); - sh(_sentgoal.budget_); - render(")"); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.Budget foo) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE _budgete = (com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE) foo; - render("BudgetE"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP _budgetp = (com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP) foo; - render("("); - render("BudgetP"); - sh(_budgetp.double_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD _budgetpd = (com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD) foo; - render("("); - render("BudgetPD"); - sh(_budgetpd.double_1); - sh(_budgetpd.double_2); - render(")"); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.Stm foo) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl _stmimpl = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl) foo; - render("("); - render("StmImpl"); - sh(_stmimpl.stm_1); - sh(_stmimpl.stm_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv _stmequiv = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv) foo; - render("("); - render("StmEquiv"); - sh(_stmequiv.stm_1); - sh(_stmequiv.stm_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred _stmimppred = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred) foo; - render("("); - render("StmImpPred"); - sh(_stmimppred.stm_1); - sh(_stmimppred.stm_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet _stmimpret = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet) foo; - render("("); - render("StmImpRet"); - sh(_stmimpret.stm_1); - sh(_stmimpret.stm_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc _stmimpconc = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc) foo; - render("("); - render("StmImpConc"); - sh(_stmimpconc.stm_1); - sh(_stmimpconc.stm_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred _stmeqvpred = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred) foo; - render("("); - render("StmEqvPred"); - sh(_stmeqvpred.stm_1); - sh(_stmeqvpred.stm_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc _stmeqvconc = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc) foo; - render("("); - render("StmEqvConc"); - sh(_stmeqvconc.stm_1); - sh(_stmeqvconc.stm_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj _stmconj = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj) foo; - render("("); - render("StmConj"); - sh(_stmconj.stm_1); - sh(_stmconj.stm_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj _stmdisj = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj) foo; - render("("); - render("StmDisj"); - sh(_stmdisj.stm_1); - sh(_stmdisj.stm_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar _stmpar = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar) foo; - render("("); - render("StmPar"); - sh(_stmpar.stm_1); - sh(_stmpar.stm_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq _stmseq = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq) foo; - render("("); - render("StmSeq"); - sh(_stmseq.stm_1); - sh(_stmseq.stm_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot _stmnot = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot) foo; - render("("); - render("StmNot"); - sh(_stmnot.stm_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst _stmpst = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst) foo; - render("("); - render("StmPst"); - sh(_stmpst.stm_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres _stmpres = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres) foo; - render("("); - render("StmPres"); - sh(_stmpres.stm_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut _stmfut = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut) foo; - render("("); - render("StmFut"); - sh(_stmfut.stm_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher _stminher = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher) foo; - render("("); - render("StmInher"); - sh(_stminher.term_1); - sh(_stminher.term_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim _stmsim = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim) foo; - render("("); - render("StmSim"); - sh(_stmsim.term_1); - sh(_stmsim.term_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst _stminst = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst) foo; - render("("); - render("StmInst"); - sh(_stminst.term_1); - sh(_stminst.term_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp _stmprop = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp) foo; - render("("); - render("StmProp"); - sh(_stmprop.term_1); - sh(_stmprop.term_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp _stminpp = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp) foo; - render("("); - render("StmInPp"); - sh(_stminpp.term_1); - sh(_stminpp.term_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp _stmop = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp) foo; - render("("); - render("StmOp"); - sh(_stmop.term_); - render("["); - sh(_stmop.listterm_); - render("]"); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm _stmtrm = (com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm) foo; - render("("); - render("StmTrm"); - sh(_stmtrm.term_); - render(")"); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.Term foo) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt _trmexint = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt) foo; - render("("); - render("TrmExInt"); - sh(_trmexint.term_1); - sh(_trmexint.term_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt _trminint = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt) foo; - render("("); - render("TrmInInt"); - sh(_trminint.term_1); - sh(_trminint.term_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif _trmexdif = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif) foo; - render("("); - render("TrmExDif"); - sh(_trmexdif.term_1); - sh(_trmexdif.term_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif _trmindif = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif) foo; - render("("); - render("TrmInDif"); - sh(_trmindif.term_1); - sh(_trmindif.term_2); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg _trmeximg = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg) foo; - render("("); - render("TrmExImg"); - sh(_trmeximg.term_); - render("["); - sh(_trmeximg.listterm_1); - render("]"); - render("["); - sh(_trmeximg.listterm_2); - render("]"); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg _trminimg = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg) foo; - render("("); - render("TrmInImg"); - sh(_trminimg.term_); - render("["); - sh(_trminimg.listterm_1); - render("]"); - render("["); - sh(_trminimg.listterm_2); - render("]"); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet _trmexset = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet) foo; - render("("); - render("TrmExSet"); - render("["); - sh(_trmexset.listterm_); - render("]"); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet _trminset = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet) foo; - render("("); - render("TrmInSet"); - render("["); - sh(_trminset.listterm_); - render("]"); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd _trmprod = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd) foo; - render("("); - render("TrmProd"); - render("["); - sh(_trmprod.listterm_); - render("]"); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit _trmlit = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit) foo; - render("("); - render("TrmLit"); - sh(_trmlit.literal_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm _trmstm = (com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm) foo; - render("("); - render("TrmStm"); - sh(_trmstm.stm_); - render(")"); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm foo) - { - for (java.util.Iterator<Term> it = foo.iterator(); it.hasNext();) - { - sh(it.next()); - if (it.hasNext()) - render(","); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent foo) - { - for (java.util.Iterator<String> it = foo.iterator(); it.hasNext();) - { - sh(it.next()); - if (it.hasNext()) - render(","); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef foo) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul _uriful = (com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul) foo; - render("("); - render("URIFul"); - sh(_uriful.urilit_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.URICur) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.URICur _uricur = (com.googlecode.opennars.parser.loan.Loan.Absyn.URICur) foo; - render("("); - render("URICur"); - sh(_uricur.nsprefix_); - sh(_uricur.ident_); - render(")"); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.Literal foo) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar _litqvar = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar) foo; - render("("); - render("LitQVar"); - sh(_litqvar.ident_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn _litqvaran = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn) foo; - render("LitQVarAn"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD _litsvard = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD) foo; - render("("); - render("LitSVarD"); - sh(_litsvard.ident_); - render("["); - sh(_litsvard.listident_); - render("]"); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI _litsvari = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI) foo; - render("("); - render("LitSVarI"); - sh(_litsvari.ident_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI _lituri = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI) foo; - render("("); - render("LitURI"); - sh(_lituri.uriref_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt _litint = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt) foo; - render("("); - render("LitInt"); - sh(_litint.integer_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl _litdbl = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl) foo; - render("("); - render("LitDbl"); - sh(_litdbl.double_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitString) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitString _litstring = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitString) foo; - render("("); - render("LitString"); - sh(_litstring.string_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue _littrue = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue) foo; - render("LitTrue"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse _litfalse = (com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse) foo; - render("LitFalse"); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix foo) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1 _nsprefix1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1) foo; - render("("); - render("NSPrefix1"); - sh(_nsprefix1.ident_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2 _nsprefix2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2) foo; - render("NSPrefix2"); - } - } - - private static void sh(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue foo) - { - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE _truthe = (com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE) foo; - render("TruthE"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF _truthf = (com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF) foo; - render("("); - render("TruthF"); - sh(_truthf.double_); - render(")"); - } - if (foo instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC) - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC _truthfc = (com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC) foo; - render("("); - render("TruthFC"); - sh(_truthfc.double_1); - sh(_truthfc.double_2); - render(")"); - } - } - - - private static void pp(Integer n, int _i_) { buf_.append(n); buf_.append(" "); } - private static void pp(Double d, int _i_) { buf_.append(d); buf_.append(" "); } - private static void pp(String s, int _i_) { buf_.append(s); buf_.append(" "); } - private static void pp(Character c, int _i_) { buf_.append("'" + c.toString() + "'"); buf_.append(" "); } - private static void sh(Integer n) { render(n.toString()); } - private static void sh(Double d) { render(d.toString()); } - private static void sh(Character c) { render(c.toString()); } - private static void sh(String s) { printQuoted(s); } - private static void printQuoted(String s) { render("\"" + s + "\""); } - private static void indent() - { - int n = _n_; - while (n > 0) - { - buf_.append(" "); - n--; - } - } - private static void backup() - { - if (buf_.charAt(buf_.length() - 1) == ' ') { - buf_.setLength(buf_.length() - 1); - } - } - private static void trim() - { - while (buf_.length() > 0 && buf_.charAt(0) == ' ') - buf_.deleteCharAt(0); - while (buf_.length() > 0 && buf_.charAt(buf_.length()-1) == ' ') - buf_.deleteCharAt(buf_.length()-1); - } - private static int _n_ = 0; - private static StringBuilder buf_ = new StringBuilder(INITIAL_BUFFER_SIZE); -} - diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Test.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Test.java deleted file mode 100644 index 72587a88bfaebcc738e15e57e009e7c1684aa6fc..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Test.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan; -import java_cup.runtime.*; -import com.googlecode.opennars.parser.loan.Loan.*; -import com.googlecode.opennars.parser.loan.Loan.Absyn.*; -import java.io.*; - -public class Test -{ - public static void main(String args[]) throws Exception - { - Yylex l = null; - parser p; - try - { - if (args.length == 0) l = new Yylex(System.in); - else l = new Yylex(new FileReader(args[0])); - } - catch(FileNotFoundException e) - { - System.err.println("Error: File not found: " + args[0]); - System.exit(1); - } - p = new parser(l); - /* The default parser is the first-defined entry point. */ - /* You may want to change this. Other options are: */ - /* pSentence */ - try - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Document parse_tree = p.pDocument(); - System.out.println(); - System.out.println("Parse Succesful!"); - System.out.println(); - System.out.println("[Abstract Syntax]"); - System.out.println(); - System.out.println(PrettyPrinter.show(parse_tree)); - System.out.println(); - System.out.println("[Linearized Tree]"); - System.out.println(); - System.out.println(PrettyPrinter.print(parse_tree)); - } - catch(Throwable e) - { - System.err.println("At line " + String.valueOf(l.line_num()) + ", near \"" + l.buff() + "\" :"); - System.err.println(" " + e.getMessage()); - System.exit(1); - } - } -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/VisitSkel.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/VisitSkel.java deleted file mode 100644 index 4d7f1574a0de3b0794bd8dacd6ca52247be132fd..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/VisitSkel.java +++ /dev/null @@ -1,597 +0,0 @@ -package com.googlecode.opennars.parser.loan.Loan; -import com.googlecode.opennars.parser.loan.Loan.Absyn.*; -/*** BNFC-Generated Visitor Design Pattern Skeleton. ***/ -/* This implements the common visitor design pattern. - Tests show it to be slightly less efficient than the - instanceof method, but easier to use. - Replace the R and A parameters with the desired return - and context types.*/ - -public class VisitSkel -{ - public class DocumentVisitor<R,A> implements Document.Visitor<R,A> - { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR p, A arg) - { - /* Code For DocBR Goes Here */ - - p.baserule_.accept(new BaseRuleVisitor<R,A>(), arg); - for (Sentence x : p.listsentence_) { - } - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.Doc p, A arg) - { - /* Code For Doc Goes Here */ - - for (Sentence x : p.listsentence_) { - } - - return null; - } - - } - public class BaseRuleVisitor<R,A> implements BaseRule.Visitor<R,A> - { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR p, A arg) - { - /* Code For BaseR Goes Here */ - - //p.urilit_; - - return null; - } - - } - public class SentenceVisitor<R,A> implements Sentence.Visitor<R,A> - { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix p, A arg) - { - /* Code For SentPrefix Goes Here */ - - p.nsprefix_.accept(new NSPrefixVisitor<R,A>(), arg); - //p.urilit_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport p, A arg) - { - /* Code For SentImport Goes Here */ - - //p.urilit_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay p, A arg) - { - /* Code For SentDelay Goes Here */ - - //p.integer_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp p, A arg) - { - /* Code For SentOp Goes Here */ - - p.uriref_.accept(new URIRefVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge p, A arg) - { - /* Code For SentJudge Goes Here */ - - p.stm_.accept(new StmVisitor<R,A>(), arg); - p.truthvalue_.accept(new TruthValueVisitor<R,A>(), arg); - p.budget_.accept(new BudgetVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest p, A arg) - { - /* Code For SentQuest Goes Here */ - - p.stm_.accept(new StmVisitor<R,A>(), arg); - p.budget_.accept(new BudgetVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal p, A arg) - { - /* Code For SentGoal Goes Here */ - - p.stm_.accept(new StmVisitor<R,A>(), arg); - p.truthvalue_.accept(new TruthValueVisitor<R,A>(), arg); - p.budget_.accept(new BudgetVisitor<R,A>(), arg); - - return null; - } - - } - public class BudgetVisitor<R,A> implements Budget.Visitor<R,A> - { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE p, A arg) - { - /* Code For BudgetE Goes Here */ - - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP p, A arg) - { - /* Code For BudgetP Goes Here */ - - //p.double_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD p, A arg) - { - /* Code For BudgetPD Goes Here */ - - //p.double_1; - //p.double_2; - - return null; - } - - } - public class StmVisitor<R,A> implements Stm.Visitor<R,A> - { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl p, A arg) - { - /* Code For StmImpl Goes Here */ - - p.stm_1.accept(new StmVisitor<R,A>(), arg); - p.stm_2.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv p, A arg) - { - /* Code For StmEquiv Goes Here */ - - p.stm_1.accept(new StmVisitor<R,A>(), arg); - p.stm_2.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred p, A arg) - { - /* Code For StmImpPred Goes Here */ - - p.stm_1.accept(new StmVisitor<R,A>(), arg); - p.stm_2.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet p, A arg) - { - /* Code For StmImpRet Goes Here */ - - p.stm_1.accept(new StmVisitor<R,A>(), arg); - p.stm_2.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc p, A arg) - { - /* Code For StmImpConc Goes Here */ - - p.stm_1.accept(new StmVisitor<R,A>(), arg); - p.stm_2.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred p, A arg) - { - /* Code For StmEqvPred Goes Here */ - - p.stm_1.accept(new StmVisitor<R,A>(), arg); - p.stm_2.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc p, A arg) - { - /* Code For StmEqvConc Goes Here */ - - p.stm_1.accept(new StmVisitor<R,A>(), arg); - p.stm_2.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj p, A arg) - { - /* Code For StmConj Goes Here */ - - p.stm_1.accept(new StmVisitor<R,A>(), arg); - p.stm_2.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj p, A arg) - { - /* Code For StmDisj Goes Here */ - - p.stm_1.accept(new StmVisitor<R,A>(), arg); - p.stm_2.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar p, A arg) - { - /* Code For StmPar Goes Here */ - - p.stm_1.accept(new StmVisitor<R,A>(), arg); - p.stm_2.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq p, A arg) - { - /* Code For StmSeq Goes Here */ - - p.stm_1.accept(new StmVisitor<R,A>(), arg); - p.stm_2.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot p, A arg) - { - /* Code For StmNot Goes Here */ - - p.stm_.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst p, A arg) - { - /* Code For StmPst Goes Here */ - - p.stm_.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres p, A arg) - { - /* Code For StmPres Goes Here */ - - p.stm_.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut p, A arg) - { - /* Code For StmFut Goes Here */ - - p.stm_.accept(new StmVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher p, A arg) - { - /* Code For StmInher Goes Here */ - - p.term_1.accept(new TermVisitor<R,A>(), arg); - p.term_2.accept(new TermVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim p, A arg) - { - /* Code For StmSim Goes Here */ - - p.term_1.accept(new TermVisitor<R,A>(), arg); - p.term_2.accept(new TermVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst p, A arg) - { - /* Code For StmInst Goes Here */ - - p.term_1.accept(new TermVisitor<R,A>(), arg); - p.term_2.accept(new TermVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp p, A arg) - { - /* Code For StmProp Goes Here */ - - p.term_1.accept(new TermVisitor<R,A>(), arg); - p.term_2.accept(new TermVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp p, A arg) - { - /* Code For StmInPp Goes Here */ - - p.term_1.accept(new TermVisitor<R,A>(), arg); - p.term_2.accept(new TermVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp p, A arg) - { - /* Code For StmOp Goes Here */ - - p.term_.accept(new TermVisitor<R,A>(), arg); - for (Term x : p.listterm_) { - } - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm p, A arg) - { - /* Code For StmTrm Goes Here */ - - p.term_.accept(new TermVisitor<R,A>(), arg); - - return null; - } - - } - public class TermVisitor<R,A> implements Term.Visitor<R,A> - { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt p, A arg) - { - /* Code For TrmExInt Goes Here */ - - p.term_1.accept(new TermVisitor<R,A>(), arg); - p.term_2.accept(new TermVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt p, A arg) - { - /* Code For TrmInInt Goes Here */ - - p.term_1.accept(new TermVisitor<R,A>(), arg); - p.term_2.accept(new TermVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif p, A arg) - { - /* Code For TrmExDif Goes Here */ - - p.term_1.accept(new TermVisitor<R,A>(), arg); - p.term_2.accept(new TermVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif p, A arg) - { - /* Code For TrmInDif Goes Here */ - - p.term_1.accept(new TermVisitor<R,A>(), arg); - p.term_2.accept(new TermVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg p, A arg) - { - /* Code For TrmExImg Goes Here */ - - p.term_.accept(new TermVisitor<R,A>(), arg); - for (Term x : p.listterm_1) { - } - for (Term x : p.listterm_2) { - } - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg p, A arg) - { - /* Code For TrmInImg Goes Here */ - - p.term_.accept(new TermVisitor<R,A>(), arg); - for (Term x : p.listterm_1) { - } - for (Term x : p.listterm_2) { - } - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet p, A arg) - { - /* Code For TrmExSet Goes Here */ - - for (Term x : p.listterm_) { - } - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet p, A arg) - { - /* Code For TrmInSet Goes Here */ - - for (Term x : p.listterm_) { - } - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd p, A arg) - { - /* Code For TrmProd Goes Here */ - - for (Term x : p.listterm_) { - } - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit p, A arg) - { - /* Code For TrmLit Goes Here */ - - p.literal_.accept(new LiteralVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm p, A arg) - { - /* Code For TrmStm Goes Here */ - - p.stm_.accept(new StmVisitor<R,A>(), arg); - - return null; - } - - } - public class URIRefVisitor<R,A> implements URIRef.Visitor<R,A> - { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul p, A arg) - { - /* Code For URIFul Goes Here */ - - //p.urilit_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URICur p, A arg) - { - /* Code For URICur Goes Here */ - - p.nsprefix_.accept(new NSPrefixVisitor<R,A>(), arg); - //p.ident_; - - return null; - } - - } - public class LiteralVisitor<R,A> implements Literal.Visitor<R,A> - { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar p, A arg) - { - /* Code For LitQVar Goes Here */ - - //p.ident_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn p, A arg) - { - /* Code For LitQVarAn Goes Here */ - - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD p, A arg) - { - /* Code For LitSVarD Goes Here */ - - //p.ident_; - for (String x : p.listident_) { - } - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI p, A arg) - { - /* Code For LitSVarI Goes Here */ - - //p.ident_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI p, A arg) - { - /* Code For LitURI Goes Here */ - - p.uriref_.accept(new URIRefVisitor<R,A>(), arg); - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt p, A arg) - { - /* Code For LitInt Goes Here */ - - //p.integer_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl p, A arg) - { - /* Code For LitDbl Goes Here */ - - //p.double_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitString p, A arg) - { - /* Code For LitString Goes Here */ - - //p.string_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue p, A arg) - { - /* Code For LitTrue Goes Here */ - - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse p, A arg) - { - /* Code For LitFalse Goes Here */ - - - return null; - } - - } - public class NSPrefixVisitor<R,A> implements NSPrefix.Visitor<R,A> - { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1 p, A arg) - { - /* Code For NSPrefix1 Goes Here */ - - //p.ident_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2 p, A arg) - { - /* Code For NSPrefix2 Goes Here */ - - - return null; - } - - } - public class TruthValueVisitor<R,A> implements TruthValue.Visitor<R,A> - { - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE p, A arg) - { - /* Code For TruthE Goes Here */ - - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF p, A arg) - { - /* Code For TruthF Goes Here */ - - //p.double_; - - return null; - } - public R visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC p, A arg) - { - /* Code For TruthFC Goes Here */ - - //p.double_1; - //p.double_2; - - return null; - } - - } -} \ No newline at end of file diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Yylex b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Yylex deleted file mode 100644 index b9cbfdba97a5ec78e411f313cb4912413e915783..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Yylex +++ /dev/null @@ -1,96 +0,0 @@ -// This JLex file was machine-generated by the BNF converter -package com.googlecode.opennars.parser.loan.Loan; - -import java_cup.runtime.*; -%% -%cup -%unicode -%line -%public -%{ - String pstring = new String(); - public int line_num() { return (yyline+1); } - public String buff() { return new String(yy_buffer,yy_buffer_index,10).trim(); } -%} -LETTER = ({CAPITAL}|{SMALL}) -CAPITAL = [A-Z\xC0-\xD6\xD8-\xDE] -SMALL = [a-z\xDF-\xF6\xF8-\xFF] -DIGIT = [0-9] -IDENT = ({LETTER}|{DIGIT}|['_]) -%state COMMENT -%state CHAR -%state CHARESC -%state CHAREND -%state STRING -%state ESCAPED -%% -<YYINITIAL>@base { return new Symbol(sym._SYMB_0); } -<YYINITIAL>\. { return new Symbol(sym._SYMB_1); } -<YYINITIAL>@prefix { return new Symbol(sym._SYMB_2); } -<YYINITIAL>@import { return new Symbol(sym._SYMB_3); } -<YYINITIAL>@delay { return new Symbol(sym._SYMB_4); } -<YYINITIAL>@operator { return new Symbol(sym._SYMB_5); } -<YYINITIAL>\? { return new Symbol(sym._SYMB_6); } -<YYINITIAL>! { return new Symbol(sym._SYMB_7); } -<YYINITIAL>@budget { return new Symbol(sym._SYMB_8); } -<YYINITIAL>\( { return new Symbol(sym._SYMB_9); } -<YYINITIAL>\) { return new Symbol(sym._SYMB_10); } -<YYINITIAL>; { return new Symbol(sym._SYMB_11); } -<YYINITIAL>==> { return new Symbol(sym._SYMB_12); } -<YYINITIAL><=> { return new Symbol(sym._SYMB_13); } -<YYINITIAL>=/> { return new Symbol(sym._SYMB_14); } -<YYINITIAL>=\\> { return new Symbol(sym._SYMB_15); } -<YYINITIAL>=\|> { return new Symbol(sym._SYMB_16); } -<YYINITIAL></> { return new Symbol(sym._SYMB_17); } -<YYINITIAL><\|> { return new Symbol(sym._SYMB_18); } -<YYINITIAL>&& { return new Symbol(sym._SYMB_19); } -<YYINITIAL>\|\| { return new Symbol(sym._SYMB_20); } -<YYINITIAL>, { return new Symbol(sym._SYMB_21); } -<YYINITIAL>--> { return new Symbol(sym._SYMB_22); } -<YYINITIAL><-> { return new Symbol(sym._SYMB_23); } -<YYINITIAL>\}-> { return new Symbol(sym._SYMB_24); } -<YYINITIAL>--\[ { return new Symbol(sym._SYMB_25); } -<YYINITIAL>\}-\[ { return new Symbol(sym._SYMB_26); } -<YYINITIAL>& { return new Symbol(sym._SYMB_27); } -<YYINITIAL>\| { return new Symbol(sym._SYMB_28); } -<YYINITIAL>- { return new Symbol(sym._SYMB_29); } -<YYINITIAL>~ { return new Symbol(sym._SYMB_30); } -<YYINITIAL>/ { return new Symbol(sym._SYMB_31); } -<YYINITIAL>\\ { return new Symbol(sym._SYMB_32); } -<YYINITIAL>\{ { return new Symbol(sym._SYMB_33); } -<YYINITIAL>\} { return new Symbol(sym._SYMB_34); } -<YYINITIAL>\[ { return new Symbol(sym._SYMB_35); } -<YYINITIAL>\] { return new Symbol(sym._SYMB_36); } -<YYINITIAL># { return new Symbol(sym._SYMB_37); } -<YYINITIAL>: { return new Symbol(sym._SYMB_38); } -<YYINITIAL>% { return new Symbol(sym._SYMB_39); } -<YYINITIAL>false { return new Symbol(sym._SYMB_40); } -<YYINITIAL>future { return new Symbol(sym._SYMB_41); } -<YYINITIAL>not { return new Symbol(sym._SYMB_42); } -<YYINITIAL>past { return new Symbol(sym._SYMB_43); } -<YYINITIAL>present { return new Symbol(sym._SYMB_44); } -<YYINITIAL>true { return new Symbol(sym._SYMB_45); } -<YYINITIAL>"---"[^\n]*\n { /* BNFC single-line comment */ } -<YYINITIAL>"{---" { yybegin(COMMENT); } -<COMMENT>"---}" { yybegin(YYINITIAL); } -<COMMENT>. { } -<COMMENT>[\n] { } - - -<YYINITIAL><[^<>\"\{\}\|\\`]*> { return new Symbol(sym.URILit, yytext().intern()); } - -<YYINITIAL>"\"" { yybegin(STRING); } -<STRING>\\ { yybegin(ESCAPED); } -<STRING>\" { String foo = pstring; pstring = new String(); yybegin(YYINITIAL); return new Symbol(sym._STRING_, foo.intern()); } -<STRING>. { pstring += yytext(); } -<ESCAPED>n { pstring += "\n"; yybegin(STRING); } -<ESCAPED>\" { pstring += "\""; yybegin(STRING); } -<ESCAPED>\\ { pstring += "\\"; yybegin(STRING); } -<ESCAPED>t { pstring += "\t"; yybegin(STRING); } -<ESCAPED>. { pstring += yytext(); yybegin(STRING); } - - -<YYINITIAL>{DIGIT}+"."{DIGIT}+("e"(\-)?{DIGIT}+)? { return new Symbol(sym._DOUBLE_, new Double(yytext())); } -<YYINITIAL>{DIGIT}+ { return new Symbol(sym._INTEGER_, new Integer(yytext())); } -<YYINITIAL>{LETTER}{IDENT}* { return new Symbol(sym._IDENT_, yytext().intern()); } -<YYINITIAL>[ \t\r\n\f] { /* ignore white space. */ } diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Yylex.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Yylex.java deleted file mode 100644 index 610a3ff67ae8a57803c628c659c81a4649f365d7..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/Yylex.java +++ /dev/null @@ -1,830 +0,0 @@ -// This JLex file was machine-generated by the BNF converter -package com.googlecode.opennars.parser.loan.Loan; -import java_cup.runtime.*; - - -public class Yylex implements java_cup.runtime.Scanner { - private final int YY_BUFFER_SIZE = 512; - private final int YY_F = -1; - private final int YY_NO_STATE = -1; - private final int YY_NOT_ACCEPT = 0; - private final int YY_START = 1; - private final int YY_END = 2; - private final int YY_NO_ANCHOR = 4; - private final int YY_BOL = 65536; - private final int YY_EOF = 65537; - - String pstring = new String(); - public int line_num() { return (yyline+1); } - public String buff() { return new String(yy_buffer,yy_buffer_index,10).trim(); } - private java.io.BufferedReader yy_reader; - private int yy_buffer_index; - private int yy_buffer_read; - private int yy_buffer_start; - private int yy_buffer_end; - private char yy_buffer[]; - private int yyline; - private boolean yy_at_bol; - private int yy_lexical_state; - - public Yylex (java.io.Reader reader) { - this (); - if (null == reader) { - throw (new Error("Error: Bad input stream initializer.")); - } - yy_reader = new java.io.BufferedReader(reader); - } - - public Yylex (java.io.InputStream instream) { - this (); - if (null == instream) { - throw (new Error("Error: Bad input stream initializer.")); - } - yy_reader = new java.io.BufferedReader(new java.io.InputStreamReader(instream)); - } - - private Yylex () { - yy_buffer = new char[YY_BUFFER_SIZE]; - yy_buffer_read = 0; - yy_buffer_index = 0; - yy_buffer_start = 0; - yy_buffer_end = 0; - yyline = 0; - yy_at_bol = true; - yy_lexical_state = YYINITIAL; - } - - private boolean yy_eof_done = false; - private final int STRING = 5; - private final int ESCAPED = 6; - private final int YYINITIAL = 0; - private final int COMMENT = 1; - private final int CHAREND = 4; - private final int CHARESC = 3; - private final int CHAR = 2; - private final int yy_state_dtrans[] = { - 0, - 118, - 121, - 121, - 121, - 122, - 123 - }; - private void yybegin (int state) { - yy_lexical_state = state; - } - private int yy_advance () - throws java.io.IOException { - int next_read; - int i; - int j; - - if (yy_buffer_index < yy_buffer_read) { - return yy_buffer[yy_buffer_index++]; - } - - if (0 != yy_buffer_start) { - i = yy_buffer_start; - j = 0; - while (i < yy_buffer_read) { - yy_buffer[j] = yy_buffer[i]; - ++i; - ++j; - } - yy_buffer_end = yy_buffer_end - yy_buffer_start; - yy_buffer_start = 0; - yy_buffer_read = j; - yy_buffer_index = j; - next_read = yy_reader.read(yy_buffer, - yy_buffer_read, - yy_buffer.length - yy_buffer_read); - if (-1 == next_read) { - return YY_EOF; - } - yy_buffer_read = yy_buffer_read + next_read; - } - - while (yy_buffer_index >= yy_buffer_read) { - if (yy_buffer_index >= yy_buffer.length) { - yy_buffer = yy_double(yy_buffer); - } - next_read = yy_reader.read(yy_buffer, - yy_buffer_read, - yy_buffer.length - yy_buffer_read); - if (-1 == next_read) { - return YY_EOF; - } - yy_buffer_read = yy_buffer_read + next_read; - } - return yy_buffer[yy_buffer_index++]; - } - private void yy_move_end () { - if (yy_buffer_end > yy_buffer_start && - '\n' == yy_buffer[yy_buffer_end-1]) - yy_buffer_end--; - if (yy_buffer_end > yy_buffer_start && - '\r' == yy_buffer[yy_buffer_end-1]) - yy_buffer_end--; - } - private boolean yy_last_was_cr=false; - private void yy_mark_start () { - int i; - for (i = yy_buffer_start; i < yy_buffer_index; ++i) { - if ('\n' == yy_buffer[i] && !yy_last_was_cr) { - ++yyline; - } - if ('\r' == yy_buffer[i]) { - ++yyline; - yy_last_was_cr=true; - } else yy_last_was_cr=false; - } - yy_buffer_start = yy_buffer_index; - } - private void yy_mark_end () { - yy_buffer_end = yy_buffer_index; - } - private void yy_to_mark () { - yy_buffer_index = yy_buffer_end; - yy_at_bol = (yy_buffer_end > yy_buffer_start) && - ('\r' == yy_buffer[yy_buffer_end-1] || - '\n' == yy_buffer[yy_buffer_end-1] || - 2028/*LS*/ == yy_buffer[yy_buffer_end-1] || - 2029/*PS*/ == yy_buffer[yy_buffer_end-1]); - } - private java.lang.String yytext () { - return (new java.lang.String(yy_buffer, - yy_buffer_start, - yy_buffer_end - yy_buffer_start)); - } - private int yylength () { - return yy_buffer_end - yy_buffer_start; - } - private char[] yy_double (char buf[]) { - int i; - char newbuf[]; - newbuf = new char[2*buf.length]; - for (i = 0; i < buf.length; ++i) { - newbuf[i] = buf[i]; - } - return newbuf; - } - private final int YY_E_INTERNAL = 0; - private final int YY_E_MATCH = 1; - private java.lang.String yy_error_string[] = { - "Error: Internal error.\n", - "Error: Unmatched input.\n" - }; - private void yy_error (int code,boolean fatal) { - java.lang.System.out.print(yy_error_string[code]); - java.lang.System.out.flush(); - if (fatal) { - throw new Error("Fatal Error.\n"); - } - } - private int[][] unpackFromString(int size1, int size2, String st) { - int colonIndex = -1; - String lengthString; - int sequenceLength = 0; - int sequenceInteger = 0; - - int commaIndex; - String workString; - - int res[][] = new int[size1][size2]; - for (int i= 0; i < size1; i++) { - for (int j= 0; j < size2; j++) { - if (sequenceLength != 0) { - res[i][j] = sequenceInteger; - sequenceLength--; - continue; - } - commaIndex = st.indexOf(','); - workString = (commaIndex==-1) ? st : - st.substring(0, commaIndex); - st = st.substring(commaIndex+1); - colonIndex = workString.indexOf(':'); - if (colonIndex == -1) { - res[i][j]=Integer.parseInt(workString); - continue; - } - lengthString = - workString.substring(colonIndex+1); - sequenceLength=Integer.parseInt(lengthString); - workString=workString.substring(0,colonIndex); - sequenceInteger=Integer.parseInt(workString); - res[i][j] = sequenceInteger; - sequenceLength--; - } - } - return res; - } - private int yy_acpt[] = { - /* 0 */ YY_NOT_ACCEPT, - /* 1 */ YY_NO_ANCHOR, - /* 2 */ YY_NO_ANCHOR, - /* 3 */ YY_NO_ANCHOR, - /* 4 */ YY_NO_ANCHOR, - /* 5 */ YY_NO_ANCHOR, - /* 6 */ YY_NO_ANCHOR, - /* 7 */ YY_NO_ANCHOR, - /* 8 */ YY_NO_ANCHOR, - /* 9 */ YY_NO_ANCHOR, - /* 10 */ YY_NO_ANCHOR, - /* 11 */ YY_NO_ANCHOR, - /* 12 */ YY_NO_ANCHOR, - /* 13 */ YY_NO_ANCHOR, - /* 14 */ YY_NO_ANCHOR, - /* 15 */ YY_NO_ANCHOR, - /* 16 */ YY_NO_ANCHOR, - /* 17 */ YY_NO_ANCHOR, - /* 18 */ YY_NO_ANCHOR, - /* 19 */ YY_NO_ANCHOR, - /* 20 */ YY_NO_ANCHOR, - /* 21 */ YY_NO_ANCHOR, - /* 22 */ YY_NO_ANCHOR, - /* 23 */ YY_NO_ANCHOR, - /* 24 */ YY_NO_ANCHOR, - /* 25 */ YY_NO_ANCHOR, - /* 26 */ YY_NO_ANCHOR, - /* 27 */ YY_NO_ANCHOR, - /* 28 */ YY_NO_ANCHOR, - /* 29 */ YY_NO_ANCHOR, - /* 30 */ YY_NO_ANCHOR, - /* 31 */ YY_NO_ANCHOR, - /* 32 */ YY_NO_ANCHOR, - /* 33 */ YY_NO_ANCHOR, - /* 34 */ YY_NO_ANCHOR, - /* 35 */ YY_NO_ANCHOR, - /* 36 */ YY_NO_ANCHOR, - /* 37 */ YY_NO_ANCHOR, - /* 38 */ YY_NO_ANCHOR, - /* 39 */ YY_NO_ANCHOR, - /* 40 */ YY_NO_ANCHOR, - /* 41 */ YY_NO_ANCHOR, - /* 42 */ YY_NO_ANCHOR, - /* 43 */ YY_NO_ANCHOR, - /* 44 */ YY_NO_ANCHOR, - /* 45 */ YY_NO_ANCHOR, - /* 46 */ YY_NO_ANCHOR, - /* 47 */ YY_NO_ANCHOR, - /* 48 */ YY_NO_ANCHOR, - /* 49 */ YY_NO_ANCHOR, - /* 50 */ YY_NO_ANCHOR, - /* 51 */ YY_NO_ANCHOR, - /* 52 */ YY_NO_ANCHOR, - /* 53 */ YY_NO_ANCHOR, - /* 54 */ YY_NO_ANCHOR, - /* 55 */ YY_NO_ANCHOR, - /* 56 */ YY_NO_ANCHOR, - /* 57 */ YY_NO_ANCHOR, - /* 58 */ YY_NO_ANCHOR, - /* 59 */ YY_NO_ANCHOR, - /* 60 */ YY_NO_ANCHOR, - /* 61 */ YY_NO_ANCHOR, - /* 62 */ YY_NO_ANCHOR, - /* 63 */ YY_NO_ANCHOR, - /* 64 */ YY_NO_ANCHOR, - /* 65 */ YY_NO_ANCHOR, - /* 66 */ YY_NO_ANCHOR, - /* 67 */ YY_NOT_ACCEPT, - /* 68 */ YY_NO_ANCHOR, - /* 69 */ YY_NO_ANCHOR, - /* 70 */ YY_NO_ANCHOR, - /* 71 */ YY_NOT_ACCEPT, - /* 72 */ YY_NO_ANCHOR, - /* 73 */ YY_NOT_ACCEPT, - /* 74 */ YY_NO_ANCHOR, - /* 75 */ YY_NOT_ACCEPT, - /* 76 */ YY_NO_ANCHOR, - /* 77 */ YY_NOT_ACCEPT, - /* 78 */ YY_NO_ANCHOR, - /* 79 */ YY_NOT_ACCEPT, - /* 80 */ YY_NO_ANCHOR, - /* 81 */ YY_NOT_ACCEPT, - /* 82 */ YY_NOT_ACCEPT, - /* 83 */ YY_NOT_ACCEPT, - /* 84 */ YY_NOT_ACCEPT, - /* 85 */ YY_NOT_ACCEPT, - /* 86 */ YY_NOT_ACCEPT, - /* 87 */ YY_NOT_ACCEPT, - /* 88 */ YY_NOT_ACCEPT, - /* 89 */ YY_NOT_ACCEPT, - /* 90 */ YY_NOT_ACCEPT, - /* 91 */ YY_NOT_ACCEPT, - /* 92 */ YY_NOT_ACCEPT, - /* 93 */ YY_NOT_ACCEPT, - /* 94 */ YY_NOT_ACCEPT, - /* 95 */ YY_NOT_ACCEPT, - /* 96 */ YY_NOT_ACCEPT, - /* 97 */ YY_NOT_ACCEPT, - /* 98 */ YY_NOT_ACCEPT, - /* 99 */ YY_NOT_ACCEPT, - /* 100 */ YY_NOT_ACCEPT, - /* 101 */ YY_NOT_ACCEPT, - /* 102 */ YY_NOT_ACCEPT, - /* 103 */ YY_NOT_ACCEPT, - /* 104 */ YY_NOT_ACCEPT, - /* 105 */ YY_NOT_ACCEPT, - /* 106 */ YY_NOT_ACCEPT, - /* 107 */ YY_NOT_ACCEPT, - /* 108 */ YY_NOT_ACCEPT, - /* 109 */ YY_NOT_ACCEPT, - /* 110 */ YY_NOT_ACCEPT, - /* 111 */ YY_NOT_ACCEPT, - /* 112 */ YY_NOT_ACCEPT, - /* 113 */ YY_NOT_ACCEPT, - /* 114 */ YY_NOT_ACCEPT, - /* 115 */ YY_NOT_ACCEPT, - /* 116 */ YY_NOT_ACCEPT, - /* 117 */ YY_NOT_ACCEPT, - /* 118 */ YY_NOT_ACCEPT, - /* 119 */ YY_NOT_ACCEPT, - /* 120 */ YY_NOT_ACCEPT, - /* 121 */ YY_NOT_ACCEPT, - /* 122 */ YY_NOT_ACCEPT, - /* 123 */ YY_NOT_ACCEPT, - /* 124 */ YY_NO_ANCHOR, - /* 125 */ YY_NOT_ACCEPT, - /* 126 */ YY_NOT_ACCEPT, - /* 127 */ YY_NOT_ACCEPT, - /* 128 */ YY_NOT_ACCEPT, - /* 129 */ YY_NO_ANCHOR, - /* 130 */ YY_NOT_ACCEPT, - /* 131 */ YY_NO_ANCHOR, - /* 132 */ YY_NO_ANCHOR, - /* 133 */ YY_NO_ANCHOR, - /* 134 */ YY_NO_ANCHOR, - /* 135 */ YY_NO_ANCHOR, - /* 136 */ YY_NO_ANCHOR, - /* 137 */ YY_NO_ANCHOR, - /* 138 */ YY_NO_ANCHOR, - /* 139 */ YY_NO_ANCHOR, - /* 140 */ YY_NO_ANCHOR, - /* 141 */ YY_NO_ANCHOR, - /* 142 */ YY_NO_ANCHOR, - /* 143 */ YY_NO_ANCHOR - }; - private int yy_cmap[] = unpackFromString(1,65538, -"46:9,51,44,46,51,43,46:18,51,19,47,39,46,41,31,50,22,23,46:2,32,33,6,28,48:" + -"10,40,24,27,25,26,18,1,49:26,35,29,38,46,50,45,3,2,49,15,5,9,21,49,10,49:2," + -"16,12,42,13,7,49,8,4,14,20,49:2,11,17,49,37,30,34,36,46:65,49:23,46,49:31,4" + -"6,49:8,46:65280,0:2")[0]; - - private int yy_rmap[] = unpackFromString(1,144, -"0,1,2,1:8,3,4,1,5,6,1:2,7,1:6,8,1:15,2,9,2:2,1:3,2,1,2,1:3,2,1:12,10,11,12," + -"13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37," + -"38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,12,54,55,56,57,58,59,60,61," + -"62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85")[0]; - - private int yy_nxt[][] = unpackFromString(86,52, -"1,67,2:4,3,135,2,140,2:4,136,2:3,4,5,2:2,6,7,8,71,-1,73,9,10,11,12,13,14,15" + -",16,17,18,19,20,21,22,124,23:2,-1:2,24,25,2,-1,23,-1:54,2:4,-1,2:11,-1:2,2:" + -"2,-1:20,2,-1:5,2:3,-1:31,27,-1:52,28,-1:53,92,-1:51,93,-1:51,94,-1:24,95,-1" + -":41,25,-1:8,107,-1:42,42,-1:5,75,-1:4,77,-1:2,79,-1:2,81,-1,82,-1:38,2:4,-1" + -",2:7,41,2:3,-1:2,2:2,-1:20,2,-1:5,2:3,-1:49,69,-1:36,119,-1:43,83,-1:2,84,8" + -"5,86,-1:23,2:4,-1,2:7,43,2:3,-1:2,2:2,-1:20,2,-1:5,2:3,-1:2,87:24,88,26,-1," + -"89,-1,90,87:2,91,-1,87:2,-1,87:7,-1,87,-1,87:4,-1:2,2:3,44,-1,2:11,-1:2,2:2" + -",-1:20,2,-1:5,2:3,-1:4,96,-1:16,97,-1:33,2:3,48,-1,2:11,-1:2,2:2,-1:20,2,-1" + -":5,2:3,-1:9,126,-1:45,2:3,50,-1,2:11,-1:2,2:2,-1:20,2,-1:5,2:3,-1:13,125,-1" + -":41,2:4,-1,2:7,54,2:3,-1:2,2:2,-1:20,2,-1:5,2:3,-1:8,130,-1:49,98,-1:72,29," + -"-1:51,30,-1:51,31,-1:51,32,-1:26,87:25,26,-1,87,-1:2,87:3,-1,87:2,-1,87:7,-" + -"1,87,-1,87:4,-1,87:25,33,-1,87,-1:2,87:3,-1,87:2,-1,87:7,-1,87,-1,87:4,-1,8" + -"7:25,34,-1,87,-1:2,87:3,-1,87:2,-1,87:7,-1,87,-1,87:4,-1:26,35,-1:26,87:25," + -"36,-1,87,-1:2,87:3,-1,87:2,-1,87:7,-1,87,-1,87:4,-1:26,37,-1:6,99,-1,38,-1:" + -"42,39,-1:8,40,-1:49,100,-1:66,42,-1:7,101,-1:62,102,-1:52,106,-1:36,99:43,4" + -"5,99:7,-1:33,46,-1:23,47,-1:67,108,-1:39,109,-1:55,127,-1:46,128,-1:46,110," + -"-1:81,111,-1:14,69,-1:8,112,-1:56,113,-1:58,49,-1:48,51,-1:48,52,-1:54,53,-" + -"1:51,116,-1:50,117,-1:46,55,-1:43,1,56:32,70,56:9,-1,57,56:7,-1:33,120,-1:5" + -"2,58,-1:17,1,-1:51,1,59:28,60,59:13,-1:2,59:2,61,59:4,1,62:13,63,62:14,64,6" + -"2:12,65,-1:2,62:2,66,62:4,-1:2,2:4,-1,2:6,68,2:4,-1:2,2:2,-1:20,2,-1:5,2:3," + -"-1:8,104,-1:49,103,-1:54,114,-1:46,115,-1:50,2:2,72,2,-1,2:11,-1:2,2:2,-1:2" + -"0,2,-1:5,2:3,-1:6,105,-1:48,2:4,-1,2:11,-1:2,74,2,-1:20,2,-1:5,2:3,-1:3,2:2" + -",76,2,-1,2:11,-1:2,2:2,-1:20,2,-1:5,2:3,-1:3,2:4,-1,2,78,2:9,-1:2,2:2,-1:20" + -",2,-1:5,2:3,-1:3,2:4,-1,2:11,-1:2,2:2,-1:20,80,-1:5,2:3,-1:3,2,129,2:2,-1,2" + -",143,2:9,-1:2,2:2,-1:20,2,-1:5,2:3,-1:3,2:4,-1,2,131,2:9,-1:2,2:2,-1:20,2,-" + -"1:5,2:3,-1:3,2:4,-1,2:9,132,2,-1:2,2:2,-1:20,2,-1:5,2:3,-1:3,2:4,-1,2:11,-1" + -":2,133,2,-1:20,2,-1:5,2:3,-1:3,2:3,134,-1,2:11,-1:2,2:2,-1:20,2,-1:5,2:3,-1" + -":3,2,137,2:2,-1,2:11,-1:2,141,2,-1:20,2,-1:5,2:3,-1:3,2:4,-1,2:7,138,2:3,-1" + -":2,2:2,-1:20,2,-1:5,2:3,-1:3,2:2,139,2,-1,2:11,-1:2,2:2,-1:20,2,-1:5,2:3,-1" + -":3,2:3,142,-1,2:11,-1:2,2:2,-1:20,2,-1:5,2:3,-1"); - - public java_cup.runtime.Symbol next_token () - throws java.io.IOException { - int yy_lookahead; - int yy_anchor = YY_NO_ANCHOR; - int yy_state = yy_state_dtrans[yy_lexical_state]; - int yy_next_state = YY_NO_STATE; - int yy_last_accept_state = YY_NO_STATE; - boolean yy_initial = true; - int yy_this_accept; - - yy_mark_start(); - yy_this_accept = yy_acpt[yy_state]; - if (YY_NOT_ACCEPT != yy_this_accept) { - yy_last_accept_state = yy_state; - yy_mark_end(); - } - while (true) { - if (yy_initial && yy_at_bol) yy_lookahead = YY_BOL; - else yy_lookahead = yy_advance(); - yy_next_state = YY_F; - yy_next_state = yy_nxt[yy_rmap[yy_state]][yy_cmap[yy_lookahead]]; - if (YY_EOF == yy_lookahead && true == yy_initial) { - return null; - } - if (YY_F != yy_next_state) { - yy_state = yy_next_state; - yy_initial = false; - yy_this_accept = yy_acpt[yy_state]; - if (YY_NOT_ACCEPT != yy_this_accept) { - yy_last_accept_state = yy_state; - yy_mark_end(); - } - } - else { - if (YY_NO_STATE == yy_last_accept_state) { - throw (new Error("Lexical Error: Unmatched Input.")); - } - else { - yy_anchor = yy_acpt[yy_last_accept_state]; - if (0 != (YY_END & yy_anchor)) { - yy_move_end(); - } - yy_to_mark(); - switch (yy_last_accept_state) { - case 1: - - case -2: - break; - case 2: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -3: - break; - case 3: - { return new Symbol(sym._SYMB_1); } - case -4: - break; - case 4: - { return new Symbol(sym._SYMB_6); } - case -5: - break; - case 5: - { return new Symbol(sym._SYMB_7); } - case -6: - break; - case 6: - { return new Symbol(sym._SYMB_9); } - case -7: - break; - case 7: - { return new Symbol(sym._SYMB_10); } - case -8: - break; - case 8: - { return new Symbol(sym._SYMB_11); } - case -9: - break; - case 9: - { return new Symbol(sym._SYMB_31); } - case -10: - break; - case 10: - { return new Symbol(sym._SYMB_32); } - case -11: - break; - case 11: - { return new Symbol(sym._SYMB_28); } - case -12: - break; - case 12: - { return new Symbol(sym._SYMB_27); } - case -13: - break; - case 13: - { return new Symbol(sym._SYMB_21); } - case -14: - break; - case 14: - { return new Symbol(sym._SYMB_29); } - case -15: - break; - case 15: - { return new Symbol(sym._SYMB_34); } - case -16: - break; - case 16: - { return new Symbol(sym._SYMB_35); } - case -17: - break; - case 17: - { return new Symbol(sym._SYMB_30); } - case -18: - break; - case 18: - { return new Symbol(sym._SYMB_33); } - case -19: - break; - case 19: - { return new Symbol(sym._SYMB_36); } - case -20: - break; - case 20: - { return new Symbol(sym._SYMB_37); } - case -21: - break; - case 21: - { return new Symbol(sym._SYMB_38); } - case -22: - break; - case 22: - { return new Symbol(sym._SYMB_39); } - case -23: - break; - case 23: - { /* ignore white space. */ } - case -24: - break; - case 24: - { yybegin(STRING); } - case -25: - break; - case 25: - { return new Symbol(sym._INTEGER_, new Integer(yytext())); } - case -26: - break; - case 26: - { return new Symbol(sym.URILit, yytext().intern()); } - case -27: - break; - case 27: - { return new Symbol(sym._SYMB_20); } - case -28: - break; - case 28: - { return new Symbol(sym._SYMB_19); } - case -29: - break; - case 29: - { return new Symbol(sym._SYMB_12); } - case -30: - break; - case 30: - { return new Symbol(sym._SYMB_14); } - case -31: - break; - case 31: - { return new Symbol(sym._SYMB_15); } - case -32: - break; - case 32: - { return new Symbol(sym._SYMB_16); } - case -33: - break; - case 33: - { return new Symbol(sym._SYMB_13); } - case -34: - break; - case 34: - { return new Symbol(sym._SYMB_17); } - case -35: - break; - case 35: - { return new Symbol(sym._SYMB_18); } - case -36: - break; - case 36: - { return new Symbol(sym._SYMB_23); } - case -37: - break; - case 37: - { return new Symbol(sym._SYMB_22); } - case -38: - break; - case 38: - { return new Symbol(sym._SYMB_25); } - case -39: - break; - case 39: - { return new Symbol(sym._SYMB_24); } - case -40: - break; - case 40: - { return new Symbol(sym._SYMB_26); } - case -41: - break; - case 41: - { return new Symbol(sym._SYMB_42); } - case -42: - break; - case 42: - { return new Symbol(sym._DOUBLE_, new Double(yytext())); } - case -43: - break; - case 43: - { return new Symbol(sym._SYMB_43); } - case -44: - break; - case 44: - { return new Symbol(sym._SYMB_45); } - case -45: - break; - case 45: - { /* BNFC single-line comment */ } - case -46: - break; - case 46: - { yybegin(COMMENT); } - case -47: - break; - case 47: - { return new Symbol(sym._SYMB_0); } - case -48: - break; - case 48: - { return new Symbol(sym._SYMB_40); } - case -49: - break; - case 49: - { return new Symbol(sym._SYMB_4); } - case -50: - break; - case 50: - { return new Symbol(sym._SYMB_41); } - case -51: - break; - case 51: - { return new Symbol(sym._SYMB_8); } - case -52: - break; - case 52: - { return new Symbol(sym._SYMB_2); } - case -53: - break; - case 53: - { return new Symbol(sym._SYMB_3); } - case -54: - break; - case 54: - { return new Symbol(sym._SYMB_44); } - case -55: - break; - case 55: - { return new Symbol(sym._SYMB_5); } - case -56: - break; - case 56: - { } - case -57: - break; - case 57: - { } - case -58: - break; - case 58: - { yybegin(YYINITIAL); } - case -59: - break; - case 59: - { pstring += yytext(); } - case -60: - break; - case 60: - { yybegin(ESCAPED); } - case -61: - break; - case 61: - { String foo = pstring; pstring = new String(); yybegin(YYINITIAL); return new Symbol(sym._STRING_, foo.intern()); } - case -62: - break; - case 62: - { pstring += yytext(); yybegin(STRING); } - case -63: - break; - case 63: - { pstring += "\t"; yybegin(STRING); } - case -64: - break; - case 64: - { pstring += "\\"; yybegin(STRING); } - case -65: - break; - case 65: - { pstring += "\n"; yybegin(STRING); } - case -66: - break; - case 66: - { pstring += "\""; yybegin(STRING); } - case -67: - break; - case 68: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -68: - break; - case 69: - { return new Symbol(sym._DOUBLE_, new Double(yytext())); } - case -69: - break; - case 70: - { } - case -70: - break; - case 72: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -71: - break; - case 74: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -72: - break; - case 76: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -73: - break; - case 78: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -74: - break; - case 80: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -75: - break; - case 124: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -76: - break; - case 129: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -77: - break; - case 131: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -78: - break; - case 132: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -79: - break; - case 133: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -80: - break; - case 134: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -81: - break; - case 135: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -82: - break; - case 136: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -83: - break; - case 137: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -84: - break; - case 138: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -85: - break; - case 139: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -86: - break; - case 140: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -87: - break; - case 141: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -88: - break; - case 142: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -89: - break; - case 143: - { return new Symbol(sym._IDENT_, yytext().intern()); } - case -90: - break; - default: - yy_error(YY_E_INTERNAL,false); - case -1: - } - yy_initial = true; - yy_state = yy_state_dtrans[yy_lexical_state]; - yy_next_state = YY_NO_STATE; - yy_last_accept_state = YY_NO_STATE; - yy_mark_start(); - yy_this_accept = yy_acpt[yy_state]; - if (YY_NOT_ACCEPT != yy_this_accept) { - yy_last_accept_state = yy_state; - yy_mark_end(); - } - } - } - } - } -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/parser.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/parser.java deleted file mode 100644 index 688c7d8ddad5b7407da98aa8381dc1c9c78706e7..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/parser.java +++ /dev/null @@ -1,1482 +0,0 @@ - -//---------------------------------------------------- -// The following code was generated by CUP v0.10k -// Fri Apr 04 22:02:41 BST 2008 -//---------------------------------------------------- - -package com.googlecode.opennars.parser.loan.Loan; - - -/** CUP v0.10k generated parser. - * @version Fri Apr 04 22:02:41 BST 2008 - */ -public class parser extends java_cup.runtime.lr_parser { - - /** Default constructor. */ - public parser() {super();} - - /** Constructor which sets the default scanner. */ - public parser(java_cup.runtime.Scanner s) {super(s);} - - /** Production table. */ - protected static final short _production_table[][] = - unpackFromStrings(new String[] { - "\000\120\000\002\002\004\000\002\003\004\000\002\003" + - "\003\000\002\004\005\000\002\005\002\000\002\005\004" + - "\000\002\006\006\000\002\006\005\000\002\006\005\000" + - "\002\006\005\000\002\006\006\000\002\006\005\000\002" + - "\006\006\000\002\007\002\000\002\007\006\000\002\007" + - "\010\000\002\010\005\000\002\010\005\000\002\010\005" + - "\000\002\010\005\000\002\010\005\000\002\010\005\000" + - "\002\010\005\000\002\010\003\000\002\011\005\000\002" + - "\011\005\000\002\011\005\000\002\011\005\000\002\011" + - "\003\000\002\012\004\000\002\012\004\000\002\012\004" + - "\000\002\012\004\000\002\012\003\000\002\013\005\000" + - "\002\013\005\000\002\013\005\000\002\013\005\000\002" + - "\013\005\000\002\013\006\000\002\013\003\000\002\013" + - "\005\000\002\014\005\000\002\014\005\000\002\014\003" + - "\000\002\015\005\000\002\015\005\000\002\015\003\000" + - "\002\016\010\000\002\016\010\000\002\016\003\000\002" + - "\017\005\000\002\017\005\000\002\017\005\000\002\017" + - "\003\000\002\017\005\000\002\017\005\000\002\020\002" + - "\000\002\020\003\000\002\020\005\000\002\021\002\000" + - "\002\021\003\000\002\021\005\000\002\022\003\000\002" + - "\022\004\000\002\023\004\000\002\023\003\000\002\023" + - "\007\000\002\023\004\000\002\023\003\000\002\023\003" + - "\000\002\023\003\000\002\023\003\000\002\023\003\000" + - "\002\023\003\000\002\024\004\000\002\024\003\000\002" + - "\025\002\000\002\025\005\000\002\025\007" }); - - /** Access to production table. */ - public short[][] production_table() {return _production_table;} - - /** Parse-action table. */ - protected static final short[][] _action_table = - unpackFromStrings(new String[] { - "\000\230\000\060\002\ufffd\004\006\006\ufffd\007\ufffd\010" + - "\ufffd\011\ufffd\012\ufffd\015\ufffd\045\ufffd\047\ufffd\051\ufffd" + - "\052\ufffd\054\ufffd\055\ufffd\056\ufffd\057\ufffd\060\ufffd\061" + - "\ufffd\062\ufffd\063\ufffd\064\ufffd\065\ufffd\066\ufffd\001\002" + - "\000\056\002\ufffd\006\ufffd\007\ufffd\010\ufffd\011\ufffd\012" + - "\ufffd\015\ufffd\045\ufffd\047\ufffd\051\ufffd\052\ufffd\054\ufffd" + - "\055\ufffd\056\ufffd\057\ufffd\060\ufffd\061\ufffd\062\ufffd\063" + - "\ufffd\064\ufffd\065\ufffd\066\ufffd\001\002\000\004\002\231" + - "\001\002\000\004\066\227\001\002\000\056\002\uffff\006" + - "\040\007\035\010\033\011\032\012\031\015\025\045\014" + - "\047\012\051\047\052\045\054\030\055\027\056\024\057" + - "\023\060\022\061\021\062\011\063\010\064\020\065\016" + - "\066\013\001\002\000\100\005\uffbb\012\uffbb\013\uffbb\014" + - "\uffbb\015\uffbb\016\uffbb\017\uffbb\020\uffbb\021\uffbb\022\uffbb" + - "\023\uffbb\024\uffbb\025\uffbb\026\uffbb\027\uffbb\030\uffbb\031" + - "\uffbb\032\uffbb\033\uffbb\034\uffbb\035\uffbb\036\uffbb\037\uffbb" + - "\040\uffbb\041\uffbb\042\uffbb\043\uffbb\044\uffbb\046\uffbb\050" + - "\uffbb\053\uffbb\001\002\000\100\005\uffb9\012\uffb9\013\uffb9" + - "\014\uffb9\015\uffb9\016\uffb9\017\uffb9\020\uffb9\021\uffb9\022" + - "\uffb9\023\uffb9\024\uffb9\025\uffb9\026\uffb9\027\uffb9\030\uffb9" + - "\031\uffb9\032\uffb9\033\uffb9\034\uffb9\035\uffb9\036\uffb9\037" + - "\uffb9\040\uffb9\041\uffb9\042\uffb9\043\uffb9\044\uffb9\046\uffb9" + - "\050\uffb9\053\uffb9\001\002\000\036\012\031\015\053\045" + - "\014\047\012\050\uffc8\051\047\052\045\054\030\061\021" + - "\062\011\063\010\064\020\065\016\066\013\001\002\000" + - "\100\005\uffc2\012\uffc2\013\uffc2\014\uffc2\015\uffc2\016\uffc2" + - "\017\uffc2\020\uffc2\021\uffc2\022\uffc2\023\uffc2\024\uffc2\025" + - "\uffc2\026\uffc2\027\uffc2\030\uffc2\031\uffc2\032\uffc2\033\uffc2" + - "\034\uffc2\035\uffc2\036\uffc2\037\uffc2\040\uffc2\041\uffc2\042" + - "\uffc2\043\uffc2\044\uffc2\046\uffc2\050\uffc2\053\uffc2\001\002" + - "\000\036\012\031\015\053\045\014\046\uffc8\047\012\051" + - "\047\052\045\054\030\061\021\062\011\063\010\064\020" + - "\065\016\066\013\001\002\000\032\005\uffb4\012\200\013" + - "\uffb4\014\uffb4\020\126\021\125\022\124\023\123\024\122" + - "\025\121\026\120\053\202\001\002\000\004\052\177\001" + - "\002\000\100\005\uffbc\012\uffbc\013\uffbc\014\uffbc\015\uffbc" + - "\016\uffbc\017\uffbc\020\uffbc\021\uffbc\022\uffbc\023\uffbc\024" + - "\uffbc\025\uffbc\026\uffbc\027\uffbc\030\uffbc\031\uffbc\032\uffbc" + - "\033\uffbc\034\uffbc\035\uffbc\036\uffbc\037\uffbc\040\uffbc\041" + - "\uffbc\042\uffbc\043\uffbc\044\uffbc\046\uffbc\050\uffbc\053\uffbc" + - "\001\002\000\100\005\uffba\012\uffba\013\uffba\014\uffba\015" + - "\uffba\016\uffba\017\uffba\020\uffba\021\uffba\022\uffba\023\uffba" + - "\024\uffba\025\uffba\026\uffba\027\uffba\030\uffba\031\uffba\032" + - "\uffba\033\uffba\034\uffba\035\uffba\036\uffba\037\uffba\040\uffba" + - "\041\uffba\042\uffba\043\uffba\044\uffba\046\uffba\050\uffba\053" + - "\uffba\001\002\000\100\005\uffb8\012\uffb8\013\uffb8\014\uffb8" + - "\015\uffb8\016\uffb8\017\uffb8\020\uffb8\021\uffb8\022\uffb8\023" + - "\uffb8\024\uffb8\025\uffb8\026\uffb8\027\uffb8\030\uffb8\031\uffb8" + - "\032\uffb8\033\uffb8\034\uffb8\035\uffb8\036\uffb8\037\uffb8\040" + - "\uffb8\041\uffb8\042\uffb8\043\uffb8\044\uffb8\046\uffb8\050\uffb8" + - "\053\uffb8\001\002\000\034\012\031\015\025\045\014\047" + - "\012\051\047\052\045\054\030\061\021\062\011\063\010" + - "\064\020\065\016\066\013\001\002\000\034\012\031\015" + - "\025\045\014\047\012\051\047\052\045\054\030\061\021" + - "\062\011\063\010\064\020\065\016\066\013\001\002\000" + - "\034\012\031\015\025\045\014\047\012\051\047\052\045" + - "\054\030\061\021\062\011\063\010\064\020\065\016\066" + - "\013\001\002\000\046\012\031\015\025\016\uffc8\045\014" + - "\047\012\051\047\052\045\054\030\055\027\056\024\057" + - "\023\060\022\061\021\062\011\063\010\064\020\065\016" + - "\066\013\001\002\000\056\002\ufffc\006\ufffc\007\ufffc\010" + - "\ufffc\011\ufffc\012\ufffc\015\ufffc\045\ufffc\047\ufffc\051\ufffc" + - "\052\ufffc\054\ufffc\055\ufffc\056\ufffc\057\ufffc\060\ufffc\061" + - "\ufffc\062\ufffc\063\ufffc\064\ufffc\065\ufffc\066\ufffc\001\002" + - "\000\034\012\031\015\025\045\014\047\012\051\047\052" + - "\045\054\030\061\021\062\011\063\010\064\020\065\016" + - "\066\013\001\002\000\100\005\uffb7\012\uffb7\013\uffb7\014" + - "\uffb7\015\uffb7\016\uffb7\017\uffb7\020\uffb7\021\uffb7\022\uffb7" + - "\023\uffb7\024\uffb7\025\uffb7\026\uffb7\027\uffb7\030\uffb7\031" + - "\uffb7\032\uffb7\033\uffb7\034\uffb7\035\uffb7\036\uffb7\037\uffb7" + - "\040\uffb7\041\uffb7\042\uffb7\043\uffb7\044\uffb7\046\uffb7\050" + - "\uffb7\053\uffb7\001\002\000\102\005\uffbf\012\uffbf\013\uffbf" + - "\014\uffbf\015\uffbf\016\uffbf\017\uffbf\020\uffbf\021\uffbf\022" + - "\uffbf\023\uffbf\024\uffbf\025\uffbf\026\uffbf\027\uffbf\030\uffbf" + - "\031\uffbf\032\uffbf\033\uffbf\034\uffbf\035\uffbf\036\uffbf\037" + - "\uffbf\040\uffbf\041\uffbf\042\uffbf\043\uffbf\044\uffbf\046\uffbf" + - "\050\uffbf\053\uffbf\065\170\001\002\000\010\052\045\065" + - "\016\066\013\001\002\000\004\063\164\001\002\000\044" + - "\005\uffe0\012\uffe0\013\uffe0\014\uffe0\016\uffe0\017\uffe0\020" + - "\uffe0\021\uffe0\022\uffe0\023\uffe0\024\uffe0\025\uffe0\026\uffe0" + - "\027\uffe0\030\uffe0\031\uffe0\053\uffe0\001\002\000\004\066" + - "\162\001\002\000\044\005\uffe5\012\uffe5\013\uffe5\014\uffe5" + - "\016\uffe5\017\uffe5\020\uffe5\021\uffe5\022\uffe5\023\uffe5\024" + - "\uffe5\025\uffe5\026\uffe5\027\uffe5\030\uffe5\031\uffe5\053\uffe5" + - "\001\002\000\044\005\uffea\012\uffea\013\uffea\014\uffea\016" + - "\uffea\017\133\020\uffea\021\uffea\022\uffea\023\uffea\024\uffea" + - "\025\uffea\026\uffea\027\132\030\131\031\130\053\uffea\001" + - "\002\000\006\052\045\065\016\001\002\000\004\065\156" + - "\001\002\000\100\005\uffcb\012\uffcb\013\uffcb\014\uffcb\015" + - "\uffcb\016\uffcb\017\uffcb\020\uffcb\021\uffcb\022\uffcb\023\uffcb" + - "\024\uffcb\025\uffcb\026\uffcb\027\uffcb\030\uffcb\031\uffcb\032" + - "\uffcb\033\uffcb\034\uffcb\035\uffcb\036\uffcb\037\uffcb\040\uffcb" + - "\041\uffcb\042\uffcb\043\uffcb\044\uffcb\046\uffcb\050\uffcb\053" + - "\uffcb\001\002\000\064\005\uffd9\012\uffd9\013\uffd9\014\uffd9" + - "\015\106\016\uffd9\017\uffd9\020\uffd9\021\uffd9\022\uffd9\023" + - "\uffd9\024\uffd9\025\uffd9\026\uffd9\027\uffd9\030\uffd9\031\uffd9" + - "\032\104\033\103\034\102\035\101\036\100\037\057\040" + - "\056\053\uffd9\001\002\000\100\005\uffcf\012\uffcf\013\uffcf" + - "\014\uffcf\015\uffcf\016\uffcf\017\uffcf\020\uffcf\021\uffcf\022" + - "\uffcf\023\uffcf\024\uffcf\025\uffcf\026\uffcf\027\uffcf\030\uffcf" + - "\031\uffcf\032\uffcf\033\uffcf\034\uffcf\035\uffcf\036\uffcf\037" + - "\uffcf\040\uffcf\041\uffcf\042\uffcf\043\uffcf\044\uffcf\046\uffcf" + - "\050\uffcf\053\uffcf\001\002\000\006\065\uffb5\066\uffb5\001" + - "\002\000\100\005\uffd2\012\uffd2\013\uffd2\014\uffd2\015\uffd2" + - "\016\uffd2\017\uffd2\020\uffd2\021\uffd2\022\uffd2\023\uffd2\024" + - "\uffd2\025\uffd2\026\uffd2\027\uffd2\030\uffd2\031\uffd2\032\uffd2" + - "\033\uffd2\034\uffd2\035\uffd2\036\uffd2\037\uffd2\040\uffd2\041" + - "\uffd2\042\uffd2\043\uffd2\044\uffd2\046\uffd2\050\uffd2\053\uffd2" + - "\001\002\000\004\065\147\001\002\000\100\005\uffd5\012" + - "\uffd5\013\uffd5\014\uffd5\015\uffd5\016\uffd5\017\uffd5\020\uffd5" + - "\021\uffd5\022\uffd5\023\uffd5\024\uffd5\025\uffd5\026\uffd5\027" + - "\uffd5\030\uffd5\031\uffd5\032\uffd5\033\uffd5\034\uffd5\035\uffd5" + - "\036\uffd5\037\uffd5\040\uffd5\041\051\042\052\043\uffd5\044" + - "\uffd5\046\uffd5\050\uffd5\053\uffd5\001\002\000\034\012\031" + - "\015\053\045\014\047\012\051\047\052\045\054\030\061" + - "\021\062\011\063\010\064\020\065\016\066\013\001\002" + - "\000\034\012\031\015\053\045\014\047\012\051\047\052" + - "\045\054\030\061\021\062\011\063\010\064\020\065\016" + - "\066\013\001\002\000\046\012\031\015\025\016\uffc8\045" + - "\014\047\012\051\047\052\045\054\030\055\027\056\024" + - "\057\023\060\022\061\021\062\011\063\010\064\020\065" + - "\016\066\013\001\002\000\010\015\060\037\057\040\056" + - "\001\002\000\100\005\uffd3\012\uffd3\013\uffd3\014\uffd3\015" + - "\uffd3\016\uffd3\017\uffd3\020\uffd3\021\uffd3\022\uffd3\023\uffd3" + - "\024\uffd3\025\uffd3\026\uffd3\027\uffd3\030\uffd3\031\uffd3\032" + - "\uffd3\033\uffd3\034\uffd3\035\uffd3\036\uffd3\037\uffd3\040\uffd3" + - "\041\uffd3\042\uffd3\043\uffd3\044\uffd3\046\uffd3\050\uffd3\053" + - "\uffd3\001\002\000\034\012\031\015\053\045\014\047\012" + - "\051\047\052\045\054\030\061\021\062\011\063\010\064" + - "\020\065\016\066\013\001\002\000\034\012\031\015\053" + - "\045\014\047\012\051\047\052\045\054\030\061\021\062" + - "\011\063\010\064\020\065\016\066\013\001\002\000\040" + - "\012\031\015\053\043\uffc8\044\uffc8\045\014\047\012\051" + - "\047\052\045\054\030\061\021\062\011\063\010\064\020" + - "\065\016\066\013\001\002\000\006\043\066\044\065\001" + - "\002\000\024\015\060\016\uffc7\031\063\037\057\040\056" + - "\043\uffc7\044\uffc7\046\uffc7\050\uffc7\001\002\000\046\012" + - "\031\015\053\016\uffc8\043\uffc8\044\uffc8\045\014\046\uffc8" + - "\047\012\050\uffc8\051\047\052\045\054\030\061\021\062" + - "\011\063\010\064\020\065\016\066\013\001\002\000\014" + - "\016\uffc6\043\uffc6\044\uffc6\046\uffc6\050\uffc6\001\002\000" + - "\036\012\031\015\053\016\uffc8\045\014\047\012\051\047" + - "\052\045\054\030\061\021\062\011\063\010\064\020\065" + - "\016\066\013\001\002\000\036\012\031\015\053\016\uffc8" + - "\045\014\047\012\051\047\052\045\054\030\061\021\062" + - "\011\063\010\064\020\065\016\066\013\001\002\000\004" + - "\016\070\001\002\000\100\005\uffd1\012\uffd1\013\uffd1\014" + - "\uffd1\015\uffd1\016\uffd1\017\uffd1\020\uffd1\021\uffd1\022\uffd1" + - "\023\uffd1\024\uffd1\025\uffd1\026\uffd1\027\uffd1\030\uffd1\031" + - "\uffd1\032\uffd1\033\uffd1\034\uffd1\035\uffd1\036\uffd1\037\uffd1" + - "\040\uffd1\041\uffd1\042\uffd1\043\uffd1\044\uffd1\046\uffd1\050" + - "\uffd1\053\uffd1\001\002\000\004\016\072\001\002\000\100" + - "\005\uffd0\012\uffd0\013\uffd0\014\uffd0\015\uffd0\016\uffd0\017" + - "\uffd0\020\uffd0\021\uffd0\022\uffd0\023\uffd0\024\uffd0\025\uffd0" + - "\026\uffd0\027\uffd0\030\uffd0\031\uffd0\032\uffd0\033\uffd0\034" + - "\uffd0\035\uffd0\036\uffd0\037\uffd0\040\uffd0\041\uffd0\042\uffd0" + - "\043\uffd0\044\uffd0\046\uffd0\050\uffd0\053\uffd0\001\002\000" + - "\100\005\uffd7\012\uffd7\013\uffd7\014\uffd7\015\uffd7\016\uffd7" + - "\017\uffd7\020\uffd7\021\uffd7\022\uffd7\023\uffd7\024\uffd7\025" + - "\uffd7\026\uffd7\027\uffd7\030\uffd7\031\uffd7\032\uffd7\033\uffd7" + - "\034\uffd7\035\uffd7\036\uffd7\037\uffd7\040\uffd7\041\051\042" + - "\052\043\uffd7\044\uffd7\046\uffd7\050\uffd7\053\uffd7\001\002" + - "\000\100\005\uffd6\012\uffd6\013\uffd6\014\uffd6\015\uffd6\016" + - "\uffd6\017\uffd6\020\uffd6\021\uffd6\022\uffd6\023\uffd6\024\uffd6" + - "\025\uffd6\026\uffd6\027\uffd6\030\uffd6\031\uffd6\032\uffd6\033" + - "\uffd6\034\uffd6\035\uffd6\036\uffd6\037\uffd6\040\uffd6\041\051" + - "\042\052\043\uffd6\044\uffd6\046\uffd6\050\uffd6\053\uffd6\001" + - "\002\000\022\016\117\020\126\021\125\022\124\023\123" + - "\024\122\025\121\026\120\001\002\000\004\016\116\001" + - "\002\000\052\015\106\016\105\017\uffd9\020\uffd9\021\uffd9" + - "\022\uffd9\023\uffd9\024\uffd9\025\uffd9\026\uffd9\027\uffd9\030" + - "\uffd9\031\063\032\104\033\103\034\102\035\101\036\100" + - "\037\057\040\056\001\002\000\034\012\031\015\053\045" + - "\014\047\012\051\047\052\045\054\030\061\021\062\011" + - "\063\010\064\020\065\016\066\013\001\002\000\034\012" + - "\031\015\053\045\014\047\012\051\047\052\045\054\030" + - "\061\021\062\011\063\010\064\020\065\016\066\013\001" + - "\002\000\034\012\031\015\053\045\014\047\012\051\047" + - "\052\045\054\030\061\021\062\011\063\010\064\020\065" + - "\016\066\013\001\002\000\034\012\031\015\053\045\014" + - "\047\012\051\047\052\045\054\030\061\021\062\011\063" + - "\010\064\020\065\016\066\013\001\002\000\034\012\031" + - "\015\053\045\014\047\012\051\047\052\045\054\030\061" + - "\021\062\011\063\010\064\020\065\016\066\013\001\002" + - "\000\100\005\uffc9\012\uffc9\013\uffc9\014\uffc9\015\uffc9\016" + - "\uffc9\017\uffc9\020\uffc9\021\uffc9\022\uffc9\023\uffc9\024\uffc9" + - "\025\uffc9\026\uffc9\027\uffc9\030\uffc9\031\uffc9\032\uffc9\033" + - "\uffc9\034\uffc9\035\uffc9\036\uffc9\037\uffc9\040\uffc9\041\uffc9" + - "\042\uffc9\043\uffc9\044\uffc9\046\uffc9\050\uffc9\053\uffc9\001" + - "\002\000\042\012\031\015\053\016\uffc8\043\uffc8\044\uffc8" + - "\045\014\047\012\051\047\052\045\054\030\061\021\062" + - "\011\063\010\064\020\065\016\066\013\001\002\000\010" + - "\016\110\043\066\044\065\001\002\000\044\005\uffda\012" + - "\uffda\013\uffda\014\uffda\016\uffda\017\uffda\020\uffda\021\uffda" + - "\022\uffda\023\uffda\024\uffda\025\uffda\026\uffda\027\uffda\030" + - "\uffda\031\uffda\053\uffda\001\002\000\052\005\uffdf\012\uffdf" + - "\013\uffdf\014\uffdf\015\060\016\uffdf\017\uffdf\020\uffdf\021" + - "\uffdf\022\uffdf\023\uffdf\024\uffdf\025\uffdf\026\uffdf\027\uffdf" + - "\030\uffdf\031\uffdf\037\057\040\056\053\uffdf\001\002\000" + - "\052\005\uffde\012\uffde\013\uffde\014\uffde\015\060\016\uffde" + - "\017\uffde\020\uffde\021\uffde\022\uffde\023\uffde\024\uffde\025" + - "\uffde\026\uffde\027\uffde\030\uffde\031\uffde\037\057\040\056" + - "\053\uffde\001\002\000\052\005\uffdd\012\uffdd\013\uffdd\014" + - "\uffdd\015\060\016\uffdd\017\uffdd\020\uffdd\021\uffdd\022\uffdd" + - "\023\uffdd\024\uffdd\025\uffdd\026\uffdd\027\uffdd\030\uffdd\031" + - "\uffdd\037\057\040\056\053\uffdd\001\002\000\052\005\uffdc" + - "\012\uffdc\013\uffdc\014\uffdc\015\060\016\uffdc\017\uffdc\020" + - "\uffdc\021\uffdc\022\uffdc\023\uffdc\024\uffdc\025\uffdc\026\uffdc" + - "\027\uffdc\030\uffdc\031\uffdc\037\057\040\056\053\uffdc\001" + - "\002\000\052\005\uffdb\012\uffdb\013\uffdb\014\uffdb\015\060" + - "\016\uffdb\017\uffdb\020\uffdb\021\uffdb\022\uffdb\023\uffdb\024" + - "\uffdb\025\uffdb\026\uffdb\027\uffdb\030\uffdb\031\uffdb\037\057" + - "\040\056\053\uffdb\001\002\000\100\005\uffcc\012\uffcc\013" + - "\uffcc\014\uffcc\015\uffcc\016\uffcc\017\uffcc\020\uffcc\021\uffcc" + - "\022\uffcc\023\uffcc\024\uffcc\025\uffcc\026\uffcc\027\uffcc\030" + - "\uffcc\031\uffcc\032\uffcc\033\uffcc\034\uffcc\035\uffcc\036\uffcc" + - "\037\uffcc\040\uffcc\041\uffcc\042\uffcc\043\uffcc\044\uffcc\046" + - "\uffcc\050\uffcc\053\uffcc\001\002\000\100\005\uffca\012\uffca" + - "\013\uffca\014\uffca\015\uffca\016\uffca\017\uffca\020\uffca\021" + - "\uffca\022\uffca\023\uffca\024\uffca\025\uffca\026\uffca\027\uffca" + - "\030\uffca\031\uffca\032\uffca\033\uffca\034\uffca\035\uffca\036" + - "\uffca\037\uffca\040\uffca\041\uffca\042\uffca\043\uffca\044\uffca" + - "\046\uffca\050\uffca\053\uffca\001\002\000\044\012\031\015" + - "\025\045\014\047\012\051\047\052\045\054\030\055\027" + - "\056\024\057\023\060\022\061\021\062\011\063\010\064" + - "\020\065\016\066\013\001\002\000\044\012\031\015\025" + - "\045\014\047\012\051\047\052\045\054\030\055\027\056" + - "\024\057\023\060\022\061\021\062\011\063\010\064\020" + - "\065\016\066\013\001\002\000\044\012\031\015\025\045" + - "\014\047\012\051\047\052\045\054\030\055\027\056\024" + - "\057\023\060\022\061\021\062\011\063\010\064\020\065" + - "\016\066\013\001\002\000\044\012\031\015\025\045\014" + - "\047\012\051\047\052\045\054\030\055\027\056\024\057" + - "\023\060\022\061\021\062\011\063\010\064\020\065\016" + - "\066\013\001\002\000\044\012\031\015\025\045\014\047" + - "\012\051\047\052\045\054\030\055\027\056\024\057\023" + - "\060\022\061\021\062\011\063\010\064\020\065\016\066" + - "\013\001\002\000\044\012\031\015\025\045\014\047\012" + - "\051\047\052\045\054\030\055\027\056\024\057\023\060" + - "\022\061\021\062\011\063\010\064\020\065\016\066\013" + - "\001\002\000\044\012\031\015\025\045\014\047\012\051" + - "\047\052\045\054\030\055\027\056\024\057\023\060\022" + - "\061\021\062\011\063\010\064\020\065\016\066\013\001" + - "\002\000\044\005\ufff1\012\ufff1\013\ufff1\014\ufff1\016\ufff1" + - "\017\133\020\ufff1\021\ufff1\022\ufff1\023\ufff1\024\ufff1\025" + - "\ufff1\026\ufff1\027\132\030\131\031\130\053\ufff1\001\002" + - "\000\044\012\031\015\025\045\014\047\012\051\047\052" + - "\045\054\030\055\027\056\024\057\023\060\022\061\021" + - "\062\011\063\010\064\020\065\016\066\013\001\002\000" + - "\044\012\031\015\025\045\014\047\012\051\047\052\045" + - "\054\030\055\027\056\024\057\023\060\022\061\021\062" + - "\011\063\010\064\020\065\016\066\013\001\002\000\044" + - "\012\031\015\025\045\014\047\012\051\047\052\045\054" + - "\030\055\027\056\024\057\023\060\022\061\021\062\011" + - "\063\010\064\020\065\016\066\013\001\002\000\044\012" + - "\031\015\025\045\014\047\012\051\047\052\045\054\030" + - "\055\027\056\024\057\023\060\022\061\021\062\011\063" + - "\010\064\020\065\016\066\013\001\002\000\044\005\uffe7" + - "\012\uffe7\013\uffe7\014\uffe7\016\uffe7\017\uffe7\020\uffe7\021" + - "\uffe7\022\uffe7\023\uffe7\024\uffe7\025\uffe7\026\uffe7\027\uffe7" + - "\030\uffe7\031\uffe7\053\uffe7\001\002\000\044\005\uffe9\012" + - "\uffe9\013\uffe9\014\uffe9\016\uffe9\017\uffe9\020\uffe9\021\uffe9" + - "\022\uffe9\023\uffe9\024\uffe9\025\uffe9\026\uffe9\027\uffe9\030" + - "\uffe9\031\uffe9\053\uffe9\001\002\000\044\005\uffe8\012\uffe8" + - "\013\uffe8\014\uffe8\016\uffe8\017\uffe8\020\uffe8\021\uffe8\022" + - "\uffe8\023\uffe8\024\uffe8\025\uffe8\026\uffe8\027\uffe8\030\uffe8" + - "\031\uffe8\053\uffe8\001\002\000\044\005\uffe6\012\uffe6\013" + - "\uffe6\014\uffe6\016\uffe6\017\uffe6\020\uffe6\021\uffe6\022\uffe6" + - "\023\uffe6\024\uffe6\025\uffe6\026\uffe6\027\uffe6\030\uffe6\031" + - "\uffe6\053\uffe6\001\002\000\044\005\ufff0\012\ufff0\013\ufff0" + - "\014\ufff0\016\ufff0\017\133\020\ufff0\021\ufff0\022\ufff0\023" + - "\ufff0\024\ufff0\025\ufff0\026\ufff0\027\132\030\131\031\130" + - "\053\ufff0\001\002\000\044\005\uffef\012\uffef\013\uffef\014" + - "\uffef\016\uffef\017\133\020\uffef\021\uffef\022\uffef\023\uffef" + - "\024\uffef\025\uffef\026\uffef\027\132\030\131\031\130\053" + - "\uffef\001\002\000\044\005\uffee\012\uffee\013\uffee\014\uffee" + - "\016\uffee\017\133\020\uffee\021\uffee\022\uffee\023\uffee\024" + - "\uffee\025\uffee\026\uffee\027\132\030\131\031\130\053\uffee" + - "\001\002\000\044\005\uffed\012\uffed\013\uffed\014\uffed\016" + - "\uffed\017\133\020\uffed\021\uffed\022\uffed\023\uffed\024\uffed" + - "\025\uffed\026\uffed\027\132\030\131\031\130\053\uffed\001" + - "\002\000\044\005\uffec\012\uffec\013\uffec\014\uffec\016\uffec" + - "\017\133\020\uffec\021\uffec\022\uffec\023\uffec\024\uffec\025" + - "\uffec\026\uffec\027\132\030\131\031\130\053\uffec\001\002" + - "\000\044\005\uffeb\012\uffeb\013\uffeb\014\uffeb\016\uffeb\017" + - "\133\020\uffeb\021\uffeb\022\uffeb\023\uffeb\024\uffeb\025\uffeb" + - "\026\uffeb\027\132\030\131\031\130\053\uffeb\001\002\000" + - "\100\005\uffd4\012\uffd4\013\uffd4\014\uffd4\015\uffd4\016\uffd4" + - "\017\uffd4\020\uffd4\021\uffd4\022\uffd4\023\uffd4\024\uffd4\025" + - "\uffd4\026\uffd4\027\uffd4\030\uffd4\031\uffd4\032\uffd4\033\uffd4" + - "\034\uffd4\035\uffd4\036\uffd4\037\uffd4\040\uffd4\041\uffd4\042" + - "\uffd4\043\uffd4\044\uffd4\046\uffd4\050\uffd4\053\uffd4\001\002" + - "\000\100\005\uffbd\012\uffbd\013\uffbd\014\uffbd\015\150\016" + - "\uffbd\017\uffbd\020\uffbd\021\uffbd\022\uffbd\023\uffbd\024\uffbd" + - "\025\uffbd\026\uffbd\027\uffbd\030\uffbd\031\uffbd\032\uffbd\033" + - "\uffbd\034\uffbd\035\uffbd\036\uffbd\037\uffbd\040\uffbd\041\uffbd" + - "\042\uffbd\043\uffbd\044\uffbd\046\uffbd\050\uffbd\053\uffbd\001" + - "\002\000\006\016\uffc5\065\152\001\002\000\004\016\155" + - "\001\002\000\006\016\uffc4\031\153\001\002\000\006\016" + - "\uffc5\065\152\001\002\000\004\016\uffc3\001\002\000\100" + - "\005\uffbe\012\uffbe\013\uffbe\014\uffbe\015\uffbe\016\uffbe\017" + - "\uffbe\020\uffbe\021\uffbe\022\uffbe\023\uffbe\024\uffbe\025\uffbe" + - "\026\uffbe\027\uffbe\030\uffbe\031\uffbe\032\uffbe\033\uffbe\034" + - "\uffbe\035\uffbe\036\uffbe\037\uffbe\040\uffbe\041\uffbe\042\uffbe" + - "\043\uffbe\044\uffbe\046\uffbe\050\uffbe\053\uffbe\001\002\000" + - "\100\005\uffc1\012\uffc1\013\uffc1\014\uffc1\015\uffc1\016\uffc1" + - "\017\uffc1\020\uffc1\021\uffc1\022\uffc1\023\uffc1\024\uffc1\025" + - "\uffc1\026\uffc1\027\uffc1\030\uffc1\031\uffc1\032\uffc1\033\uffc1" + - "\034\uffc1\035\uffc1\036\uffc1\037\uffc1\040\uffc1\041\uffc1\042" + - "\uffc1\043\uffc1\044\uffc1\046\uffc1\050\uffc1\053\uffc1\001\002" + - "\000\004\066\160\001\002\000\004\005\161\001\002\000" + - "\056\002\ufffb\006\ufffb\007\ufffb\010\ufffb\011\ufffb\012\ufffb" + - "\015\ufffb\045\ufffb\047\ufffb\051\ufffb\052\ufffb\054\ufffb\055" + - "\ufffb\056\ufffb\057\ufffb\060\ufffb\061\ufffb\062\ufffb\063\ufffb" + - "\064\ufffb\065\ufffb\066\ufffb\001\002\000\004\005\163\001" + - "\002\000\056\002\ufffa\006\ufffa\007\ufffa\010\ufffa\011\ufffa" + - "\012\ufffa\015\ufffa\045\ufffa\047\ufffa\051\ufffa\052\ufffa\054" + - "\ufffa\055\ufffa\056\ufffa\057\ufffa\060\ufffa\061\ufffa\062\ufffa" + - "\063\ufffa\064\ufffa\065\ufffa\066\ufffa\001\002\000\004\005" + - "\165\001\002\000\056\002\ufff9\006\ufff9\007\ufff9\010\ufff9" + - "\011\ufff9\012\ufff9\015\ufff9\045\ufff9\047\ufff9\051\ufff9\052" + - "\ufff9\054\ufff9\055\ufff9\056\ufff9\057\ufff9\060\ufff9\061\ufff9" + - "\062\ufff9\063\ufff9\064\ufff9\065\ufff9\066\ufff9\001\002\000" + - "\004\005\167\001\002\000\056\002\ufff8\006\ufff8\007\ufff8" + - "\010\ufff8\011\ufff8\012\ufff8\015\ufff8\045\ufff8\047\ufff8\051" + - "\ufff8\052\ufff8\054\ufff8\055\ufff8\056\ufff8\057\ufff8\060\ufff8" + - "\061\ufff8\062\ufff8\063\ufff8\064\ufff8\065\ufff8\066\ufff8\001" + - "\002\000\100\005\uffc0\012\uffc0\013\uffc0\014\uffc0\015\uffc0" + - "\016\uffc0\017\uffc0\020\uffc0\021\uffc0\022\uffc0\023\uffc0\024" + - "\uffc0\025\uffc0\026\uffc0\027\uffc0\030\uffc0\031\uffc0\032\uffc0" + - "\033\uffc0\034\uffc0\035\uffc0\036\uffc0\037\uffc0\040\uffc0\041" + - "\uffc0\042\uffc0\043\uffc0\044\uffc0\046\uffc0\050\uffc0\053\uffc0" + - "\001\002\000\044\005\uffe1\012\uffe1\013\uffe1\014\uffe1\016" + - "\uffe1\017\uffe1\020\uffe1\021\uffe1\022\uffe1\023\uffe1\024\uffe1" + - "\025\uffe1\026\uffe1\027\uffe1\030\uffe1\031\uffe1\053\uffe1\001" + - "\002\000\022\016\173\020\126\021\125\022\124\023\123" + - "\024\122\025\121\026\120\001\002\000\070\005\uffd8\012" + - "\uffd8\013\uffd8\014\uffd8\015\uffca\016\uffd8\017\uffd8\020\uffd8" + - "\021\uffd8\022\uffd8\023\uffd8\024\uffd8\025\uffd8\026\uffd8\027" + - "\uffd8\030\uffd8\031\uffd8\032\uffca\033\uffca\034\uffca\035\uffca" + - "\036\uffca\037\uffca\040\uffca\041\uffca\042\uffca\053\uffd8\001" + - "\002\000\044\005\uffe4\012\uffe4\013\uffe4\014\uffe4\016\uffe4" + - "\017\uffe4\020\uffe4\021\uffe4\022\uffe4\023\uffe4\024\uffe4\025" + - "\uffe4\026\uffe4\027\uffe4\030\uffe4\031\uffe4\053\uffe4\001\002" + - "\000\044\005\uffe3\012\uffe3\013\uffe3\014\uffe3\016\uffe3\017" + - "\uffe3\020\uffe3\021\uffe3\022\uffe3\023\uffe3\024\uffe3\025\uffe3" + - "\026\uffe3\027\uffe3\030\uffe3\031\uffe3\053\uffe3\001\002\000" + - "\044\005\uffe2\012\uffe2\013\uffe2\014\uffe2\016\uffe2\017\uffe2" + - "\020\uffe2\021\uffe2\022\uffe2\023\uffe2\024\uffe2\025\uffe2\026" + - "\uffe2\027\uffe2\030\uffe2\031\uffe2\053\uffe2\001\002\000\006" + - "\065\uffb6\066\uffb6\001\002\000\060\002\ufff4\006\ufff4\007" + - "\ufff4\010\ufff4\011\ufff4\012\ufff4\014\210\015\ufff4\045\ufff4" + - "\047\ufff4\051\ufff4\052\ufff4\054\ufff4\055\ufff4\056\ufff4\057" + - "\ufff4\060\ufff4\061\ufff4\062\ufff4\063\ufff4\064\ufff4\065\ufff4" + - "\066\ufff4\001\002\000\010\005\ufff4\013\ufff4\014\210\001" + - "\002\000\004\064\203\001\002\000\006\017\205\053\204" + - "\001\002\000\010\005\uffb3\013\uffb3\014\uffb3\001\002\000" + - "\004\064\206\001\002\000\004\053\207\001\002\000\010" + - "\005\uffb2\013\uffb2\014\uffb2\001\002\000\004\015\214\001" + - "\002\000\006\005\212\013\213\001\002\000\056\002\ufff7" + - "\006\ufff7\007\ufff7\010\ufff7\011\ufff7\012\ufff7\015\ufff7\045" + - "\ufff7\047\ufff7\051\ufff7\052\ufff7\054\ufff7\055\ufff7\056\ufff7" + - "\057\ufff7\060\ufff7\061\ufff7\062\ufff7\063\ufff7\064\ufff7\065" + - "\ufff7\066\ufff7\001\002\000\056\002\ufff5\006\ufff5\007\ufff5" + - "\010\ufff5\011\ufff5\012\ufff5\015\ufff5\045\ufff5\047\ufff5\051" + - "\ufff5\052\ufff5\054\ufff5\055\ufff5\056\ufff5\057\ufff5\060\ufff5" + - "\061\ufff5\062\ufff5\063\ufff5\064\ufff5\065\ufff5\066\ufff5\001" + - "\002\000\004\064\215\001\002\000\006\016\216\017\217" + - "\001\002\000\062\002\ufff3\005\ufff3\006\ufff3\007\ufff3\010" + - "\ufff3\011\ufff3\012\ufff3\013\ufff3\015\ufff3\045\ufff3\047\ufff3" + - "\051\ufff3\052\ufff3\054\ufff3\055\ufff3\056\ufff3\057\ufff3\060" + - "\ufff3\061\ufff3\062\ufff3\063\ufff3\064\ufff3\065\ufff3\066\ufff3" + - "\001\002\000\004\064\220\001\002\000\004\016\221\001" + - "\002\000\062\002\ufff2\005\ufff2\006\ufff2\007\ufff2\010\ufff2" + - "\011\ufff2\012\ufff2\013\ufff2\015\ufff2\045\ufff2\047\ufff2\051" + - "\ufff2\052\ufff2\054\ufff2\055\ufff2\056\ufff2\057\ufff2\060\ufff2" + - "\061\ufff2\062\ufff2\063\ufff2\064\ufff2\065\ufff2\066\ufff2\001" + - "\002\000\056\002\ufff6\006\ufff6\007\ufff6\010\ufff6\011\ufff6" + - "\012\ufff6\015\ufff6\045\ufff6\047\ufff6\051\ufff6\052\ufff6\054" + - "\ufff6\055\ufff6\056\ufff6\057\ufff6\060\ufff6\061\ufff6\062\ufff6" + - "\063\ufff6\064\ufff6\065\ufff6\066\ufff6\001\002\000\004\046" + - "\224\001\002\000\100\005\uffce\012\uffce\013\uffce\014\uffce" + - "\015\uffce\016\uffce\017\uffce\020\uffce\021\uffce\022\uffce\023" + - "\uffce\024\uffce\025\uffce\026\uffce\027\uffce\030\uffce\031\uffce" + - "\032\uffce\033\uffce\034\uffce\035\uffce\036\uffce\037\uffce\040" + - "\uffce\041\uffce\042\uffce\043\uffce\044\uffce\046\uffce\050\uffce" + - "\053\uffce\001\002\000\004\050\226\001\002\000\100\005" + - "\uffcd\012\uffcd\013\uffcd\014\uffcd\015\uffcd\016\uffcd\017\uffcd" + - "\020\uffcd\021\uffcd\022\uffcd\023\uffcd\024\uffcd\025\uffcd\026" + - "\uffcd\027\uffcd\030\uffcd\031\uffcd\032\uffcd\033\uffcd\034\uffcd" + - "\035\uffcd\036\uffcd\037\uffcd\040\uffcd\041\uffcd\042\uffcd\043" + - "\uffcd\044\uffcd\046\uffcd\050\uffcd\053\uffcd\001\002\000\004" + - "\005\230\001\002\000\056\002\ufffe\006\ufffe\007\ufffe\010" + - "\ufffe\011\ufffe\012\ufffe\015\ufffe\045\ufffe\047\ufffe\051\ufffe" + - "\052\ufffe\054\ufffe\055\ufffe\056\ufffe\057\ufffe\060\ufffe\061" + - "\ufffe\062\ufffe\063\ufffe\064\ufffe\065\ufffe\066\ufffe\001\002" + - "\000\004\002\001\001\002\000\056\002\000\006\040\007" + - "\035\010\033\011\032\012\031\015\025\045\014\047\012" + - "\051\047\052\045\054\030\055\027\056\024\057\023\060" + - "\022\061\021\062\011\063\010\064\020\065\016\066\013" + - "\001\002" }); - - /** Access to parse-action table. */ - public short[][] action_table() {return _action_table;} - - /** <code>reduce_goto</code> table. */ - protected static final short[][] _reduce_table = - unpackFromStrings(new String[] { - "\000\230\000\010\003\004\004\003\005\006\001\001\000" + - "\004\005\231\001\001\000\002\001\001\000\002\001\001" + - "\000\032\006\025\010\014\011\036\012\035\013\033\014" + - "\042\015\047\016\045\017\043\022\016\023\041\024\040" + - "\001\001\000\002\001\001\000\002\001\001\000\022\014" + - "\061\015\047\016\045\017\043\020\224\022\016\023\041" + - "\024\040\001\001\000\002\001\001\000\022\014\061\015" + - "\047\016\045\017\043\020\222\022\016\023\041\024\040" + - "\001\001\000\004\025\200\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\022" + - "\013\175\014\042\015\047\016\045\017\043\022\016\023" + - "\041\024\040\001\001\000\022\013\174\014\042\015\047" + - "\016\045\017\043\022\016\023\041\024\040\001\001\000" + - "\022\013\173\014\042\015\047\016\045\017\043\022\016" + - "\023\041\024\040\001\001\000\032\010\171\011\036\012" + - "\035\013\033\014\076\015\047\016\045\017\043\020\075" + - "\022\016\023\041\024\040\001\001\000\002\001\001\000" + - "\022\013\170\014\042\015\047\016\045\017\043\022\016" + - "\023\041\024\040\001\001\000\002\001\001\000\002\001" + - "\001\000\006\022\165\024\040\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\004\024\156\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\002" + - "\001\001\000\020\014\053\015\047\016\145\017\043\022" + - "\016\023\041\024\040\001\001\000\020\014\053\015\047" + - "\016\054\017\043\022\016\023\041\024\040\001\001\000" + - "\032\010\074\011\036\012\035\013\033\014\076\015\047" + - "\016\045\017\043\020\075\022\016\023\041\024\040\001" + - "\001\000\002\001\001\000\002\001\001\000\020\014\053" + - "\015\073\016\045\017\043\022\016\023\041\024\040\001" + - "\001\000\020\014\053\015\072\016\045\017\043\022\016" + - "\023\041\024\040\001\001\000\022\014\061\015\047\016" + - "\045\017\043\020\060\022\016\023\041\024\040\001\001" + - "\000\002\001\001\000\002\001\001\000\022\014\061\015" + - "\047\016\045\017\043\020\063\022\016\023\041\024\040" + - "\001\001\000\002\001\001\000\022\014\061\015\047\016" + - "\045\017\043\020\070\022\016\023\041\024\040\001\001" + - "\000\022\014\061\015\047\016\045\017\043\020\066\022" + - "\016\023\041\024\040\001\001\000\002\001\001\000\002" + - "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\020\014\114\015\047\016\045\017" + - "\043\022\016\023\041\024\040\001\001\000\020\014\113" + - "\015\047\016\045\017\043\022\016\023\041\024\040\001" + - "\001\000\020\014\112\015\047\016\045\017\043\022\016" + - "\023\041\024\040\001\001\000\020\014\111\015\047\016" + - "\045\017\043\022\016\023\041\024\040\001\001\000\020" + - "\014\110\015\047\016\045\017\043\022\016\023\041\024" + - "\040\001\001\000\002\001\001\000\022\014\061\015\047" + - "\016\045\017\043\020\106\022\016\023\041\024\040\001" + - "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\026" + - "\011\144\012\035\013\033\014\042\015\047\016\045\017" + - "\043\022\016\023\041\024\040\001\001\000\026\011\143" + - "\012\035\013\033\014\042\015\047\016\045\017\043\022" + - "\016\023\041\024\040\001\001\000\026\011\142\012\035" + - "\013\033\014\042\015\047\016\045\017\043\022\016\023" + - "\041\024\040\001\001\000\026\011\141\012\035\013\033" + - "\014\042\015\047\016\045\017\043\022\016\023\041\024" + - "\040\001\001\000\026\011\140\012\035\013\033\014\042" + - "\015\047\016\045\017\043\022\016\023\041\024\040\001" + - "\001\000\026\011\137\012\035\013\033\014\042\015\047" + - "\016\045\017\043\022\016\023\041\024\040\001\001\000" + - "\026\011\126\012\035\013\033\014\042\015\047\016\045" + - "\017\043\022\016\023\041\024\040\001\001\000\002\001" + - "\001\000\024\012\136\013\033\014\042\015\047\016\045" + - "\017\043\022\016\023\041\024\040\001\001\000\024\012" + - "\135\013\033\014\042\015\047\016\045\017\043\022\016" + - "\023\041\024\040\001\001\000\024\012\134\013\033\014" + - "\042\015\047\016\045\017\043\022\016\023\041\024\040" + - "\001\001\000\024\012\133\013\033\014\042\015\047\016" + - "\045\017\043\022\016\023\041\024\040\001\001\000\002" + - "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\004\021\150\001\001" + - "\000\002\001\001\000\002\001\001\000\004\021\153\001" + - "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\002" + - "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\004\007\221\001\001\000\004\007\210" + - "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\002" + - "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\032\006\025\010\014" + - "\011\036\012\035\013\033\014\042\015\047\016\045\017" + - "\043\022\016\023\041\024\040\001\001" }); - - /** Access to <code>reduce_goto</code> table. */ - public short[][] reduce_table() {return _reduce_table;} - - /** Instance of action encapsulation class. */ - protected CUP$parser$actions action_obj; - - /** Action encapsulation object initializer. */ - protected void init_actions() - { - action_obj = new CUP$parser$actions(this); - } - - /** Invoke a user supplied parse action. */ - public java_cup.runtime.Symbol do_action( - int act_num, - java_cup.runtime.lr_parser parser, - java.util.Stack stack, - int top) - throws java.lang.Exception - { - /* call code in generated class */ - return action_obj.CUP$parser$do_action(act_num, parser, stack, top); - } - - /** Indicates start state. */ - public int start_state() {return 0;} - /** Indicates start production. */ - public int start_production() {return 0;} - - /** <code>EOF</code> Symbol index. */ - public int EOF_sym() {return 0;} - - /** <code>error</code> Symbol index. */ - public int error_sym() {return 1;} - - - - public com.googlecode.opennars.parser.loan.Loan.Absyn.Document pDocument() throws Exception - { - java_cup.runtime.Symbol res = parse(); - return (com.googlecode.opennars.parser.loan.Loan.Absyn.Document) res.value; - } - -public <B,A extends java.util.LinkedList<? super B>> A cons_(B x, A xs) { xs.addFirst(x); return xs; } - -public void syntax_error(java_cup.runtime.Symbol cur_token) -{ - report_error("Syntax Error, trying to recover and continue parse...", cur_token); -} - -public void unrecovered_syntax_error(java_cup.runtime.Symbol cur_token) throws java.lang.Exception -{ - throw new Exception("Unrecoverable Syntax Error"); -} - - -} - -/** Cup generated class to encapsulate user supplied action code.*/ -class CUP$parser$actions { - private final parser parser; - - /** Constructor */ - CUP$parser$actions(parser parser) { - this.parser = parser; - } - - /** Method with the actual generated action code. */ - public final java_cup.runtime.Symbol CUP$parser$do_action( - int CUP$parser$act_num, - java_cup.runtime.lr_parser CUP$parser$parser, - java.util.Stack CUP$parser$stack, - int CUP$parser$top) - throws java.lang.Exception - { - /* Symbol object for return from actions */ - java_cup.runtime.Symbol CUP$parser$result; - - /* select the action based on the action number */ - switch (CUP$parser$act_num) - { - /*. . . . . . . . . . . . . . . . . . . .*/ - case 79: // TruthValue ::= _SYMB_39 _DOUBLE_ _SYMB_11 _DOUBLE_ _SYMB_39 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue RESULT = null; - Double p_2 = (Double)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; - Double p_4 = (Double)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC(p_2,p_4); - CUP$parser$result = new java_cup.runtime.Symbol(19/*TruthValue*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 78: // TruthValue ::= _SYMB_39 _DOUBLE_ _SYMB_39 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue RESULT = null; - Double p_2 = (Double)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(19/*TruthValue*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 77: // TruthValue ::= - { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue RESULT = null; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE(); - CUP$parser$result = new java_cup.runtime.Symbol(19/*TruthValue*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 76: // NSPrefix ::= _SYMB_38 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix RESULT = null; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2(); - CUP$parser$result = new java_cup.runtime.Symbol(18/*NSPrefix*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 75: // NSPrefix ::= _IDENT_ _SYMB_38 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix RESULT = null; - String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(18/*NSPrefix*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 74: // Literal ::= _SYMB_40 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal RESULT = null; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse(); - CUP$parser$result = new java_cup.runtime.Symbol(17/*Literal*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 73: // Literal ::= _SYMB_45 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal RESULT = null; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue(); - CUP$parser$result = new java_cup.runtime.Symbol(17/*Literal*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 72: // Literal ::= _STRING_ - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal RESULT = null; - String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitString(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(17/*Literal*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 71: // Literal ::= _DOUBLE_ - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal RESULT = null; - Double p_1 = (Double)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(17/*Literal*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 70: // Literal ::= _INTEGER_ - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal RESULT = null; - Integer p_1 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(17/*Literal*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 69: // Literal ::= URIRef - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(17/*Literal*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 68: // Literal ::= _SYMB_37 _IDENT_ - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal RESULT = null; - String p_2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(17/*Literal*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 67: // Literal ::= _SYMB_37 _IDENT_ _SYMB_9 ListIdent _SYMB_10 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal RESULT = null; - String p_2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent p_4 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD(p_2,p_4); - CUP$parser$result = new java_cup.runtime.Symbol(17/*Literal*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 66: // Literal ::= _SYMB_6 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal RESULT = null; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn(); - CUP$parser$result = new java_cup.runtime.Symbol(17/*Literal*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 65: // Literal ::= _SYMB_6 _IDENT_ - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal RESULT = null; - String p_2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(17/*Literal*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 64: // URIRef ::= NSPrefix _IDENT_ - { - com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - String p_2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.URICur(p_1,p_2); - CUP$parser$result = new java_cup.runtime.Symbol(16/*URIRef*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 63: // URIRef ::= URILit - { - com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef RESULT = null; - String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(16/*URIRef*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 62: // ListIdent ::= _IDENT_ _SYMB_21 ListIdent - { - com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent RESULT = null; - String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = p_3; p_3.addFirst(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(15/*ListIdent*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 61: // ListIdent ::= _IDENT_ - { - com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent RESULT = null; - String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent(); RESULT.addLast(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(15/*ListIdent*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 60: // ListIdent ::= - { - com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent RESULT = null; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent(); - CUP$parser$result = new java_cup.runtime.Symbol(15/*ListIdent*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 59: // ListTerm ::= Term _SYMB_21 ListTerm - { - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = p_3; p_3.addFirst(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(14/*ListTerm*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 58: // ListTerm ::= Term - { - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm(); RESULT.addLast(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(14/*ListTerm*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 57: // ListTerm ::= - { - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm RESULT = null; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm(); - CUP$parser$result = new java_cup.runtime.Symbol(14/*ListTerm*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 56: // Term3 ::= _SYMB_9 Term _SYMB_10 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = p_2; - CUP$parser$result = new java_cup.runtime.Symbol(13/*Term3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 55: // Term3 ::= _SYMB_9 Stm _SYMB_10 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(13/*Term3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 54: // Term3 ::= Literal - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Literal p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Literal)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(13/*Term3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 53: // Term3 ::= _SYMB_9 ListTerm _SYMB_10 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(13/*Term3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 52: // Term3 ::= _SYMB_35 ListTerm _SYMB_36 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(13/*Term3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 51: // Term3 ::= _SYMB_33 ListTerm _SYMB_34 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(13/*Term3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 50: // Term2 ::= Term3 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = p_1; - CUP$parser$result = new java_cup.runtime.Symbol(12/*Term2*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 49: // Term2 ::= Term _SYMB_9 ListTerm _SYMB_32 ListTerm _SYMB_10 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-5)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm p_5 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg(p_1,p_3,p_5); - CUP$parser$result = new java_cup.runtime.Symbol(12/*Term2*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 48: // Term2 ::= Term _SYMB_9 ListTerm _SYMB_31 ListTerm _SYMB_10 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-5)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm p_5 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg(p_1,p_3,p_5); - CUP$parser$result = new java_cup.runtime.Symbol(12/*Term2*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 47: // Term1 ::= Term2 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = p_1; - CUP$parser$result = new java_cup.runtime.Symbol(11/*Term1*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 46: // Term1 ::= Term1 _SYMB_30 Term2 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(11/*Term1*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 45: // Term1 ::= Term1 _SYMB_29 Term2 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(11/*Term1*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 44: // Term ::= Term1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = p_1; - CUP$parser$result = new java_cup.runtime.Symbol(10/*Term*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 43: // Term ::= Term _SYMB_28 Term1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(10/*Term*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 42: // Term ::= Term _SYMB_27 Term1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(10/*Term*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 41: // Stm3 ::= _SYMB_9 Stm _SYMB_10 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = p_2; - CUP$parser$result = new java_cup.runtime.Symbol(9/*Stm3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 40: // Stm3 ::= Term - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(9/*Stm3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 39: // Stm3 ::= Term _SYMB_9 ListTerm _SYMB_10 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(9/*Stm3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 38: // Stm3 ::= Term _SYMB_26 Term - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(9/*Stm3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 37: // Stm3 ::= Term _SYMB_25 Term - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(9/*Stm3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 36: // Stm3 ::= Term _SYMB_24 Term - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(9/*Stm3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 35: // Stm3 ::= Term _SYMB_23 Term - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(9/*Stm3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 34: // Stm3 ::= Term _SYMB_22 Term - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Term p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Term)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(9/*Stm3*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 33: // Stm2 ::= Stm3 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = p_1; - CUP$parser$result = new java_cup.runtime.Symbol(8/*Stm2*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 32: // Stm2 ::= _SYMB_41 Stm3 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(8/*Stm2*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 31: // Stm2 ::= _SYMB_44 Stm3 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(8/*Stm2*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 30: // Stm2 ::= _SYMB_43 Stm3 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(8/*Stm2*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 29: // Stm2 ::= _SYMB_42 Stm3 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(8/*Stm2*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 28: // Stm1 ::= Stm2 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = p_1; - CUP$parser$result = new java_cup.runtime.Symbol(7/*Stm1*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 27: // Stm1 ::= Stm1 _SYMB_21 Stm2 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(7/*Stm1*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 26: // Stm1 ::= Stm1 _SYMB_11 Stm2 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(7/*Stm1*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 25: // Stm1 ::= Stm1 _SYMB_20 Stm2 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(7/*Stm1*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 24: // Stm1 ::= Stm1 _SYMB_19 Stm2 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(7/*Stm1*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 23: // Stm ::= Stm1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = p_1; - CUP$parser$result = new java_cup.runtime.Symbol(6/*Stm*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 22: // Stm ::= Stm _SYMB_18 Stm1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(6/*Stm*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 21: // Stm ::= Stm _SYMB_17 Stm1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(6/*Stm*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 20: // Stm ::= Stm _SYMB_16 Stm1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(6/*Stm*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 19: // Stm ::= Stm _SYMB_15 Stm1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(6/*Stm*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 18: // Stm ::= Stm _SYMB_14 Stm1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(6/*Stm*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 17: // Stm ::= Stm _SYMB_13 Stm1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(6/*Stm*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 16: // Stm ::= Stm _SYMB_12 Stm1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(6/*Stm*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 15: // Budget ::= _SYMB_8 _SYMB_9 _DOUBLE_ _SYMB_11 _DOUBLE_ _SYMB_10 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Budget RESULT = null; - Double p_3 = (Double)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; - Double p_5 = (Double)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD(p_3,p_5); - CUP$parser$result = new java_cup.runtime.Symbol(5/*Budget*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 14: // Budget ::= _SYMB_8 _SYMB_9 _DOUBLE_ _SYMB_10 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Budget RESULT = null; - Double p_3 = (Double)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP(p_3); - CUP$parser$result = new java_cup.runtime.Symbol(5/*Budget*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 13: // Budget ::= - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Budget RESULT = null; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE(); - CUP$parser$result = new java_cup.runtime.Symbol(5/*Budget*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 12: // Sentence ::= Stm TruthValue Budget _SYMB_7 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Budget p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Budget)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal(p_1,p_2,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(4/*Sentence*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 11: // Sentence ::= Stm _SYMB_6 Budget - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Budget p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Budget)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest(p_1,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(4/*Sentence*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 10: // Sentence ::= Stm TruthValue Budget _SYMB_1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Stm)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Budget p_3 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Budget)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge(p_1,p_2,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(4/*Sentence*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 9: // Sentence ::= _SYMB_5 URIRef _SYMB_1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.URIRef)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(4/*Sentence*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 8: // Sentence ::= _SYMB_4 _INTEGER_ _SYMB_1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence RESULT = null; - Integer p_2 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(4/*Sentence*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 7: // Sentence ::= _SYMB_3 URILit _SYMB_1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence RESULT = null; - String p_2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(4/*Sentence*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 6: // Sentence ::= _SYMB_2 NSPrefix URILit _SYMB_1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; - String p_3 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix(p_2,p_3); - CUP$parser$result = new java_cup.runtime.Symbol(4/*Sentence*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 5: // ListSentence ::= ListSentence Sentence - { - com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = p_1; p_1.addLast(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(3/*ListSentence*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 4: // ListSentence ::= - { - com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence RESULT = null; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence(); - CUP$parser$result = new java_cup.runtime.Symbol(3/*ListSentence*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 3: // BaseRule ::= _SYMB_0 URILit _SYMB_1 - { - com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule RESULT = null; - String p_2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR(p_2); - CUP$parser$result = new java_cup.runtime.Symbol(2/*BaseRule*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 2: // Document ::= ListSentence - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Document RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.Doc(p_1); - CUP$parser$result = new java_cup.runtime.Symbol(1/*Document*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 1: // Document ::= BaseRule ListSentence - { - com.googlecode.opennars.parser.loan.Loan.Absyn.Document RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule p_1 = (com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence p_2 = (com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; - RESULT = new com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR(p_1,p_2); - CUP$parser$result = new java_cup.runtime.Symbol(1/*Document*/, RESULT); - } - return CUP$parser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 0: // $START ::= Document EOF - { - Object RESULT = null; - com.googlecode.opennars.parser.loan.Loan.Absyn.Document start_val = (com.googlecode.opennars.parser.loan.Loan.Absyn.Document)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; - RESULT = start_val; - CUP$parser$result = new java_cup.runtime.Symbol(0/*$START*/, RESULT); - } - /* ACCEPT */ - CUP$parser$parser.done_parsing(); - return CUP$parser$result; - - /* . . . . . .*/ - default: - throw new Exception( - "Invalid action number found in internal parse table"); - - } - } -} - diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/sym.java b/open-nars/src/com/googlecode/opennars/parser/loan/Loan/sym.java deleted file mode 100644 index f698b3da81c74d41f7caf53ea5cd67943e9d0e56..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/Loan/sym.java +++ /dev/null @@ -1,66 +0,0 @@ - -//---------------------------------------------------- -// The following code was generated by CUP v0.10k -// Fri Apr 04 22:02:41 BST 2008 -//---------------------------------------------------- - -package com.googlecode.opennars.parser.loan.Loan; - -/** CUP generated class containing symbol constants. */ -public class sym { - /* terminals */ - public static final int _SYMB_18 = 20; - public static final int _SYMB_17 = 19; - public static final int _SYMB_16 = 18; - public static final int _SYMB_15 = 17; - public static final int _SYMB_14 = 16; - public static final int _SYMB_45 = 47; - public static final int _SYMB_13 = 15; - public static final int _SYMB_44 = 46; - public static final int _SYMB_12 = 14; - public static final int _SYMB_43 = 45; - public static final int _SYMB_11 = 13; - public static final int _SYMB_9 = 11; - public static final int _SYMB_42 = 44; - public static final int _SYMB_8 = 10; - public static final int _SYMB_10 = 12; - public static final int _SYMB_41 = 43; - public static final int _SYMB_7 = 9; - public static final int URILit = 52; - public static final int _SYMB_40 = 42; - public static final int _SYMB_6 = 8; - public static final int _SYMB_5 = 7; - public static final int _SYMB_4 = 6; - public static final int _SYMB_3 = 5; - public static final int _SYMB_2 = 4; - public static final int _SYMB_1 = 3; - public static final int _SYMB_0 = 2; - public static final int _IDENT_ = 51; - public static final int _INTEGER_ = 49; - public static final int _STRING_ = 48; - public static final int _SYMB_39 = 41; - public static final int _SYMB_38 = 40; - public static final int _SYMB_37 = 39; - public static final int _SYMB_36 = 38; - public static final int _SYMB_35 = 37; - public static final int _SYMB_34 = 36; - public static final int _SYMB_33 = 35; - public static final int _SYMB_32 = 34; - public static final int _SYMB_31 = 33; - public static final int _SYMB_30 = 32; - public static final int EOF = 0; - public static final int error = 1; - public static final int _SYMB_29 = 31; - public static final int _SYMB_28 = 30; - public static final int _SYMB_27 = 29; - public static final int _SYMB_26 = 28; - public static final int _SYMB_25 = 27; - public static final int _SYMB_24 = 26; - public static final int _SYMB_23 = 25; - public static final int _SYMB_22 = 24; - public static final int _SYMB_21 = 23; - public static final int _SYMB_20 = 22; - public static final int _DOUBLE_ = 50; - public static final int _SYMB_19 = 21; -} - diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/LoanParser.java b/open-nars/src/com/googlecode/opennars/parser/loan/LoanParser.java deleted file mode 100644 index 5253ae12deb330217321de4b3ed013b2e202abfe..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/LoanParser.java +++ /dev/null @@ -1,1478 +0,0 @@ -package com.googlecode.opennars.parser.loan; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.StringReader; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; - -import com.googlecode.opennars.entity.Base; -import com.googlecode.opennars.entity.BudgetValue; -import com.googlecode.opennars.entity.Sentence; -import com.googlecode.opennars.entity.Task; -import com.googlecode.opennars.entity.TruthValue; -import com.googlecode.opennars.language.BooleanLiteral; -import com.googlecode.opennars.language.CompoundTerm; -import com.googlecode.opennars.language.Conjunction; -import com.googlecode.opennars.language.ConjunctionParallel; -import com.googlecode.opennars.language.ConjunctionSequence; -import com.googlecode.opennars.language.DifferenceExt; -import com.googlecode.opennars.language.DifferenceInt; -import com.googlecode.opennars.language.Disjunction; -import com.googlecode.opennars.language.Equivalence; -import com.googlecode.opennars.language.EquivalenceAfter; -import com.googlecode.opennars.language.EquivalenceWhen; -import com.googlecode.opennars.language.ImageExt; -import com.googlecode.opennars.language.ImageInt; -import com.googlecode.opennars.language.Implication; -import com.googlecode.opennars.language.ImplicationAfter; -import com.googlecode.opennars.language.ImplicationBefore; -import com.googlecode.opennars.language.ImplicationWhen; -import com.googlecode.opennars.language.Inheritance; -import com.googlecode.opennars.language.Instance; -import com.googlecode.opennars.language.InstanceProperty; -import com.googlecode.opennars.language.IntersectionExt; -import com.googlecode.opennars.language.IntersectionInt; -import com.googlecode.opennars.language.Literal; -import com.googlecode.opennars.language.Negation; -import com.googlecode.opennars.language.NumericLiteral; -import com.googlecode.opennars.language.Product; -import com.googlecode.opennars.language.Property; -import com.googlecode.opennars.language.SetExt; -import com.googlecode.opennars.language.SetInt; -import com.googlecode.opennars.language.Similarity; -import com.googlecode.opennars.language.Statement; -import com.googlecode.opennars.language.StringLiteral; -import com.googlecode.opennars.language.TenseFuture; -import com.googlecode.opennars.language.TensePast; -import com.googlecode.opennars.language.TensePresent; -import com.googlecode.opennars.language.Term; -import com.googlecode.opennars.language.URIRef; -import com.googlecode.opennars.language.Variable; -import com.googlecode.opennars.main.Memory; -import com.googlecode.opennars.parser.InvalidInputException; -import com.googlecode.opennars.parser.Parser; -import com.googlecode.opennars.parser.Symbols; -import com.googlecode.opennars.parser.TermVisitor; -import com.googlecode.opennars.parser.loan.Loan.AbstractVisitor; -import com.googlecode.opennars.parser.loan.Loan.PrettyPrinter; -import com.googlecode.opennars.parser.loan.Loan.Yylex; -import com.googlecode.opennars.parser.loan.Loan.parser; -import com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR; -import com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE; -import com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP; -import com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD; -import com.googlecode.opennars.parser.loan.Loan.Absyn.Doc; -import com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR; -import com.googlecode.opennars.parser.loan.Loan.Absyn.Document; -import com.googlecode.opennars.parser.loan.Loan.Absyn.ListIdent; -import com.googlecode.opennars.parser.loan.Loan.Absyn.ListTerm; -import com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl; -import com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse; -import com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt; -import com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar; -import com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn; -import com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD; -import com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI; -import com.googlecode.opennars.parser.loan.Loan.Absyn.LitString; -import com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue; -import com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI; -import com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1; -import com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2; -import com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay; -import com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal; -import com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport; -import com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge; -import com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp; -import com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix; -import com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest; -import com.googlecode.opennars.parser.loan.Loan.Absyn.Stm; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim; -import com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF; -import com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC; -import com.googlecode.opennars.parser.loan.Loan.Absyn.URICur; -import com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul; - -public class LoanParser extends Parser { - - public class SerialiseVisitor implements TermVisitor<Object,LoanParser> { - - /** - * If the provided object is a term, wrap it in a StmTrm object - * @param o the object to (potentially) wrap - * @return the wrapped object - */ - private Stm wrapTerm(Object o) { - if(o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.Term) { - return new StmTrm((com.googlecode.opennars.parser.loan.Loan.Absyn.Term) o); - } - else - return (Stm) o; - } - - /** - * If the provided object is a statement, wrap it in a TrmStm object - * @param o the object to (potentially) wrap - * @return the wrapped object - */ - private com.googlecode.opennars.parser.loan.Loan.Absyn.Term wrapStatement(Object o) { - if(o instanceof com.googlecode.opennars.parser.loan.Loan.Absyn.Stm) { - return new TrmStm((com.googlecode.opennars.parser.loan.Loan.Absyn.Stm) o); - } - else - return (com.googlecode.opennars.parser.loan.Loan.Absyn.Term) o; - } - - public Object visit(Term p, LoanParser arg) { - // TODO: Fix this awful ladder. I wish Java had a more dynamic invocation procedure like Smalltalk or Objective-C - if(p instanceof BooleanLiteral) - return visit((BooleanLiteral) p, arg); - if(p instanceof Conjunction) - return visit((Conjunction) p, arg); - if(p instanceof ConjunctionParallel) - return visit((ConjunctionParallel) p, arg); - if(p instanceof ConjunctionSequence) - return visit((ConjunctionSequence) p, arg); - if(p instanceof DifferenceExt) - return visit((DifferenceExt) p, arg); - if(p instanceof DifferenceInt) - return visit((DifferenceInt) p, arg); - if(p instanceof Disjunction) - return visit((Disjunction) p, arg); - if(p instanceof Equivalence) - return visit((Equivalence) p, arg); - if(p instanceof EquivalenceAfter) - return visit((EquivalenceAfter) p, arg); - if(p instanceof EquivalenceWhen) - return visit((EquivalenceWhen) p, arg); - if(p instanceof ImageExt) - return visit((ImageExt) p, arg); - if(p instanceof ImageInt) - return visit((ImageInt) p, arg); - if(p instanceof Implication) - return visit((Implication) p, arg); - if(p instanceof ImplicationAfter) - return visit((ImplicationAfter) p, arg); - if(p instanceof ImplicationBefore) - return visit((ImplicationBefore) p, arg); - if(p instanceof ImplicationWhen) - return visit((ImplicationWhen) p, arg); - if(p instanceof Inheritance) - return visit((Inheritance) p, arg); - if(p instanceof Instance) - return visit((Instance) p, arg); - if(p instanceof InstanceProperty) - return visit((InstanceProperty) p, arg); - if(p instanceof IntersectionExt) - return visit((IntersectionExt) p, arg); - if(p instanceof IntersectionInt) - return visit((IntersectionInt) p, arg); - if(p instanceof Negation) - return visit((Negation) p, arg); - if(p instanceof NumericLiteral) - return visit((NumericLiteral) p, arg); - if(p instanceof Product) - return visit((Product) p, arg); - if(p instanceof Property) - return visit((Property) p, arg); - if(p instanceof SetExt) - return visit((SetExt) p, arg); - if(p instanceof SetInt) - return visit((SetInt) p, arg); - if(p instanceof Similarity) - return visit((Similarity) p, arg); - if(p instanceof TenseFuture) - return visit((TenseFuture) p, arg); - if(p instanceof TensePast) - return visit((TensePast) p, arg); - if(p instanceof TensePresent) - return visit((TensePresent) p, arg); - if(p instanceof URIRef) - return visit((URIRef) p, arg); - if(p instanceof Variable) - return visit((Variable) p, arg); - - return new TrmLit(new LitString(p.getName())); - } - - public Object visit(BooleanLiteral p, LoanParser arg) { - if(p.getName().equals("true")) - return new TrmLit(new LitTrue()); - else - return new TrmLit(new LitFalse()); - } - - public Object visit(Conjunction p, LoanParser arg) { - ArrayList<Term> components = p.getComponents(); - Iterator<Term> iter = components.iterator(); - Term t = iter.next(); - Stm s = wrapTerm(t.accept(this, arg)); - while(iter.hasNext()) { - s = new StmConj(s, wrapTerm(iter.next().accept(this, arg))); - } - return s; - } - - public Object visit(ConjunctionParallel p, LoanParser arg) { - ArrayList<Term> components = p.getComponents(); - Iterator<Term> iter = components.iterator(); - Term t = iter.next(); - Stm s = wrapTerm(t.accept(this, arg)); - while(iter.hasNext()) { - s = new StmPar(s, wrapTerm(iter.next().accept(this, arg))); - } - return s; - } - - public Object visit(ConjunctionSequence p, LoanParser arg) { - ArrayList<Term> components = p.getComponents(); - Iterator<Term> iter = components.iterator(); - Term t = iter.next(); - Stm s = wrapTerm(t.accept(this, arg)); - while(iter.hasNext()) { - s = new StmSeq(s, wrapTerm(iter.next().accept(this, arg))); - } - return s; - } - - public Object visit(DifferenceExt p, LoanParser arg) { - ArrayList<Term> components = p.getComponents(); - Term t1 = components.get(0); - Term t2 = components.get(1); - return new TrmExDif(wrapStatement(t1.accept(this, arg)), wrapStatement(t2.accept(this, arg))); - } - - public Object visit(DifferenceInt p, LoanParser arg) { - ArrayList<Term> components = p.getComponents(); - Term t1 = components.get(0); - Term t2 = components.get(1); - return new TrmInDif(wrapStatement(t1.accept(this, arg)), wrapStatement(t2.accept(this, arg))); - } - - public Object visit(Disjunction p, LoanParser arg) { - ArrayList<Term> components = p.getComponents(); - Iterator<Term> iter = components.iterator(); - Term t = iter.next(); - Stm s = wrapTerm(t.accept(this, arg)); - while(iter.hasNext()) { - s = new StmDisj(s, wrapTerm(iter.next().accept(this, arg))); - } - return s; - } - - public Object visit(Equivalence p, LoanParser arg) { - Stm subj = wrapTerm(p.getSubject().accept(this, arg)); - Stm pred = wrapTerm(p.getPredicate().accept(this, arg)); - return new StmEquiv(subj,pred); - } - - public Object visit(EquivalenceAfter p, LoanParser arg) { - Stm subj = wrapTerm(p.getSubject().accept(this, arg)); - Stm pred = wrapTerm(p.getPredicate().accept(this, arg)); - return new StmEqvPred(subj,pred); - } - - public Object visit(EquivalenceWhen p, LoanParser arg) { - Stm subj = wrapTerm(p.getSubject().accept(this, arg)); - Stm pred = wrapTerm(p.getPredicate().accept(this, arg)); - return new StmEqvConc(subj,pred); - } - - public Object visit(ImageExt p, LoanParser arg) { - List<Term> pre = p.getComponents().subList(0, p.getRelationIndex()); - Term reln = p.getComponents().get(p.getRelationIndex()); - List<Term> post = p.getComponents().subList(p.getRelationIndex() + 1, p.size()); - - com.googlecode.opennars.parser.loan.Loan.Absyn.Term relnT = wrapStatement(reln.accept(this, arg)); - - ListTerm preList = new ListTerm(); - Iterator<Term> iter = pre.iterator(); - while(iter.hasNext()) { - preList.add(wrapStatement(iter.next().accept(this, arg))); - } - - ListTerm postList = new ListTerm(); - iter = post.iterator(); - while(iter.hasNext()) { - postList.add(wrapStatement(iter.next().accept(this, arg))); - } - - return new TrmExImg(relnT, preList, postList); - } - - public Object visit(ImageInt p, LoanParser arg) { - List<Term> pre = p.getComponents().subList(0, p.getRelationIndex()); - Term reln = p.getComponents().get(p.getRelationIndex()); - List<Term> post = p.getComponents().subList(p.getRelationIndex() + 1, p.size()); - - com.googlecode.opennars.parser.loan.Loan.Absyn.Term relnT = wrapStatement(reln.accept(this, arg)); - - ListTerm preList = new ListTerm(); - Iterator<Term> iter = pre.iterator(); - while(iter.hasNext()) { - preList.add(wrapStatement(iter.next().accept(this, arg))); - } - - ListTerm postList = new ListTerm(); - iter = post.iterator(); - while(iter.hasNext()) { - postList.add(wrapStatement(iter.next().accept(this, arg))); - } - - return new TrmInImg(relnT, preList, postList); - } - - public Object visit(Implication p, LoanParser arg) { - Stm subj = wrapTerm(p.getSubject().accept(this, arg)); - Stm pred = wrapTerm(p.getPredicate().accept(this, arg)); - return new StmImpl(subj,pred); - } - - public Object visit(ImplicationAfter p, LoanParser arg) { - Stm subj = wrapTerm(p.getSubject().accept(this, arg)); - Stm pred = wrapTerm(p.getPredicate().accept(this, arg)); - return new StmImpPred(subj,pred); - } - - public Object visit(ImplicationBefore p, LoanParser arg) { - Stm subj = wrapTerm(p.getSubject().accept(this, arg)); - Stm pred = wrapTerm(p.getPredicate().accept(this, arg)); - return new StmImpRet(subj,pred); - } - - public Object visit(ImplicationWhen p, LoanParser arg) { - Stm subj = wrapTerm(p.getSubject().accept(this, arg)); - Stm pred = wrapTerm(p.getPredicate().accept(this, arg)); - return new StmImpConc(subj,pred); - } - - public Object visit(Inheritance p, LoanParser arg) { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term subj = wrapStatement(p.getSubject().accept(this, arg)); - com.googlecode.opennars.parser.loan.Loan.Absyn.Term pred = wrapStatement(p.getPredicate().accept(this, arg)); - return new StmInher(subj,pred); - } - - public Object visit(Instance p, LoanParser arg) { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term subj = wrapStatement(p.getSubject().accept(this, arg)); - com.googlecode.opennars.parser.loan.Loan.Absyn.Term pred = wrapStatement(p.getPredicate().accept(this, arg)); - return new StmInst(subj,pred); - } - - public Object visit(InstanceProperty p, LoanParser arg) { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term subj = wrapStatement(p.getSubject().accept(this, arg)); - com.googlecode.opennars.parser.loan.Loan.Absyn.Term pred = wrapStatement(p.getPredicate().accept(this, arg)); - return new StmInPp(subj,pred); - } - - public Object visit(IntersectionExt p, LoanParser arg) { - ArrayList<Term> components = p.getComponents(); - Iterator<Term> iter = components.iterator(); - Term t = iter.next(); - com.googlecode.opennars.parser.loan.Loan.Absyn.Term s = wrapStatement(t.accept(this, arg)); - while(iter.hasNext()) { - s = new TrmExInt(s, wrapStatement(iter.next().accept(this, arg))); - } - return s; - } - - public Object visit(IntersectionInt p, LoanParser arg) { - ArrayList<Term> components = p.getComponents(); - Iterator<Term> iter = components.iterator(); - Term t = iter.next(); - com.googlecode.opennars.parser.loan.Loan.Absyn.Term s = wrapStatement(t.accept(this, arg)); - while(iter.hasNext()) { - s = new TrmInInt(s, wrapStatement(iter.next().accept(this, arg))); - } - return s; - } - - public Object visit(Negation p, LoanParser arg) { - Stm s = wrapTerm(p.getComponents().get(0).accept(this, arg)); - return new StmNot(s); - } - - public Object visit(NumericLiteral p, LoanParser arg) { - if(p.getType() == NumericLiteral.TYPE.INTEGER) - return new TrmLit(new LitInt(Integer.parseInt(p.getName()))); - else if(p.getType() == NumericLiteral.TYPE.DOUBLE) - return new TrmLit(new LitDbl(Double.parseDouble(p.getName()))); - else - return null; - } - - public Object visit(Product p, LoanParser arg) { - Iterator<Term> iter = p.getComponents().iterator(); - ListTerm ts = new ListTerm(); - while(iter.hasNext()) { - ts.add(wrapStatement(iter.next().accept(this, arg))); - } - return new TrmProd(ts); - } - - public Object visit(Property p, LoanParser arg) { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term subj = wrapStatement(p.getSubject().accept(this, arg)); - com.googlecode.opennars.parser.loan.Loan.Absyn.Term pred = wrapStatement(p.getPredicate().accept(this, arg)); - return new StmProp(subj,pred); - } - - public Object visit(SetExt p, LoanParser arg) { - Iterator<Term> iter = p.getComponents().iterator(); - ListTerm ts = new ListTerm(); - while(iter.hasNext()) { - ts.add(wrapStatement(iter.next().accept(this, arg))); - } - return new TrmExSet(ts); - } - - public Object visit(SetInt p, LoanParser arg) { - Iterator<Term> iter = p.getComponents().iterator(); - ListTerm ts = new ListTerm(); - while(iter.hasNext()) { - ts.add(wrapStatement(iter.next().accept(this, arg))); - } - return new TrmInSet(ts); - } - - public Object visit(Similarity p, LoanParser arg) { - com.googlecode.opennars.parser.loan.Loan.Absyn.Term subj = wrapStatement(p.getSubject().accept(this, arg)); - com.googlecode.opennars.parser.loan.Loan.Absyn.Term pred = wrapStatement(p.getPredicate().accept(this, arg)); - return new StmSim(subj,pred); - } - - public Object visit(TenseFuture p, LoanParser arg) { - Stm s = wrapTerm(p.getComponents().get(0).accept(this, arg)); - return new StmFut(s); - } - - public Object visit(TensePast p, LoanParser arg) { - Stm s = wrapTerm(p.getComponents().get(0).accept(this, arg)); - return new StmPst(s); - } - - public Object visit(TensePresent p, LoanParser arg) { - Stm s = wrapTerm(p.getComponents().get(0).accept(this, arg)); - return new StmPres(s); - } - - public Object visit(StringLiteral p, LoanParser arg) { - return new TrmLit(new LitString(p.getName())); - } - - public Object visit(URIRef p, LoanParser arg) { - String uriref = p.getName(); - // Try namespaces first - Iterator<String> iter = arg.getNamespaces().keySet().iterator(); - while(iter.hasNext()) { - String pre = iter.next(); - URI u = arg.getNamespaces().get(pre); - // Can we match the start of the URI to any known sequence? - if(uriref.startsWith(u.toString())) { - // Blank prefix is dealt with separately in the abstract syntax for parsing reasons - if(u.equals("")) - return new TrmLit(new LitURI(new URICur(new NSPrefix2(), uriref.substring(u.toString().length())))); - else - return new TrmLit(new LitURI(new URICur(new NSPrefix1(pre), uriref.substring(u.toString().length())))); - } - } - - try { - // Try resolving against the base - URI b = arg.getBaseURI(); - URI r = b.relativize(new URI(uriref)); - return new TrmLit(new LitURI(new URIFul("<" + r.toString() + ">"))); - } - catch (URISyntaxException e) { - e.printStackTrace(); - } - return new TrmLit(new LitURI(new URIFul("<" + p.getName() + ">"))); - } - - public Object visit(Variable p, LoanParser arg) { - if(p.getType() == Variable.VarType.QUERY) - return new TrmLit(new LitQVar(p.getName().substring(1))); - else if(p.getType() == Variable.VarType.INDEPENDENT) - return new TrmLit(new LitSVarI(p.getName().substring(1))); - else if(p.getType() == Variable.VarType.DEPENDENT) - return new TrmLit(new LitSVarD(p.getName().substring(1), new ListIdent())); - else if(p.getType() == Variable.VarType.ANONYMOUS) - return new TrmLit(new LitQVarAn()); - else - return null; - } - - } - - public class ParserVisitor extends AbstractVisitor<Object, LoanParser> { - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetE, java.lang.Object) - */ - @Override - public Object visit(BudgetE p, LoanParser arg) { - return super.visit(p, arg); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetP, java.lang.Object) - */ - @Override - public Object visit(BudgetP p, LoanParser arg) { - // TODO Auto-generated method stub - return super.visit(p, arg); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BudgetPD, java.lang.Object) - */ - @Override - public Object visit(BudgetPD p, LoanParser arg) { - // TODO Auto-generated method stub - return super.visit(p, arg); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR, java.lang.Object) - */ - @Override - public Object visit(BaseR p, LoanParser arg) { - try { - arg.setBaseURI(new URI(p.urilit_.substring(1, p.urilit_.length()-1))); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - return null; - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.Doc, java.lang.Object) - */ - @Override - public Object visit(Doc p, LoanParser arg) { - List<Task> tasks = new ArrayList<Task>(); - Iterator<com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence> iter = p.listsentence_.iterator(); - while(iter.hasNext()) { - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence s = iter.next(); - Object t = s.accept(this, arg); - if(t != null) { - if(t instanceof List) // Should only happen with an @import - tasks.addAll((Collection<? extends Task>) t); - else - tasks.add((Task) t); - } - } - return tasks; - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.DocBR, java.lang.Object) - */ - @Override - public Object visit(DocBR p, LoanParser arg) { - p.baserule_.accept(this, arg); - List<Task> tasks = new ArrayList<Task>(); - Iterator<com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence> iter = p.listsentence_.iterator(); - while(iter.hasNext()) { - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence s = iter.next(); - Task t = (Task) s.accept(this, arg); - if(t != null) - tasks.add(t); - } - return tasks; - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitDbl, java.lang.Object) - */ - @Override - public Object visit(LitDbl p, LoanParser arg) { - return new NumericLiteral(p.double_.doubleValue()); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitFalse, java.lang.Object) - */ - @Override - public Object visit(LitFalse p, LoanParser arg) { - return new BooleanLiteral(false); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitInt, java.lang.Object) - */ - @Override - public Object visit(LitInt p, LoanParser arg) { - return new NumericLiteral(p.integer_.intValue()); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVar, java.lang.Object) - */ - @Override - public Object visit(LitQVar p, LoanParser arg) { - return new Variable("" + Symbols.QUERY_VARIABLE_TAG + p.ident_); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitQVarAn, java.lang.Object) - */ - @Override - public Object visit(LitQVarAn p, LoanParser arg) { - return new Variable("" + Symbols.QUERY_VARIABLE_TAG); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitString, java.lang.Object) - */ - @Override - public Object visit(LitString p, LoanParser arg) { - // TODO Auto-generated method stub - return new StringLiteral(p.string_); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarD, java.lang.Object) - */ - @Override - public Object visit(LitSVarD p, LoanParser arg) { - StringBuilder builder = new StringBuilder(); - builder.append(Symbols.VARIABLE_TAG); - builder.append(p.ident_); - builder.append(Symbols.COMPOUND_TERM_OPENER); - Iterator<String> iter = p.listident_.iterator(); - while(iter.hasNext()) { - builder.append(iter.next()); - if(iter.hasNext()) - builder.append(","); - } - builder.append(Symbols.COMPOUND_TERM_CLOSER); - return new Variable(builder.toString()); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitSVarI, java.lang.Object) - */ - @Override - public Object visit(LitSVarI p, LoanParser arg) { - return new Variable("" + Symbols.VARIABLE_TAG + p.ident_); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitTrue, java.lang.Object) - */ - @Override - public Object visit(LitTrue p, LoanParser arg) { - return new BooleanLiteral(true); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.LitURI, java.lang.Object) - */ - @Override - public Object visit(LitURI p, LoanParser arg) { - URI u = (URI) p.uriref_.accept(this, arg); - return new URIRef(u); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1, java.lang.Object) - */ - @Override - public Object visit(NSPrefix1 p, LoanParser arg) { - // TODO Auto-generated method stub - return p.ident_; - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix2, java.lang.Object) - */ - @Override - public Object visit(NSPrefix2 p, LoanParser arg) { - // TODO Auto-generated method stub - return ""; - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentDelay, java.lang.Object) - */ - @Override - public Object visit(SentDelay p, LoanParser arg) { - int delay = p.integer_.intValue(); - for(int i = 0; i < delay; i++) - arg.getMemory().cycle(); - return null; - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal, java.lang.Object) - */ - @Override - public Object visit(SentGoal p, LoanParser arg) { - // Get the truth - TruthValue truth = (TruthValue) p.truthvalue_.accept(this, arg); - - // We don't actually do budget values (yet) in LOAN - float priority = memory.getParameters().DEFAULT_GOAL_PRIORITY; - float durability = memory.getParameters().DEFAULT_GOAL_DURABILITY; - float quality = memory.budgetfunctions.truthToQuality(truth); - BudgetValue budget = new BudgetValue(priority, durability, quality, memory); - - // Process the sentence itself - Term content = (Term) p.stm_.accept(this, arg); - Base base = new Base(); - Sentence sentence = Sentence.make(content, Symbols.GOAL_MARK, truth, base, memory); - sentence.setInput(); - - return new Task(sentence, budget, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentImport, java.lang.Object) - */ - @Override - public Object visit(SentImport p, LoanParser arg) { - try { - URL u = new URL(p.urilit_.substring(1, p.urilit_.length()-1)); - BufferedReader reader = new BufferedReader(new InputStreamReader(u.openStream())); - StringBuilder builder = new StringBuilder(); - String line = ""; - while(line != null) { - builder.append(line); - builder.append("\n"); - line = reader.readLine(); - } - - LoanParser parser = new LoanParser(); - parser.setBaseURI(u.toURI()); - List<Task> ts = parser.parseTasks(builder.toString(), memory); - return ts; - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } catch (InvalidInputException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge, java.lang.Object) - */ - @Override - public Object visit(SentJudge p, LoanParser arg) { - // Get the truth - TruthValue truth = (TruthValue) p.truthvalue_.accept(this, arg); - - // We don't actually do budget values (yet) in LOAN - float priority = memory.getParameters().DEFAULT_JUDGMENT_PRIORITY; - float durability = memory.getParameters().DEFAULT_JUDGMENT_DURABILITY; - float quality = memory.budgetfunctions.truthToQuality(truth); - BudgetValue budget = new BudgetValue(priority, durability, quality, memory); - - // Process the sentence itself - Term content = (Term) p.stm_.accept(this, arg); - Base base = new Base(); - Sentence sentence = Sentence.make(content, Symbols.JUDGMENT_MARK, truth, base, memory); - sentence.setInput(); - - return new Task(sentence, budget, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentOp, java.lang.Object) - */ - @Override - public Object visit(SentOp p, LoanParser arg) { - // TODO Handle the adding of operators once we can do something with them - return null; - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix, java.lang.Object) - */ - @Override - public Object visit(SentPrefix p, LoanParser arg) { - String pre = (String) p.nsprefix_.accept(this, arg); - try { - URI u = new URI(p.urilit_.substring(1, p.urilit_.length()-1)); - arg.getNamespaces().put(pre, u); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest, java.lang.Object) - */ - @Override - public Object visit(SentQuest p, LoanParser arg) { - // Questions don't have truth - TruthValue truth = null; - - // We don't actually do budget values (yet) in LOAN - float priority = memory.getParameters().DEFAULT_QUESTION_PRIORITY; - float durability = memory.getParameters().DEFAULT_QUESTION_DURABILITY; - float quality = 1; - BudgetValue budget = new BudgetValue(priority, durability, quality, memory); - - // Process the sentence itself - Term content = (Term) p.stm_.accept(this, arg); - Base base = null; - Sentence sentence = Sentence.make(content, Symbols.QUESTION_MARK, truth, base, memory); - sentence.setInput(); - - // ++DEBUG - System.out.println(sentence.toString2()); - // --DEBUG - - return new Task(sentence, budget, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmConj, java.lang.Object) - */ - @Override - public Object visit(StmConj p, LoanParser arg) { - Term t1 = (Term) p.stm_1.accept(this, arg); - Term t2 = (Term) p.stm_2.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - ts.add(t2); - - return CompoundTerm.make(Symbols.CONJUNCTION_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmDisj, java.lang.Object) - */ - @Override - public Object visit(StmDisj p, LoanParser arg) { - Term t1 = (Term) p.stm_1.accept(this, arg); - Term t2 = (Term) p.stm_2.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - ts.add(t2); - - return CompoundTerm.make(Symbols.DISJUNCTION_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEquiv, java.lang.Object) - */ - @Override - public Object visit(StmEquiv p, LoanParser arg) { - Term t1 = (Term) p.stm_1.accept(this, arg); - Term t2 = (Term) p.stm_2.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - ts.add(t2); - - return Statement.make(Symbols.EQUIVALENCE_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvConc, java.lang.Object) - */ - @Override - public Object visit(StmEqvConc p, LoanParser arg) { - Term t1 = (Term) p.stm_1.accept(this, arg); - Term t2 = (Term) p.stm_2.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - ts.add(t2); - - return Statement.make(Symbols.EQUIVALENCE_WHEN_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmEqvPred, java.lang.Object) - */ - @Override - public Object visit(StmEqvPred p, LoanParser arg) { - Term t1 = (Term) p.stm_1.accept(this, arg); - Term t2 = (Term) p.stm_2.accept(this, arg); - - return Statement.make(Symbols.EQUIVALENCE_AFTER_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmFut, java.lang.Object) - */ - @Override - public Object visit(StmFut p, LoanParser arg) { - Term t1 = (Term) p.stm_.accept(this, arg); - - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - - return CompoundTerm.make(Symbols.FUTURE_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpConc, java.lang.Object) - */ - @Override - public Object visit(StmImpConc p, LoanParser arg) { - Term t1 = (Term) p.stm_1.accept(this, arg); - Term t2 = (Term) p.stm_2.accept(this, arg); - - return Statement.make(Symbols.IMPLICATION_WHEN_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpl, java.lang.Object) - */ - @Override - public Object visit(StmImpl p, LoanParser arg) { - Term t1 = (Term) p.stm_1.accept(this, arg); - Term t2 = (Term) p.stm_2.accept(this, arg); - - return Statement.make(Symbols.IMPLICATION_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpPred, java.lang.Object) - */ - @Override - public Object visit(StmImpPred p, LoanParser arg) { - Term t1 = (Term) p.stm_1.accept(this, arg); - Term t2 = (Term) p.stm_2.accept(this, arg); - - return Statement.make(Symbols.IMPLICATION_AFTER_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmImpRet, java.lang.Object) - */ - @Override - public Object visit(StmImpRet p, LoanParser arg) { - Term t1 = (Term) p.stm_1.accept(this, arg); - Term t2 = (Term) p.stm_2.accept(this, arg); - - return Statement.make(Symbols.IMPLICATION_BEFORE_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInher, java.lang.Object) - */ - @Override - public Object visit(StmInher p, LoanParser arg) { - Term t1 = (Term) p.term_1.accept(this, arg); - Term t2 = (Term) p.term_2.accept(this, arg); - - return Statement.make(Symbols.INHERITANCE_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInPp, java.lang.Object) - */ - @Override - public Object visit(StmInPp p, LoanParser arg) { - Term t1 = (Term) p.term_1.accept(this, arg); - Term t2 = (Term) p.term_2.accept(this, arg); - - return Statement.make(Symbols.INSTANCE_PROPERTY_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmInst, java.lang.Object) - */ - @Override - public Object visit(StmInst p, LoanParser arg) { - Term t1 = (Term) p.term_1.accept(this, arg); - Term t2 = (Term) p.term_2.accept(this, arg); - - return Statement.make(Symbols.INSTANCE_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmNot, java.lang.Object) - */ - @Override - public Object visit(StmNot p, LoanParser arg) { - Term t1 = (Term) p.stm_.accept(this, arg); - - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - - return CompoundTerm.make(Symbols.NEGATION_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmOp, java.lang.Object) - */ - @Override - public Object visit(StmOp p, LoanParser arg) { - // Get the functor - Term t1 = (Term) p.term_.accept(this, arg); - - // Get the arguments - ArrayList<Term> opargs = new ArrayList<Term>(); - Iterator<com.googlecode.opennars.parser.loan.Loan.Absyn.Term> iter = p.listterm_.iterator(); - while(iter.hasNext()) { - Term t = (Term) iter.next().accept(this, arg); - opargs.add(t); - } - - // Make arguments into a product - Term prod = CompoundTerm.make(Symbols.PRODUCT_OPERATOR, opargs, memory); - - return Statement.make(Symbols.INHERITANCE_RELATION, prod, t1, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPar, java.lang.Object) - */ - @Override - public Object visit(StmPar p, LoanParser arg) { - Term t1 = (Term) p.stm_1.accept(this, arg); - Term t2 = (Term) p.stm_2.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - ts.add(t2); - - return CompoundTerm.make(Symbols.PARALLEL_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPres, java.lang.Object) - */ - @Override - public Object visit(StmPres p, LoanParser arg) { - Term t1 = (Term) p.stm_.accept(this, arg); - - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - - return CompoundTerm.make(Symbols.PRESENT_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmProp, java.lang.Object) - */ - @Override - public Object visit(StmProp p, LoanParser arg) { - Term t1 = (Term) p.term_1.accept(this, arg); - Term t2 = (Term) p.term_2.accept(this, arg); - - return Statement.make(Symbols.PROPERTY_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmPst, java.lang.Object) - */ - @Override - public Object visit(StmPst p, LoanParser arg) { - Term t1 = (Term) p.stm_.accept(this, arg); - - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - - return CompoundTerm.make(Symbols.PAST_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSeq, java.lang.Object) - */ - @Override - public Object visit(StmSeq p, LoanParser arg) { - Term t1 = (Term) p.stm_1.accept(this, arg); - Term t2 = (Term) p.stm_2.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - ts.add(t2); - - return CompoundTerm.make(Symbols.SEQUENCE_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmSim, java.lang.Object) - */ - @Override - public Object visit(StmSim p, LoanParser arg) { - Term t1 = (Term) p.term_1.accept(this, arg); - Term t2 = (Term) p.term_2.accept(this, arg); - - return Statement.make(Symbols.SIMILARITY_RELATION, t1, t2, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.StmTrm, java.lang.Object) - */ - @Override - public Object visit(StmTrm p, LoanParser arg) { - return p.term_.accept(this, arg); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExDif, java.lang.Object) - */ - @Override - public Object visit(TrmExDif p, LoanParser arg) { - Term t1 = (Term) p.term_1.accept(this, arg); - Term t2 = (Term) p.term_2.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - ts.add(t2); - - return CompoundTerm.make(Symbols.DIFFERENCE_EXT_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExImg, java.lang.Object) - */ - @Override - public Object visit(TrmExImg p, LoanParser arg) { - Term reln = (Term) p.term_.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(reln); - - Iterator<com.googlecode.opennars.parser.loan.Loan.Absyn.Term> iter = p.listterm_1.iterator(); - while(iter.hasNext()) - ts.add((Term) iter.next().accept(this, arg)); - ts.add(new Term("" + Symbols.IMAGE_PLACE_HOLDER)); - iter = p.listterm_2.iterator(); - while(iter.hasNext()) - ts.add((Term) iter.next().accept(this, arg)); - - return CompoundTerm.make(Symbols.IMAGE_EXT_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExInt, java.lang.Object) - */ - @Override - public Object visit(TrmExInt p, LoanParser arg) { - Term t1 = (Term) p.term_1.accept(this, arg); - Term t2 = (Term) p.term_2.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - ts.add(t2); - - return CompoundTerm.make(Symbols.INTERSECTION_EXT_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmExSet, java.lang.Object) - */ - @Override - public Object visit(TrmExSet p, LoanParser arg) { - ArrayList<Term> ts = new ArrayList<Term>(); - Iterator<com.googlecode.opennars.parser.loan.Loan.Absyn.Term> iter = p.listterm_.iterator(); - while(iter.hasNext()) { - Term t = (Term) iter.next().accept(this, arg); - ts.add(t); - } - - return SetExt.make(ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInDif, java.lang.Object) - */ - @Override - public Object visit(TrmInDif p, LoanParser arg) { - Term t1 = (Term) p.term_1.accept(this, arg); - Term t2 = (Term) p.term_2.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - ts.add(t2); - - return CompoundTerm.make(Symbols.DIFFERENCE_INT_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInImg, java.lang.Object) - */ - @Override - public Object visit(TrmInImg p, LoanParser arg) { - Term reln = (Term) p.term_.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(reln); - - Iterator<com.googlecode.opennars.parser.loan.Loan.Absyn.Term> iter = p.listterm_1.iterator(); - while(iter.hasNext()) - ts.add((Term) iter.next().accept(this, arg)); - ts.add(new Term("" + Symbols.IMAGE_PLACE_HOLDER)); - iter = p.listterm_2.iterator(); - while(iter.hasNext()) - ts.add((Term) iter.next().accept(this, arg)); - - return CompoundTerm.make(Symbols.IMAGE_INT_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInInt, java.lang.Object) - */ - @Override - public Object visit(TrmInInt p, LoanParser arg) { - Term t1 = (Term) p.term_1.accept(this, arg); - Term t2 = (Term) p.term_2.accept(this, arg); - ArrayList<Term> ts = new ArrayList<Term>(); - ts.add(t1); - ts.add(t2); - - return CompoundTerm.make(Symbols.INTERSECTION_INT_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmInSet, java.lang.Object) - */ - @Override - public Object visit(TrmInSet p, LoanParser arg) { - ArrayList<Term> ts = new ArrayList<Term>(); - Iterator<com.googlecode.opennars.parser.loan.Loan.Absyn.Term> iter = p.listterm_.iterator(); - while(iter.hasNext()) { - Term t = (Term) iter.next().accept(this, arg); - ts.add(t); - } - - return SetInt.make(ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmLit, java.lang.Object) - */ - @Override - public Object visit(TrmLit p, LoanParser arg) { - return p.literal_.accept(this, arg); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmProd, java.lang.Object) - */ - @Override - public Object visit(TrmProd p, LoanParser arg) { - ArrayList<Term> ts = new ArrayList<Term>(); - Iterator<com.googlecode.opennars.parser.loan.Loan.Absyn.Term> iter = p.listterm_.iterator(); - while(iter.hasNext()) { - Term t = (Term) iter.next().accept(this, arg); - ts.add(t); - } - - return CompoundTerm.make(Symbols.PRODUCT_OPERATOR, ts, memory); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TrmStm, java.lang.Object) - */ - @Override - public Object visit(TrmStm p, LoanParser arg) { - return p.stm_.accept(this, arg); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthE, java.lang.Object) - */ - @Override - public Object visit(TruthE p, LoanParser arg) { - return new TruthValue(1, memory.getParameters().DEFAULT_JUDGMENT_CONFIDENCE); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthF, java.lang.Object) - */ - @Override - public Object visit(TruthF p, LoanParser arg) { - return new TruthValue(p.double_.floatValue(), memory.getParameters().DEFAULT_JUDGMENT_CONFIDENCE); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC, java.lang.Object) - */ - @Override - public Object visit(TruthFC p, LoanParser arg) { - return new TruthValue(p.double_1.floatValue(),p.double_2.floatValue()); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URICur, java.lang.Object) - */ - @Override - public Object visit(URICur p, LoanParser arg) { - String pre = (String) p.nsprefix_.accept(this, arg); - URI u = arg.getNamespaces().get(pre); - return u.resolve(p.ident_); - } - - /* (non-Javadoc) - * @see com.googlecode.opennars.parser.loan.Loan.AbstractVisitor#visit(com.googlecode.opennars.parser.loan.Loan.Absyn.URIFul, java.lang.Object) - */ - @Override - public Object visit(URIFul p, LoanParser arg) { - URI base = arg.getBaseURI(); - String u = p.urilit_.substring(1, p.urilit_.length()-1); - return base.resolve(u); - } - - } - - private Map<String,URI> namespaces = new HashMap<String,URI>(); - private URI baseURI = null; - private Memory memory = null; - - @Override - public Task parseTask(String input, Memory memory) - throws InvalidInputException { - this.memory = memory; - List<Task> tasks = null; - Yylex l = new Yylex(new StringReader(input)); - parser p = new parser(l); - try { - Document parse_tree = p.pDocument(); - tasks = (List<Task>) parse_tree.accept(new ParserVisitor(), this); - } catch (Exception e) { - e.printStackTrace(); - throw new InvalidInputException(); - } - if(tasks.size() > 0) - return tasks.get(0); - else - return null; - } - - @Override - public List<Task> parseTasks(String input, Memory memory) - throws InvalidInputException { - this.memory = memory; - List<Task> tasks = null; - Yylex l = new Yylex(new StringReader(input)); - parser p = new parser(l); - try { - Document parse_tree = p.pDocument(); - tasks = (List<Task>) parse_tree.accept(new ParserVisitor(), this); - } catch (Exception e) { - e.printStackTrace(); - throw new InvalidInputException(); - } - - return tasks; - } - - @Override - public String serialiseSentence(Sentence task, Memory memory) { - com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence ss = new com.googlecode.opennars.parser.loan.Loan.Absyn.ListSentence(); - com.googlecode.opennars.parser.loan.Loan.Absyn.Sentence s; - com.googlecode.opennars.parser.loan.Loan.Absyn.Stm stm = (Stm) ((CompoundTerm) task.getContent()).accept(new SerialiseVisitor(), this); - if(task.isJudgment()) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue tv = new com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC(Double.valueOf(task.getTruth().getFrequency()), Double.valueOf(task.getTruth().getConfidence())); - s = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentJudge(stm, tv, new BudgetE()); - ss.add(s); - } - else if(task.isQuestion()) { - s = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentQuest(stm, new BudgetE()); - ss.add(s); - } - else if(task.isGoal()) { - com.googlecode.opennars.parser.loan.Loan.Absyn.TruthValue tv = new com.googlecode.opennars.parser.loan.Loan.Absyn.TruthFC(Double.valueOf(task.getTruth().getFrequency()), Double.valueOf(task.getTruth().getConfidence())); - s = new com.googlecode.opennars.parser.loan.Loan.Absyn.SentGoal(stm, tv, new BudgetE()); - ss.add(s); - } - - com.googlecode.opennars.parser.loan.Loan.Absyn.Doc doc = new Doc(ss); - return PrettyPrinter.print(doc).replace('\n', ' '); - } - - @Override - public String serialiseSentences(List<Sentence> tasks, Memory memory) { - // TODO: Write this method - com.googlecode.opennars.parser.loan.Loan.Absyn.BaseRule br = new com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR(this.getBaseURI().toString()); - return null; - } - - /** - * @return the memory - */ - public Memory getMemory() { - return memory; - } - - /** - * @param memory the memory to set - */ - public void setMemory(Memory memory) { - this.memory = memory; - } - - /** - * @return the namespaces - */ - public Map<String, URI> getNamespaces() { - return namespaces; - } - - /** - * @param namespaces the namespaces to set - */ - public void setNamespaces(Map<String, URI> namespaces) { - this.namespaces = namespaces; - } - - /** - * @return the base URI - */ - public URI getBaseURI() { - return baseURI; - } - - /** - * @param baseURI the base URI to set - */ - public void setBaseURI(URI baseURI) { - this.baseURI = baseURI; - } - -} diff --git a/open-nars/src/com/googlecode/opennars/parser/loan/loan.g b/open-nars/src/com/googlecode/opennars/parser/loan/loan.g deleted file mode 100644 index 604a9a87e10d2aaee4a351e17180e5c70dda7689..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/loan/loan.g +++ /dev/null @@ -1,514 +0,0 @@ -grammar loan; - -options { - output = AST; -} - -tokens { - NUM_LIT = 'numeric'; - BOOL_LIT = 'boolean'; - STRING_LIT = 'string'; - URI = 'uri'; - CURIE = 'curie'; - PRODUCT = 'product'; - JUDGEMENT = 'judgement'; - GOAL = 'goal'; -} - -// $<Parser - -document - : base_rule? (at_rule | sentence)* EOF; - -base_rule - : AT_BASE^ IRI_REF DOT! - ; - -at_rule : AT_IMPORT^ IRI_REF DOT! - | AT_PREFIX^ PNAME_NS IRI_REF DOT! - | AT_DELAY^ LPAREN! INTEGER RPAREN! DOT! - ; - -sentence - : statement ( judgement - | question - | goal - ) - ; - -judgement - : DOT^ truthvalue? - ; - -goal : EXCLAMATION^ truthvalue? - ; - -question - : QUESTION^ - ; - -truthvalue - : PERCENT^ (DECIMAL | INTEGER) (SEMICOLON! DECIMAL)? PERCENT!; - -statement - : unary_statement ((CONJ^ | SEMICOLON^ | COMMA^ | DISJ^) unary_statement)* - ; - -unary_statement - : NOT simple_statement - | PAST simple_statement - | PRESENT simple_statement - | FUTURE simple_statement - | simple_statement - ; - -simple_statement - : term ((INHERITANCE^ | SIMILARITY^ | INSTANCE^ | PROPERTY^ | INSTANCE_PROPERTY^ | IMPLICATION^ | IMPLICATION_PRED^ | IMPLICATION_RETRO^ | IMPLICATION_CONC^ | EQUIVALENCE^ | EQUIVALENCE_PRED^ | EQUIVALENCE_CONC^) term)? - ; - - -term : difference ((AMPERSAND^ | BAR^) difference)* - ; - -ext_set : OPEN_BRACE^ (term (COMMA! term)*)? CLOSE_BRACE! - ; - -int_set : LBRACKET^ (term (COMMA! term)*)? RBRACKET! - ; - -ext_image - : EXT_IMG^ LPAREN! term COMMA! term_or_wild (COMMA! term_or_wild)* RPAREN! - ; - -int_image - : INT_IMG^ LPAREN! term COMMA! term_or_wild (COMMA! term_or_wild)* RPAREN! - ; - -term_or_wild - : WILDCARD - | term - ; - -difference - : product ((MINUS^ | TILDE^) product)* - ; - -product : atomic_term (STAR atomic_term)* -> ^(PRODUCT atomic_term*) - ; - -atomic_term - : ext_set - | int_set - | ext_image - | int_image - | LPAREN! statement RPAREN! - | variable - | iriRef - | literal - ; - -variable - : query_variable - | statement_variable - ; - -query_variable - : QUERY_VAR - ; - -statement_variable - : STM_VAR - ; - - - -literal - : numericLiteral -> ^(NUM_LIT numericLiteral) - | booleanLiteral -> ^(BOOL_LIT booleanLiteral) - | string -> ^(STRING_LIT string) - ; - -numericLiteral - : numericLiteralUnsigned | numericLiteralPositive | numericLiteralNegative - ; - -numericLiteralUnsigned - : INTEGER - | DECIMAL - | DOUBLE - ; - -numericLiteralPositive - : INTEGER_POSITIVE - | DECIMAL_POSITIVE - | DOUBLE_POSITIVE - ; - -numericLiteralNegative - : INTEGER_NEGATIVE - | DECIMAL_NEGATIVE - | DOUBLE_NEGATIVE - ; - -booleanLiteral - : TRUE - | FALSE - ; - -string - : STRING_LITERAL1 - | STRING_LITERAL2 - | STRING_LITERAL_LONG1 - | STRING_LITERAL_LONG2 - ; - -iriRef - : IRI_REF -> ^(URI IRI_REF) - | prefixedName -> ^(CURIE prefixedName) - ; - -prefixedName - : PNAME_LN - | PNAME_NS - ; - - -// $> - -// $<Lexer - -WS - : (' '| '\t'| EOL)+ { $channel=HIDDEN; } - ; - -AT_IMPORT - : '@import' - ; - -AT_PREFIX - : '@prefix' - ; - -AT_BASE : '@base' - ; - -AT_DELAY - : '@delay' - ; - -protected -INHERITANCE - : '-->'; - -protected -SIMILARITY - : '<->'; - -protected -INSTANCE - : '}->' - ; - -protected -PROPERTY - : '--[' - ; - -protected -INSTANCE_PROPERTY - : '}-[' - ; - -protected -IMPLICATION - : '==>' - ; - -protected -IMPLICATION_PRED - : '=/>' - ; - -protected -IMPLICATION_RETRO - : '=\\>' - ; - -protected -IMPLICATION_CONC - : '=|>' - ; - -protected -EQUIVALENCE - : '<=>' - ; - -protected -EQUIVALENCE_PRED - : '</>' - ; - -protected -EQUIVALENCE_CONC - : '<|>' - ; - -EXT_IMG : 'ext' - ; - -INT_IMG : 'int' - ; - -WILDCARD - : '_' - ; - - -NOT : '!!' - ; - -PAST : '\\>' - ; - -PRESENT : '|>' - ; - -FUTURE : '/>' - ; - -CONJ : '&&' - ; - -DISJ : '||' - ; - -OPEN_BRACE - : '{' - ; - -CLOSE_BRACE - : '}' - ; - -LPAREN : '(' - ; - -RPAREN : ')' - ; - -LBRACKET - : '[' - ; - -RBRACKET - : ']' - ; - - - -PNAME_NS - : p=PN_PREFIX? ':' - ; - -PNAME_LN - : PNAME_NS PN_LOCAL - ; - -TRUE - : ('T'|'t')('R'|'r')('U'|'u')('E'|'e') - ; - -FALSE - : ('F'|'f')('A'|'a')('L'|'l')('S'|'s')('E'|'e') - ; - -IRI_REF - : LANGLE ( options {greedy=false;} : ~(LANGLE | RANGLE | '"' | OPEN_BRACE | CLOSE_BRACE | '|' | '^' | '\\' | '`' | ('\u0000'..'\u0020')) )* RANGLE { setText($text.substring(1, $text.length() - 1)); } - ; - -LANGTAG - : '@' PN_CHARS_BASE+ (MINUS (PN_CHARS_BASE DIGIT)+)* - ; - -QUERY_VAR - : '?' PN_LOCAL - ; - -STM_VAR : '#' PN_LOCAL ('(' (PN_LOCAL (',' PN_LOCAL)*)? ')')? - ; - -INTEGER - : DIGIT+ - ; - -DECIMAL - : DIGIT+ DOT DIGIT* - | DOT DIGIT+ - ; - -DOUBLE - : DIGIT+ DOT DIGIT* EXPONENT - | DOT DIGIT+ EXPONENT - | DIGIT+ EXPONENT - ; - -INTEGER_POSITIVE - : PLUS INTEGER - ; - -DECIMAL_POSITIVE - : PLUS DECIMAL - ; - -DOUBLE_POSITIVE - : PLUS DOUBLE - ; - -INTEGER_NEGATIVE - : MINUS INTEGER - ; - -DECIMAL_NEGATIVE - : MINUS DECIMAL - ; - -DOUBLE_NEGATIVE - : MINUS DOUBLE - ; - -fragment -EXPONENT - : ('e'|'E') (PLUS|MINUS)? DIGIT+ - ; - -STRING_LITERAL1 - : '\'' ( options {greedy=false;} : ~('\u0027' | '\u005C' | '\u000A' | '\u000D') | ECHAR )* '\'' - ; - -STRING_LITERAL2 - : '"' ( options {greedy=false;} : ~('\u0022' | '\u005C' | '\u000A' | '\u000D') | ECHAR )* '"' - ; - -STRING_LITERAL_LONG1 - : '\'\'\'' ( options {greedy=false;} : ( '\'' | '\'\'' )? ( ~('\''|'\\') | ECHAR ) )* '\'\'\'' - ; - -STRING_LITERAL_LONG2 - : '"""' ( options {greedy=false;} : ( '"' | '""' )? ( ~('"'|'\\') | ECHAR ) )* '"""' - ; - -fragment -ECHAR - : '\\' ('t' | 'b' | 'n' | 'r' | 'f' | '\\' | '"' | '\'') - ; - -fragment -PN_CHARS_U - : PN_CHARS_BASE | '_' - ; - -fragment -VARNAME - : ( PN_CHARS_U | DIGIT ) ( PN_CHARS_U | DIGIT | '\u00B7' | '\u0300'..'\u036F' | '\u203F'..'\u2040' )* - ; - -fragment -PN_CHARS - : PN_CHARS_U - | MINUS - | DIGIT - | '\u00B7' - | '\u0300'..'\u036F' - | '\u203F'..'\u2040' - ; - -fragment -PN_PREFIX - : PN_CHARS_BASE ((PN_CHARS|DOT)* PN_CHARS)? - ; - -fragment -PN_LOCAL - : ( PN_CHARS_U | DIGIT ) ((PN_CHARS)* PN_CHARS)? - ; - -fragment -PN_CHARS_BASE - : 'A'..'Z' - | 'a'..'z' - | '\u00C0'..'\u00D6' - | '\u00D8'..'\u00F6' - | '\u00F8'..'\u02FF' - | '\u0370'..'\u037D' - | '\u037F'..'\u1FFF' - | '\u200C'..'\u200D' - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' - ; - -fragment -DIGIT - : '0'..'9' - ; - -COMMENT - : '//' ( options{greedy=false;} : .)* EOL { $channel=HIDDEN; } - ; - -fragment -EOL - : '\n' | '\r' - ; - -REFERENCE - : '^^'; - -EXCLAMATION - : '!'; - -QUESTION - : '?'; - -DOT : '.' - ; - -COMMA : ',' - ; - -//COLON : ':' -// ; - -SEMICOLON - : ';' - ; - -AMPERSAND - : '&'; - -BAR : '|' - ; - -LANGLE : '<' - ; - -RANGLE : '>' - ; - -PERCENT : '%' - ; - -PLUS : '+' - ; - -MINUS : '-' - ; - -STAR : '*' - ; - -TILDE : '~' - ; diff --git a/open-nars/src/com/googlecode/opennars/parser/narsese/NarseseParser.java b/open-nars/src/com/googlecode/opennars/parser/narsese/NarseseParser.java deleted file mode 100644 index d94256ae23cc336baa3c658099cc0063bc80e498..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/parser/narsese/NarseseParser.java +++ /dev/null @@ -1,404 +0,0 @@ -/* - * StringParser.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.parser.narsese; - -import java.util.*; - -import com.googlecode.opennars.entity.*; -import com.googlecode.opennars.language.*; -import com.googlecode.opennars.main.*; -import com.googlecode.opennars.parser.InvalidInputException; -import com.googlecode.opennars.parser.Parser; - - -/** - * Parse input String into Task. - */ -public class NarseseParser extends Parser { - - /** - * return the prefex of a task string that contains a BudgetValue - * @return a String containing a BudgetValue - * @param s the input in a StringBuffer - * @throws com.googlecode.opennars.parser.NarseseParser.InvalidInputException if the input cannot be parsed into a BudgetValue - */ - static String getBudgetString(StringBuffer s) throws InvalidInputException { - if (s.charAt(0) != BUDGET_VALUE_MARK) // use default - return null; // null values - int i = s.indexOf(BUDGET_VALUE_MARK + "", 1); // looking for the end - if (i < 0) // no matching closer - throw new InvalidInputException("missing budget closer"); - String budgetString = s.substring(1, i).trim(); - if (budgetString.length() == 0) // empty usage - throw new InvalidInputException("empty budget"); - s.delete(0, i+1); // remaining input to be processed outside - return budgetString; - } - - /** - * return the postfex of a task string that contains a TruthValue - * @return a String containing a TruthValue - * @param s the input in a StringBuffer - * @throws com.googlecode.opennars.parser.NarseseParser.InvalidInputException if the input cannot be parsed into a TruthValue - */ - static String getTruthString(StringBuffer s) throws InvalidInputException { - int last = s.length()-1; - if (s.charAt(last) != TRUTH_VALUE_MARK) // use default - return null; - int first = s.indexOf(TRUTH_VALUE_MARK + ""); // looking for the beginning - if (first == last) // no matching closer - throw new InvalidInputException("missing truth mark"); - String truthString = s.substring(first+1, last).trim(); - if (truthString.length() == 0) // empty usage - throw new InvalidInputException("empty truth"); - s.delete(first, last+1); // remaining input to be processed outside - return truthString; - } - - /** - * parse the input String into a TruthValue (or DesireValue) - * @param s input String - * @param type Task type - * @param memory the memory object being inserted into - * @throws com.googlecode.opennars.parser.NarseseParser.InvalidInputException If the String cannot be parsed into a TruthValue - * @return the input TruthValue - */ - static TruthValue parseTruth(String s, char type, Memory memory) throws InvalidInputException { - if (type == QUESTION_MARK) - return null; - float frequency = 1.0f; - float confidence = memory.getParameters().DEFAULT_JUDGMENT_CONFIDENCE; - if (s != null) { - int i = s.indexOf(VALUE_SEPARATOR); - if (i < 0) - frequency = Float.parseFloat(s); - else { - frequency = Float.parseFloat(s.substring(0,i)); - confidence = Float.parseFloat(s.substring(i+1)); - } - } - return new TruthValue(frequency, confidence); - } - - /** - * parse the input String into a BudgetValue - * @param s input String - * @param punctuation Task punctuation - * @param truth the TruthValue of the task - * @param memory the memory object being inserted into - * - * @return the input BudgetValue - * @throws com.googlecode.opennars.parser.NarseseParser.InvalidInputException If the String cannot be parsed into a BudgetValue - */ - static BudgetValue parseBudget(String s, char punctuation, TruthValue truth, Memory memory) throws InvalidInputException { - float priority, durability; - switch (punctuation) { - case JUDGMENT_MARK: - priority = memory.getParameters().DEFAULT_JUDGMENT_PRIORITY; - durability = memory.getParameters().DEFAULT_JUDGMENT_DURABILITY; - break; - case GOAL_MARK: - priority = memory.getParameters().DEFAULT_GOAL_PRIORITY; - durability = memory.getParameters().DEFAULT_GOAL_DURABILITY; - break; - case QUESTION_MARK: - priority = memory.getParameters().DEFAULT_QUESTION_PRIORITY; - durability = memory.getParameters().DEFAULT_QUESTION_DURABILITY; - break; - default: - throw new InvalidInputException("unknown punctuation"); - } - if (s != null) { // overrite default - int i = s.indexOf(VALUE_SEPARATOR); - if (i < 0) { // default durability - priority = Float.parseFloat(s); - } else { - priority = Float.parseFloat(s.substring(0, i)); - durability = Float.parseFloat(s.substring(i+1)); - } - } - float quality = (punctuation == QUESTION_MARK) ? 1 : memory.budgetfunctions.truthToQuality(truth); - return new BudgetValue(priority, durability, quality, memory); - } - - /* ---------- parse String into term ---------- */ - - /** - * Top-level method that parse a Term in general, which may recursively call itself. - * <p> - * There are 5 valid cases: - * 1. (Op, A1, ..., An) is a common CompoundTerm (including CompoundStatement); - * 2. {A1, ..., An} is an SetExt; - * 3. [A1, ..., An] is an SetInt; - * 4. <T1 Re T2> is a Statement (including higher-order Statement); - * 5. otherwise it is a simple term. - * @param s0 the String to be parsed - * @param memory the memory object being inserted into - * @throws com.googlecode.opennars.parser.NarseseParser.InvalidInputException the String cannot be parsed into a Term - * @return the Term generated from the String - */ - static Term parseTerm(String s0, Memory memory) throws InvalidInputException { - String s = s0.trim(); - if (s.length() == 0) - throw new InvalidInputException("missing content"); - Term t = memory.nameToListedTerm(s); // existing constant or operator - if (t != null) - return t; // existing Term - int index = s.length()-1; - char first = s.charAt(0); - char last = s.charAt(index); - switch (first) { - case COMPOUND_TERM_OPENER: - if (last == COMPOUND_TERM_CLOSER) - return parseCompoundTerm(s.substring(1, index), memory); - else - throw new InvalidInputException("missing CompoundTerm closer"); - case SET_EXT_OPENER: - if (last == SET_EXT_CLOSER) - return SetExt.make(parseArguments(s.substring(1, index) + ARGUMENT_SEPARATOR, memory), memory); - else - throw new InvalidInputException("missing ExtensionSet closer"); - case SET_INT_OPENER: - if (last == SET_INT_CLOSER) - return SetInt.make(parseArguments(s.substring(1, index) + ARGUMENT_SEPARATOR, memory), memory); - else - throw new InvalidInputException("missing IntensionSet closer"); - case STATEMENT_OPENER: - if (last == STATEMENT_CLOSER) - return parseStatement(s.substring(1, index), memory); - else - throw new InvalidInputException("missing Statement closer"); - default: - return parseSimpleTerm(s); - } - } - - /** - * Parse a Term that has no internal structure. - * <p> - * The Term can be a constant or a variable. - * @param s0 the String to be parsed - * @throws com.googlecode.opennars.parser.NarseseParser.InvalidInputException the String cannot be parsed into a Term - * @return the Term generated from the String - */ - private static Term parseSimpleTerm(String s0) throws InvalidInputException { - String s = s0.trim(); - if (s.length() == 0) - throw new InvalidInputException("missing term"); - if (s.contains(" ")) // invalid characters in a name - throw new InvalidInputException("invalid term"); - Term term; - char prefix = s.charAt(0); - if ((prefix == VARIABLE_TAG) || (prefix == QUERY_VARIABLE_TAG)) { - term = new Variable(s); // the only place to directly call this constructor - } else - term = new Term(s); // the only place to directly call this constructor - return term; - } - - /** - * Parse a String to create a Statement. - * @return the Statement generated from the String - * @param s0 The input String to be parsed - * @param memory the memory object being inserted into - * @throws com.googlecode.opennars.parser.NarseseParser.InvalidInputException the String cannot be parsed into a Term - */ - private static Statement parseStatement(String s0, Memory memory) throws InvalidInputException { - String s = s0.trim(); - int i = topRelation(s); - if (i < 0) - throw new InvalidInputException("invalid statement"); - String relation = s.substring(i, i+3); - Term subject = parseTerm(s.substring(0, i), memory); - Term predicate = parseTerm(s.substring(i+3), memory); - Statement t = Statement.make(relation, subject, predicate, memory); - if (t == null) - throw new InvalidInputException("invalid statement"); - return t; - } - - /** - * Parse a String to create a CompoundTerm. - * @return the Term generated from the String - * @param s0 The String to be parsed - * @param memory the memory object being inserted into - * @throws com.googlecode.opennars.parser.NarseseParser.InvalidInputException the String cannot be parsed into a Term - */ - private static Term parseCompoundTerm(String s0, Memory memory) throws InvalidInputException { - String s = s0.trim(); - int firstSeparator = s.indexOf(ARGUMENT_SEPARATOR); - String op = s.substring(0, firstSeparator).trim(); - if (!CompoundTerm.isOperator(op, memory)) - throw new InvalidInputException("unknown operator: " + op); - ArrayList<Term> arg = parseArguments(s.substring(firstSeparator+1) + ARGUMENT_SEPARATOR, memory); - Term t = CompoundTerm.make(op, arg, memory); - if (t == null) - throw new InvalidInputException("invalid compound term"); - return t; - } - - /** - * Parse a String into the argument list of a CompoundTerm. - * @return the arguments in an ArrayList - * @param s0 The String to be parsed - * @param memory the memory object being inserted into - * @throws com.googlecode.opennars.parser.NarseseParser.InvalidInputException the String cannot be parsed into an argument list - */ - private static ArrayList<Term> parseArguments(String s0, Memory memory) throws InvalidInputException { - String s = s0.trim(); - ArrayList<Term> list = new ArrayList<Term>(); - int start = 0; - int end = 0; - Term t; - while (end < s.length()-1) { - end = nextSeparator(s, start); - t = parseTerm(s.substring(start, end), memory); // recursive call - list.add(t); - start = end+1; - } - if (list.isEmpty()) - throw new InvalidInputException("null argument"); - return list; - } - - /* ---------- locate top-level substring ---------- */ - - /** - * Locate the first top-level separator in a CompoundTerm - * @return the index of the next seperator in a String - * @param s The String to be parsed - * @param first The starting index - */ - private static int nextSeparator(String s, int first) { - int levelCounter = 0; - int i = first; - while (i < s.length()-1) { - if (isOpener(s, i)) - levelCounter++; - else if (isCloser(s, i)) - levelCounter--; - else if (s.charAt(i) == ARGUMENT_SEPARATOR) - if (levelCounter == 0) - break; - i++; - } - return i; - } - - /** - * locate the top-level relation in a statement - * @return the index of the top-level relation - * @param s The String to be parsed - */ - private static int topRelation(String s) { // need efficiency improvement - int levelCounter = 0; - int i = 0; - while (i < s.length()-3) { // don't need to check the last 3 characters - if ((levelCounter == 0) && (Statement.isRelation(s.substring(i, i+3)))) - return i; - if (isOpener(s, i)) - levelCounter++; - else if (isCloser(s, i)) - levelCounter--; - i++; - } - return -1; - } - - /* ---------- recognize symbols ---------- */ - - /** - * check CompoundTerm opener symbol - * @return if the given String is an opener symbol - * @param s The String to be checked - * @param i The starting index - */ - private static boolean isOpener(String s, int i) { - char c = s.charAt(i); - boolean b = (c == COMPOUND_TERM_OPENER) || - (c == SET_EXT_OPENER) || - (c == SET_INT_OPENER) || - (c == STATEMENT_OPENER); - if (!b) - return false; - if (i+3 <= s.length() && Statement.isRelation(s.substring(i, i+3))) - return false; - return true; - } - - /** - * check CompoundTerm closer symbol - * @return if the given String is a closer symbol - * @param s The String to be checked - * @param i The starting index - */ - private static boolean isCloser(String s, int i) { - char c = s.charAt(i); - boolean b = (c == COMPOUND_TERM_CLOSER) || - (c == SET_EXT_CLOSER) || - (c == SET_INT_CLOSER) || - (c == STATEMENT_CLOSER); - if (!b) - return false; - if (i >= 2 && Statement.isRelation(s.substring(i-2, i+1))) - return false; - return true; - } - - public Task parseTask(String input, Memory memory) throws InvalidInputException { - StringBuffer buffer = new StringBuffer(input); - String budgetString = getBudgetString(buffer); - String truthString = getTruthString(buffer); - String str = buffer.toString().trim(); - int last = str.length() - 1; - char punc = str.charAt(last); - TruthValue truth = parseTruth(truthString, punc, memory); - BudgetValue budget = parseBudget(budgetString, punc, truth, memory); - Term content = parseTerm(str.substring(0,last), memory); - Base base = (punc == QUESTION_MARK) ? null : new Base(); - Sentence sentence = Sentence.make(content, punc, truth, base, memory); - if (sentence == null) - throw new InvalidInputException("invalid sentence"); - sentence.setInput(); - Task task = new Task(sentence, budget, memory); - return task; - } - - @Override - public List<Task> parseTasks(String input, Memory memory) - throws InvalidInputException { - // TODO Auto-generated method stub - return null; - } - - @Override - public String serialiseSentence(Sentence task, Memory memory) { - // TODO Auto-generated method stub - return null; - } - - @Override - public String serialiseSentences(List<Sentence> tasks, Memory memory) { - // TODO Auto-generated method stub - return null; - } -} diff --git a/open-nars/src/com/googlecode/opennars/storage/Bag.java b/open-nars/src/com/googlecode/opennars/storage/Bag.java deleted file mode 100644 index 97c5a6c3bceb60369e95e765d87037872a0158e0..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/storage/Bag.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Bag.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.storage; - -import java.util.*; - -import com.googlecode.opennars.entity.Item; -import com.googlecode.opennars.inference.BudgetFunctions; -import com.googlecode.opennars.main.Parameters; - - -/** - * A Bag is a storage with a constant capacity and maintains an internal priority - * distribution for retrieval. - * - * Each entity in a bag must extend Item, which is a UsageValue with a key. - * - * A name table is used to merge duplicate items. - * - * The bag space is divided by a threshold, above which is mainly time management, - * and below, space mamagement. - * Differences: (1) level selection vs. item selection, (2) decay rate - */ -public abstract class Bag<Type extends Item> { - - protected static final int TOTAL_LEVEL = Parameters.BAG_LEVEL; // priority levels - protected static final int THRESHOLD = Parameters.BAG_THRESHOLD; // firing threshold - protected static final float RELATIVE_THRESHOLD = (float) THRESHOLD / (float) TOTAL_LEVEL; - protected static final float LOAD_FACTOR = Parameters.LOAD_FACTOR; // hashtable parameter - protected static final Distributor DISTRIBUTOR = new Distributor(TOTAL_LEVEL); // only one instance - - protected HashMap<String, Type> nameTable; // from key to item - protected ArrayList<Type> itemTable[]; // array of lists of items, for items on different level - - protected int capacity; // defined in different bags - protected int mass; // current sum of occupied level - protected int levelIndex; // index to get next level, kept in individual objects - protected int currentLevel; // current take out level - protected int currentCounter; // maximum number of items to be taken out at current level - - - // ---------- constructor ---------- // - - // called from subclasses - protected Bag() { - capacity = capacity(); - levelIndex = capacity % TOTAL_LEVEL; // so that different bags start at different point - currentLevel = TOTAL_LEVEL - 1; - itemTable = new ArrayList[TOTAL_LEVEL]; - nameTable = new HashMap<String, Type>((int) (capacity / LOAD_FACTOR), LOAD_FACTOR); - } - - // --- property methods --- // - - protected abstract int capacity(); - - // the number of times for a decay factor to be fully applied - // it can be changed in run time by the user, so not a constant - protected abstract int forgetRate(); - - // --- Bag property --- // - - public ArrayList<Type> getAllContents() { - return (ArrayList<Type>) this.nameTable.values(); - } - - // get the average priority of the bag --- can be removed??? - public float averagePriority() { - if (nameTable.size() == 0) - return 0.01f; - float f = (float) mass / (nameTable.size() * TOTAL_LEVEL); - if (f > 1) - return 1.0f; - return f; - } - - // check if an item is in the bag - public boolean contains(Type it) { - return nameTable.containsValue(it); - } - - public Type get(String key) { - return nameTable.get(key); - } - - // ---------- put/remove methods ---------- // - - // put a new Item into the Bag - public void putIn(Type newItem) { - String newKey = newItem.getKey(); - Type oldItem = nameTable.put(newKey, newItem); - if (oldItem != null) { // merge duplications - outOfBase(oldItem); - newItem.merge(oldItem); - } - Type overflowItem = intoBase(newItem); // put the (new or merged) item into itemTable - if (overflowItem != null) { // remove overflow - String overflowKey = overflowItem.getKey(); - nameTable.remove(overflowKey); - } - } - - // put an item back into the itemTable (it is already in the table) - public void putBack(Type oldItem) { - BudgetFunctions.forget(oldItem.getBudget(), forgetRate(), RELATIVE_THRESHOLD); - putIn(oldItem); - } - - // choose an item according to priority distribution - // and take it out of the itemTable - public Type takeOut() { // default behavior: the Item will be putBack - if (mass == 0) // empty bag - return null; - if (emptyLevel(currentLevel) || (currentCounter == 0)) { // done with the current level - currentLevel = DISTRIBUTOR.pick(levelIndex); - levelIndex = DISTRIBUTOR.next(levelIndex); - while (emptyLevel(currentLevel)) { // look for a non-empty level - currentLevel = DISTRIBUTOR.pick(levelIndex); - levelIndex = DISTRIBUTOR.next(levelIndex); - } - if (currentLevel < THRESHOLD) - currentCounter = 1; // for dormant levels, take one item - else - currentCounter = itemTable[currentLevel].size(); // for active levels, take all current items - } - Type selected = takeOutFirst(currentLevel); // take out the first item in the level - currentCounter--; - nameTable.remove(selected.getKey()); // 01-07-04 - return selected; - } - - // pick an item by key, then remove it from the bag - public Type pickOut(String key) { - Type picked = nameTable.get(key); - if (picked != null) { - outOfBase(picked); - nameTable.remove(key); // 01-07-04 - } - return picked; - } - - // ---------- private methods ---------- // - - // check whether a level is empty - private boolean emptyLevel(int n) { - if (itemTable[n] == null) - return true; - else - return itemTable[n].isEmpty(); - } - - // decide the in level according to priority - private int getLevel(Type item) { - float fl = item.getPriority() * TOTAL_LEVEL; - int level = (int) Math.ceil(fl) - 1; - return (level < 0) ? 0 : level; // cannot be -1 - } - - // insert an item into the itemTable, and return the overflow - private Type intoBase(Type newItem) { - Type oldItem = null; - int inLevel = getLevel(newItem); - if (nameTable.size() > capacity) { // the bag is full - int outLevel = 0; - while (emptyLevel(outLevel)) - outLevel++; - if (outLevel > inLevel) { // ignore the item and exit - return newItem; - } else { // remove an old item in the lowest non-empty level - oldItem = takeOutFirst(outLevel); - } - } - if (itemTable[inLevel] == null) - itemTable[inLevel] = new ArrayList(); // first time insert - itemTable[inLevel].add(newItem); // FIFO - mass += (inLevel + 1); // increase total mass - return oldItem; - } - - // take out the first or last Type in a level from the itemTable - private Type takeOutFirst(int level) { - Type selected = itemTable[level].get(0); - itemTable[level].remove(0); // take the item out - mass -= (level + 1); // decrease total mass - return selected; - } - - // remove an item from itemTable, then adjust mass - protected void outOfBase(Type oldItem) { - int level = getLevel(oldItem); - itemTable[level].remove(oldItem); - mass -= (level + 1); // decrease total mass - } -} diff --git a/open-nars/src/com/googlecode/opennars/storage/ConceptBag.java b/open-nars/src/com/googlecode/opennars/storage/ConceptBag.java deleted file mode 100644 index 57698efb58d20fbe5999327840b71bbd93ebf234..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/storage/ConceptBag.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ConceptBag.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.storage; - -import java.util.HashMap; - -import com.googlecode.opennars.entity.Concept; -import com.googlecode.opennars.main.Parameters; - -/** - * Contains Concepts. - */ -public class ConceptBag extends Bag<Concept> { - - protected int capacity() { - return Parameters.CONCEPT_BAG_SIZE; - } - - // this is for active concept only - protected int forgetRate() { - return Parameters.CONCEPT_DEFAULT_FORGETTING_CYCLE; - } - - public HashMap<String, Concept> getNameTable() { - return this.nameTable; - } -} \ No newline at end of file diff --git a/open-nars/src/com/googlecode/opennars/storage/Distributor.java b/open-nars/src/com/googlecode/opennars/storage/Distributor.java deleted file mode 100644 index c6af10337c601c7e8aa94c81d2e49bb9882e7e71..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/storage/Distributor.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Distributor.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.storage; - -/** - * A pseudo-random number generator, used in Bag. - */ -class Distributor { - /** - * Random sequence of valid numbers - */ - private int order[]; - /** - * Capacity of the array - */ - private int capacity; - - /** - * For any number N < range, there is N+1 copies of it in the array. - * - * @param range Range of valid numbers - */ - public Distributor(int range) { - int index, rank, time; - capacity = (range * (range + 1)) / 2; - order = new int[capacity]; - for (index = 0; index < capacity; index++) - order[index] = -1; - for (rank = range; rank > 0; rank--) - for (time = 0; time < rank; time++) { - index = (((int) (capacity / rank)) + index) % capacity; - while (order[index] >= 0) - index = (index + 1) % capacity; - order[index] = rank - 1; - } - } - - /** - * Get the next number according to the given index - * - * @param index The current index - * @return the random value - */ - public int pick(int index) { - return order[index]; - } - - /** - * Advance the index - * - * @param index The current index - * @return the next index - */ - public int next(int index) { - return (index + 1) % capacity; - } -} \ No newline at end of file diff --git a/open-nars/src/com/googlecode/opennars/storage/TaskBag.java b/open-nars/src/com/googlecode/opennars/storage/TaskBag.java deleted file mode 100644 index c4b5f4def43dca86741250b4f506728b0c679c6e..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/storage/TaskBag.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * TaskBag.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.storage; - -import com.googlecode.opennars.entity.Task; -import com.googlecode.opennars.main.*; - -/** - * New tasks that contain new Term. - */ -public class TaskBag extends Bag<Task> { - public static final int defaultForgetRate = Parameters.NEW_TASK_DEFAULT_FORGETTING_CYCLE; - - protected int capacity() { - return Parameters.TASK_BUFFER_SIZE; - } - - protected int forgetRate() { - return Parameters.TASK_DEFAULT_FORGETTING_CYCLE; - } - -} - diff --git a/open-nars/src/com/googlecode/opennars/storage/TaskLinkBag.java b/open-nars/src/com/googlecode/opennars/storage/TaskLinkBag.java deleted file mode 100644 index 051dc27a4b220ea6455af1e2d1dab0a832fac1bf..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/storage/TaskLinkBag.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * TaskLinkBag.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.storage; - -import com.googlecode.opennars.entity.TaskLink; -import com.googlecode.opennars.main.Parameters; - -/** - * TaskLinkBag contains links to tasks. - */ -public class TaskLinkBag extends Bag<TaskLink> { - - protected int capacity() { - return Parameters.TASK_BAG_SIZE; - } - - protected int forgetRate() { - return Parameters.TASK_DEFAULT_FORGETTING_CYCLE; - } -} - diff --git a/open-nars/src/com/googlecode/opennars/storage/TermLinkBag.java b/open-nars/src/com/googlecode/opennars/storage/TermLinkBag.java deleted file mode 100644 index 743a44d1dfc653c50189d4800beb39249b6b8882..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/storage/TermLinkBag.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * TermLinkBag.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS 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. - * - * Open-NARS 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 Foobar. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.googlecode.opennars.storage; - -import com.googlecode.opennars.entity.*; -import com.googlecode.opennars.main.Parameters; - -/** - * Contains CompositionLinks to relevant Terms. - */ -public class TermLinkBag extends Bag<TermLink> { - - private static final int maxTakeOut = Parameters.MAX_TAKE_OUT_K_LINK; - - protected int capacity() { - return Parameters.BELIEF_BAG_SIZE; - } - - protected int forgetRate() { - return Parameters.BELIEF_DEFAULT_FORGETTING_CYCLE; - } - - // replace defualt to prevent repeated inference - public TermLink takeOut(TaskLink tLink) { - for (int i = 0; i < maxTakeOut; i++) { - TermLink bLink = takeOut(); - if (bLink == null) - return null; - if (tLink.novel(bLink)) { - return bLink; - } - putBack(bLink); - } - return null; - } -} - diff --git a/open-nars/src/com/googlecode/opennars/storage/package.html b/open-nars/src/com/googlecode/opennars/storage/package.html deleted file mode 100644 index 7e267931eef36c0e33f24628a0ee52fb7a433670..0000000000000000000000000000000000000000 --- a/open-nars/src/com/googlecode/opennars/storage/package.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<body bgcolor="white"> - -Storage management - -<h2>Package Specification</h2> - -All items (Concept within Memory, TaskLinks and CompositionLinks within Concept) are put into Bags, which supports priority-based resources allocation. Also, bag supports access by key (String). -<p> -A bag supports three major operations: -<ul> -<li>To take out an item by key.</li> -<li>To take out an item probabilistically according to priority.</li> -<li>To put an item into the bag.</li> -</ul> -All the operations take constant time to finish. -<p> -The "take out by priority" operation takes an item out probablistically, with the -probability proportional to the priority value. -<p> -The probability distribution is generated from a deterministic table. -<p> -All classes in package <tt>nars.storage</tt> extend <tt>Bag</tt>. -<p> -In NARS, the memory consists of a bag of concepts. Each concept uniquely corresponds to a term, which uniquely corresponds to a String served as its name. It is necessary to separate a term and the corresponding concept, because a concept may be deleted due to space competition, and a term is removed only when no other term is linked to it. In the system, there may be multiple terms refer to the same concept, though the concept just refer to one of them. NARS does not follow a "one term, one concept" policy and use a hash table in memory to maps names into terms, because the system needs to remove a concept without removing the term that naming it. -<p> -Variable terms correspond to no concept, and their meaning is local to the "smallest" term that contains all occurences of the variable. -<p> -From name to term, call Term.nameToTerm(String). From name to concept, call Concept.nameToConcept(String). Both use the name as key to get the concept from the concept hashtable in memory. -<p> -The main memory also contains buffers for new tasks. One buffer contains tasks to be processed immediately (to be finished in constant time), and the other, a bag, for the tasks to be processed later. - -</body> -</html>