|
From: <jom...@us...> - 2008-03-31 20:04:25
|
Revision: 1183
http://jason.svn.sourceforge.net/jason/?rev=1183&view=rev
Author: jomifred
Date: 2008-03-31 13:04:20 -0700 (Mon, 31 Mar 2008)
Log Message:
-----------
rename BodyLiteral to BodyPlan (old class is still there, but deprecated)
Modified Paths:
--------------
trunk/demos/directives/myp/LoggerDirective.java
trunk/src/jason/asSemantics/IntendedMeans.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/BodyLiteral.java
trunk/src/jason/asSyntax/Plan.java
trunk/src/jason/asSyntax/PlanLibrary.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/asSyntax/parser/as2jTokenManager.java
trunk/src/jason/asSyntax/patterns/goal/DG.java
trunk/src/jason/asSyntax/patterns/goal/EBDG.java
trunk/src/jason/stdlib/remove_plan.java
trunk/src/jason/stdlib/wait.java
trunk/src/test/ASParserTest.java
trunk/src/test/PlanTest.java
Removed Paths:
-------------
trunk/src/jason/asSyntax/BodyLiteralImpl.java
trunk/src/jason/stdlib/myName.java
Modified: trunk/demos/directives/myp/LoggerDirective.java
===================================================================
--- trunk/demos/directives/myp/LoggerDirective.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/demos/directives/myp/LoggerDirective.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -2,12 +2,12 @@
package myp;
import jason.asSemantics.Agent;
-import jason.asSyntax.BodyLiteral;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.Plan;
import jason.asSyntax.Pred;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.directives.Directive;
import java.util.logging.Level;
@@ -28,11 +28,11 @@
// add .print(te) in the begin and end of the plan
for (Plan p: innerContent.getPL()) {
Literal print1 = Literal.parseLiteral(".print(\"Entering \","+p.getTrigger().getLiteral()+")");
- BodyLiteral b1 = new BodyLiteralImpl(BodyType.internalAction, print1);
+ PlanBody b1 = new PlanBodyImpl(BodyType.internalAction, print1);
p.getBody().add(0,b1);
Literal print2 = Literal.parseLiteral(".print(\"Leaving \","+p.getTrigger().getLiteral()+")");
- BodyLiteral b2 = new BodyLiteralImpl(BodyType.internalAction, print2);
+ PlanBody b2 = new PlanBodyImpl(BodyType.internalAction, print2);
p.getBody().add(b2);
newAg.getPL().add(p);
Modified: trunk/src/jason/asSemantics/IntendedMeans.java
===================================================================
--- trunk/src/jason/asSemantics/IntendedMeans.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSemantics/IntendedMeans.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -24,8 +24,8 @@
package jason.asSemantics;
-import jason.asSyntax.BodyLiteral;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
@@ -73,7 +73,7 @@
/** removes the current action of the IM and returns the term of the body */
public Term removeCurrentStep() {
- BodyLiteral current = plan.getBody();
+ PlanBody current = plan.getBody();
if (current.isEmptyBody()) {
return null;
} else {
@@ -81,7 +81,7 @@
}
}
- public BodyLiteral getCurrentStep() {
+ public PlanBody getCurrentStep() {
return plan.getBody();
}
@@ -129,10 +129,10 @@
public Term getAsTerm() {
Structure im = new Structure("im");
im.addTerm(new StringTermImpl(plan.getLabel().toString()));
- if (plan.getBody() instanceof BodyLiteralImpl) {
+ if (plan.getBody() instanceof PlanBodyImpl) {
ListTerm lt = new ListTermImpl();
- for (BodyLiteral bd: (BodyLiteralImpl)plan.getBody()) {
- BodyLiteral c = (BodyLiteral)bd.clone();
+ for (PlanBody bd: (PlanBodyImpl)plan.getBody()) {
+ PlanBody c = (PlanBody)bd.clone();
c.apply(unif);
lt.add(new StringTermImpl(c.getBodyType().toString()+c.getBodyTerm()));
}
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -27,7 +27,7 @@
import jason.RevisionFailedException;
import jason.architecture.AgArch;
import jason.asSyntax.Atom;
-import jason.asSyntax.BodyLiteral;
+import jason.asSyntax.PlanBody;
import jason.asSyntax.DefaultTerm;
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.ListTermImpl;
@@ -286,11 +286,11 @@
}
/**
- * This step is new in Jason 1.0.2 and replaces the steps RelPl->ApplPl->SelAppl when the user
+ * This step is new in Jason 1.1 and replaces the steps RelPl->ApplPl->SelAppl when the user
* does not customise selectOption. This version does not create the RP and AP lists and thus
* optimise the reasoning cycle. It searches for the first option and automatically selects it.
*
- * @since 1.0.2
+ * @since 1.1
*/
private void applyFindOp() throws JasonException {
confP.step = State.AddIM; // default next step
@@ -402,7 +402,7 @@
return;
}
Unifier u = im.unif;
- BodyLiteral h = im.getCurrentStep();
+ PlanBody h = im.getCurrentStep();
h.apply(u);
Literal body = null;
Modified: trunk/src/jason/asSyntax/BodyLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/BodyLiteral.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/BodyLiteral.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -1,7 +1,12 @@
package jason.asSyntax;
-public interface BodyLiteral extends Term {
+/**
+ * @deprecated use PlanBodyImpl instead.
+ */
+public class BodyLiteral extends PlanBodyImpl {
+
+ /** @deprecated Use BodyType of PlanBody instead */
public enum BodyType {
none { public String toString() { return ""; }},
action { public String toString() { return ""; }},
@@ -15,19 +20,24 @@
constraint { public String toString() { return ""; }}
}
- public BodyType getBodyType();
- public Term getBodyTerm();
- public BodyLiteral getBodyNext();
+ public BodyLiteral(BodyType t, Term b) {
+ super(oldToNew(t),b);
+ }
+
+ private static PlanBody.BodyType oldToNew(BodyType old) {
+ // TODO: implement it!
+ switch (old) {
+ case action: return PlanBody.BodyType.action;
+ case internalAction: return PlanBody.BodyType.internalAction;
+ case achieve: return PlanBody.BodyType.achieve;
+ case test: return PlanBody.BodyType.test;
+ case addBel: return PlanBody.BodyType.addBel;
+ case delBel: return PlanBody.BodyType.delBel;
+ case delAddBel: return PlanBody.BodyType.delAddBel;
+ case achieveNF: return PlanBody.BodyType.achieveNF;
+ case constraint: return PlanBody.BodyType.constraint;
+ }
+ return PlanBody.BodyType.none;
+ }
- public boolean isEmptyBody();
- public int getPlanSize();
-
- public void setBodyType(BodyType bt);
- public void setBodyTerm(Term t);
- public void setBodyNext(BodyLiteral bl);
-
-
- public boolean add(BodyLiteral bl);
- public boolean add(int index, BodyLiteral bl);
- public Term removeBody(int index);
-}
\ No newline at end of file
+}
Deleted: trunk/src/jason/asSyntax/BodyLiteralImpl.java
===================================================================
--- trunk/src/jason/asSyntax/BodyLiteralImpl.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/BodyLiteralImpl.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -1,236 +0,0 @@
-package jason.asSyntax;
-
-import jason.asSemantics.Unifier;
-
-import java.util.Iterator;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Represents a plan body item (achieve, test, action, ...) and its successors.
- *
- * A plan body like <code>a1; ?t; !g</code> is represented by the following structure
- * <code>(a1, (?t, (!g)))</code>.
- *
- * @author Jomi
- */
-public class BodyLiteralImpl extends Structure implements BodyLiteral, Iterable<BodyLiteral> {
-
- public static final String BODY_PLAN_FUNCTOR = ";";
-
- private Term term = null;
- private BodyLiteral next = null;
- private BodyType formType = BodyType.none;
-
- /** constructor for empty plan body */
- public BodyLiteralImpl() {
- super(BODY_PLAN_FUNCTOR, 0);
- }
-
- public BodyLiteralImpl(BodyType t, Term b) {
- super(BODY_PLAN_FUNCTOR, 0);
- term = b;
- formType = t;
- setSrc(b);
- }
-
- public void setBodyNext(BodyLiteral next) {
- this.next = next;
- }
- public BodyLiteral getBodyNext() {
- return next;
- }
-
- public boolean isEmptyBody() {
- return term == null;
- }
-
- public BodyType getBodyType() {
- return formType;
- }
- public void setBodyType(BodyType bt) {
- formType = bt;
- }
-
- public Term getBodyTerm() {
- return term;
- }
- public void setBodyTerm(Term t) {
- term = t;
- }
-
- @Override
- public boolean isPlanBody() {
- return true;
- }
-
- public Iterator<BodyLiteral> iterator() {
- return new Iterator<BodyLiteral>() {
- BodyLiteral current = BodyLiteralImpl.this;
- public boolean hasNext() {
- return current != null && current.getBodyTerm() != null;
- }
- public BodyLiteral next() {
- BodyLiteral r = current;
- if (current != null)
- current = current.getBodyNext();
- return r;
- }
- public void remove() { }
- };
- }
-
- // Override some structure methods to work with unification/equals
- @Override
- public int getArity() {
- if (term == null)
- return 0;
- else if (next == null)
- return 1;
- else
- return 2;
- }
-
- @Override
- public Term getTerm(int i) {
- if (i == 0)
- return term;
- if (i == 1) {
- if (next != null && next.getBodyTerm().isVar() && next.getBodyNext() == null)
- // if next is the last VAR, return that var
- return next.getBodyTerm();
- else
- return next;
- }
- return null;
- }
-
- @Override
- public void setTerm(int i, Term t) {
- if (i == 0) term = t;
- if (i == 1) System.out.println("Should not set next of body literal!");
- }
-
- @Override
- public boolean apply(Unifier u) {
- // do not apply in next!
- resetHashCodeCache();
- if (term != null && term.apply(u)) {
- if (term.isPlanBody()) { // we can not have "inner" body literals
- formType = ((BodyLiteral)term).getBodyType();
- term = ((BodyLiteral)term).getBodyTerm();
- }
- return true;
- }
- return false;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == null) return false;
- if (o == this) return true;
-
- if (o instanceof BodyLiteral) {
- BodyLiteral b = (BodyLiteral)o;
- return formType == b.getBodyType() && super.equals(o);
- }
- return false;
- }
-
- @Override
- public int calcHashCode() {
- return formType.hashCode() + super.calcHashCode();
- }
-
- public boolean add(BodyLiteral bl) {
- if (term == null)
- swap(bl);
- else if (next == null)
- next = bl;
- else
- next.add(bl);
- return true;
- }
-
- public boolean add(int index, BodyLiteral bl) {
- if (index == 0) {
- swap(bl);
- this.next = bl;
- } else {
- next.add(index - 1, bl);
- }
- return true;
- }
-
- public Term removeBody(int index) {
- if (index == 0) {
- if (next == null) {
- term = null; // becomes an empty
- } else {
- Term oldvalue = term;
- swap(next); // get values of text
- next = next.getBodyNext();
- return oldvalue;
- }
- return this;
- } else {
- return next.removeBody(index - 1);
- }
- }
-
- public int getPlanSize() {
- if (term == null)
- return 0;
- else if (next == null)
- return 1;
- else
- return next.getPlanSize() + 1;
- }
-
- private void swap(BodyLiteral bl) {
- BodyType bt = this.formType;
- this.formType = bl.getBodyType();
- bl.setBodyType(bt);
-
- Term l = this.term;
- this.term = bl.getBodyTerm();
- bl.setBodyTerm(l);
- }
-
- public Object clone() {
- if (term == null) // empty
- return new BodyLiteralImpl();
-
- BodyLiteralImpl c = new BodyLiteralImpl(formType, (Term)term.clone());
- if (next != null)
- c.setBodyNext((BodyLiteral)getBodyNext().clone());
- return c;
- }
-
- public String toString() {
- if (term == null)
- return "";
- else if (next == null)
- return formType.toString() + term;
- else
- return formType.toString() + term + "; " + next;
- }
-
- /** get as XML */
- public Element getAsDOM(Document document) {
- Element eb = (Element) document.createElement("body");
- BodyLiteral bl = this;
- while (bl != null && !bl.isEmptyBody()) {
- Element u = (Element) document.createElement("body-literal");
- if (bl.getBodyType().toString().length() > 0) {
- u.setAttribute("type", bl.getBodyType().toString());
- }
- u.appendChild( ((Structure)bl.getBodyTerm()).getAsDOM(document));
- eb.appendChild(u);
-
- bl = bl.getBodyNext();
- }
- return eb;
- }
-}
Modified: trunk/src/jason/asSyntax/Plan.java
===================================================================
--- trunk/src/jason/asSyntax/Plan.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/Plan.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -51,7 +51,7 @@
private Pred label = null;
private Trigger tevent = null;
private LogicalFormula context;
- private BodyLiteral body;
+ private PlanBody body;
private boolean isAtomic = false;
@@ -63,12 +63,12 @@
}
// used by parser
- public Plan(Pred label, Trigger te, LogicalFormula ct, BodyLiteral bd) {
+ public Plan(Pred label, Trigger te, LogicalFormula ct, PlanBody bd) {
tevent = te;
setLabel(label);
setContext(ct);
if (bd == null)
- body = new BodyLiteralImpl();
+ body = new PlanBodyImpl();
else
body = bd;
}
@@ -121,7 +121,7 @@
return context;
}
- public BodyLiteral getBody() {
+ public PlanBody getBody() {
return body;
}
@@ -201,7 +201,7 @@
if (context != null)
p.context = (LogicalFormula)context.clone();
- p.body = (BodyLiteral)body.clone();
+ p.body = (PlanBody)body.clone();
p.setSrc(this);
@@ -219,7 +219,7 @@
p.tevent = (Trigger)tevent.clone();
p.context = context;
- p.body = (BodyLiteral)body.clone();
+ p.body = (PlanBody)body.clone();
p.setSrc(this);
Modified: trunk/src/jason/asSyntax/PlanLibrary.java
===================================================================
--- trunk/src/jason/asSyntax/PlanLibrary.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/PlanLibrary.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -195,7 +195,7 @@
* Remove a plan represented by the label <i>pLabel</i>.
* In case the plan has many sources, only the plan's source is removed.
*/
- public boolean removePlan(Structure pLabel, Structure source) {
+ public boolean remove(Structure pLabel, Structure source) {
// find the plan
Plan p = get(pLabel.getFunctor());
if (p != null) {
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -46,7 +46,7 @@
*
* @author jomi
*/
-public class VarTerm extends Literal implements NumberTerm, ListTerm, StringTerm, ObjectTerm, BodyLiteral {
+public class VarTerm extends Literal implements NumberTerm, ListTerm, StringTerm, ObjectTerm, PlanBody {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(VarTerm.class.getName());
@@ -873,72 +873,72 @@
// -----------------------
public BodyType getBodyType() {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).getBodyType();
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).getBodyType();
else
return BodyType.none;
}
public Term getBodyTerm() {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).getBodyTerm();
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).getBodyTerm();
else
return null;
}
- public BodyLiteral getBodyNext() {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).getBodyNext();
+ public PlanBody getBodyNext() {
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).getBodyNext();
else
return null;
}
public boolean isEmptyBody() {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).isEmptyBody();
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).isEmptyBody();
else
return true;
}
public int getPlanSize() {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).getPlanSize();
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).getPlanSize();
else
return 0;
}
public void setBodyType(BodyType bt) {
- if (value != null && getValue() instanceof BodyLiteral)
- ((BodyLiteral) getValue()).setBodyType(bt);
+ if (value != null && getValue() instanceof PlanBody)
+ ((PlanBody) getValue()).setBodyType(bt);
}
public void setBodyTerm(Term t) {
- if (value != null && getValue() instanceof BodyLiteral)
- ((BodyLiteral) getValue()).setBodyTerm(t);
+ if (value != null && getValue() instanceof PlanBody)
+ ((PlanBody) getValue()).setBodyTerm(t);
}
- public void setBodyNext(BodyLiteral bl) {
- if (value != null && getValue() instanceof BodyLiteral)
- ((BodyLiteral) getValue()).setBodyNext(bl);
+ public void setBodyNext(PlanBody bl) {
+ if (value != null && getValue() instanceof PlanBody)
+ ((PlanBody) getValue()).setBodyNext(bl);
}
- public boolean add(BodyLiteral bl) {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).add(bl);
+ public boolean add(PlanBody bl) {
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).add(bl);
else
return false;
}
- public boolean add(int index, BodyLiteral bl) {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).add(index, bl);
+ public boolean add(int index, PlanBody bl) {
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).add(index, bl);
else
return false;
}
public Term removeBody(int index) {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).removeBody(index);
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).removeBody(index);
else
return null;
}
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-03-31 20:04:20 UTC (rev 1183)
@@ -43,7 +43,7 @@
import jason.asSyntax.ArithExpr.ArithmeticOp;
import jason.asSyntax.LogExpr.LogicalOp;
import jason.asSyntax.RelExpr.RelationalOp;
- import jason.asSyntax.BodyLiteral.BodyType;
+ import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
import jason.jeditplugin.*;
@@ -289,7 +289,7 @@
/* Plan */
Plan plan() : { Token k; Pred L = null;
Trigger T;
- Object C = null; BodyLiteral bl = null;
+ Object C = null; PlanBody bl = null;
Object B = null;
int start = -1, end;}
{
@@ -304,11 +304,11 @@
if (ial != null)
throw new ParseException(getSourceRef(ial)+" The internal action '"+ial+"' can not be used in plan's context!");
if (B != null) {
- if (!(B instanceof BodyLiteral))
+ if (!(B instanceof PlanBody))
throw new ParseException(getSourceRef(B)+" Unknown body formula:"+B);
- bl = (BodyLiteral)B;
+ bl = (PlanBody)B;
if (bl.getBodyTerm().equals(Literal.LTrue))
- bl = (BodyLiteral)bl.getBodyNext();
+ bl = (PlanBody)bl.getBodyNext();
}
Plan p = new Plan(L,T,(LogicalFormula)C, bl);
p.setSrcLines(start,end);
@@ -366,11 +366,11 @@
{
F = body_formula()
- [ ";" { if (!(F instanceof BodyLiteral)) throw new ParseException(getSourceRef(F)+" "+F+" is not a body literal!"); }
- R = plan_body() { if (!(R instanceof BodyLiteral)) throw new ParseException(getSourceRef(R)+" "+R+" is not a body literal!"); }
+ [ ";" { if (!(F instanceof PlanBody)) throw new ParseException(getSourceRef(F)+" "+F+" is not a body literal!"); }
+ R = plan_body() { if (!(R instanceof PlanBody)) throw new ParseException(getSourceRef(R)+" "+R+" is not a body literal!"); }
]
- { if (F instanceof BodyLiteral && R instanceof BodyLiteral) {
- ((BodyLiteral)F).setBodyNext( (BodyLiteral)R );
+ { if (F instanceof PlanBody && R instanceof PlanBody) {
+ ((PlanBody)F).setBodyNext( (PlanBody)R );
}
return F;
}
@@ -394,13 +394,13 @@
{ if (B instanceof Literal) {
if ( ((Literal)B).isInternalAction() )
formType = BodyType.internalAction;
- return new BodyLiteralImpl(formType, (Literal)B);
+ return new PlanBodyImpl(formType, (Literal)B);
} else if (formType == BodyType.action && B instanceof RelExpr) {
- return new BodyLiteralImpl(BodyType.constraint, (RelExpr)B); // constraint
+ return new PlanBodyImpl(BodyType.constraint, (RelExpr)B); // constraint
} else {
if (formType == BodyType.test) {
if (B instanceof LogicalFormula)
- return new BodyLiteralImpl(BodyType.test, (Term)B); // used in ?(a & b)
+ return new PlanBodyImpl(BodyType.test, (Term)B); // used in ?(a & b)
else
throw new ParseException(getSourceRef(B)+" The argument for ? is not a logical formula.");
} else {
@@ -451,9 +451,9 @@
( o=list()
| o=log_expr() //plan_body() // plan_body includes literals/atoms/structures
)
- { // if the result is a BodyLiteral action with size = 1, it is indeed a literal and not a body literal
- /*if (o instanceof BodyLiteral) {
- BodyLiteral bl = (BodyLiteral)o;
+ { // if the result is a PlanBody action with size = 1, it is indeed a literal and not a body literal
+ /*if (o instanceof PlanBody) {
+ PlanBody bl = (PlanBody)o;
if (bl.getBodyType() == BodyType.action && bl.getPlanSize() == 1) {
o = bl.getBodyTerm();
}
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -13,7 +13,7 @@
import jason.asSyntax.ArithExpr.ArithmeticOp;
import jason.asSyntax.LogExpr.LogicalOp;
import jason.asSyntax.RelExpr.RelationalOp;
- import jason.asSyntax.BodyLiteral.BodyType;
+ import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
import jason.jeditplugin.*;
@@ -316,7 +316,7 @@
final public Plan plan() throws ParseException {
Token k; Pred L = null;
Trigger T;
- Object C = null; BodyLiteral bl = null;
+ Object C = null; PlanBody bl = null;
Object B = null;
int start = -1, end;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -358,11 +358,11 @@
if (ial != null)
{if (true) throw new ParseException(getSourceRef(ial)+" The internal action '"+ial+"' can not be used in plan's context!");}
if (B != null) {
- if (!(B instanceof BodyLiteral))
+ if (!(B instanceof PlanBody))
{if (true) throw new ParseException(getSourceRef(B)+" Unknown body formula:"+B);}
- bl = (BodyLiteral)B;
+ bl = (PlanBody)B;
if (bl.getBodyTerm().equals(Literal.LTrue))
- bl = (BodyLiteral)bl.getBodyNext();
+ bl = (PlanBody)bl.getBodyNext();
}
Plan p = new Plan(L,T,(LogicalFormula)C, bl);
p.setSrcLines(start,end);
@@ -485,16 +485,16 @@
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 37:
jj_consume_token(37);
- if (!(F instanceof BodyLiteral)) {if (true) throw new ParseException(getSourceRef(F)+" "+F+" is not a body literal!");}
+ if (!(F instanceof PlanBody)) {if (true) throw new ParseException(getSourceRef(F)+" "+F+" is not a body literal!");}
R = plan_body();
- if (!(R instanceof BodyLiteral)) {if (true) throw new ParseException(getSourceRef(R)+" "+R+" is not a body literal!");}
+ if (!(R instanceof PlanBody)) {if (true) throw new ParseException(getSourceRef(R)+" "+R+" is not a body literal!");}
break;
default:
jj_la1[19] = jj_gen;
;
}
- if (F instanceof BodyLiteral && R instanceof BodyLiteral) {
- ((BodyLiteral)F).setBodyNext( (BodyLiteral)R );
+ if (F instanceof PlanBody && R instanceof PlanBody) {
+ ((PlanBody)F).setBodyNext( (PlanBody)R );
}
{if (true) return F;}
throw new Error("Missing return statement in function");
@@ -552,13 +552,13 @@
if (B instanceof Literal) {
if ( ((Literal)B).isInternalAction() )
formType = BodyType.internalAction;
- {if (true) return new BodyLiteralImpl(formType, (Literal)B);}
+ {if (true) return new PlanBodyImpl(formType, (Literal)B);}
} else if (formType == BodyType.action && B instanceof RelExpr) {
- {if (true) return new BodyLiteralImpl(BodyType.constraint, (RelExpr)B);} // constraint
+ {if (true) return new PlanBodyImpl(BodyType.constraint, (RelExpr)B);} // constraint
} else {
if (formType == BodyType.test) {
if (B instanceof LogicalFormula)
- {if (true) return new BodyLiteralImpl(BodyType.test, (Term)B);} // used in ?(a & b)
+ {if (true) return new PlanBodyImpl(BodyType.test, (Term)B);} // used in ?(a & b)
else
{if (true) throw new ParseException(getSourceRef(B)+" The argument for ? is not a logical formula.");}
} else {
@@ -662,9 +662,9 @@
jj_consume_token(-1);
throw new ParseException();
}
- // if the result is a BodyLiteral action with size = 1, it is indeed a literal and not a body literal
- /*if (o instanceof BodyLiteral) {
- BodyLiteral bl = (BodyLiteral)o;
+ // if the result is a PlanBody action with size = 1, it is indeed a literal and not a body literal
+ /*if (o instanceof PlanBody) {
+ PlanBody bl = (PlanBody)o;
if (bl.getBodyType() == BodyType.action && bl.getPlanSize() == 1) {
o = bl.getBodyTerm();
}
Modified: trunk/src/jason/asSyntax/parser/as2jTokenManager.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2jTokenManager.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/parser/as2jTokenManager.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -11,7 +11,7 @@
import jason.asSyntax.ArithExpr.ArithmeticOp;
import jason.asSyntax.LogExpr.LogicalOp;
import jason.asSyntax.RelExpr.RelationalOp;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
import jason.jeditplugin.*;
Modified: trunk/src/jason/asSyntax/patterns/goal/DG.java
===================================================================
--- trunk/src/jason/asSyntax/patterns/goal/DG.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/patterns/goal/DG.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -1,12 +1,12 @@
package jason.asSyntax.patterns.goal;
import jason.asSemantics.Agent;
-import jason.asSyntax.BodyLiteral;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.Plan;
import jason.asSyntax.Pred;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.directives.Directive;
import java.util.logging.Level;
@@ -32,7 +32,7 @@
// add ?g in the end of all inner plans
for (Plan p: innerContent.getPL()) {
- BodyLiteral b = new BodyLiteralImpl(BodyType.test, (Literal)goal.clone());
+ PlanBody b = new PlanBodyImpl(BodyType.test, (Literal)goal.clone());
p.getBody().add(b);
newAg.getPL().add(p);
}
Modified: trunk/src/jason/asSyntax/patterns/goal/EBDG.java
===================================================================
--- trunk/src/jason/asSyntax/patterns/goal/EBDG.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/patterns/goal/EBDG.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -1,15 +1,15 @@
package jason.asSyntax.patterns.goal;
import jason.asSemantics.Agent;
-import jason.asSyntax.BodyLiteral;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.LogExpr;
import jason.asSyntax.LogicalFormula;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Plan;
import jason.asSyntax.Pred;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.LogExpr.LogicalOp;
import jason.asSyntax.directives.Directive;
@@ -53,10 +53,10 @@
// change body
// add +p__f(i,g)
- BodyLiteral b1 = new BodyLiteralImpl(BodyType.addBel, pi);
+ PlanBody b1 = new PlanBodyImpl(BodyType.addBel, pi);
p.getBody().add(0, b1);
// add ?g
- BodyLiteral b2 = new BodyLiteralImpl(BodyType.test, (Literal)goal.clone());
+ PlanBody b2 = new PlanBodyImpl(BodyType.test, (Literal)goal.clone());
p.getBody().add(b2);
newAg.getPL().add(p);
}
Deleted: trunk/src/jason/stdlib/myName.java
===================================================================
--- trunk/src/jason/stdlib/myName.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/stdlib/myName.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -1,73 +0,0 @@
-//----------------------------------------------------------------------------
-// Copyright (C) 2003 Rafael H. Bordini, Jomi F. Hubner, et al.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library 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
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// To contact the authors:
-// http://www.dur.ac.uk/r.bordini
-// http://www.inf.furb.br/~jomi
-//
-//----------------------------------------------------------------------------
-
-package jason.stdlib;
-
-import jason.JasonException;
-import jason.asSemantics.DefaultInternalAction;
-import jason.asSemantics.TransitionSystem;
-import jason.asSemantics.Unifier;
-import jason.asSyntax.Structure;
-import jason.asSyntax.Term;
-
-/**
- <p>Internal action: <b><code>.myName</code></b>.
-
- <p>Description: gets the agent unique identification in the
- multi-agent system. This identification is given by the runtime
- infrastructure of the system (centralised, saci, jade, ...).
-
- <p>Parameters:<ul>
-
- <li>+/- arg[0] (variable or atom): if this is a variable, unifies the agent
- name and the variable; if is is an atom, succeeds if the atom is equal to
- the agent's name.<br/>
-
- </ul>
-
- <p>Example:<ul>
-
- <li> <code>.myName(N)</code>: unifies <code>N</code> with the
- agent's name.</li>
-
- </ul>
-
-
- @see jason.stdlib.send
- @see jason.stdlib.broadcast
-
- @deprecated use .my_name instead
-
- */
-public class myName extends DefaultInternalAction {
-
- @Override
- public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- try {
- ts.getLogger().info("Deprecated: use .my_name instead of .myName.");
- return un.unifies(args[0], new Structure(ts.getUserAgArch().getAgName()));
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'myName' has not received the required argument.");
- }
- }
-}
Modified: trunk/src/jason/stdlib/remove_plan.java
===================================================================
--- trunk/src/jason/stdlib/remove_plan.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/stdlib/remove_plan.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -91,11 +91,11 @@
boolean r = true;
ListTerm lt = (ListTerm)args[0];
for (Term t: lt) {
- r = r && ts.getAg().getPL().removePlan((Structure)t, source);
+ r = r && ts.getAg().getPL().remove((Structure)t, source);
}
return r;
} else { // args[0] is a plan label
- return ts.getAg().getPL().removePlan((Structure)label, source);
+ return ts.getAg().getPL().remove((Structure)label, source);
}
} catch (ArrayIndexOutOfBoundsException e) {
throw new JasonException("The internal action 'remove_plan' has not received the required argument (a plan label or list of labels).");
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/stdlib/wait.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -31,12 +31,12 @@
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.Atom;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.NumberTerm;
import jason.asSyntax.StringTerm;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import java.util.ArrayList;
import java.util.Collections;
@@ -176,7 +176,7 @@
si.peek().removeCurrentStep();
if (stopByTimeout && te != null) {
// fail the .wait
- si.peek().getPlan().getBody().add(0, new BodyLiteralImpl(BodyType.internalAction, new Atom(".fail")));
+ si.peek().getPlan().getBody().add(0, new PlanBodyImpl(BodyType.internalAction, new Atom(".fail")));
}
if (si.isSuspended()) { // if the intention was suspended by .suspend
String k = suspend.SUSPENDED_INT+si.getId();
Modified: trunk/src/test/ASParserTest.java
===================================================================
--- trunk/src/test/ASParserTest.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/test/ASParserTest.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -4,7 +4,7 @@
import jason.asSemantics.Agent;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
-import jason.asSyntax.BodyLiteral;
+import jason.asSyntax.PlanBody;
import jason.asSyntax.LogExpr;
import jason.asSyntax.LogicalFormula;
import jason.asSyntax.NumberTerm;
@@ -40,7 +40,7 @@
assertTrue(ag.parseAS("examples/auction/ag1.asl"));
Plan p = ag.getPL().get("l__0");
assertEquals(p.getBody().getPlanSize(), 1);
- assertEquals(((BodyLiteral)p.getBody()).getBodyType(), BodyLiteral.BodyType.internalAction);
+ assertEquals(((PlanBody)p.getBody()).getBodyType(), PlanBody.BodyType.internalAction);
assertTrue(ag.parseAS("examples/auction/ag2.asl"));
assertTrue(ag.parseAS("examples/auction/ag3.asl"));
}
Modified: trunk/src/test/PlanTest.java
===================================================================
--- trunk/src/test/PlanTest.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/test/PlanTest.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -2,14 +2,14 @@
import jason.JasonException;
import jason.asSemantics.Unifier;
-import jason.asSyntax.BodyLiteral;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.Plan;
import jason.asSyntax.PlanLibrary;
import jason.asSyntax.Trigger;
import jason.asSyntax.VarTerm;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.parser.ParseException;
import java.util.Iterator;
@@ -58,18 +58,18 @@
public void testParser1() {
Plan p = Plan.parse("+te : a & b <- a1; a2; .print(a); !g1; !!g2; ?test1; 10 > 3; +b1; -b2; -+b3.");
p = (Plan)p.clone();
- Iterator<BodyLiteral> i = ((BodyLiteralImpl)p.getBody()).iterator();
- assertEquals( BodyLiteral.BodyType.action, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.action, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.internalAction, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.achieve, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.achieveNF, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.test, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.constraint, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.addBel, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.delBel, ((BodyLiteral)i.next()).getBodyType());
+ Iterator<PlanBody> i = ((PlanBodyImpl)p.getBody()).iterator();
+ assertEquals( PlanBody.BodyType.action, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.action, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.internalAction, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.achieve, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.achieveNF, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.test, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.constraint, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.addBel, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.delBel, ((PlanBody)i.next()).getBodyType());
assertTrue(i.hasNext());
- assertEquals( BodyLiteral.BodyType.delAddBel, ((BodyLiteral)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.delAddBel, ((PlanBody)i.next()).getBodyType());
assertFalse(i.hasNext());
}
@@ -78,7 +78,7 @@
assertEquals(4, p.getBody().getPlanSize());
p.getBody().removeBody(0);
assertEquals(3, p.getBody().getPlanSize());
- assertEquals(BodyLiteral.BodyType.test, p.getBody().getBodyType());
+ assertEquals(PlanBody.BodyType.test, p.getBody().getBodyType());
p.getBody().removeBody(0); // 2
p.getBody().removeBody(0); // 1
assertEquals(1, p.getBody().getPlanSize());
@@ -87,7 +87,7 @@
}
public void testEqualsBodyLiteral() {
- BodyLiteral bl = new BodyLiteralImpl(BodyType.achieve, new Literal("g1"));
+ PlanBody bl = new PlanBodyImpl(BodyType.achieve, new Literal("g1"));
VarTerm v = new VarTerm("X");
Unifier u = new Unifier();
// X = !g1
@@ -101,9 +101,9 @@
public void testUnifyBody() {
Plan p1 = Plan.parse("+te : a & b <- !a1; ?a2; .print(a); !g1.");
- BodyLiteral bl = new BodyLiteralImpl(BodyType.action, new VarTerm("A1"));
- bl.add(new BodyLiteralImpl(BodyType.action, new VarTerm("A2")));
- bl.add(new BodyLiteralImpl(BodyType.action, new VarTerm("A3")));
+ PlanBody bl = new PlanBodyImpl(BodyType.action, new VarTerm("A1"));
+ bl.add(new PlanBodyImpl(BodyType.action, new VarTerm("A2")));
+ bl.add(new PlanBodyImpl(BodyType.action, new VarTerm("A3")));
//assertEquals(p1.getBody().getArity(), bl.getArity());
Unifier u = new Unifier();
assertTrue(u.unifies(p1.getBody(), bl));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|