|
From: <jom...@us...> - 2008-07-17 09:16:31
|
Revision: 1352
http://jason.svn.sourceforge.net/jason/?rev=1352&view=rev
Author: jomifred
Date: 2008-07-17 09:16:19 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
copy var annots to its value (see TestVarInContext example)
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestVarInContext.java
trunk/build.xml
trunk/src/jason/asSemantics/Unifier.java
trunk/src/jason/asSemantics/VarsCluster.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/jason/asSyntax/directives/Include.java
trunk/src/jason/bb/DefaultBeliefBase.java
trunk/src/jason/jeditplugin/AboutGUI.java
trunk/src/test/VarTermTest.java
Modified: trunk/applications/as-unit-test/src/jason/tests/TestVarInContext.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestVarInContext.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/applications/as-unit-test/src/jason/tests/TestVarInContext.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -17,13 +17,17 @@
// defines the agent's AgentSpeak code
ag.parseAScode(
- "b1[b]. b2[c]. b3[d]. b4[a,d]. "+
+ "b1[b]. b2[c]. b3[d]. b4[a,d]. step(5). b(8)[step(3)]. b(9)[step(0)]."+
"+!test1 : P[e] | P[c] <- jason.asunit.print(P). " +
"+!test2 : P[e] & P[c] <- jason.asunit.print(P). " +
"-!test2 <- jason.asunit.print(\"error\"). " +
- "+!test3 : P[a] & P[d] <- jason.asunit.print(P). "
+ "+!test3 : P[a] & P[d] <- jason.asunit.print(P). " +
+
+ "is_old(P) :- (not P | (step(Current) & P[step(N)] & Current - N > 3)). " +
+ "+!test4(X) : is_old(X) <- jason.asunit.print(1). "+
+ "+!test4(_) <- jason.asunit.print(2). "
);
}
@@ -39,6 +43,12 @@
ag.addGoal("test3");
ag.assertPrint("b4", 5);
+
+ ag.addGoal("test4(b(8))");
+ ag.assertPrint("2", 5);
+
+ ag.addGoal("test4(b(9))");
+ ag.assertPrint("1", 5);
}
}
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/build.xml 2008-07-17 09:16:19 UTC (rev 1352)
@@ -146,6 +146,14 @@
</target>
<target name="plugin" depends="compile, jar">
+ <propertyfile file="${dist.properties}">
+ <entry key="version" value="${version}" />
+ <entry key="release" value="${release}" />
+ <!-- entry default="0" key="build" operation="+" type="int" /-->
+ <entry key="build.date" type="date" value="now" />
+ </propertyfile>
+ <property file="${dist.properties}" />
+
<jar jarfile="${jedit.install.dir}/jars/${plugin.jar.name}">
<fileset dir="${basedir}/src/jeditPlugin">
<include name="Jason.props" />
@@ -221,16 +229,6 @@
<echo message="Generating Jason ${version}.${release}" />
- <propertyfile file="${dist.properties}">
- <entry key="version" value="${version}" />
- <entry key="release" value="${release}" />
- <!-- entry default="0" key="build" operation="+" type="int" /-->
- <entry key="build.date" type="date" value="now" />
- </propertyfile>
- <property file="${dist.properties}" />
-
- <antcall target="plugin" />
-
<fixcrlf eol="crlf" includes="**/*.txt,**/*.bat" srcdir="${basedir}" />
<delete failonerror="no" includeEmptyDirs="true">
Modified: trunk/src/jason/asSemantics/Unifier.java
===================================================================
--- trunk/src/jason/asSemantics/Unifier.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/asSemantics/Unifier.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -195,30 +195,28 @@
t2vl = null;
// both has value, their values should unify
- if (t1vl != null && t2vl != null) {
+ if (t1vl != null && t2vl != null)
return unifiesNoUndo(t1vl, t2vl);
- }
+
// only t1 has value, t1's value should unify with var t2
- if (t1vl != null) {
+ if (t1vl != null)
return unifiesNoUndo(t2gv, t1vl);
- }
+
// only t2 has value, t2's value should unify with var t1
- if (t2vl != null) {
+ if (t2vl != null)
return unifiesNoUndo(t1gv, t2vl);
- }
// both are var with no value, like X=Y
// we must ensure that these vars will form a cluster
//if (! t1gv.isUnnamedVar() && ! t2gv.isUnnamedVar()) {
- VarTerm t1c = (VarTerm) t1gv.clone();
- VarTerm t2c = (VarTerm) t2gv.clone();
- VarsCluster cluster = new VarsCluster(t1c, t2c, this);
- if (cluster.hasValue()) {
- // all vars of the cluster should have the same value
- for (VarTerm vtc : cluster) {
- function.put(vtc, cluster);
- }
- }
+ VarTerm t1c = (VarTerm) t1gv.clone();
+ VarTerm t2c = (VarTerm) t2gv.clone();
+ VarsCluster cluster = new VarsCluster(t1c, t2c, this);
+ if (cluster.hasValue()) {
+ // all vars of the cluster should have the same value
+ for (VarTerm vtc : cluster)
+ function.put(vtc, cluster);
+ }
//}
return true;
}
Modified: trunk/src/jason/asSemantics/VarsCluster.java
===================================================================
--- trunk/src/jason/asSemantics/VarsCluster.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/asSemantics/VarsCluster.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -77,18 +77,16 @@
private void add(VarTerm vt) {
Term vl = u.get(vt);
- if (vl == null) {
- // v1 has no value
- if (vars == null) {
+ if (vl == null) { // vt is not in a VarsCluster
+ if (vars == null)
vars = new TreeSet<VarTerm>();
- }
vars.add(vt);
} else if (vl instanceof VarsCluster) {
- if (vars == null) {
+ // since vt is in a VarsCluster, join the two sets here
+ if (vars == null)
vars = ((VarsCluster) vl).vars;
- } else {
+ else
vars.addAll(((VarsCluster) vl).vars);
- }
} else {
logger.warning("joining var that has value!");
}
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -42,7 +42,12 @@
/**
* Represents a variable Term: like X (starts with upper case). It may have a
- * value, after {@link Unifier}.apply.
+ * value, after {@link VarTerm}.apply.
+ *
+ * An object of this class can be used in place of a
+ * Literal, Number, List, String, .... It behaves like a
+ * Literal, Number, .... just in case its value is a Literal,
+ * Number, ...
*
* @author jomi
*/
@@ -110,15 +115,17 @@
}
vl = (Term)vl.clone(); // should clone here, since there is no cloning in unify
- // TODO: decide whether to use var annots in apply
+ // decide whether to use var annots in apply
// X = p[a]
// !X[b]
// what's the event:
// +!p[a]
// or
// +!p[a,b]
- //if (vl.isPred() && this.hasAnnot()) // if this var has annots, add them in the value's annots (Experimental)
- // ((Pred)vl).addAnnots(this.getAnnots());
+ // Answer: use annots of var, useful for meta-programming like
+ // P[step(N)]
+ if (vl.isPred() && this.hasAnnot()) // if this var has annots, add them in the value's annots (Experimental)
+ ((Pred)vl).addAnnots(this.getAnnots());
value = vl;
resetHashCodeCache();
@@ -147,8 +154,9 @@
protected UnnamedVar preferredUnnamedVar(Unifier un) {
if (un != null) {
- // check if I have a var cluster with another unnamed var there
- // and then prefer that unnamed var instead of a new one
+ // check if I am in a var cluster with another unnamed var,
+ // i.e. I am unified with an unnamed var,
+ // then prefer that unnamed var instead of a new one
Term vl = un.get(this);
if (vl != null && vl instanceof VarsCluster)
for (VarTerm v: (VarsCluster)vl)
Modified: trunk/src/jason/asSyntax/directives/Include.java
===================================================================
--- trunk/src/jason/asSyntax/directives/Include.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/asSyntax/directives/Include.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -56,7 +56,8 @@
// or in the source paths
List<String> newpath = new ArrayList<String>();
newpath.add(new File(outerPrefix).getAbsoluteFile().getParent());
- newpath.addAll(aslSourcePath);
+ if (aslSourcePath != null)
+ newpath.addAll(aslSourcePath);
file = checkPathAndFixWithSourcePath(file, newpath, null);
in = new FileInputStream(file);
}
Modified: trunk/src/jason/bb/DefaultBeliefBase.java
===================================================================
--- trunk/src/jason/bb/DefaultBeliefBase.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/bb/DefaultBeliefBase.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -62,7 +62,9 @@
protected Set<Literal> percepts = new HashSet<Literal>();
public void init(Agent ag, String[] args) {
- logger = Logger.getLogger(ag.getTS().getUserAgArch().getAgName() + "-"+DefaultBeliefBase.class.getSimpleName());
+ if (ag != null) {
+ logger = Logger.getLogger(ag.getTS().getUserAgArch().getAgName() + "-"+DefaultBeliefBase.class.getSimpleName());
+ }
}
public void stop() {
Modified: trunk/src/jason/jeditplugin/AboutGUI.java
===================================================================
--- trunk/src/jason/jeditplugin/AboutGUI.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/jeditplugin/AboutGUI.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -18,12 +18,12 @@
Properties p = new Properties();
p.load(JasonID.class.getResource("/dist.properties").openStream());
version = "Jason " + p.get("version") + "." + p.get("release");
- build = " build " + p.get("build") + " on " + p.get("build.date") + "\n\n";
+ build = " build on " + p.get("build.date") + "\n\n";
} catch (Exception ex) { }
JOptionPane.showMessageDialog(parent,
version + build+
- "Copyright (C) 2003-2005 Rafael H. Bordini, Jomi F. Hubner, et al.\n\n"+
+ "Copyright (C) 2003-2008 Rafael H. Bordini, Jomi F. Hubner, et al.\n\n"+
"This library is free software; you can redistribute it and/or\n"+
"modify it under the terms of the GNU Lesser General Public\n"+
"License as published by the Free Software Foundation; either\n"+
@@ -40,7 +40,7 @@
"Musees Nationaux, France). Photograph by Herve Lewandowski.\n\n"+
"To contact the authors:\n"+
"http://www.dur.ac.uk/r.bordini\n"+
- "http://www.inf.furb.br/~jomi",
+ "http://www.emse.fr/~hubner",
"JasonID - About",
JOptionPane.INFORMATION_MESSAGE,
new ImageIcon(JasonID.class.getResource("/images/Jason-GMoreau-Small.jpg")));
Modified: trunk/src/test/VarTermTest.java
===================================================================
--- trunk/src/test/VarTermTest.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/test/VarTermTest.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -261,7 +261,7 @@
assertTrue(u.unifies(v1, p1));
assertEquals(u.get("X").toString(), "p(t1,t2)");
v1.apply(u);
- assertEquals("p(t1,t2)",v1.toString());
+ assertEquals("p(t1,t2)[a,b,c]",v1.toString());
}
public void testVarWithAnnots2() {
@@ -280,7 +280,7 @@
assertTrue(u.unifies(v1, v2));
assertTrue(u.unifies(new Literal("vvv"), v1));
v1.apply(u);
- assertEquals("vvv", v1.toString());
+ assertEquals("vvv[a]", v1.toString());
}
public void testVarWithAnnots3() {
@@ -315,7 +315,7 @@
assertEquals("a", u.get("A").toString());
assertEquals("p(1)", u.get(v).toString());
v.apply(u);
- assertEquals("p(1)", v.toString());
+ assertEquals("p(1)[a]", v.toString());
}
/*
@@ -348,7 +348,7 @@
assertTrue(i.hasNext());
u = i.next(); // u = {P[d]=b2}
v1.apply(u);
- assertEquals("b2",v1.toString());
+ assertEquals("b2[d]",v1.toString());
}
@SuppressWarnings("unchecked")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-08-16 10:13:20
|
Revision: 1355
http://jason.svn.sourceforge.net/jason/?rev=1355&view=rev
Author: jomifred
Date: 2008-08-16 10:13:14 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
use the classical "deref" for vars binding instead of VarsCluster
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSemantics/Unifier.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/ObjectTermImpl.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
trunk/src/jason/asSyntax/Pred.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/asSyntax/UnnamedVar.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/test/TermTest.java
trunk/src/test/VarTermTest.java
Removed Paths:
-------------
trunk/src/jason/asSemantics/VarsCluster.java
Modified: trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -20,12 +20,19 @@
"test_rule(A,a(A)). "+
"ml0(L,L). "+
"ml(V1,V2,R) :- ml0([V1,V2],R). "+
+
+ "append([], L, L). "+
+ "append([H|T], L1, [H|L2]) :- append(T, L1, L2). "+
+
"+!test1 <- ?test_rule(T,A); A = a(V); T=45; jason.asunit.print(V). "+
- "+!test2 <- ?ml(A,B,L); A=1; B=2; jason.asunit.print(L). "
+ "+!test2 <- ?ml(A,B,L); A=1; B=2; jason.asunit.print(L). "+
+ "+!test3 <- L=[X,Y]; ?append(L, [Z], L2); Z=a; X=f; Y=i; jason.asunit.print(L2). "
);
}
- @Test
+
+
+ @Test
public void testRule1() {
ag.addGoal("test1");
ag.assertPrint("45", 5);
@@ -36,4 +43,10 @@
ag.addGoal("test2");
ag.assertPrint("[1,2]", 5);
}
+
+ @Test
+ public void testRule3() {
+ ag.addGoal("test3");
+ ag.assertPrint("[f,i,a]", 10);
+ }
}
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSemantics/Agent.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -367,7 +367,7 @@
public void addInitialGoalsInTS() {
for (Literal g: initialGoals) {
- g.makeVarsAnnon(null);
+ g.makeVarsAnnon();
if (! g.hasSource())
g.addAnnot(BeliefBase.TSelf);
getTS().getC().addAchvGoal(g,Intention.EmptyInt);
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -403,7 +403,7 @@
return;
}
Unifier u = im.unif;
- PlanBody h = im.getCurrentStep();
+ PlanBody h = im.getCurrentStep();
h.apply(u);
Literal body = null;
@@ -466,8 +466,8 @@
body.addAnnot(BeliefBase.TSelf);
}
// free variables in an event cannot conflict with those in the plan
- body = (Literal)body.clone();
- body.makeVarsAnnon(null);
+ body = body.copy();
+ body.makeVarsAnnon(u);
conf.C.addAchvGoal(body, conf.C.SI);
confP.step = State.StartRC;
break;
@@ -479,8 +479,8 @@
// programmer set some annotation
body.addAnnot(BeliefBase.TSelf);
}
- body = (Literal)body.clone();
- body.makeVarsAnnon();
+ body = body.copy();
+ body.makeVarsAnnon(u);
conf.C.addAchvGoal(body, Intention.EmptyInt);
updateIntention();
break;
@@ -495,7 +495,7 @@
if (f instanceof Literal) { // generate event when using literal in the test (no events for log. expr. like ?(a & b))
body = (Literal)f.clone();
if (body.isLiteral()) { // in case body is a var with content that is not a literal (note the VarTerm pass in the instanceof Literal)
- body.makeVarsAnnon();
+ body.makeVarsAnnon(u);
Trigger te = new Trigger(TEOperator.add, TEType.test, body);
if (ag.getPL().hasCandidatePlan(te)) {
Event evt = new Event(te, conf.C.SI);
@@ -553,7 +553,7 @@
newfocus = conf.C.SI;
// rename free vars
- body.makeVarsAnnon();
+ body.makeVarsAnnon(u);
// call BRF
try {
Modified: trunk/src/jason/asSemantics/Unifier.java
===================================================================
--- trunk/src/jason/asSemantics/Unifier.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSemantics/Unifier.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -70,16 +70,22 @@
* other's value
*/
public Term get(VarTerm vtp) {
- return function.get(vtp);
+ Term vl = function.get(vtp);
+ if (vl != null && vl.isVar()) { // optimised deref
+ return get((VarTerm)vl);
+ }
+ return vl;
}
+ /*
public Term get(Term t) {
if (t.isVar()) {
- return function.get((VarTerm) t);
+ return function.get( deref((VarTerm) t));
} else {
return null;
}
}
+ */
public boolean unifies(Trigger te1, Trigger te2) {
return te1.sameType(te2) && unifies(te1.getLiteral(), te2.getLiteral());
@@ -143,19 +149,21 @@
// X = p(1), An = a, R=[b]
if (ok && np1 != null) { // they are predicates
if (np1.isVar() && np1.hasAnnot()) {
- Term np1vl = function.get((VarTerm) np1);
- if (np1vl.isPred()) {
- Pred pvl = (Pred)np1vl.clone();
+ np1 = deref( (VarTerm)np1);
+ Term np1vl = function.get( (VarTerm) np1);
+ if (np1vl != null && np1vl.isPred()) {
+ Pred pvl = (Pred)np1vl.clone();
pvl.clearAnnots();
- function.put((VarTerm) np1, pvl);
+ bind((VarTerm) np1, pvl);
}
}
if (np2.isVar() && np2.hasAnnot()) {
+ np2 = deref( (VarTerm)np2);
Term np2vl = function.get((VarTerm) np2);
- if (np2vl.isPred()) {
+ if (np2vl != null && np2vl.isPred()) {
Pred pvl = (Pred)np2vl.clone();
pvl.clearAnnots();
- function.put((VarTerm) np2, pvl);
+ bind((VarTerm) np2, pvl);
}
}
}
@@ -179,74 +187,31 @@
final boolean t1gisvar = t1g.isVar();
final boolean t2gisvar = t2g.isVar();
- // both are vars
- if (t1gisvar && t2gisvar) {
- VarTerm t1gv = (VarTerm) t1g;
- VarTerm t2gv = (VarTerm) t2g;
-
- // get their values
- Term t1vl = function.get(t1gv);
- Term t2vl = function.get(t2gv);
+ // one of the args is a var
+ if (t1gisvar || t2gisvar) {
- // if the variable value is a var cluster, it means it has no value
- if (t1vl instanceof VarsCluster)
- t1vl = null;
- if (t2vl instanceof VarsCluster)
- t2vl = null;
+ // deref vars
+ final VarTerm t1gv = t1gisvar ? deref((VarTerm)t1g) : null;
+ final VarTerm t2gv = t2gisvar ? deref((VarTerm)t2g) : null;
- // both has value, their values should unify
- if (t1vl != null && t2vl != null)
- return unifiesNoUndo(t1vl, t2vl);
+ // get their values
+ final Term t1vl = t1gisvar ? function.get(t1gv) : t1g;
+ final Term t2vl = t2gisvar ? function.get(t2gv) : t2g;
- // only t1 has value, t1's value should unify with var t2
- if (t1vl != null)
- return unifiesNoUndo(t2gv, t1vl);
-
- // only t2 has value, t2's value should unify with var t1
- if (t2vl != null)
- return unifiesNoUndo(t1gv, t2vl);
-
- // both are var with no value, like X=Y
- // we must ensure that these vars will form a cluster
- //if (! t1gv.isUnnamedVar() && ! t2gv.isUnnamedVar()) {
- VarTerm t1c = (VarTerm) t1gv.clone();
- VarTerm t2c = (VarTerm) t2gv.clone();
- VarsCluster cluster = new VarsCluster(t1c, t2c, this);
- if (cluster.hasValue()) {
- // all vars of the cluster should have the same value
- for (VarTerm vtc : cluster)
- function.put(vtc, cluster);
+ if (t1vl != null && t2vl != null) {
+ // unifies the two values of the vars
+ return unifiesNoUndo(t1vl, t2vl);
+ } else if (t1vl != null) {
+ bind(t2gv, t1vl);
+ } else if (t2vl != null) {
+ bind(t1gv, t2vl);
+ } else { //if (t1gv != null && t2gv != null) {
+ // unify two vars
+ bind(t1gv, t2gv);
}
- //}
return true;
- }
-
- // t1 is var that doesn't occur in t2
- if (t1gisvar) {
- VarTerm t1gv = (VarTerm) t1g;
- // if t1g is not free, must unify values
- Term t1vl = function.get(t1gv);
- if (t1vl != null && !(t1vl instanceof VarsCluster))
- return unifiesNoUndo(t1vl,t2g);
- else if (!t2g.hasVar(t1gv))
- return setVarValue(t1gv, t2g);
- else
- return false;
- }
-
- // t2 is var that doesn't occur in t1
- if (t2gisvar) {
- VarTerm t2gv = (VarTerm) t2g;
- // if t1g is not free, must unify values
- Term t2vl = function.get(t2gv);
- if (t2vl != null && !(t2vl instanceof VarsCluster))
- return unifiesNoUndo(t2vl,t1g);
- else if (!t1g.hasVar(t2gv))
- return setVarValue(t2gv, t1g);
- else
- return false;
- }
-
+ }
+
// both terms are not vars
// if any of the terms is not a structure (is a number or a
@@ -300,21 +265,40 @@
return true;
}
-
- protected boolean setVarValue(VarTerm vt, Term value) {
- // if the var has a cluster, set value for all cluster
- Term currentVl = function.get(vt);
- if (currentVl != null && currentVl instanceof VarsCluster) {
- VarsCluster cluster = (VarsCluster) currentVl;
- for (VarTerm cvt : cluster)
- function.put(cvt, value); //(Term) value.clone()); // the clone is done in apply
- } else {
- // no value in cluster
- function.put((VarTerm) vt.clone(), value); //(Term) value.clone()); // the clone is done in apply
+
+ public VarTerm deref(VarTerm v) {
+ Term vl = function.get(v);
+ // original def (before optimise)
+ // if (vl != null && vl.isVar())
+ // return deref(vl);
+ // return v;
+
+ VarTerm first = v;
+ while (vl != null && vl.isVar()) {
+ v = (VarTerm)vl;
+ vl = function.get(v);
}
- return true;
+ if (first != v) {
+ function.put(first, v); // optimise map
+ }
+ return v;
}
-
+
+
+
+ public void bind(VarTerm vt1, VarTerm vt2) {
+ final int comp = vt1.compareTo(vt2);
+ if (comp < 0) {
+ function.put((VarTerm)vt1.clone(), vt2);
+ } else if (comp > 0){
+ function.put((VarTerm)vt2.clone(), vt1);
+ } // if they are the same (comp == 0), do not bind
+ }
+
+ private void bind(VarTerm vt, Term vl) {
+ function.put((VarTerm) vt.clone(), vl);
+ }
+
public void clear() {
function.clear();
}
Deleted: trunk/src/jason/asSemantics/VarsCluster.java
===================================================================
--- trunk/src/jason/asSemantics/VarsCluster.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSemantics/VarsCluster.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -1,130 +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.asSemantics;
-
-import jason.asSyntax.DefaultTerm;
-import jason.asSyntax.Term;
-import jason.asSyntax.VarTerm;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.logging.Logger;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- Stores a set of vars that were unified.
-
- E.g.: when X = Y = W = Z the unifier function maps
- X -> { X, Y, W, Z }
- Y -> { X, Y, W, Z }
- W -> { X, Y, W, Z }
- Z -> { X, Y, W, Z }
- where { X, Y, W, Z } is a VarsCluster instance.
-
- So when one var is assigned to a value, all vars in the
- cluster receive this same value.
-
- @author Jomi
-*/
-public class VarsCluster extends DefaultTerm implements Iterable<VarTerm> {
-
- private static final long serialVersionUID = 1L;
- private static Logger logger = Logger.getLogger(VarsCluster.class.getName());
-
- private static int idCount = 0;
-
- private int id = 0;
- private Set<VarTerm> vars = null;
- private Unifier u;
-
- // used in clone
- protected VarsCluster(Unifier u) {
- this.u = u;
- }
-
- public VarsCluster(VarTerm v1, VarTerm v2, Unifier u) {
- id = ++idCount;
- this.u = u;
- add(v1);
- add(v2);
- }
-
- private void add(VarTerm vt) {
- Term vl = u.get(vt);
- if (vl == null) { // vt is not in a VarsCluster
- if (vars == null)
- vars = new TreeSet<VarTerm>();
- vars.add(vt);
- } else if (vl instanceof VarsCluster) {
- // since vt is in a VarsCluster, join the two sets here
- if (vars == null)
- vars = ((VarsCluster) vl).vars;
- else
- vars.addAll(((VarsCluster) vl).vars);
- } else {
- logger.warning("joining var that has value!");
- }
- }
-
- public Iterator<VarTerm> iterator() {
- return vars.iterator();
- }
-
- public boolean equals(Object o) {
- if (o == null) return false;
- if (o == this) return true;
- if (o instanceof VarsCluster) return vars.equals(((VarsCluster) o).vars);
- return false;
- }
-
- public boolean hasValue() {
- return vars != null && !vars.isEmpty();
- }
-
- public Object clone() {
- VarsCluster c = new VarsCluster(u);
- c.vars = new HashSet<VarTerm>();
- for (VarTerm vt : this.vars) {
- c.vars.add((VarTerm) vt.clone());
- }
- return c;
- }
-
- protected int calcHashCode() {
- return vars.hashCode();
- }
-
- public Element getAsDOM(Document document) {
- return null;
- }
-
- public String toString() {
- return "_VC" + id;
- }
-}
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/Literal.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -185,9 +185,9 @@
// it is used to define what will be the unifier used
// inside the rule.
if (cloneAnnon == null) {
- cloneAnnon = (Literal)Literal.this.clone();
+ cloneAnnon = Literal.this.copy();
cloneAnnon.apply(un);
- cloneAnnon.makeVarsAnnon(null);
+ cloneAnnon.makeVarsAnnon(un);
}
Unifier ruleUn = new Unifier();
if (ruleUn.unifiesNoUndo(cloneAnnon, rule)) { // the rule head unifies with the literal
@@ -198,7 +198,7 @@
}
}
} else {
- Unifier u = (Unifier) un.clone();
+ Unifier u = un.copy();
if (u.unifiesNoUndo(Literal.this, b)) {
current = u;
return;
Modified: trunk/src/jason/asSyntax/ObjectTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/ObjectTermImpl.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/ObjectTermImpl.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -6,7 +6,8 @@
import org.w3c.dom.Element;
public class ObjectTermImpl extends DefaultTerm implements ObjectTerm {
-
+ private static final long serialVersionUID = 1L;
+
private final Object o;
private Method mclone;
private boolean hasTestedClone = false;
Modified: trunk/src/jason/asSyntax/PlanBodyImpl.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -17,6 +17,8 @@
*/
public class PlanBodyImpl extends Structure implements PlanBody, Iterable<PlanBody> {
+ private static final long serialVersionUID = 1L;
+
public static final String BODY_PLAN_FUNCTOR = ";";
private Term term = null;
Modified: trunk/src/jason/asSyntax/Pred.java
===================================================================
--- trunk/src/jason/asSyntax/Pred.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/Pred.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -417,27 +417,30 @@
* @param changes is the map of replacements
*/
@Override
- protected void makeVarsAnnon(Unifier un, Map<VarTerm,UnnamedVar> changes) {
+ public void makeVarsAnnon(Unifier un) {
if (annots != null) {
Iterator<ListTerm> i = annots.listTermIterator();
while (i.hasNext()) {
ListTerm lt = i.next();
Term ta = lt.getTerm();
- if (ta.isVar()) {
- // replace ta to an unnamed var
- UnnamedVar uv = changes.get(ta);
- if (uv == null) {
- VarTerm vt = (VarTerm)ta;
- uv = vt.preferredUnnamedVar(un);
- changes.put((VarTerm)ta, uv);
- }
- lt.setTerm(uv);
+
+ if (ta.isVar() && !ta.isUnnamedVar()) {
+ // replace ta to an unnamed var
+ VarTerm vt = un == null ? (VarTerm)ta : un.deref((VarTerm)ta);
+ UnnamedVar uv;
+ if (vt.isUnnamedVar()) {
+ uv = (UnnamedVar)vt;
+ } else {
+ uv = new UnnamedVar();
+ un.bind(vt, uv);
+ }
+ lt.setTerm(uv);
} else if (ta.isStructure()) {
- ((Structure)ta).makeVarsAnnon(un,changes);
+ ((Structure)ta).makeVarsAnnon(un);
}
}
}
- super.makeVarsAnnon(un, changes);
+ super.makeVarsAnnon(un);
}
@Override
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/Structure.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -308,35 +308,31 @@
return true;
}
- /** Replaces all variables of the term for unnamed variables (_). */
+ /** Replaces all variables by unnamed variables (_). */
public void makeVarsAnnon() {
- makeVarsAnnon(null, new HashMap<VarTerm,UnnamedVar>());
+ makeVarsAnnon(new Unifier());
}
- /** Replaces all variables of the term for unnamed variables (_).
- if un != null, unnamed vars unified to the var are preferred */
- public void makeVarsAnnon(Unifier un) {
- makeVarsAnnon(un, new HashMap<VarTerm,UnnamedVar>());
- }
-
- /** change all vars by unnamed vars, if un != null, unnamed vars unified to the var are preferred */
- protected void makeVarsAnnon(Unifier un, Map<VarTerm,UnnamedVar> changes) {
+ /** change all vars by unnamed vars, the unifier un is used to consistently replace vars. */
+ public void makeVarsAnnon(Unifier un) {
final int size = getArity();
for (int i=0; i<size; i++) {
Term ti = getTerm(i);
- if (ti.isVar()) {
+ if (ti.isVar() && !ti.isUnnamedVar()) {
// replace ti to an unnamed var
- UnnamedVar uv = changes.get(ti);
- if (uv == null) {
- VarTerm vt = (VarTerm)ti;
- uv = vt.preferredUnnamedVar(un);
- changes.put((VarTerm)ti, uv);
- }
- setTerm(i,uv);
+ VarTerm vt = un == null ? (VarTerm)ti : un.deref((VarTerm)ti);
+ UnnamedVar uv = null;
+ if (vt.isUnnamedVar()) {
+ uv = (UnnamedVar)vt;
+ } else {
+ uv = new UnnamedVar();
+ un.bind(vt, uv);
+ }
+ setTerm(i,uv);
} else if (ti.isStructure()) {
Structure tis = (Structure)ti;
if (tis.hasTerm()) {
- tis.makeVarsAnnon(un, changes);
+ tis.makeVarsAnnon(un);
}
}
}
Modified: trunk/src/jason/asSyntax/UnnamedVar.java
===================================================================
--- trunk/src/jason/asSyntax/UnnamedVar.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/UnnamedVar.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -67,11 +67,13 @@
return super.compareTo(t);
} else if (t instanceof UnnamedVar) {
if (myId > ((UnnamedVar)t).myId)
+ return -1;
+ else if (myId < ((UnnamedVar)t).myId)
return 1;
- else if (myId < ((UnnamedVar)t).myId)
- return -1;
else
return 0;
+ } else if (t instanceof VarTerm) {
+ return 1;
} else {
return super.compareTo(t);
}
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -25,7 +25,6 @@
import jason.asSemantics.Agent;
import jason.asSemantics.Unifier;
-import jason.asSemantics.VarsCluster;
import jason.asSyntax.parser.as2j;
import java.io.StringReader;
@@ -141,7 +140,7 @@
if (value == null) {
Term vl = u.get(this);
//System.out.println("applying "+this+"="+vl+" un="+u);
- if (vl != null && !(vl instanceof VarsCluster)) {
+ if (vl != null) { // && !(vl instanceof VarsCluster)) {
setValue(vl);
value.apply(u); // in case t has var args
return true;
@@ -151,20 +150,6 @@
}
return false;
}
-
- protected UnnamedVar preferredUnnamedVar(Unifier un) {
- if (un != null) {
- // check if I am in a var cluster with another unnamed var,
- // i.e. I am unified with an unnamed var,
- // then prefer that unnamed var instead of a new one
- Term vl = un.get(this);
- if (vl != null && vl instanceof VarsCluster)
- for (VarTerm v: (VarsCluster)vl)
- if (v.isUnnamedVar())
- return (UnnamedVar)v;
- }
- return new UnnamedVar();
- }
/**
* returns the value of this var.
@@ -200,6 +185,8 @@
public int compareTo(Term t) {
if (value != null)
return value.compareTo(t);
+ else if (t.isUnnamedVar())
+ return -1;
else
return super.compareTo(t);
}
Modified: trunk/src/test/TermTest.java
===================================================================
--- trunk/src/test/TermTest.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/test/TermTest.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -12,6 +12,7 @@
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
+import jason.asSyntax.UnnamedVar;
import jason.asSyntax.VarTerm;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
@@ -578,9 +579,9 @@
u.clear();
assertTrue(u.unifies(l1, l2));
l2.apply(u);
- assertEquals(l2.toString(), "calc(32,33,33)");
+ assertEquals("calc(32,33,33)", l2.toString());
l1.apply(u);
- assertEquals(l1.toString(), "calc(32,33,33)");
+ assertEquals("calc(32,33,33)", l1.toString());
}
public void testMakeVarAnnon3() {
@@ -591,7 +592,35 @@
assertEquals(3, v.size());
assertEquals("vl("+l1.getTerm(1)+")",l1.getAnnots("vl").get(0).toString());
}
+
+ public void testMakeVarAnnon4() {
+ Literal l = Literal.parseLiteral("p(X)");
+ Unifier u = new Unifier();
+ u.unifies(new UnnamedVar(4), new VarTerm("X"));
+ u.unifies(new VarTerm("X"), new UnnamedVar(2));
+ u.unifies(new UnnamedVar(2), new VarTerm("Y"));
+ u.unifies(new UnnamedVar(10), new VarTerm("Y"));
+ u.unifies(new VarTerm("X"), new VarTerm("Z"));
+ /*
+ Iterator<VarTerm> i = u.binds(new VarTerm("X"));
+ while (i.hasNext()) {
+ System.out.println(i.next());
+ }
+ */
+ l.makeVarsAnnon(u);
+ //System.out.println(u+ " "+l);
+ assertEquals("p(_2)", l.toString());
+ }
+ public void testMakeVarAnnon5() {
+ Literal l = Literal.parseLiteral("p(X,Y)[s(Y)]");
+ Unifier u = new Unifier();
+ u.unifies(new VarTerm("X"), new VarTerm("Y"));
+ l.makeVarsAnnon(u);
+ assertEquals(l.getTerm(0), l.getTerm(1));
+ assertEquals("[s("+l.getTerm(0)+")]", l.getAnnots().toString());
+ }
+
public void testAddAnnots() {
Literal p1 = Literal.parseLiteral("p1");
Literal p2 = Literal.parseLiteral("p2[a1,a2]");
Modified: trunk/src/test/VarTermTest.java
===================================================================
--- trunk/src/test/VarTermTest.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/test/VarTermTest.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -74,7 +74,6 @@
u.unifies(x9,x8);
u.unifies(x7,x4);
-
u.unifies(x3,new Structure("a"));
assertEquals(u.get(x1).toString(),"a");
assertEquals(u.get(x2).toString(),"a");
@@ -493,11 +492,14 @@
public void testUnnamedvarsorder() {
// the order is important for the "return" of plans/rules (where makeVarAnnon is used)
// the most recently created unnamed vars should come first
- List<UnnamedVar> l = new ArrayList<UnnamedVar>();
+ List<VarTerm> l = new ArrayList<VarTerm>();
l.add(new UnnamedVar(5));
+ l.add(new VarTerm("F"));
l.add(new UnnamedVar(6));
l.add(new UnnamedVar(11));
+ l.add(new VarTerm("B"));
Collections.sort(l);
- assertEquals("[_5, _6, _11]", l.toString());
+ assertEquals("[B, F, _11, _6, _5]", l.toString()); // this order is VERY important for unification!
}
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-08-19 09:19:18
|
Revision: 1356
http://jason.svn.sourceforge.net/jason/?rev=1356&view=rev
Author: jomifred
Date: 2008-08-19 09:19:09 +0000 (Tue, 19 Aug 2008)
Log Message:
-----------
fix minor issue in Jade/saci infra related to source path
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/demos/suspend-resume/test.asl
trunk/doc/index.html
trunk/examples/auction/AuctioneerGUI.java
trunk/examples/cleaning-robots/MarsEnv.java
trunk/examples/food-simulation/FoodSimulation.mas2j
trunk/examples/food-simulation/src/java/FoodEnvironment.java
trunk/src/jason/asSyntax/NumberTermImpl.java
trunk/src/jason/asSyntax/Pred.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/asSyntax/directives/Include.java
trunk/src/jason/infra/jade/JadeAgArch.java
trunk/src/jason/infra/saci/SaciAgArch.java
trunk/src/jason/mas2j/MAS2JProject.java
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-08-19 09:19:09 UTC (rev 1356)
@@ -142,7 +142,7 @@
+!change_to_herding[scheme(Sch),mission(Mission)]
: cow(_,_,_)
<- .print("ooo I see some cows, create the herding group");
- // check these cows are being herded by other group
+ // check whether the seen cows are being herded by other group
.findall(L, group_leader(_,L),Leaders);
!ask_all_cows(Leaders,LCows);
.findall(cow(ID,X,Y), cow(ID,X,Y), MyCows);
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-08-19 09:19:09 UTC (rev 1356)
@@ -58,7 +58,7 @@
!create_exploration_gr.
+!restart
<- .print("*** restart -- even ***");
- !quite_all_missions_roles;
+ !quit_all_missions_roles;
.my_name(Me);
// try to adopt scouter in some exploration
@@ -66,10 +66,10 @@
!try_adopt(scouter,LGE);
// if I still have no role, try herdboy
- if ( not play(Me,_,_) ) {
+ if ( not play(Me,_,_) ) {
.findall(GH, group(herding_grp,GH), LGH);
!try_adopt(herdboy,LGH)
- }.
+ }.
+!try_adopt(_Role,[]).
+!try_adopt(Role,[G|_])
@@ -135,7 +135,7 @@
.findall(Boy,play(Boy,herdboy,G),HerdBoys);
.send(HerdBoys, achieve, change_role(herdboy,GT))
};
- !quite_all_missions_roles;
+ !quit_all_missions_roles;
jmoise.adopt_role(NewRole,GT).
// causes a loop:
@@ -148,7 +148,7 @@
<- .print("ooo Adopting role ",Role," in group ",Group,", as asked by ",Ag);
jmoise.adopt_role(Role, Group).
-+!quite_all_missions_roles
++!quit_all_missions_roles
<- .my_name(Me);
// give up all missions
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-08-19 09:19:09 UTC (rev 1356)
@@ -98,6 +98,7 @@
.send(gaucho5,achieve,create_exploration_gr);
.send(gaucho6,achieve,restart).
*/
+// TODO: find a nice solution for this plan!
+!release_boys[scheme(Sch),mission(Mission),group(Gr)]
: .count(play(_,herdboy,Gr),N) &
(N > 3 | (N > 1 & current_cluster(CAsList) & .length(CAsList) < 5))
Modified: trunk/demos/suspend-resume/test.asl
===================================================================
--- trunk/demos/suspend-resume/test.asl 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/demos/suspend-resume/test.asl 2008-08-19 09:19:09 UTC (rev 1356)
@@ -12,7 +12,7 @@
<- .print(".");
!!dots.
-// another loop that resumes and suspend the start
+// another loop that resumes and suspend the "dops" goal
+!control
<- .wait(30);
.suspend(dots); // suspend the intention with goal dots
Modified: trunk/doc/index.html
===================================================================
--- trunk/doc/index.html 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/doc/index.html 2008-08-19 09:19:09 UTC (rev 1356)
@@ -40,7 +40,8 @@
<li><a href="http://sourceforge.net/mail/?group_id=98417">Mailing lists</a>
<li><a href="http://jason.sourceforge.net/JasonWebSite/Examples/Examples.html">Examples</a>
<li><a href="http://jason.sourceforge.net/JasonWebSite/Demos.html">Demos</a>
- <li><a href="http://jason.sourceforge.net/JasonWebSite/Publications.html">Publications</a>
+ <li><a href="http://jason.sourceforge.net/JasonWebSite/Documents.html">Publications</a>
+ <li><a href="http://jason.sourceforge.net/JasonWebSite/Related%20Projects.html">Related projects</a>
</ul>
</li>
<br/>
Modified: trunk/examples/auction/AuctioneerGUI.java
===================================================================
--- trunk/examples/auction/AuctioneerGUI.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/examples/auction/AuctioneerGUI.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -41,9 +41,13 @@
if (action.getActionTerm().getFunctor().startsWith("show_winner")) {
jt.append("Winner of auction " + action.getActionTerm().getTerm(0));
jt.append(" is " + action.getActionTerm().getTerm(1) + "\n");
- auction.setEnabled(true);
+ action.setResult(true);
+ feedback.add(action);
+
+ auction.setEnabled(true); // enable GUI button
+ } else {
+ super.act(action,feedback); // send the action to the environment to be performed.
}
- super.act(action,feedback); // send the action to the environment to be performed.
}
public void stopAg() {
Modified: trunk/examples/cleaning-robots/MarsEnv.java
===================================================================
--- trunk/examples/cleaning-robots/MarsEnv.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/examples/cleaning-robots/MarsEnv.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -37,6 +37,7 @@
@Override
public boolean executeAction(String ag, Structure action) {
+ logger.info(ag+" doing: "+ action);
try {
if (action.equals(ns)) {
model.nextSlot();
Modified: trunk/examples/food-simulation/FoodSimulation.mas2j
===================================================================
--- trunk/examples/food-simulation/FoodSimulation.mas2j 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/examples/food-simulation/FoodSimulation.mas2j 2008-08-19 09:19:09 UTC (rev 1356)
@@ -53,6 +53,8 @@
MAS normative_simulation {
+ infrastructure: Centralised
+
// the class that implements the environment is FoodEnvironment
// parameters are: grid size, number of agents, number of food units
environment: FoodEnvironment(10,50,25)
Modified: trunk/examples/food-simulation/src/java/FoodEnvironment.java
===================================================================
--- trunk/examples/food-simulation/src/java/FoodEnvironment.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/examples/food-simulation/src/java/FoodEnvironment.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -165,7 +165,7 @@
if (name != null) {
updateAgPercept(name, ag);
} else {
- logger.warning("Can not give perception to "+ag+" bacause it is no registered!");
+ logger.warning("Can not give perception to "+ag+" because it is no registered!");
}
}
Modified: trunk/src/jason/asSyntax/NumberTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/NumberTermImpl.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/asSyntax/NumberTermImpl.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -77,14 +77,11 @@
public boolean equals(Object o) {
if (o == this) return true;
- if (o != null && o instanceof Term && ((Term)o).isNumeric()) {
+ if (o != null && o instanceof Term && ((Term)o).isNumeric() && !((Term)o).isArithExpr()) {
NumberTerm st = (NumberTerm)o;
- if (st.isVar() || st.isArithExpr())
- return false;
- else
- try {
- return solve() == st.solve();
- } catch (Exception e) { }
+ try {
+ return solve() == st.solve();
+ } catch (Exception e) { }
}
return false;
}
Modified: trunk/src/jason/asSyntax/Pred.java
===================================================================
--- trunk/src/jason/asSyntax/Pred.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/asSyntax/Pred.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -426,7 +426,7 @@
if (ta.isVar() && !ta.isUnnamedVar()) {
// replace ta to an unnamed var
- VarTerm vt = un == null ? (VarTerm)ta : un.deref((VarTerm)ta);
+ VarTerm vt = un.deref((VarTerm)ta);
UnnamedVar uv;
if (vt.isUnnamedVar()) {
uv = (UnnamedVar)vt;
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/asSyntax/Structure.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -320,8 +320,8 @@
Term ti = getTerm(i);
if (ti.isVar() && !ti.isUnnamedVar()) {
// replace ti to an unnamed var
- VarTerm vt = un == null ? (VarTerm)ti : un.deref((VarTerm)ti);
- UnnamedVar uv = null;
+ VarTerm vt = un.deref((VarTerm)ti);
+ UnnamedVar uv;
if (vt.isUnnamedVar()) {
uv = (UnnamedVar)vt;
} else {
Modified: trunk/src/jason/asSyntax/directives/Include.java
===================================================================
--- trunk/src/jason/asSyntax/directives/Include.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/asSyntax/directives/Include.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -90,13 +90,13 @@
return f;
} else if (srcpath != null) {
for (String path: srcpath) {
- File newname = new File(path + "/" + f.toString());
- if (newname.exists()) {
- try {
+ try {
+ File newname = new File(path + "/" + f.toString());
+ if (newname.exists()) {
return newname.getCanonicalFile().toString();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
}
}
}
Modified: trunk/src/jason/infra/jade/JadeAgArch.java
===================================================================
--- trunk/src/jason/infra/jade/JadeAgArch.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/infra/jade/JadeAgArch.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -382,7 +382,7 @@
try {
Term acTerm = action.getActionTerm();
- logger.info("doing: " + acTerm);
+ logger.fine("doing: " + acTerm);
rwid++;
String rw = "id"+rwid;
Modified: trunk/src/jason/infra/saci/SaciAgArch.java
===================================================================
--- trunk/src/jason/infra/saci/SaciAgArch.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/infra/saci/SaciAgArch.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -422,7 +422,7 @@
TransitionSystem ts = userAgArch.getTS();
try {
Term acTerm = action.getActionTerm();
- logger.info("doing: " + acTerm);
+ logger.fine("doing: " + acTerm);
String rw = mboxPercept.getRW();
saci.Message m = new saci.Message("(ask :receiver environment :ontology AS-Action :content execute)");
Modified: trunk/src/jason/mas2j/MAS2JProject.java
===================================================================
--- trunk/src/jason/mas2j/MAS2JProject.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/mas2j/MAS2JProject.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -89,10 +89,6 @@
}
}
- public boolean isDefaultDirectory() {
- return projectDir.equals(".");
- }
-
public String getDirectory() {
return projectDir;
}
@@ -198,10 +194,11 @@
r.add(getDirectory());
}
for (String p: sourcepaths) {
- if (getDirectory().startsWith(".") || getDirectory().startsWith("/") || getDirectory().charAt(1) == ':') {
+ //if (getDirectory().startsWith(".") || getDirectory().startsWith("/") || getDirectory().charAt(1) == ':') {
+ if (p.startsWith(".") || p.startsWith("/") || p.charAt(1) == ':') {
r.add(p);
} else {
- r.add(getDirectory()+File.separator+p);
+ r.add(getDirectory()+"/"+p);
}
}
return r;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-08-29 08:46:13
|
Revision: 1357
http://jason.svn.sourceforge.net/jason/?rev=1357&view=rev
Author: jomifred
Date: 2008-08-29 08:46:07 +0000 (Fri, 29 Aug 2008)
Log Message:
-----------
make attributes of ClassParameters private
Modified Paths:
--------------
trunk/applications/jason-moise/readme.txt
trunk/demos/suspend-resume/test.asl
trunk/doc/faq/faq.tex
trunk/doc/index.html
trunk/examples/food-simulation/FoodSimulation.mas2j
trunk/src/jason/architecture/AgArch.java
trunk/src/jason/infra/centralised/CentralisedEnvironment.java
trunk/src/jason/infra/centralised/CentralisedExecutionControl.java
trunk/src/jason/infra/centralised/CentralisedRuntimeServices.java
trunk/src/jason/infra/centralised/RunCentralisedMAS.java
trunk/src/jason/infra/centralised/StartNewAgentGUI.java
trunk/src/jason/infra/jade/JadeAgArch.java
trunk/src/jason/infra/jade/JadeEnvironment.java
trunk/src/jason/infra/jade/JadeExecutionControl.java
trunk/src/jason/infra/saci/SaciMASLauncherAnt.java
trunk/src/jason/mas2j/AgentParameters.java
trunk/src/jason/mas2j/ClassParameters.java
trunk/src/jason/mas2j/MAS2JProject.java
trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc
trunk/src/jason/mas2j/parser/mas2j.java
Added Paths:
-----------
trunk/doc/jason.doxygen
Modified: trunk/applications/jason-moise/readme.txt
===================================================================
--- trunk/applications/jason-moise/readme.txt 2008-08-19 09:19:09 UTC (rev 1356)
+++ trunk/applications/jason-moise/readme.txt 2008-08-29 08:46:07 UTC (rev 1357)
@@ -1,7 +1,7 @@
This Jason application exemplifies how to develop agent in an organised
society based on the Moise+ organisational model (http://moise.sf.net).
-To run the some applications using JasonIDE, open a project
+To run some application, using JasonIDE open the project
example/writePaper/writePaper.mas2j
or
example/auction/orgAuction.mas2j
Modified: trunk/demos/suspend-resume/test.asl
===================================================================
--- trunk/demos/suspend-resume/test.asl 2008-08-19 09:19:09 UTC (rev 1356)
+++ trunk/demos/suspend-resume/test.asl 2008-08-29 08:46:07 UTC (rev 1357)
@@ -12,7 +12,7 @@
<- .print(".");
!!dots.
-// another loop that resumes and suspend the "dops" goal
+// another loop that resumes and suspend the "dots" goal
+!control
<- .wait(30);
.suspend(dots); // suspend the intention with goal dots
Modified: trunk/doc/faq/faq.tex
===================================================================
--- trunk/doc/faq/faq.tex 2008-08-19 09:19:09 UTC (rev 1356)
+++ trunk/doc/faq/faq.tex 2008-08-29 08:46:07 UTC (rev 1357)
@@ -27,8 +27,15 @@
% ---------------------------------------------------------------------
\section{Platform Name}
-\subsection{Does the name "Jason" have anything to do with a horror film?}
-NO! \jason is a hero in Greek mythology. Click
+\subsection{Why is the platform called "Jason"?}
+
+Jason initially stood for `\textbf{J}ava-based \textbf{A}gentSpeak interpreter
+used with \textbf{S}ACI for multi-agent distribution \textbf{o}ver the
+\textbf{n}et'. Since it not based only on SACI anymore (other infrastructures
+are available) and the acronyms was quite `forced', we decided the use Jason
+as a proper name for the interpreter.
+
+We are also somehow inspired by the \jason as a hero in Greek mythology. Click
\begin{rawhtml}
<a
href="http://www.perseus.tufts.edu/cgi-bin/ptext?doc=Perseus%3Atext%3A1999.04.0004%3Ahead%3D%234815">here</a>
Modified: trunk/doc/index.html
===================================================================
--- trunk/doc/index.html 2008-08-19 09:19:09 UTC (rev 1356)
+++ trunk/doc/index.html 2008-08-29 08:46:07 UTC (rev 1357)
@@ -20,7 +20,7 @@
<li><a href="api/jason/stdlib/package-summary.html#package_description">Stantard internal actions</a> (html)</li>
<li><a href="api/jason/functions/package-summary.html">Stantard arithmetic functions</a> (html)</li>
-<li><a href="api/index.html">API of all classes</a> (html)</li><br>
+<li><a href="api-doxygen/html/index.html">API of all classes</a> (html)</li><br>
<li><a href="AS2JavaParser.html">Syntax of AgentSpeak</a> as
interpreted by <a href="http://jason.sf.net"><b><i>Jason</i></b></a> (html
Added: trunk/doc/jason.doxygen
===================================================================
--- trunk/doc/jason.doxygen (rev 0)
+++ trunk/doc/jason.doxygen 2008-08-29 08:46:07 UTC (rev 1357)
@@ -0,0 +1,1417 @@
+# Doxyfile 1.5.6
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = Jason
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = 1.1.3
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = doc/api-doxygen
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek,
+# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish,
+# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish,
+# and Ukrainian.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH = src/jason
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = Yes
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member
+# documentation.
+
+DETAILS_AT_TOP = YES
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 4
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = YES
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = YES
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page. This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = src/jason
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS = *.java
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH ...
[truncated message content] |
|
From: <jom...@us...> - 2008-08-29 09:59:31
|
Revision: 1359
http://jason.svn.sourceforge.net/jason/?rev=1359&view=rev
Author: jomifred
Date: 2008-08-29 09:59:27 +0000 (Fri, 29 Aug 2008)
Log Message:
-----------
use doxygen apidoc
Modified Paths:
--------------
trunk/build.xml
trunk/doc/index.html
trunk/doc/jason.doxygen
trunk/src/jason/functions/time.java
trunk/src/jason/stdlib/time.java
Added Paths:
-----------
trunk/src/jason/stdlib/package.dox
Removed Paths:
-------------
trunk/src/jason/stdlib/package.html
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-08-29 09:22:29 UTC (rev 1358)
+++ trunk/build.xml 2008-08-29 09:59:27 UTC (rev 1359)
@@ -259,6 +259,7 @@
</delete>
<delete dir="${distDir}/bin/classes" />
<delete dir="${distDir}/doc/faq" />
+ <delete dir="${distDir}/doc/api" />
<delete dir="${distDir}/doc/mini-tutorial/src" />
<tar compression="gzip" tarfile="${distFile}.tgz">
Modified: trunk/doc/index.html
===================================================================
--- trunk/doc/index.html 2008-08-29 09:22:29 UTC (rev 1358)
+++ trunk/doc/index.html 2008-08-29 09:59:27 UTC (rev 1359)
@@ -17,8 +17,8 @@
<li><a href="faq.html">FAQ</a> (html)</li><br/>
-<li><a href="api/jason/stdlib/package-summary.html#package_description">Stantard internal actions</a> (html)</li>
-<li><a href="api/jason/functions/package-summary.html">Stantard arithmetic functions</a> (html)</li>
+<li><a href="api-doxygen/html/namespacejason_1_1stdlib.html">Stantard internal actions</a> (html)</li>
+<li><a href="api-doxygen/html/namespacejason_1_1functions.html">Stantard arithmetic functions</a> (html)</li>
<li><a href="api-doxygen/html/index.html">API of all classes</a> (html)</li><br>
Modified: trunk/doc/jason.doxygen
===================================================================
--- trunk/doc/jason.doxygen 2008-08-29 09:22:29 UTC (rev 1358)
+++ trunk/doc/jason.doxygen 2008-08-29 09:59:27 UTC (rev 1359)
@@ -551,7 +551,7 @@
# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
-FILE_PATTERNS = *.java
+FILE_PATTERNS = *.java *.dox
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
Modified: trunk/src/jason/functions/time.java
===================================================================
--- trunk/src/jason/functions/time.java 2008-08-29 09:22:29 UTC (rev 1358)
+++ trunk/src/jason/functions/time.java 2008-08-29 09:59:27 UTC (rev 1359)
@@ -8,6 +8,8 @@
<p>Function: <b><code>system.time</code></b>: encapsulates java System.currentTimeMillis(),
returns the current time in milliseconds.
+ @see jason.stdlib.time
+
@author Jomi
*/
public class time extends DefaultArithFunction {
Added: trunk/src/jason/stdlib/package.dox
===================================================================
--- trunk/src/jason/stdlib/package.dox (rev 0)
+++ trunk/src/jason/stdlib/package.dox 2008-08-29 09:59:27 UTC (rev 1359)
@@ -0,0 +1,127 @@
+/*! @package jason.stdlib
+
+Provides all default internal actions of Jason.
+
+<h2>BDI</h2>
+<ul>
+ <li>{@link jason.stdlib.desire desire}: check agent's desires.</li>
+ <li>{@link jason.stdlib.drop_desire drop_desire}: remove one agent's desire.</li>
+ <li>{@link jason.stdlib.drop_all_desires drop_all_desires}: remove agent's desires.</li>
+
+
+ <li>{@link jason.stdlib.intend intend}: check agent's intentions.</li>
+ <li>{@link jason.stdlib.drop_intention drop_intention}: remove one agent's intention.</li>
+ <li>{@link jason.stdlib.drop_all_intentions drop_all_intentions}: remove agent's intentions.</li>
+ <li>{@link jason.stdlib.current_intention current_intention}: get a description of the
+ current intention.</li>
+
+ <li>{@link jason.stdlib.drop_event drop_event}: remove one event.</li>
+ <li>{@link jason.stdlib.drop_all_events drop_all_events}: remove events in the interpreter.</li>
+
+ <li>{@link jason.stdlib.succeed_goal succeed_goal}: abort some goal with success.</li>
+ <li>{@link jason.stdlib.fail_goal fail_goal}: abort some goal with failure.</li>
+
+ <li>{@link jason.stdlib.suspend suspend}: suspend intentions.</li>
+ <li>{@link jason.stdlib.resume resume}: resume suspended intentions.</li>
+</ul>
+
+<h2>Belief base</h2>
+<ul>
+ <li>{@link jason.stdlib.abolish abolish}: remove some beliefs.</li>
+ <li>{@link jason.stdlib.findall findall}: find all beliefs of some kind.</li>
+ <li>{@link jason.stdlib.count count}: count the number of beliefs of some kind.</li>
+</ul>
+
+
+<h2>Plan Library</h2>
+<ul>
+ <li>{@link jason.stdlib.add_plan add_plan}: add new plans.</li>
+ <li>{@link jason.stdlib.remove_plan remove_plan}: remove a plan.</li>
+ <li>{@link jason.stdlib.plan_label plan_label}: get the label of a plan.</li>
+ <li>{@link jason.stdlib.relevant_plans relevant_plans}: get a list of plans.</li>
+</ul>
+
+
+
+<h2>Communication</h2>
+<ul>
+ <li>{@link jason.stdlib.send send}: send messages. </li>
+ <li>{@link jason.stdlib.broadcast broadcast}: broadcast messages.</li>
+ <li>{@link jason.stdlib.my_name my_name}: get the agent's name.</li>
+</ul>
+
+
+<h2>Lists and Sets</h2>
+<ul>
+ <li>{@link jason.stdlib.member member}: list members. </li>
+ <li>{@link jason.stdlib.length length}: size of lists. </li>
+
+ <li>{@link jason.stdlib.concat concat}: concat lists. </li>
+ <li>{@link jason.stdlib.delete delete}: delete members of a lists. </li>
+
+ <li>{@link jason.stdlib.reverse reverse}: reverse lists. </li>
+ <li>{@link jason.stdlib.nth nth}: nth element of a lists. </li>
+ <li>{@link jason.stdlib.max max}: maximum value of a lists. </li>
+ <li>{@link jason.stdlib.min min}: minimum value of a lists. </li>
+ <li>{@link jason.stdlib.sort sort}: sort lists. </li>
+ <li>{@link jason.stdlib.list list}: check whether an argument is a list.</li>
+
+ <li>{@link jason.stdlib.difference difference}: difference of sets. </li>
+ <li>{@link jason.stdlib.intersection intersection}: intersection of sets. </li>
+ <li>{@link jason.stdlib.union union}: union of sets. </li>
+
+</ul>
+
+
+<h2>String</h2>
+<ul>
+ <li>{@link jason.stdlib.length length}: size of strings. </li>
+ <li>{@link jason.stdlib.concat concat}: append strings. </li>
+ <li>{@link jason.stdlib.delete delete}: delete characters of a string. </li>
+ <li>{@link jason.stdlib.reverse reverse}: reverse strings. </li>
+ <li>{@link jason.stdlib.substring substring}: test substrings of strings. </li>
+ <li>{@link jason.stdlib.string string}: check whether an argument is a string.</li>
+ <li>{@link jason.stdlib.term2string term2string}: convert terms to strings and vice-versa.</li>
+</ul>
+
+<h2>Execution control</h2>
+<ul>
+ <li>{@link jason.stdlib.conditional if}: implementation of <b>if</b>.</li>
+ <li>{@link jason.stdlib.loop while}: implementation of <b>while</b>.</li>
+ <li>{@link jason.stdlib.foreach for}: implementation of <b>for</b>.</li>
+</ul>
+
+
+<h2>Meta programming</h2>
+<ul>
+ <li>{@link jason.stdlib.atom atom}: check whether an argument is an atom (p).</li>
+ <li>{@link jason.stdlib.structure structure}: check whether an argument is a structure (p(t1,t2), [a,b]).</li>
+ <li>{@link jason.stdlib.literal literal}: check whether an argument is a literal (p(t1,t2), ~p(t1,t2), p(t1,t2)[a1,a2]).</li>
+ <li>{@link jason.stdlib.list list}: check whether an argument is a list ([a,b]).</li>
+ <li>{@link jason.stdlib.ground ground}: check whether an argument is ground.</li>
+ <li>{@link jason.stdlib.number number}: check whether an argument is a number (1, 2.3).</li>
+ <li>{@link jason.stdlib.string string}: check whether an argument is a string ("s").</li>
+ <li>{@link jason.stdlib.ground ground}: check whether an argument is ground.</li>
+ <li>{@link jason.stdlib.add_annot add_annot}: add an annotation in a literal.</li>
+ <li>{@link jason.stdlib.add_nested_source add_nested_source}: add a source in a literal.</li>
+</ul>
+
+
+<h2>Miscellaneous</h2>
+<ul>
+ <li>{@link jason.stdlib.at at}: add a future event.</li>
+ <li>{@link jason.stdlib.wait wait}: wait some event.</li>
+
+ <li>{@link jason.stdlib.create_agent create_agent}: create a new agent.</li>
+ <li>{@link jason.stdlib.kill_agent kill_agent}: kill an agent.</li>
+ <li>{@link jason.stdlib.stopMAS stopMAS}: stop all agents.</li>
+
+ <li>{@link jason.stdlib.date date}: get the current date.</li>
+ <li>{@link jason.stdlib.time time}: get the current time.</li>
+ <li>{@link jason.stdlib.fail fail}: an action that always fails.</li>
+ <li>{@link jason.stdlib.perceive perceive}: force perception.</li>
+ <li>{@link jason.stdlib.range range}: backtrack values in a range (used in <b>for</b>).</li>
+</ul>
+
+*/
+
Deleted: trunk/src/jason/stdlib/package.html
===================================================================
--- trunk/src/jason/stdlib/package.html 2008-08-29 09:22:29 UTC (rev 1358)
+++ trunk/src/jason/stdlib/package.html 2008-08-29 09:59:27 UTC (rev 1359)
@@ -1,129 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<body bgcolor="white">
-
-Provides all default internal actions of Jason.
-
-<h2>BDI</h2>
-<ul>
- <li>{@link jason.stdlib.desire}: check agent's desires.</li>
- <li>{@link jason.stdlib.drop_desire}: remove one agent's desire.</li>
- <li>{@link jason.stdlib.drop_all_desires}: remove agent's desires.</li>
-
-
- <li>{@link jason.stdlib.intend}: check agent's intentions.</li>
- <li>{@link jason.stdlib.drop_intention}: remove one agent's intention.</li>
- <li>{@link jason.stdlib.drop_all_intentions}: remove agent's intentions.</li>
- <li>{@link jason.stdlib.current_intention}: get a description of the
- current intention.</li>
-
- <li>{@link jason.stdlib.drop_event}: remove one event.</li>
- <li>{@link jason.stdlib.drop_all_events}: remove events in the interpreter.</li>
-
- <li>{@link jason.stdlib.succeed_goal}: abort some goal with success.</li>
- <li>{@link jason.stdlib.fail_goal}: abort some goal with failure.</li>
-
- <li>{@link jason.stdlib.suspend}: suspend intentions.</li>
- <li>{@link jason.stdlib.resume}: resume suspended intentions.</li>
-</ul>
-
-<h2>Belief base</h2>
-<ul>
- <li>{@link jason.stdlib.abolish}: remove some beliefs.</li>
- <li>{@link jason.stdlib.findall}: find all beliefs of some kind.</li>
- <li>{@link jason.stdlib.count}: count the number of beliefs of some kind.</li>
-</ul>
-
-
-<h2>Plan Library</h2>
-<ul>
- <li>{@link jason.stdlib.add_plan}: add new plans.</li>
- <li>{@link jason.stdlib.remove_plan}: remove a plan.</li>
- <li>{@link jason.stdlib.plan_label}: get the label of a plan.</li>
- <li>{@link jason.stdlib.relevant_plans}: get a list of plans.</li>
-</ul>
-
-
-
-<h2>Communication</h2>
-<ul>
- <li>{@link jason.stdlib.send}: send messages. </li>
- <li>{@link jason.stdlib.broadcast}: broadcast messages.</li>
- <li>{@link jason.stdlib.my_name}: get the agent's name.</li>
-</ul>
-
-
-<h2>Lists and Sets</h2>
-<ul>
- <li>{@link jason.stdlib.member}: list members. </li>
- <li>{@link jason.stdlib.length}: size of lists. </li>
-
- <li>{@link jason.stdlib.concat}: concat lists. </li>
- <li>{@link jason.stdlib.delete}: delete members of a lists. </li>
-
- <li>{@link jason.stdlib.reverse}: reverse lists. </li>
- <li>{@link jason.stdlib.nth}: nth element of a lists. </li>
- <li>{@link jason.stdlib.max}: maximum value of a lists. </li>
- <li>{@link jason.stdlib.min}: minimum value of a lists. </li>
- <li>{@link jason.stdlib.sort}: sort lists. </li>
- <li>{@link jason.stdlib.list}: check whether an argument is a list.</li>
-
- <li>{@link jason.stdlib.difference}: difference of sets. </li>
- <li>{@link jason.stdlib.intersection}: intersection of sets. </li>
- <li>{@link jason.stdlib.union}: union of sets. </li>
-
-</ul>
-
-
-<h2>String</h2>
-<ul>
- <li>{@link jason.stdlib.length}: size of strings. </li>
- <li>{@link jason.stdlib.concat}: append strings. </li>
- <li>{@link jason.stdlib.delete}: delete characters of a string. </li>
- <li>{@link jason.stdlib.reverse}: reverse strings. </li>
- <li>{@link jason.stdlib.substring}: test substrings of strings. </li>
- <li>{@link jason.stdlib.string}: check whether an argument is a string.</li>
- <li>{@link jason.stdlib.term2string}: convert terms to strings and vice-versa.</li>
-</ul>
-
-<h2>Execution control</h2>
-<ul>
- <li>{@link jason.stdlib.conditional}: implementation of <b>if</b>.</li>
- <li>{@link jason.stdlib.loop}: implementation of <b>while</b>.</li>
- <li>{@link jason.stdlib.foreach}: implementation of <b>for</b>.</li>
-</ul>
-
-
-<h2>Meta programming</h2>
-<ul>
- <li>{@link jason.stdlib.atom}: check whether an argument is an atom (p).</li>
- <li>{@link jason.stdlib.structure}: check whether an argument is a structure (p(t1,t2), [a,b]).</li>
- <li>{@link jason.stdlib.literal}: check whether an argument is a literal (p(t1,t2), ~p(t1,t2), p(t1,t2)[a1,a2]).</li>
- <li>{@link jason.stdlib.list}: check whether an argument is a list ([a,b]).</li>
- <li>{@link jason.stdlib.ground}: check whether an argument is ground.</li>
- <li>{@link jason.stdlib.number}: check whether an argument is a number (1, 2.3).</li>
- <li>{@link jason.stdlib.string}: check whether an argument is a string ("s").</li>
- <li>{@link jason.stdlib.ground}: check whether an argument is ground.</li>
- <li>{@link jason.stdlib.add_annot}: add an annotation in a literal.</li>
- <li>{@link jason.stdlib.add_nested_source}: add a source in a literal.</li>
-</ul>
-
-
-<h2>Miscellaneous</h2>
-<ul>
- <li>{@link jason.stdlib.at}: add a future event.</li>
- <li>{@link jason.stdlib.wait}: wait some event.</li>
-
- <li>{@link jason.stdlib.create_agent}: create a new agent.</li>
- <li>{@link jason.stdlib.kill_agent}: kill an agent.</li>
- <li>{@link jason.stdlib.stopMAS}: stop all agents.</li>
-
- <li>{@link jason.stdlib.date}: get the current date.</li>
- <li>{@link jason.stdlib.time}: get the current time.</li>
- <li>{@link jason.stdlib.fail}: an action that always fails.</li>
- <li>{@link jason.stdlib.perceive}: force perception.</li>
- <li>{@link jason.stdlib.range}: backtrack values in a range (used in <b>for</b>).</li>
-</ul>
-
-</body>
-</html>
Modified: trunk/src/jason/stdlib/time.java
===================================================================
--- trunk/src/jason/stdlib/time.java 2008-08-29 09:22:29 UTC (rev 1358)
+++ trunk/src/jason/stdlib/time.java 2008-08-29 09:59:27 UTC (rev 1359)
@@ -36,6 +36,7 @@
</ul>
@see jason.stdlib.date
+ @see jason.functions.time
*/
public class time extends DefaultInternalAction {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-09-09 08:57:25
|
Revision: 1361
http://jason.svn.sourceforge.net/jason/?rev=1361&view=rev
Author: jomifred
Date: 2008-09-09 08:57:21 +0000 (Tue, 09 Sep 2008)
Log Message:
-----------
the source of beliefs can now be strings
Modified Paths:
--------------
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/src/jason/asSyntax/Pred.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/bb/BeliefBase.java
trunk/src/jason/bb/DefaultBeliefBase.java
trunk/src/jason/functions/time.java
trunk/src/jason/stdlib/time.java
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-09-07 11:13:09 UTC (rev 1360)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-09-09 08:57:21 UTC (rev 1361)
@@ -53,7 +53,7 @@
*/
public class OrgAgent extends AgArch {
- private static final Term managerSource = Pred.createSource("orgManager");
+ private static final Term managerSource = Pred.createSource(new Atom("orgManager"));
private static final Atom rootAtom = new Atom("root");
private Logger logger = Logger.getLogger(OrgAgent.class.getName());
Modified: trunk/src/jason/asSyntax/Pred.java
===================================================================
--- trunk/src/jason/asSyntax/Pred.java 2008-09-07 11:13:09 UTC (rev 1360)
+++ trunk/src/jason/asSyntax/Pred.java 2008-09-09 08:57:21 UTC (rev 1361)
@@ -230,6 +230,27 @@
return removed;
}
+ /**
+ * returns all annots with the specified functor e.g.: from annots
+ * [t(a), t(b), source(tom)]
+ * and functor "t",
+ * it returns [t(a),t(b)]
+ */
+ public ListTerm getAnnots(String functor) {
+ ListTerm ls = new ListTermImpl();
+ if (annots != null) {
+ ListTerm tail = ls;
+ for (Term ta : annots) {
+ if (ta.isStructure()) {
+ if (((Structure)ta).getFunctor().equals(functor)) {
+ tail = tail.append(ta);
+ }
+ }
+ }
+ }
+ return ls;
+ }
+
/** returns true if all this predicate annots are in p's annots */
public boolean hasSubsetAnnot(Pred p) {
if (annots == null) return true;
@@ -307,26 +328,21 @@
/**
* Adds a source annotation like "source(<i>agName</i>)".
*/
- public void addSource(Structure agName) {
+ public void addSource(Term agName) {
if (agName != null)
addAnnot(createSource(agName));
}
/** deletes "source(<i>agName</i>)" */
- public boolean delSource(Structure agName) {
+ public boolean delSource(Term agName) {
if (annots != null)
return annots.remove(createSource(agName));
else
return false;
}
- public static Term createSource(String source) {
+ public static Term createSource(Term source) {
Structure s = new Structure("source",1);
- s.addTerm(new Atom(source));
- return s;
- }
- public static Term createSource(Structure source) {
- Structure s = new Structure("source",1);
s.addTerm(source);
return s;
}
@@ -351,27 +367,6 @@
return ls;
}
- /**
- * returns all annots with the specified functor e.g.: from annots
- * [t(a), t(b), source(tom)]
- * and functor "t",
- * it returns [t(a),t(b)]
- */
- public ListTerm getAnnots(String functor) {
- ListTerm ls = new ListTermImpl();
- if (annots != null) {
- ListTerm tail = ls;
- for (Term ta : annots) {
- if (ta.isStructure()) {
- if (((Structure)ta).getFunctor().equals(functor)) {
- tail = tail.append(ta);
- }
- }
- }
- }
- return ls;
- }
-
/** deletes all sources annotations */
public void delSources() {
if (annots != null) {
@@ -401,11 +396,9 @@
}
/** returns true if this pred has a "source(<i>agName</i>)" */
- public boolean hasSource(Structure agName) {
+ public boolean hasSource(Term agName) {
if (annots != null) {
- Structure ts = new Structure("source");
- ts.addTerm(agName);
- return annots.contains(ts);
+ return annots.contains(createSource(agName));
}
return false;
}
@@ -414,7 +407,7 @@
/**
* Replaces all variables of the term for unnamed variables (_).
*
- * @param un is the unifier that containt the map of replacements
+ * @param un is the unifier that contains the map of replacements
*/
@Override
public void makeVarsAnnon(Unifier un) {
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-09-07 11:13:09 UTC (rev 1360)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-09-09 08:57:21 UTC (rev 1361)
@@ -512,7 +512,7 @@
}
@Override
- public void addSource(Structure t) {
+ public void addSource(Term t) {
if (value != null && getValue().isPred())
((Pred) getValue()).addSource(t);
else
@@ -521,7 +521,7 @@
}
@Override
- public boolean delSource(Structure s) {
+ public boolean delSource(Term s) {
if (value != null && getValue().isPred())
return ((Pred) getValue()).delSource(s);
else
@@ -553,7 +553,7 @@
}
@Override
- public boolean hasSource(Structure s) {
+ public boolean hasSource(Term s) {
if (value != null && getValue().isPred())
return ((Pred) getValue()).hasSource(s);
else
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-09-07 11:13:09 UTC (rev 1360)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-09-09 08:57:21 UTC (rev 1361)
@@ -460,12 +460,14 @@
/* List of terms */
-List terms() : { List listTerms = new ArrayList(); Term v; PlanBody o; }
+List terms() : { ArrayList listTerms = new ArrayList(); Term v; PlanBody o; }
{
v=term() { listTerms.add(v); }
( "," v=term() { listTerms.add(v); }
)*
- { return listTerms; }
+ { listTerms.trimToSize();
+ return listTerms;
+ }
}
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-09-07 11:13:09 UTC (rev 1360)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-09-09 08:57:21 UTC (rev 1361)
@@ -647,7 +647,7 @@
/* List of terms */
final public List terms() throws ParseException {
- List listTerms = new ArrayList(); Term v; PlanBody o;
+ ArrayList listTerms = new ArrayList(); Term v; PlanBody o;
v = term();
listTerms.add(v);
label_10:
@@ -664,6 +664,7 @@
v = term();
listTerms.add(v);
}
+ listTerms.trimToSize();
{if (true) return listTerms;}
throw new Error("Missing return statement in function");
}
@@ -1233,13 +1234,13 @@
return false;
}
- final private boolean jj_3R_13() {
- if (jj_scan_token(39)) return true;
+ final private boolean jj_3R_17() {
+ if (jj_scan_token(42)) return true;
return false;
}
- final private boolean jj_3R_17() {
- if (jj_scan_token(42)) return true;
+ final private boolean jj_3R_13() {
+ if (jj_scan_token(39)) return true;
return false;
}
Modified: trunk/src/jason/bb/BeliefBase.java
===================================================================
--- trunk/src/jason/bb/BeliefBase.java 2008-09-07 11:13:09 UTC (rev 1360)
+++ trunk/src/jason/bb/BeliefBase.java 2008-09-09 08:57:21 UTC (rev 1361)
@@ -25,6 +25,7 @@
import jason.asSemantics.Agent;
import jason.asSemantics.Unifier;
+import jason.asSyntax.Atom;
import jason.asSyntax.Literal;
import jason.asSyntax.Pred;
import jason.asSyntax.PredicateIndicator;
@@ -42,8 +43,8 @@
*/
public interface BeliefBase extends Iterable<Literal>, Cloneable {
- public static final Term TPercept = Pred.createSource("percept");
- public static final Term TSelf = Pred.createSource("self");
+ public static final Term TPercept = Pred.createSource(new Atom("percept"));
+ public static final Term TSelf = Pred.createSource(new Atom("self"));
/**
* Called before the MAS execution with the agent that uses this
Modified: trunk/src/jason/bb/DefaultBeliefBase.java
===================================================================
--- trunk/src/jason/bb/DefaultBeliefBase.java 2008-09-07 11:13:09 UTC (rev 1360)
+++ trunk/src/jason/bb/DefaultBeliefBase.java 2008-09-09 08:57:21 UTC (rev 1361)
@@ -272,10 +272,11 @@
@SuppressWarnings("unchecked")
public void add(Literal l, boolean addInEnd) {
- try {
+ //try {
// minimise the allocation space of terms
- if (!l.isAtom()) ((ArrayList) l.getTerms()).trimToSize();
- } catch (Exception e) {}
+ // Moved to the parser.
+ // if (!l.isAtom()) ((ArrayList) l.getTerms()).trimToSize();
+ //} catch (Exception e) {}
map.put(new LiteralWrapper(l), l);
if (addInEnd) {
Modified: trunk/src/jason/functions/time.java
===================================================================
--- trunk/src/jason/functions/time.java 2008-09-07 11:13:09 UTC (rev 1360)
+++ trunk/src/jason/functions/time.java 2008-09-09 08:57:21 UTC (rev 1361)
@@ -8,7 +8,7 @@
<p>Function: <b><code>system.time</code></b>: encapsulates java System.currentTimeMillis(),
returns the current time in milliseconds.
- @see jason.stdlib.time
+ @see jason.stdlib.time internal action time
@author Jomi
*/
Modified: trunk/src/jason/stdlib/time.java
===================================================================
--- trunk/src/jason/stdlib/time.java 2008-09-07 11:13:09 UTC (rev 1360)
+++ trunk/src/jason/stdlib/time.java 2008-09-09 08:57:21 UTC (rev 1361)
@@ -36,7 +36,7 @@
</ul>
@see jason.stdlib.date
- @see jason.functions.time
+ @see jason.functions.time function time
*/
public class time extends DefaultInternalAction {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-09-09 11:44:04
|
Revision: 1362
http://jason.svn.sourceforge.net/jason/?rev=1362&view=rev
Author: jomifred
Date: 2008-09-09 11:44:01 +0000 (Tue, 09 Sep 2008)
Log Message:
-----------
put jedit jars in the lib directory
Modified Paths:
--------------
trunk/build.xml
trunk/doc/faq/faq.tex
Added Paths:
-----------
trunk/lib/jedit/
trunk/lib/jedit/BufferTabs.jar
trunk/lib/jedit/ErrorList.jar
trunk/lib/jedit/SideKick.jar
trunk/lib/jedit/jedit.jar
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-09-09 08:57:21 UTC (rev 1361)
+++ trunk/build.xml 2008-09-09 11:44:01 UTC (rev 1362)
@@ -19,7 +19,7 @@
<property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" />
<property name="distFile" value="${env.HOME}/Jason-${version}.${release}" />
- <property name="jedit.install.dir" value="${basedir}/bin/jedit" />
+ <property name="jedit.install.dir" value="${basedir}/lib/jedit" />
<property name="plugin.jar.name" value="jason-jedit-plugin.jar" />
<path id="run.classpath">
@@ -36,8 +36,8 @@
<pathelement location="${basedir}/lib/ant-launcher.jar" />
<pathelement location="${basedir}/lib/ant.jar" />
<pathelement location="${basedir}/demos/persistent-belief-base/lib/hsqldb.jar" />
- <pathelement location="${jedit.install.dir}/jars/ErrorList.jar" />
- <pathelement location="${jedit.install.dir}/jars/SideKick.jar" />
+ <pathelement location="${jedit.install.dir}/ErrorList.jar" />
+ <pathelement location="${jedit.install.dir}/SideKick.jar" />
<pathelement location="${jasonJar}" />
</path>
@@ -223,6 +223,9 @@
windowtitle="Jason - AgentSpeak Java Interpreter">
<classpath refid="project.classpath" />
</javadoc>
+ <exec executable="doxygen">
+ <arg line="doc/jason.doxygen"/>
+ </exec>
</target>
<target name="dist" depends="cleanExamples,plugin" description="Build distribution.">
Modified: trunk/doc/faq/faq.tex
===================================================================
--- trunk/doc/faq/faq.tex 2008-09-09 08:57:21 UTC (rev 1361)
+++ trunk/doc/faq/faq.tex 2008-09-09 11:44:01 UTC (rev 1362)
@@ -25,7 +25,7 @@
% ---------------------------------------------------------------------
-\section{Platform Name}
+\section{General}
\subsection{Why is the platform called "Jason"?}
@@ -842,11 +842,6 @@
ant plugin
\end{verbatim}
-\textbb{Note}: if you are using Eclipse, set the output directory as
-\texttt{bin/classes}.
-
-
-
\item create the API documentation:
\begin{verbatim}
ant apidoc
@@ -857,4 +852,16 @@
\end{enumerate}
+\subsection{How to create an Eclipse project for \jason?}
+
+\begin{enumerate}
+\item Select new Java Project wizard in Eclipse.
+\item In "create project from existing source" select the directory where
+ \Jason is installed. [Next]
+\item Set \texttt{"src"} directory for the sources.
+\item Set \texttt{"bin/classes"} for "Default output folder".
+\item Add all jars in \texttt{"lib"} for "Libraries". [Finish]
+\end{enumerate}
+
+
\end{document}
Property changes on: trunk/lib/jedit/BufferTabs.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/lib/jedit/ErrorList.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/lib/jedit/SideKick.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/lib/jedit/jedit.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-09-10 11:52:54
|
Revision: 1364
http://jason.svn.sourceforge.net/jason/?rev=1364&view=rev
Author: jomifred
Date: 2008-09-10 11:52:51 +0000 (Wed, 10 Sep 2008)
Log Message:
-----------
rename SuspendIA to ConcurrentIA
wake up the agent in timeout operations (.wait, .send ask, .at, ...)
Modified Paths:
--------------
trunk/demos/gui/gui1/gui/yes_no.java
trunk/demos/gui/gui1/sample.asl
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/stdlib/at.java
trunk/src/jason/stdlib/send.java
trunk/src/jason/stdlib/wait.java
Added Paths:
-----------
trunk/src/jason/asSemantics/ConcurrentInternalAction.java
Removed Paths:
-------------
trunk/src/jason/asSemantics/SuspendInternalAction.java
Modified: trunk/demos/gui/gui1/gui/yes_no.java
===================================================================
--- trunk/demos/gui/gui1/gui/yes_no.java 2008-09-10 09:42:28 UTC (rev 1363)
+++ trunk/demos/gui/gui1/gui/yes_no.java 2008-09-10 11:52:51 UTC (rev 1364)
@@ -6,7 +6,7 @@
import javax.swing.JOptionPane;
-public class yes_no extends SuspendInternalAction {
+public class yes_no extends ConcurrentInternalAction {
private Logger logger = Logger.getLogger("gui."+yes_no.class.getName());
@@ -14,20 +14,20 @@
public Object execute(final TransitionSystem ts, Unifier un, final Term[] args) throws Exception {
try {
// suspend the intention (max 5 seconds)
- final String key = suspend(ts, "gui", 5000);
+ final String key = suspendInt(ts, "gui", 5000);
// to not block the agent thread,
- // create a new thread that show the GUI and resume the intention latter
- new Thread() {
+ // create a new task that show the GUI and resume the intention latter
+ startInternalAction(ts, new Runnable() {
public void run() {
int answer = JOptionPane.showConfirmDialog(null, args[0].toString());
- // resume the intention with success
+
if (answer == JOptionPane.YES_OPTION)
- yes_no.this.resume(ts, key);
+ resumeInt(ts, key); // resume the intention with success
else
- fail(ts, key);
+ failInt(ts, key); // resume the intention with fail
}
- }.start();
+ });
return true;
} catch (Exception e) {
@@ -44,6 +44,6 @@
//resume(ts,intentionKey);
// 2: fail
- fail(ts, intentionKey);
+ failInt(ts, intentionKey);
}
}
Modified: trunk/demos/gui/gui1/sample.asl
===================================================================
--- trunk/demos/gui/gui1/sample.asl 2008-09-10 09:42:28 UTC (rev 1363)
+++ trunk/demos/gui/gui1/sample.asl 2008-09-10 11:52:51 UTC (rev 1364)
@@ -1,7 +1,7 @@
/* Initial goals */
!start.
-!print.
+!print(system.time).
/* Plans */
@@ -14,6 +14,6 @@
+!start <- gui.yes_no("Is it Ok?"); .print(ok).
-!start <- .print(nok).
-+!print <- .wait(500); .print("."); !!print.
++!print(S) <- .wait(500); .print(". ", system.time-S); !!print(system.time).
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-09-10 09:42:28 UTC (rev 1363)
+++ trunk/src/jason/asSemantics/Agent.java 2008-09-10 11:52:51 UTC (rev 1364)
@@ -206,7 +206,7 @@
public ScheduledExecutorService getScheduler() {
if (scheduler == null)
- scheduler = Executors.newScheduledThreadPool(1);
+ scheduler = Executors.newScheduledThreadPool(2);
return scheduler;
}
Copied: trunk/src/jason/asSemantics/ConcurrentInternalAction.java (from rev 1363, trunk/src/jason/asSemantics/SuspendInternalAction.java)
===================================================================
--- trunk/src/jason/asSemantics/ConcurrentInternalAction.java (rev 0)
+++ trunk/src/jason/asSemantics/ConcurrentInternalAction.java 2008-09-10 11:52:51 UTC (rev 1364)
@@ -0,0 +1,102 @@
+package jason.asSemantics;
+
+import jason.asSyntax.InternalActionLiteral;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
+import jason.asSyntax.Term;
+import jason.asSyntax.PlanBody.BodyType;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+
+ This class can be used in place of DefaultInternalAction to create an IA that
+ suspend the intention while it is being executed.
+
+ Example: a plan may ask something to an user and wait the answer.
+ If DefaultInternalAction is used for that, all the agent thread is blocked until
+ the answer. With SuspendInternalAction, only the intention using the IA is
+ suspended. See demos/gui/gui1.
+
+ @author jomi
+*/
+public abstract class ConcurrentInternalAction implements InternalAction {
+
+ private static int actcount = 0;
+
+ public boolean canBeUsedInContext() {
+ return false;
+ }
+
+ public boolean suspendIntention() {
+ return true;
+ }
+
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ return false;
+ }
+
+ /**
+ * Suspend the current intention, put it in the PendingIntention (PI) structure and assigns it to a key.
+ *
+ * @param ts the "engine" of the agent
+ * @param basekey the base key to form final key used to get the intention back from PI (e.g. "moise", "cartago", ...)
+ * @param timeout the max time the intention will be in PI, the value 0 means until "resume"
+ * @return the final key used to store the intention in PI, this key is used the resume the intention
+ */
+ public String suspendInt(final TransitionSystem ts, String basekey, int timeout) {
+ final String key = basekey + "/" + (actcount++);
+ final Circumstance C = ts.getC();
+ Intention i = C.getSelectedIntention();
+ i.setSuspended(true);
+ C.getPendingIntentions().put(key, i);
+
+ if (timeout > 0) {
+ // schedule a future test of the end of the action
+ ts.getAg().getScheduler().schedule( new Runnable() {
+ public void run() {
+ // finish the IA by timeout
+ if (C.getPendingIntentions().get(key) != null) { // test if the intention is still there
+ timeout(ts,key);
+ }
+ }
+ }, timeout, TimeUnit.MILLISECONDS);
+ }
+ return key;
+ }
+
+ public void startInternalAction(TransitionSystem ts, Runnable code) {
+ ts.getAg().getScheduler().execute(code);
+ //new Thread(code).start();
+ }
+
+ /** called back when some intention should be resumed/failed by timeout */
+ abstract public void timeout(TransitionSystem ts, String intentionKey);
+
+ /** resume the intention identified by intentionKey */
+ public void resumeInt(TransitionSystem ts, String intentionKey) {
+ resume(ts, intentionKey, false);
+ }
+
+ /** fails the intention identified by intentionKey */
+ public void failInt(TransitionSystem ts, String intentionKey) {
+ resume(ts, intentionKey, true);
+ }
+
+ synchronized private void resume(TransitionSystem ts, String intentionKey, boolean abort) {
+ Circumstance C = ts.getC();
+ Intention pi = C.getPendingIntentions().remove(intentionKey);
+ if (pi != null) {
+ pi.setSuspended(false);
+ C.addIntention(pi); // add it back in I
+ pi.peek().removeCurrentStep(); // remove the internal action that put the intention in suspend
+
+ if (abort) {
+ // fail the IA
+ PlanBody pbody = pi.peek().getPlan().getBody();
+ pbody.add(0, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
+ }
+ ts.getUserAgArch().getArchInfraTier().wake();
+ }
+ }
+}
Deleted: trunk/src/jason/asSemantics/SuspendInternalAction.java
===================================================================
--- trunk/src/jason/asSemantics/SuspendInternalAction.java 2008-09-10 09:42:28 UTC (rev 1363)
+++ trunk/src/jason/asSemantics/SuspendInternalAction.java 2008-09-10 11:52:51 UTC (rev 1364)
@@ -1,97 +0,0 @@
-package jason.asSemantics;
-
-import jason.asSyntax.InternalActionLiteral;
-import jason.asSyntax.PlanBody;
-import jason.asSyntax.PlanBodyImpl;
-import jason.asSyntax.Term;
-import jason.asSyntax.PlanBody.BodyType;
-
-import java.util.concurrent.TimeUnit;
-
-/**
-
- This class can be used in place of DefaultInternalAction to create an IA that
- suspend the intention while it is being executed.
-
- Example: a plan may ask something to an user and wait the answer.
- If DefaultInternalAction is used for that, all the agent thread is blocked until
- the answer. With SuspendInternalAction, only the intention using the IA is
- suspended. See demos/gui/gui1.
-
- @author jomi
-*/
-public abstract class SuspendInternalAction implements InternalAction {
-
- private static int actcount = 0;
-
- public boolean canBeUsedInContext() {
- return false;
- }
-
- public boolean suspendIntention() {
- return true;
- }
-
- public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- return false;
- }
-
- /**
- * Suspend the current intention, put it in the PendingIntention (PI) structure and assigns it to a key.
- *
- * @param ts the "engine" of the agent
- * @param basekey the base key to form final key used to get the intention back from PI (e.g. "moise", "cartago", ...)
- * @param timeout the max time the intention will be in PI, the value 0 means until "resume"
- * @return the final key used to store the intention in PI
- */
- public String suspend(final TransitionSystem ts, String basekey, int timeout) {
- final String key = basekey + "/" + (actcount++);
- final Circumstance C = ts.getC();
- Intention i = C.getSelectedIntention();
- i.setSuspended(true);
- C.getPendingIntentions().put(key, i);
-
- if (timeout > 0) {
- // schedule a future test of the end of the action
- ts.getAg().getScheduler().schedule( new Runnable() {
- public void run() {
- // finish the IA by timeout
- if (C.getPendingIntentions().get(key) != null) { // test if the intention is still there
- timeout(ts,key);
- }
- }
- }, timeout, TimeUnit.MILLISECONDS);
- }
- return key;
- }
-
- /** called back when some intention should be resumed/failed by timeout */
- abstract public void timeout(TransitionSystem ts, String intentionKey);
-
- /** resume the intention identified by intentionKey */
- public void resume(TransitionSystem ts, String intentionKey) {
- resume(ts, intentionKey, false);
- }
-
- /** fails the intention identified by intentionKey */
- public void fail(TransitionSystem ts, String intentionKey) {
- resume(ts, intentionKey, true);
- }
-
- synchronized private void resume(TransitionSystem ts, String intentionKey, boolean abort) {
- Circumstance C = ts.getC();
- Intention pi = C.getPendingIntentions().remove(intentionKey);
- if (pi != null) {
- pi.setSuspended(false);
- C.addIntention(pi); // add it back in I
- pi.peek().removeCurrentStep(); // remove the internal action that put the intention in suspend
-
- if (abort) {
- // fail the IA
- PlanBody pbody = pi.peek().getPlan().getBody();
- pbody.add(0, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
- }
- ts.getUserAgArch().getArchInfraTier().wake();
- }
- }
-}
Modified: trunk/src/jason/stdlib/at.java
===================================================================
--- trunk/src/jason/stdlib/at.java 2008-09-10 09:42:28 UTC (rev 1363)
+++ trunk/src/jason/stdlib/at.java 2008-09-10 11:52:51 UTC (rev 1364)
@@ -25,7 +25,6 @@
package jason.stdlib;
import jason.JasonException;
-import jason.asSemantics.Circumstance;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.Event;
import jason.asSemantics.Intention;
@@ -121,7 +120,7 @@
Trigger te = Trigger.parseTrigger(sevent.getString());
- ts.getAg().getScheduler().schedule(new CheckDeadline(te, ts.getC()), deadline, TimeUnit.MILLISECONDS);
+ ts.getAg().getScheduler().schedule(new CheckDeadline(te, ts), deadline, TimeUnit.MILLISECONDS);
return true;
} catch (ArrayIndexOutOfBoundsException e) {
throw new JasonException("The internal action 'at' has not received two arguments.");
@@ -137,17 +136,16 @@
}
class CheckDeadline implements Runnable {
-
private int id = 0;
private Event event;
- private Circumstance c;
+ private TransitionSystem ts;
private boolean cancelled = false;
- public CheckDeadline(Trigger te, Circumstance c) {
+ public CheckDeadline(Trigger te, TransitionSystem ts) {
idCount++;
this.id = idCount;
this.event = new Event(te, Intention.EmptyInt);
- this.c = c;
+ this.ts = ts;
ats.put(id, this);
}
@@ -157,8 +155,10 @@
public void run() {
try {
- if (!cancelled)
- c.addEvent(event);
+ if (!cancelled) {
+ ts.getC().addEvent(event);
+ ts.getUserAgArch().getArchInfraTier().wake();
+ }
} finally {
ats.remove(id);
}
Modified: trunk/src/jason/stdlib/send.java
===================================================================
--- trunk/src/jason/stdlib/send.java 2008-09-10 09:42:28 UTC (rev 1363)
+++ trunk/src/jason/stdlib/send.java 2008-09-10 11:52:51 UTC (rev 1364)
@@ -204,7 +204,7 @@
intention.peek().getUnif().unifies(send.getTerm(3), new Atom("timeout"));
// add the intention back in C.I
ts.getC().addIntention(intention);
- System.out.println("OK");
+ ts.getUserAgArch().getArchInfraTier().wake();
}
}
}, (long)((NumberTerm)tto).solve(), TimeUnit.MILLISECONDS);
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2008-09-10 09:42:28 UTC (rev 1363)
+++ trunk/src/jason/stdlib/wait.java 2008-09-10 11:52:51 UTC (rev 1364)
@@ -191,6 +191,7 @@
} else {
c.addIntention(si);
}
+ ts.getUserAgArch().getArchInfraTier().wake();
}
} catch (Exception e) {
ts.getLogger().log(Level.SEVERE, "Error at .wait thread", e);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-09-11 14:22:23
|
Revision: 1365
http://jason.svn.sourceforge.net/jason/?rev=1365&view=rev
Author: jomifred
Date: 2008-09-11 14:22:12 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
add chains of BBs
and a demo to illustrate (demo/chain-bb)
add a new custom BB: indexedBB (developed for the JasonTeam in the AgentContest 2008)
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java
trunk/build.xml
trunk/demos/gui/gui1/gui/yes_no.java
trunk/demos/persistent-belief-base/bookstore.properties
trunk/demos/persistent-belief-base/bookstore.script
trunk/demos/persistent-belief-base/c.asl
trunk/demos/persistent-belief-base/custBelBase.mas2j
trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java
trunk/release-notes.txt
trunk/src/jason/architecture/AgArch.java
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/ConcurrentInternalAction.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/LogicalFormula.java
trunk/src/jason/bb/DefaultBeliefBase.java
trunk/src/jason/bb/JDBCPersistentBB.java
trunk/src/jason/bb/TextPersistentBB.java
trunk/src/jason/infra/centralised/CentralisedAgArch.java
trunk/src/jason/infra/centralised/CentralisedRuntimeServices.java
trunk/src/jason/infra/centralised/RunCentralisedMAS.java
trunk/src/jason/infra/jade/JadeAgArch.java
trunk/src/jason/infra/saci/SaciMASLauncherAnt.java
trunk/src/jason/mas2j/AgentParameters.java
trunk/src/jason/mas2j/MAS2JProject.java
trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc
trunk/src/jason/mas2j/parser/mas2j.java
trunk/src/test/MAS2JParserTest.java
Added Paths:
-----------
trunk/demos/chain-bb/
trunk/demos/chain-bb/bob.asl
trunk/demos/chain-bb/chain-bb.mas2j
trunk/src/jason/bb/ChainBB.java
trunk/src/jason/bb/ChainBBAdapter.java
trunk/src/jason/bb/IndexedBB.java
Modified: trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -4,8 +4,10 @@
import jason.JasonException;
import jason.RevisionFailedException;
import jason.asSemantics.Agent;
+import jason.asSemantics.Circumstance;
import jason.asSemantics.Event;
import jason.asSemantics.Intention;
+import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.Literal;
import jason.asSyntax.LogExpr;
@@ -39,7 +41,11 @@
arch = new TestArch();
else
arch = new TestArch(agName);
- arch.getUserAgArch().setTS(initAg(arch.getUserAgArch(), null, null, new Settings()));
+
+ TransitionSystem ts = new TransitionSystem(this, new Circumstance(), new Settings(), arch.getUserAgArch());
+ setTS(ts);
+ arch.getUserAgArch().setTS(ts);
+ initAg(null);
} catch (JasonException e) {
logger.log(Level.SEVERE, "Error creating TestArch", e);
}
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/build.xml 2008-09-11 14:22:12 UTC (rev 1365)
@@ -19,11 +19,11 @@
<property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" />
<property name="distFile" value="${env.HOME}/Jason-${version}.${release}" />
- <property name="jedit.install.dir" value="${basedir}/lib/jedit" />
+ <property name="jedit.install.dir" value="${basedir}/bin/jedit" />
<property name="plugin.jar.name" value="jason-jedit-plugin.jar" />
<path id="run.classpath">
- <pathelement location="${jedit.install.dir}/jedit.jar" />
+ <pathelement location="${basedir}/lib/jedit/jedit.jar" />
<pathelement location="${saciJar}" />
<pathelement location="${jadeJar}" />
<pathelement location="${jadeHttpJar}" />
@@ -36,8 +36,8 @@
<pathelement location="${basedir}/lib/ant-launcher.jar" />
<pathelement location="${basedir}/lib/ant.jar" />
<pathelement location="${basedir}/demos/persistent-belief-base/lib/hsqldb.jar" />
- <pathelement location="${jedit.install.dir}/ErrorList.jar" />
- <pathelement location="${jedit.install.dir}/SideKick.jar" />
+ <pathelement location="${basedir}/lib/jedit/ErrorList.jar" />
+ <pathelement location="${basedir}/lib/jedit/SideKick.jar" />
<pathelement location="${jasonJar}" />
</path>
@@ -255,17 +255,18 @@
<fileset dir="${basedir}" includes="src/**/*" />
</copy>
- <delete failonerror="no" includeEmptyDirs="true">
+ <!--delete failonerror="no" includeEmptyDirs="true">
<fileset dir="${distDir}" includes=".settings" />
<fileset dir="${distDir}" includes=".project" />
<fileset dir="${distDir}" includes=".classpath" />
- </delete>
+ </delete -->
<delete dir="${distDir}/bin/classes" />
+ <delete dir="${distDir}/bin/classes-eclipse" />
<delete dir="${distDir}/doc/faq" />
<delete dir="${distDir}/doc/api" />
<delete dir="${distDir}/doc/mini-tutorial/src" />
- <tar compression="gzip" tarfile="${distFile}.tgz">
+ <tar compression="gzip" tarfile="${distFile}.tgz" longfile="gnu">
<tarfileset dir="${distDir}/.." mode="755">
<include name="Jason-${version}.${release}/**/*.sh" />
<include name="Jason-${version}.${release}/**/asl2*" />
@@ -300,7 +301,7 @@
<fileset dir="${basedir}/examples" includes="**/MTPs-Main-Container.txt" />
<fileset dir="${basedir}/demos" includes="**/MTPs-Main-Container.txt" />
- <fileset dir="${basedir}/examples/Sniffer" includes="log.*" />
+ <fileset dir="${basedir}/examples/sniffer" includes="log.*" />
<fileset dir="${basedir}/demos/persistent-belief-base" includes="a.bb" />
<fileset defaultexcludes="no" dir="${basedir}" includes="**/*~" />
Added: trunk/demos/chain-bb/bob.asl
===================================================================
--- trunk/demos/chain-bb/bob.asl (rev 0)
+++ trunk/demos/chain-bb/bob.asl 2008-09-11 14:22:12 UTC (rev 1365)
@@ -0,0 +1,17 @@
+// Agent bob in project chainBB.mas2j
+
+/* Initial beliefs and rules */
+
+/* Initial goals */
+
+!start.
+
+/* Plans */
+
++!start : true
+ <- +boss(1,"Vercouter");
+ +boss(2,"Rosine");
+ +boss(2,"Boissier"); // will replace "boss(2,Rosine)" since both have the same key
+ +boss(math.round(math.random(10)), "Picard");
+ ?boss(2,X); .print("Boss 2 is ",X).
+
Added: trunk/demos/chain-bb/chain-bb.mas2j
===================================================================
--- trunk/demos/chain-bb/chain-bb.mas2j (rev 0)
+++ trunk/demos/chain-bb/chain-bb.mas2j 2008-09-11 14:22:12 UTC (rev 1365)
@@ -0,0 +1,29 @@
+/* Jason Project
+
+ Example of chain belief bases.
+
+ The agent bob uses two customisations of BB:
+ one to persist the beliefs and
+ another to have a king of key based BB.
+
+ To see the effect of the two BBs, run the program
+ and, when finished, click on "Debug" mode and then
+ select "bob" agent. Notice that the boss beliefs have
+ unique keys. If you run the program again you will
+ note that beliefs added in previous executions
+ are persisted (they are stored in the bob.bb file).
+
+*/
+
+MAS chainBB {
+
+ infrastructure: Centralised
+
+ agents:
+ bob beliefBaseClass jason.bb.ChainBB(
+ jason.bb.TextPersistentBB,
+ jason.bb.IndexedBB("boss(key,_)") // the first argument of boss is the key
+ );
+
+}
+
Modified: trunk/demos/gui/gui1/gui/yes_no.java
===================================================================
--- trunk/demos/gui/gui1/gui/yes_no.java 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/demos/gui/gui1/gui/yes_no.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -41,7 +41,7 @@
public void timeout(TransitionSystem ts, String intentionKey) {
// this method have to decide what to do with actions finished by timeout
// 1: resume
- //resume(ts,intentionKey);
+ //resumeInt(ts,intentionKey);
// 2: fail
failInt(ts, intentionKey);
Modified: trunk/demos/persistent-belief-base/bookstore.properties
===================================================================
--- trunk/demos/persistent-belief-base/bookstore.properties 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/demos/persistent-belief-base/bookstore.properties 2008-09-11 14:22:12 UTC (rev 1365)
@@ -1,5 +1,5 @@
#HSQL Database Engine
-#Sat Jul 05 11:30:42 CEST 2008
+#Thu Sep 11 15:58:11 CEST 2008
hsqldb.script_format=0
runtime.gc_interval=0
sql.enforce_strict_size=false
Modified: trunk/demos/persistent-belief-base/bookstore.script
===================================================================
--- trunk/demos/persistent-belief-base/bookstore.script 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/demos/persistent-belief-base/bookstore.script 2008-09-11 14:22:12 UTC (rev 1365)
@@ -28,4 +28,4 @@
INSERT INTO PUBLISHER VALUES(1,'Springer')
INSERT INTO PUBLISHER VALUES(2,'MIT Press')
INSERT INTO PUBLISHER VALUES(3,'John Wiley & Sons')
-INSERT INTO TABLEA VALUES('45',FALSE,'[source(self)]')
+INSERT INTO TABLEA VALUES('49',FALSE,'[source(self)]')
Modified: trunk/demos/persistent-belief-base/c.asl
===================================================================
--- trunk/demos/persistent-belief-base/c.asl 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/demos/persistent-belief-base/c.asl 2008-09-11 14:22:12 UTC (rev 1365)
@@ -31,4 +31,4 @@
// Rules used to show all books
show_all_titles :- book(_, Title, _, _Year, _ISBN) & .println("-- ", Title) & false.
-show_all_titles.
+show_all_titles :- true.
Modified: trunk/demos/persistent-belief-base/custBelBase.mas2j
===================================================================
--- trunk/demos/persistent-belief-base/custBelBase.mas2j 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/demos/persistent-belief-base/custBelBase.mas2j 2008-09-11 14:22:12 UTC (rev 1365)
@@ -27,7 +27,7 @@
"org.hsqldb.jdbcDriver", // driver for HSQLDB
"jdbc:hsqldb:bookstore", // URL connection
"sa", // user
- "", // password
+ "", // password
"[a(1,tablea,columns(runs(integer))),book(5),book_author(2),author(2,author,columns(id(integer),name(varchar(30)))),publisher(2)]");
// predicate a/1 is mapped to a table called "tablea" with an integer column called runs;
// the name and type of the columns is used only if the table does not exits and
Modified: trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java
===================================================================
--- trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -2,8 +2,9 @@
import jason.architecture.AgArch;
import jason.asSemantics.ActionExec;
import jason.asSemantics.Agent;
+import jason.asSemantics.Circumstance;
+import jason.asSemantics.TransitionSystem;
import jason.asSyntax.Literal;
-import jason.bb.DefaultBeliefBase;
import jason.infra.centralised.RunCentralisedMAS;
import jason.runtime.Settings;
@@ -32,7 +33,8 @@
// set up the Jason agent
try {
Agent ag = new Agent();
- setTS(ag.initAg(this, new DefaultBeliefBase(), "demo.asl", new Settings()));
+ new TransitionSystem(ag, new Circumstance(), new Settings(), this);
+ ag.initAg("demo.asl");
} catch (Exception e) {
logger.log(Level.SEVERE, "Init error", e);
}
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/release-notes.txt 2008-09-11 14:22:12 UTC (rev 1365)
@@ -2,6 +2,14 @@
version 1.1.3
-------------
+New features
+. customised belief bases can be organised in a chain so
+ that several functionalities can be composed. For more
+ information
+ see/run the demo/chain-bb
+ see API doc of ChainBB and ChainBBAdapter
+
+
New internal actions
. .term2string: transform term into strings and vice-versa.
Modified: trunk/src/jason/architecture/AgArch.java
===================================================================
--- trunk/src/jason/architecture/AgArch.java 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/src/jason/architecture/AgArch.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -25,6 +25,7 @@
import jason.JasonException;
import jason.asSemantics.ActionExec;
import jason.asSemantics.Agent;
+import jason.asSemantics.Circumstance;
import jason.asSemantics.Message;
import jason.asSemantics.TransitionSystem;
import jason.asSyntax.Literal;
@@ -71,9 +72,14 @@
// set the agent
try {
Agent ag = (Agent) Class.forName(agClass).newInstance();
+
+ new TransitionSystem(ag, new Circumstance(), stts, this);
+
BeliefBase bb = (BeliefBase) Class.forName(bbPars.getClassName()).newInstance();
- ts = ag.initAg(this, bb, asSrc, stts);
+ ag.setBB(bb); // the agent's BB have to be already set for the BB initialisation
bb.init(ag, bbPars.getParametersArray());
+
+ ag.initAg(asSrc); // load the source code of the agent
} catch (Exception e) {
throw new JasonException("as2j: error creating the agent class! - ", e);
}
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/src/jason/asSemantics/Agent.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -42,7 +42,6 @@
import jason.bb.DefaultBeliefBase;
import jason.functions.Count;
import jason.functions.RuleToFunction;
-import jason.runtime.Settings;
import java.io.File;
import java.io.FileInputStream;
@@ -103,31 +102,11 @@
checkCustomSelectOption();
}
- private void checkCustomSelectOption() {
- hasCustomSelOp = false;
- for (Method m: this.getClass().getMethods()) {
- if (!m.getDeclaringClass().equals(Agent.class) && m.getName().equals("selectOption")) {
- hasCustomSelOp = true;
- }
- }
- }
-
- public boolean hasCustomSelectOption() {
- return hasCustomSelOp;
- }
-
- /** Creates the TS of this agent, parses its AS source, and sets its Settings */
- public TransitionSystem initAg(AgArch arch, BeliefBase bb, String asSrc, Settings stts) throws JasonException {
+ /** parse and load the agent code, asSrc may be null */
+ public TransitionSystem initAg(String asSrc) throws JasonException {
// set the agent
try {
- setLogger(arch);
- logger.setLevel(stts.logLevel());
-
- if (bb != null)
- this.bb = bb;
-
initDefaultFunctions();
- setTS(new TransitionSystem(this, new Circumstance(), stts, arch));
boolean parsingOk = true;
if (asSrc != null) {
@@ -160,7 +139,6 @@
} else {
logger.warning("The kqmlPlans.asl was not found!");
}
-
return ts;
} catch (Exception e) {
@@ -444,12 +422,17 @@
/** TS Initialisation (called by the AgArch) */
public void setTS(TransitionSystem ts) {
this.ts = ts;
+ setLogger(ts.getUserAgArch());
+ logger.setLevel(ts.getSettings().logLevel());
}
public TransitionSystem getTS() {
return ts;
}
+ public void setBB(BeliefBase bb) {
+ this.bb = bb;
+ }
public BeliefBase getBB() {
return bb;
}
@@ -686,6 +669,19 @@
}
}
+ private void checkCustomSelectOption() {
+ hasCustomSelOp = false;
+ for (Method m: this.getClass().getMethods()) {
+ if (!m.getDeclaringClass().equals(Agent.class) && m.getName().equals("selectOption")) {
+ hasCustomSelOp = true;
+ }
+ }
+ }
+
+ public boolean hasCustomSelectOption() {
+ return hasCustomSelOp;
+ }
+
static DocumentBuilder builder = null;
/** Gets the agent "mind" (Beliefs, plans and circumstance) as XML */
Modified: trunk/src/jason/asSemantics/ConcurrentInternalAction.java
===================================================================
--- trunk/src/jason/asSemantics/ConcurrentInternalAction.java 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/src/jason/asSemantics/ConcurrentInternalAction.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -18,6 +18,38 @@
the answer. With SuspendInternalAction, only the intention using the IA is
suspended. See demos/gui/gui1.
+ The code of an internal action that extends this class looks like:
+
+ <pre>
+ public class ...... extends ConcurrentInternalAction {
+
+ public Object execute(final TransitionSystem ts, Unifier un, final Term[] args) throws Exception {
+ ....
+
+ final String key = suspendInt(ts, "gui", 5000); // suspend the intention (max 5 seconds)
+
+ startInternalAction(ts, new Runnable() { // to not block the agent thread, start a thread that performs the task and resume the intention latter
+ public void run() {
+
+ .... the code of the IA .....
+
+ if ( ... all Ok ...)
+ resumeInt(ts, key); // resume the intention with success
+ else
+ failInt(ts, key); // resume the intention with fail
+ }
+ });
+
+ ...
+ }
+
+ public void timeout(TransitionSystem ts, String intentionKey) { // called back when the intention should be resumed/failed by timeout (after 5 seconds in this example)
+ ... this method have to decide what to do with actions finished by timeout: resume or fail
+ ... to call resumeInt(ts,intentionKey) or failInt(ts, intentionKey)
+ }
+ }
+ </pre>
+
@author jomi
*/
public abstract class ConcurrentInternalAction implements InternalAction {
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -96,6 +96,12 @@
setLogger(agArch);
if (setts != null)
logger.setLevel(setts.logLevel());
+
+ if (a != null)
+ a.setTS(this);
+
+ if (ar != null)
+ ar.setTS(this);
}
public void setLogger(AgArch arch) {
Modified: trunk/src/jason/asSyntax/LogicalFormula.java
===================================================================
--- trunk/src/jason/asSyntax/LogicalFormula.java 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/src/jason/asSyntax/LogicalFormula.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -2,7 +2,6 @@
import jason.asSemantics.Agent;
import jason.asSemantics.Unifier;
-import jason.util.ToDOM;
import java.util.Iterator;
@@ -12,7 +11,7 @@
*
* @author Jomi
*/
-public interface LogicalFormula extends Term, Cloneable, ToDOM {
+public interface LogicalFormula extends Term, Cloneable {
/**
* Checks whether the formula is a
* logical consequence of the belief base.
Added: trunk/src/jason/bb/ChainBB.java
===================================================================
--- trunk/src/jason/bb/ChainBB.java (rev 0)
+++ trunk/src/jason/bb/ChainBB.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -0,0 +1,91 @@
+package jason.bb;
+
+import jason.asSemantics.Agent;
+import jason.asSyntax.StringTerm;
+import jason.asSyntax.Structure;
+import jason.asSyntax.Term;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+/**
+ *
+ * A wrapper for a chain of belief bases customisations.
+ *
+ * The arguments are the belief bases in the chain
+ *
+ * jason.bb.ChainBB( bb1, bb2, bb3, ... )
+ *
+ * where each BB is bbclass(bb paramters)
+ *
+ * e.g.:
+ * <pre>
+ * agents:
+ bob beliefBaseClass jason.bb.ChainBB(
+ jason.bb.TextPersistentBB,
+ jason.bb.IndexedBB("student(key,_)", "depot(_,_,_)")
+ );
+ * </pre>
+ */
+public class ChainBB extends ChainBBAdapter {
+
+ private static Logger logger = Logger.getLogger(ChainBB.class.getSimpleName());
+
+ @Override
+ public void init(Agent ag, String[] args) {
+ setNext(null); // remove DefaultBB
+ try {
+ // create all chain BBs
+ for (String s: args) {
+ Structure bbs = Structure.parse(s);
+ BeliefBase bb = (ChainBBAdapter) Class.forName(bbs.getFunctor()).newInstance();
+ addInChain(bb);
+ }
+
+ // init BB
+ ChainBBAdapter bb = getNextAdapter();
+ for (String s: args) {
+ // translate the terms to String[]
+ Structure bbs = Structure.parse(s);
+ String[] bbargs = new String[bbs.getArity()];
+ int i = 0;
+ for (Term t: bbs.getTerms()) {
+ bbargs[i++] = t.isString() ? ((StringTerm)t).getString(): t.toString();
+ }
+ bb.init(ag, bbargs);
+ bb = bb.getNextAdapter();
+ }
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "Error creating ChainBB",e);
+ }
+ }
+
+ /** add a new BB at the end of the chain */
+ public void addInChain(BeliefBase bb) {
+ if (getNextAdapter() == null) {
+ setNext(bb);
+ } else {
+ ChainBBAdapter last = getNextAdapter();
+ while (last.getNextAdapter() != null) {
+ last = last.getNextAdapter();
+ }
+ last.setNext(bb);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Class> getChainClasses() {
+ List<Class> r = new ArrayList<Class>();
+ ChainBBAdapter c = getNextAdapter();
+ while (c != null) {
+ r.add(c.getClass());
+ if (c.nextBB != null && c.nextBB instanceof DefaultBeliefBase)
+ r.add(c.nextBB.getClass());
+ c = c.getNextAdapter();
+ }
+ return r;
+ }
+}
Added: trunk/src/jason/bb/ChainBBAdapter.java
===================================================================
--- trunk/src/jason/bb/ChainBBAdapter.java (rev 0)
+++ trunk/src/jason/bb/ChainBBAdapter.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -0,0 +1,149 @@
+package jason.bb;
+
+import jason.asSemantics.Agent;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.Literal;
+import jason.asSyntax.PredicateIndicator;
+import jason.bb.BeliefBase;
+import jason.bb.DefaultBeliefBase;
+
+import java.util.Iterator;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+
+ This class is to be extended by customised belief bases that may be
+ used in chains (of responsibility).
+
+ For example, the code
+ <pre>
+ BeliefBase bb =
+ new MyBB1(
+ new MyBB2());
+ // DefaultBeliefBase is the next of the last element of the chain
+ </pre>
+ will chain 3 BBs: MyBB1, myBB2, and the DefaultBeliefBase. So, for any operation of
+ the BB interface, the operation is firstly called in MyBB1, then in MyBB2 and finally
+ in the DefaultBeliefBase.
+
+ The code of MyBB1 looks like:
+
+ <pre>
+ class MyBB1 extends ChainBBAdapter {
+ public MyBB1() { }
+ public MyBB1(BeliefBase next) {
+ super(next);
+ }
+
+ public boolean add(Literal l) {
+ ... some customisation of add ....
+ return next.add(l); // delegate the operation for the next BB in the chain
+ }
+
+ ... customisation of other operations ...
+ }
+ </pre>
+
+ @author Jomi
+
+ */
+@SuppressWarnings("deprecation")
+public class ChainBBAdapter implements BeliefBase {
+
+ protected BeliefBase nextBB = null; // the next BB in the chain
+
+ public ChainBBAdapter() {
+ nextBB = new DefaultBeliefBase();
+ }
+ public ChainBBAdapter(BeliefBase bb) {
+ nextBB = bb;
+ }
+
+ public void setNext(BeliefBase bb) {
+ nextBB = bb;
+ }
+
+ public ChainBBAdapter getNextAdapter() {
+ return nextBB instanceof ChainBBAdapter ? (ChainBBAdapter)nextBB : null;
+ }
+
+ public BeliefBase getLastBB() {
+ if (nextBB == null)
+ return this;
+ else if (nextBB instanceof ChainBBAdapter)
+ return ((ChainBBAdapter)nextBB).getLastBB();
+ else
+ return nextBB;
+ }
+
+ // Methods of BB interface
+
+ public void init(Agent ag, String[] args) {
+ nextBB.init(ag, args);
+ }
+ public void stop() {
+ nextBB.stop();
+ }
+
+
+ public boolean add(Literal l) {
+ return nextBB.add(l);
+ }
+
+ public boolean add(int index, Literal l) {
+ return nextBB.add(index, l);
+ }
+
+ public Literal contains(Literal l) {
+ return nextBB.contains(l);
+ }
+
+ public Iterator<Literal> getAll() {
+ return nextBB.getAll();
+ }
+
+ public Iterator<Literal> iterator() {
+ return nextBB.iterator();
+ }
+
+ public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u) {
+ return nextBB.getCandidateBeliefs(l, u);
+ }
+
+ public Iterator<Literal> getPercepts() {
+ return nextBB.getPercepts();
+ }
+
+ public Iterator<Literal> getRelevant(Literal l) {
+ return nextBB.getRelevant(l);
+ }
+
+ public boolean abolish(PredicateIndicator pi) {
+ return nextBB.abolish(pi);
+ }
+
+ public boolean remove(Literal l) {
+ return nextBB.remove(l);
+ }
+
+ public int size() {
+ return nextBB.size();
+ }
+
+ public Element getAsDOM(Document document) {
+ return nextBB.getAsDOM(document);
+ }
+
+ @Override
+ public Object clone() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return nextBB.toString();
+ }
+}
Modified: trunk/src/jason/bb/DefaultBeliefBase.java
===================================================================
--- trunk/src/jason/bb/DefaultBeliefBase.java 2008-09-10 11:52:51 UTC (rev 1364)
+++ trunk/src/jason/bb/DefaultBeliefBase.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -59,7 +59,7 @@
private int size = 0;
/** set of beliefs with percept annot, used to improve performance of buf */
- protected Set<Literal> percepts = new HashSet<Literal>();
+ private Set<Literal> percepts = new HashSet<Literal>();
public void init(Agent ag, String[] args) {
if (ag != null) {
@@ -103,6 +103,10 @@
//return ((Set<Literal>)percepts.clone()).iterator();
}
+ Set<Literal> getPerceptsSet() {
+ return percepts;
+ }
+
public boolean add(Literal l) {
return add(l, false);
}
Added: trunk/src/jason/bb/IndexedBB.java
===================================================================
--- trunk/src/jason/bb/IndexedBB.java (rev 0)
+++ trunk/src/jason/bb/IndexedBB.java 2008-09-11 14:22:12 UTC (rev 1365)
@@ -0,0 +1,93 @@
+package jason.bb;
+
+import jason.asSemantics.Agent;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Structure;
+import jason.asSyntax.Term;
+import jason.bb.BeliefBase;
+import jason.bb.ChainBBAdapter;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Customised version of Belief Base where some beliefs are unique (with primary keys) and
+ * indexed for faster access.
+ *
+ * <p>E.g. in a .mas2j project file:<br/>
+ * <code>agents: bob beliefBaseClass agent.IndexedBB("student(key,_)", "depot(_,_,_)")</code>
+ * <br/>
+ * The belief "student/2" has the first argument as its key, so the BB will never has
+ * two students with the same key. Or, two students in the BB will have two different keys.
+ * The belief "depot/3" has no key, so there will be always only one "depot" in the BB.
+ *
+ * When some belief with the same key than another belief in BB is added,
+ * the most recent remains in the BB and the older is removed.
+ *
+ * @author jomi
+ */
+public class IndexedBB extends ChainBBAdapter {
+
+ Map<String,Structure> indexedBels = new HashMap<String,Structure>();
+ Unifier u = new Unifier();
+
+ public IndexedBB() { }
+ public IndexedBB(BeliefBase next) {
+ super(next);
+ }
+
+ @Override
+ public void init(Agent ag, String[] args) {
+ for (int i=0; i<args.length; i++) {
+ Structure bel = Structure.parse(args[i]);
+ indexedBels.put(bel.getFunctor(), bel);
+ }
+ }
+
+ // TODO: access indexes
+
+ @Override
+ public boolean add(Literal bel) {
+ Structure kb = indexedBels.get(bel.getFunctor());
+ if (kb != null && kb.getArity() == bel.getArity()) { // is a constrained bel?
+
+ // find the bel in BB and eventually remove it
+ u.clear();
+ Literal linbb = null;
+ boolean remove = false;
+
+ Iterator<Literal> relevant = getCandidateBeliefs(bel, null);
+ if (relevant != null) {
+ final int kbArity = kb.getArity();
+ while (relevant.hasNext() && !remove) {
+ linbb = relevant.next();
+
+ if (!linbb.isRule()) {
+ // check equality of all terms that are "key"
+ // if some key is different, no problem
+ // otherwise, remove the current bel
+ boolean equals = true;
+ for (int i = 0; i<kbArity; i++) {
+ Term kbt = kb.getTerm(i);
+ if (!kbt.isVar()) { // is key?
+ ...
[truncated message content] |
|
From: <jom...@us...> - 2008-09-12 14:16:55
|
Revision: 1366
http://jason.svn.sourceforge.net/jason/?rev=1366&view=rev
Author: jomifred
Date: 2008-09-12 14:16:52 +0000 (Fri, 12 Sep 2008)
Log Message:
-----------
new method to include plans in the begin of the PlanLibrary
Message class is now serializable
Modified Paths:
--------------
trunk/demos/clone/main.asl
trunk/demos/gui/gui2/sample.asl
trunk/demos/tell-rule/receiver.asl
trunk/src/jason/asSemantics/Message.java
trunk/src/jason/asSyntax/BinaryStructure.java
trunk/src/jason/asSyntax/LogExpr.java
trunk/src/jason/asSyntax/PlanLibrary.java
Modified: trunk/demos/clone/main.asl
===================================================================
--- trunk/demos/clone/main.asl 2008-09-11 14:22:12 UTC (rev 1365)
+++ trunk/demos/clone/main.asl 2008-09-12 14:16:52 UTC (rev 1366)
@@ -6,18 +6,14 @@
/* Initial goals */
-!print.
!start.
/* Plans */
+!start
<- +a(40);
- .wait(100);
myia.clone("bob");
.send(bob,tell,p(10)).
-+!print <- .wait(500); .print(hello); !print.
++p(X) : a(V) <- .print(X," : ",V).
-+p(X) <- .print(X).
-
Modified: trunk/demos/gui/gui2/sample.asl
===================================================================
--- trunk/demos/gui/gui2/sample.asl 2008-09-11 14:22:12 UTC (rev 1365)
+++ trunk/demos/gui/gui2/sample.asl 2008-09-12 14:16:52 UTC (rev 1366)
@@ -8,7 +8,7 @@
+!start <- gui.create("Example GUI").
// the event !run is created by the GUI
-+!run(X) <- .print("running ",X,"...."); .wait(100); !!run(X).
++!run(X) <- .print("running ",X,"...."); .wait(500); !!run(X).
// the event !stop is created by the GUI
Modified: trunk/demos/tell-rule/receiver.asl
===================================================================
--- trunk/demos/tell-rule/receiver.asl 2008-09-11 14:22:12 UTC (rev 1365)
+++ trunk/demos/tell-rule/receiver.asl 2008-09-12 14:16:52 UTC (rev 1366)
@@ -12,7 +12,7 @@
// customisation of KQML performative tellRule
+!kqml_received(A,tellRule,Rule,_)
- <- .print("Received rule(s) ",Rule);
+ <- .print("Received rule(s) ",Rule, " from ",A);
rules.add_rule(Rule);
// get all rules and print them
rules.get_rules(_,LR);
Modified: trunk/src/jason/asSemantics/Message.java
===================================================================
--- trunk/src/jason/asSemantics/Message.java 2008-09-11 14:22:12 UTC (rev 1365)
+++ trunk/src/jason/asSemantics/Message.java 2008-09-12 14:16:52 UTC (rev 1366)
@@ -24,8 +24,12 @@
package jason.asSemantics;
+import jason.asSyntax.DefaultTerm;
-public class Message {
+import java.io.Serializable;
+
+
+public class Message implements Serializable {
private String ilForce = null;
private String sender = null;
@@ -126,6 +130,39 @@
return new Message(this);
}
+ /**
+ * Creates a new message object based on a string that
+ * follows the format of the toString of Message class.
+ *
+ * @author Rogier
+ * @param msg the string message
+ * @return the parsed Message
+ */
+ public static Message parseMsg(String msg) {
+ int one, two;
+ Message newmsg = new Message();
+ if (msg.startsWith("<")) {
+ one = msg.indexOf(",");
+ int arrowIndex = msg.indexOf("->");
+ if (one < arrowIndex) { // If there is an arrow before the first comma
+ newmsg.msgId = msg.substring(1, arrowIndex);
+ newmsg.inReplyTo = msg.substring(arrowIndex + 2, one);
+ } else { // If not (either there is no arrow, or there is one behind the first comma)
+ newmsg.msgId = msg.substring(1, one);
+ }
+ two = msg.indexOf(",", one + 1);
+ newmsg.sender = msg.substring(one + 1, two);
+ one = msg.indexOf(",", two + 1);
+ newmsg.ilForce = msg.substring(two + 1, one);
+ two = msg.indexOf(",", one + 1);
+ newmsg.receiver = msg.substring(one + 1, two);
+ one = msg.indexOf(">", two + 1);
+ String content = msg.substring(two + 1, one);
+ newmsg.propCont = DefaultTerm.parse(content);
+ }
+ return newmsg;
+ }
+
public String toString() {
String irt = (inReplyTo == null ? "" : "->"+inReplyTo);
return "<"+msgId+irt+","+sender+","+ilForce+","+receiver+","+propCont+">";
Modified: trunk/src/jason/asSyntax/BinaryStructure.java
===================================================================
--- trunk/src/jason/asSyntax/BinaryStructure.java 2008-09-11 14:22:12 UTC (rev 1365)
+++ trunk/src/jason/asSyntax/BinaryStructure.java 2008-09-12 14:16:52 UTC (rev 1366)
@@ -51,6 +51,16 @@
return getArity() == 1;
}
+ /** gets the LHS of this Expression */
+ public LogicalFormula getLHS() {
+ return (LogicalFormula)getTerm(0);
+ }
+
+ /** gets the RHS of this Expression */
+ public LogicalFormula getRHS() {
+ return (LogicalFormula)getTerm(1);
+ }
+
@Override
public String toString() {
if (isUnary()) {
Modified: trunk/src/jason/asSyntax/LogExpr.java
===================================================================
--- trunk/src/jason/asSyntax/LogExpr.java 2008-09-11 14:22:12 UTC (rev 1365)
+++ trunk/src/jason/asSyntax/LogExpr.java 2008-09-12 14:16:52 UTC (rev 1366)
@@ -216,16 +216,6 @@
return op;
}
- /** gets the LHS of this Expression */
- public LogicalFormula getLHS() {
- return (LogicalFormula)getTerm(0);
- }
-
- /** gets the RHS of this Expression */
- public LogicalFormula getRHS() {
- return (LogicalFormula)getTerm(1);
- }
-
/** get as XML */
public Element getAsDOM(Document document) {
Element u = super.getAsDOM(document);
Modified: trunk/src/jason/asSyntax/PlanLibrary.java
===================================================================
--- trunk/src/jason/asSyntax/PlanLibrary.java 2008-09-11 14:22:12 UTC (rev 1365)
+++ trunk/src/jason/asSyntax/PlanLibrary.java 2008-09-12 14:16:52 UTC (rev 1366)
@@ -87,7 +87,7 @@
if (i < 0) {
// add label, if necessary
if (p.getLabel() == null) {
- setAutoLabel(p);
+ p.setLabel(getUniqueLabel());
}
p.getLabel().addSource(tSource);
add(p);
@@ -104,8 +104,19 @@
}
-
public void add(Plan p) throws JasonException {
+ add(p,false);
+ }
+
+ /**
+ * Adds a plan into the plan library, either before or after all other
+ * plans depending on the boolean parameter.
+ *
+ * @param p The plan to be added to the plan library
+ * @param before Whether or not to place the new plan before others
+ * @throws JasonException
+ */
+ public void add(Plan p, boolean before) throws JasonException {
// test p.label
if (p.getLabel() != null && planLabels.keySet().contains(p.getLabel().getFunctor())) {
// test if the new plan is equal, in this case, just add a source
@@ -119,7 +130,8 @@
}
// add label, if necessary
- if (p.getLabel() == null) setAutoLabel(p);
+ if (p.getLabel() == null)
+ p.setLabel(getUniqueLabel());
// add self source
if (!p.getLabel().hasSource()) p.getLabel().addAnnot(BeliefBase.TSelf);
@@ -128,11 +140,17 @@
Trigger pte = p.getTrigger();
if (pte.getLiteral().isVar()) {
- varPlans.add(p);
+ if (before)
+ varPlans.add(0,p);
+ else
+ varPlans.add(p);
// add plan p in all entries
for (List<Plan> lp: relPlans.values())
if (!lp.isEmpty() && lp.get(0).getTrigger().sameType(pte)) // only add if same type
- lp.add(p);
+ if (before)
+ lp.add(0,p);
+ else
+ lp.add(p);
} else {
List<Plan> codesList = relPlans.get(pte.getPredicateIndicator());
if (codesList == null) {
@@ -140,13 +158,19 @@
// copy plans from var plans
for (Plan vp: varPlans)
if (vp.getTrigger().sameType(pte))
- codesList.add(vp);
+ codesList.add(vp);
relPlans.put(pte.getPredicateIndicator(), codesList);
}
- codesList.add(p);
+ if (before)
+ codesList.add(0,p);
+ else
+ codesList.add(p);
}
- plans.add(p);
+ if (before)
+ plans.add(0,p);
+ else
+ plans.add(p);
}
public void addAll(PlanLibrary pl) throws JasonException {
@@ -162,12 +186,12 @@
}
/** add a label to the plan */
- private void setAutoLabel(Plan p) {
+ private Pred getUniqueLabel() {
String l;
do {
l = "l__" + (lastPlanLabel++);
} while (planLabels.keySet().contains(l));
- p.setLabel(new Pred(l));
+ return new Pred(l);
}
/** return a plan for a label */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-09-12 15:04:25
|
Revision: 1367
http://jason.svn.sourceforge.net/jason/?rev=1367&view=rev
Author: jomifred
Date: 2008-09-12 15:04:23 +0000 (Fri, 12 Sep 2008)
Log Message:
-----------
fix the wrong cast in BinaryStructure
Modified Paths:
--------------
trunk/doc/jason.doxygen
trunk/src/jason/asSyntax/BinaryStructure.java
trunk/src/jason/asSyntax/LogExpr.java
Modified: trunk/doc/jason.doxygen
===================================================================
--- trunk/doc/jason.doxygen 2008-09-12 14:16:52 UTC (rev 1366)
+++ trunk/doc/jason.doxygen 2008-09-12 15:04:23 UTC (rev 1367)
@@ -25,7 +25,7 @@
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
-PROJECT_NAME = Jason
+PROJECT_NAME = Jason :: API
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
Modified: trunk/src/jason/asSyntax/BinaryStructure.java
===================================================================
--- trunk/src/jason/asSyntax/BinaryStructure.java 2008-09-12 14:16:52 UTC (rev 1366)
+++ trunk/src/jason/asSyntax/BinaryStructure.java 2008-09-12 15:04:23 UTC (rev 1367)
@@ -51,14 +51,14 @@
return getArity() == 1;
}
- /** gets the LHS of this Expression */
- public LogicalFormula getLHS() {
- return (LogicalFormula)getTerm(0);
+ /** gets the LHS of this operation */
+ public Term getLHS() {
+ return getTerm(0);
}
- /** gets the RHS of this Expression */
- public LogicalFormula getRHS() {
- return (LogicalFormula)getTerm(1);
+ /** gets the RHS of this operation */
+ public Term getRHS() {
+ return getTerm(1);
}
@Override
Modified: trunk/src/jason/asSyntax/LogExpr.java
===================================================================
--- trunk/src/jason/asSyntax/LogExpr.java 2008-09-12 14:16:52 UTC (rev 1366)
+++ trunk/src/jason/asSyntax/LogExpr.java 2008-09-12 15:04:23 UTC (rev 1367)
@@ -67,7 +67,17 @@
super(oper.toString(),(Term)f);
op = oper;
}
-
+
+ /** gets the LHS of this Expression */
+ public LogicalFormula getLHS() {
+ return (LogicalFormula)getTerm(0);
+ }
+
+ /** gets the RHS of this Expression */
+ public LogicalFormula getRHS() {
+ return (LogicalFormula)getTerm(1);
+ }
+
public Iterator<Unifier> logicalConsequence(final Agent ag, final Unifier un) {
try {
switch (op) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-09-12 16:45:25
|
Revision: 1368
http://jason.svn.sourceforge.net/jason/?rev=1368&view=rev
Author: jomifred
Date: 2008-09-12 16:45:23 +0000 (Fri, 12 Sep 2008)
Log Message:
-----------
add an initAg method in Agent class so that the class remains compatible with previous releases
Modified Paths:
--------------
trunk/applications/jason-team/src/team-os.xml
trunk/src/jason/asSemantics/Agent.java
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-09-12 15:04:23 UTC (rev 1367)
+++ trunk/applications/jason-team/src/team-os.xml 2008-09-12 16:45:23 UTC (rev 1368)
@@ -105,8 +105,7 @@
<goal id="herd_cows" >
<plan operator="parallel">
<goal id="recruit" ds="recruit more herdboys depending on the size of the cows cluster" type="maintenance"/>
- <goal id="release_boys" ds="if the group has
- too much boys, release some" type="maintenance"/>
+ <goal id="release_boys" ds="if the group has too much boys, release some" type="maintenance"/>
<goal id="define_formation" ds="compute the ideal location of each member of the group and share this information with them" type="maintenance"/>
<goal id="be_in_formation" ds="go to the place allocated to the agent in the formation" type="maintenance"/>
<goal id="share_seen_cows" ds="share seen cows with other agents in the scheme" type="maintenance"/>
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-09-12 15:04:23 UTC (rev 1367)
+++ trunk/src/jason/asSemantics/Agent.java 2008-09-12 16:45:23 UTC (rev 1368)
@@ -42,6 +42,7 @@
import jason.bb.DefaultBeliefBase;
import jason.functions.Count;
import jason.functions.RuleToFunction;
+import jason.runtime.Settings;
import java.io.File;
import java.io.FileInputStream;
@@ -103,7 +104,7 @@
}
/** parse and load the agent code, asSrc may be null */
- public TransitionSystem initAg(String asSrc) throws JasonException {
+ public void initAg(String asSrc) throws JasonException {
// set the agent
try {
initDefaultFunctions();
@@ -139,14 +140,38 @@
} else {
logger.warning("The kqmlPlans.asl was not found!");
}
-
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "Error creating the agent class!", e);
+ throw new JasonException("Error creating the agent class! - " + e);
+ }
+ }
+
+ /** @deprecated Prefer the initAg method with only the source code of the agent as parameter.
+ *
+ * A call of this method like
+ * <pre>
+ * TransitionSystem ts = ag.initAg(arch, bb, asSrc, stts)
+ * </pre>
+ * can be replaced by
+ * <pre>
+ * new TransitionSystem(ag, new Circumstance(), stts, arch);
+ * ag.setBB(bb); // only if you use a custom BB
+ * ag.initAg(asSrc);
+ * TransitionSystem ts = ag.getTS();
+ * </pre>
+ */
+ public TransitionSystem initAg(AgArch arch, BeliefBase bb, String asSrc, Settings stts) throws JasonException {
+ try {
+ if (bb != null) setBB(bb);
+ new TransitionSystem(this, new Circumstance(), stts, arch);
+ initAg(asSrc);
return ts;
} catch (Exception e) {
logger.log(Level.SEVERE, "Error creating the agent class!", e);
throw new JasonException("Error creating the agent class! - " + e);
}
}
-
+
public void stopAg() {
bb.stop();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-09-13 19:09:25
|
Revision: 1370
http://jason.svn.sourceforge.net/jason/?rev=1370&view=rev
Author: jomifred
Date: 2008-09-13 19:09:17 +0000 (Sat, 13 Sep 2008)
Log Message:
-----------
first implementation of annotation errors
see release notes for more info
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java
trunk/demos/failure/a.asl
trunk/release-notes.txt
trunk/src/jason/JasonException.java
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/IntendedMeans.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/Plan.java
trunk/src/jason/asSyntax/Rule.java
trunk/src/jason/asSyntax/Trigger.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/asSyntax/patterns/goal/DG.java
trunk/src/jason/asSyntax/patterns/goal/EBDG.java
trunk/src/jason/asSyntax/patterns/goal/MG.java
trunk/src/jason/bb/DefaultBeliefBase.java
trunk/src/jason/stdlib/abolish.java
trunk/src/templates/ia
Modified: trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -23,10 +23,10 @@
"+!g3(X) : true <- inig2; !g4(X); endg3. "+
"+!g4(X) : true <- inig4; !g5(X); endg4. "+
"+!g5(_) : true <- .fail. "+
- "-!g3(failure) : true <- infailg3. "+
+ "-!g3(failure)[error(ia_failed)] : true <- infailg3. "+
"+!norel <- !j; endnorel. "+
- "-!j <- infailj. "
+ "-!j[error(no_relevant)] <- infailj. "
);
}
Modified: trunk/demos/failure/a.asl
===================================================================
--- trunk/demos/failure/a.asl 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/demos/failure/a.asl 2008-09-13 19:09:17 UTC (rev 1370)
@@ -6,9 +6,10 @@
+!g3(X) : true <- .print(inig3); !g4(X); .print(endg3).
+!g4(X) : true <- .print(inig4); !g5(X); .print(endg4).
+!g5(_) : true <- .fail.
--!g3(failure) : true
- <- .current_intention(I);
- .print("In failure handling plan, current intention is: ",I);
+-!g3(failure)[error(ErrorId), error_msg(Msg), code(CodeBody), code_src(CodeSrc), code_line(CodeLine)] : true // get annotations related to the failure (these annotations are optional)
+ <- .print("Error ", ErrorId, " '",Msg,"' by ",CodeBody," in ",CodeSrc,":",CodeLine);
+ .current_intention(I);
+ .print("current intention is: ",I);
I = intention(Id,IntendedMeans);
.println;
.println("* Intention ",Id, " IM stack:");
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/release-notes.txt 2008-09-13 19:09:17 UTC (rev 1370)
@@ -9,7 +9,26 @@
see/run the demo/chain-bb
see API doc of ChainBB and ChainBBAdapter
+. annotations in failure events. All failure events are now
+ annotated with:
+ error(<atom: error id>): values used by Jason are
+ no_applicable: no applicable plan
+ no_relevant: no relevant plan
+ no_option: no option selected
+ constraint_failed: constraint failed
+ ia_failed: internal action returned false
+ action_failed: action failed in the environment
+ ask_failed: answer for an ask message failed
+ wrong_arguments: throw by internal actions
+ unknown
+ error_msg(<string>): the human readable message of the error
+ code(<literal>): the command that failed
+ code_src(<string>): the file where the command is
+ code_line(<int>): the line in the file
+ see demo/failure for an example
+ see code of JasonException and TS for more information
+
New internal actions
. .term2string: transform term into strings and vice-versa.
Modified: trunk/src/jason/JasonException.java
===================================================================
--- trunk/src/jason/JasonException.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/JasonException.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -24,18 +24,27 @@
package jason;
+import jason.asSyntax.Atom;
+import jason.asSyntax.ListTerm;
+import jason.asSyntax.ListTermImpl;
+import jason.asSyntax.StringTermImpl;
+import jason.asSyntax.Structure;
+import jason.asSyntax.Term;
+
public class JasonException extends java.lang.Exception {
private static final long serialVersionUID = 1L;
+ private static final Term defaultError = new Atom("internal_action");
+ private Term error = defaultError;
+
/**
* Creates a new instance of <code>JasonException</code> without detail message.
*/
public JasonException() {
}
-
/**
* Constructs an instance of <code>JasonException</code> with the specified detail message.
* @param msg the detail message.
@@ -44,9 +53,44 @@
super(msg);
}
+ /**
+ * Constructs an instance of <code>JasonException</code> with the specified detail message
+ * and error description term.
+ *
+ * @param msg the detail message.
+ * @param error the term that details (in AgentSpeak) the error
+ */
+ public JasonException(String msg, Term error) {
+ super(msg);
+ this.error = error;
+ }
+
public JasonException(String msg, Exception cause) {
super(msg);
initCause(cause);
}
+ public JasonException(String msg, Term error, Exception cause) {
+ super(msg);
+ initCause(cause);
+ this.error = error;
+ }
+
+ public ListTerm getErrorTerms() {
+ return createBasicErrorAnnots(error, getMessage());
+ }
+
+ public static ListTerm createBasicErrorAnnots(String id, String msg) {
+ return createBasicErrorAnnots(new Atom(id), msg);
+ }
+ public static ListTerm createBasicErrorAnnots(Term id, String msg) {
+ ListTerm failAnnots = new ListTermImpl();
+ Structure e = new Structure("error", 1);
+ e.addTerm(id);
+ failAnnots.add(e);
+ Structure m = new Structure("error_msg", 1);
+ m.addTerm(new StringTermImpl(msg));
+ failAnnots.add(m);
+ return failAnnots;
+ }
}
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSemantics/Agent.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -505,7 +505,7 @@
Trigger te = new Trigger(TEOperator.del, TEType.belief, l);
if (ts.getC().hasListener() || pl.hasCandidatePlan(te)) {
- l = (Literal)l.clone();
+ l = l.copy();
l.clearAnnots();
l.addAnnot(BeliefBase.TPercept);
te.setLiteral(l);
@@ -529,7 +529,7 @@
// checking all percepts for new beliefs
for (Literal lp : percepts) {
try {
- lp = (Literal) lp.clone();
+ lp = lp.copy();
lp.addAnnot(BeliefBase.TPercept);
if (getBB().add(lp)) {
Trigger te = new Trigger(TEOperator.add, TEType.belief, lp);
Modified: trunk/src/jason/asSemantics/IntendedMeans.java
===================================================================
--- trunk/src/jason/asSemantics/IntendedMeans.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSemantics/IntendedMeans.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -48,7 +48,7 @@
private Trigger trigger; // the trigger which created this IM
public IntendedMeans(Option opt, Trigger te) {
- plan = opt.getPlan().cloneOnlyBody();
+ plan = opt.getPlan().copyOnlyBody();
unif = opt.getUnifier(); //(Unifier)opt.getUnifier().clone();
// REMOVED: experimental
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -27,14 +27,16 @@
import jason.RevisionFailedException;
import jason.architecture.AgArch;
import jason.asSyntax.Atom;
-import jason.asSyntax.PlanBody;
import jason.asSyntax.DefaultTerm;
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.LogicalFormula;
+import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Plan;
+import jason.asSyntax.PlanBody;
import jason.asSyntax.PlanLibrary;
+import jason.asSyntax.StringTermImpl;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
@@ -177,7 +179,7 @@
getC().addIntention(intention);
} else {
conf.C.SI = intention;
- generateGoalDeletion();
+ generateGoalDeletion(JasonException.createBasicErrorAnnots("ask_failed", ""));
}
// the message is not an ask answer
@@ -255,8 +257,9 @@
confP.step = State.ProcAct; // default next step
if (conf.C.SE.trigger.isGoal()) {
// can't carry on, no relevant/applicable plan.
- logger.warning("Found a goal for which there is no "+m+" plan:" + conf.C.SE);
- generateGoalDeletionFromEvent();
+ String msg = "Found a goal for which there is no "+m+" plan:" + conf.C.SE;
+ if (!generateGoalDeletionFromEvent(JasonException.createBasicErrorAnnots("no_"+m, msg)))
+ logger.warning(msg);
} else {
if (conf.C.SE.isInternal()) {
// e.g. belief addition as internal event, just go ahead
@@ -286,7 +289,7 @@
if (logger.isLoggable(Level.FINE)) logger.fine("Selected option "+confP.C.SO+" for event "+confP.C.SE);
} else {
logger.fine("** selectOption returned null!");
- generateGoalDeletionFromEvent();
+ generateGoalDeletionFromEvent(JasonException.createBasicErrorAnnots("no_option", "selectOption returned null"));
// can't carry on, no applicable plan.
confP.step = State.ProcAct;
}
@@ -301,7 +304,7 @@
*/
private void applyFindOp() throws JasonException {
confP.step = State.AddIM; // default next step
-
+
// get all relevant plans for the selected event
//Trigger te = (Trigger) conf.C.SE.trigger.clone();
List<Plan> candidateRPs = conf.ag.pl.getCandidatePlans(conf.C.SE.trigger);
@@ -322,10 +325,11 @@
}
}
}
- }
-
- // problem: no plan
- applyRelApplPlRule2("relevant/applicable");
+ applyRelApplPlRule2("applicable");
+ } else {
+ // problem: no plan
+ applyRelApplPlRule2("relevant");
+ }
}
private void applyAddIM() throws JasonException {
@@ -361,7 +365,7 @@
updateIntention();
applyClrInt(confP.C.SI);
} else {
- generateGoalDeletion();
+ generateGoalDeletion(JasonException.createBasicErrorAnnots("action_failed", ""));
}
} else {
applyProcAct(); // get next action
@@ -426,6 +430,7 @@
case internalAction:
boolean ok = false;
+ List<Term> errorAnnots = null;
try {
InternalAction ia = ((InternalActionLiteral)bTerm).getIA(ag);
Object oresult = ia.execute(this, u, body.getTermsArray());
@@ -439,17 +444,23 @@
ok = true;
}
}
+ if (!ok) { // IA returned false
+ errorAnnots = JasonException.createBasicErrorAnnots("ia_failed", "");
+ }
}
if (ok && !ia.suspendIntention())
updateIntention();
-
+ } catch (JasonException e) {
+ errorAnnots = e.getErrorTerms();
+ if (!generateGoalDeletion(errorAnnots))
+ logger.log(Level.SEVERE, body.getErrorMsg()+": "+ e.getMessage());
+ ok = true; // just to not generate the event again
} catch (Exception e) {
logger.log(Level.SEVERE, body.getErrorMsg()+": "+ e.getMessage(), e);
- ok = false;
}
if (!ok)
- generateGoalDeletion();
+ generateGoalDeletion(errorAnnots);
break;
@@ -459,8 +470,9 @@
im.unif = iu.next();
updateIntention();
} else {
- if (logger.isLoggable(Level.FINE)) logger.fine("Constraint "+h+" was not satisfied ("+h.getErrorMsg()+").");
- generateGoalDeletion();
+ String msg = "Constraint "+h+" was not satisfied ("+h.getErrorMsg()+").";
+ generateGoalDeletion(JasonException.createBasicErrorAnnots(new Atom("constraint_failed"), msg));
+ logger.fine(msg);
}
break;
@@ -627,6 +639,7 @@
// remove the finished IM from the top of the intention
IntendedMeans topIM = i.pop();
+ Literal topLiteral = topIM.getTrigger().getLiteral();
if (logger.isLoggable(Level.FINE)) logger.fine("Returning from IM "+topIM.getPlan().getLabel()+", te="+topIM.getPlan().getTrigger());
// if finished a failure handling IM ...
@@ -641,12 +654,11 @@
// should became
// +!s: !z
im = i.peek();
- if (im.isFinished() || !im.unif.unifies(topIM.getTrigger().getLiteral(), im.getCurrentStep().getBodyTerm()))
+ if (im.isFinished() || !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral))
im = i.pop(); // +!c above
-
while (i.size() > 0 &&
- !im.unif.unifies(topIM.getTrigger().getLiteral(), im.getTrigger().getLiteral()) &&
- !im.unif.unifies(topIM.getTrigger().getLiteral(), im.getCurrentStep().getBodyTerm())) {
+ !im.unif.unifies(im.getTrigger().getLiteral(), topLiteral) &&
+ !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral)) {
im = i.pop();
}
}
@@ -654,16 +666,24 @@
im = i.peek(); // +!s or +?s
if (!im.isFinished()) {
// removes !b or ?s
+ /* I am trying against comments below and use topIM.getTrigger!
+ * since I don't remember why the trigger cann't be used
+ * probably the reason is the old buggy makeVarAnnos
+
Term g = im.removeCurrentStep();
// make the TE of finished plan ground and unify that
// with goal/test in the body (to "return" values).
- // (it must the plan TE and not the IM.trigger because the
+ // (it must be the plan TE and not the IM.trigger because the
// vars have name only in the plan TE, in the IM.trigger
- // they are anonymous)
+ // they are anonymous)
Literal tel = topIM.getPlan().getTrigger().getLiteral();
- tel.apply(topIM.unif);
- tel.makeVarsAnnon(topIM.unif);
- im.unif.unifies(tel, g);
+ // but import annots from IM.trigger
+ tel.addAnnots(topIM.getTrigger().getLiteral().getAnnots());
+ tel.topLiteral.makeVarsAnnon(topIM.unif);
+ */
+ // unifies the final event with the body that called it
+ topLiteral.apply(topIM.unif);
+ im.unif.unifies(im.removeCurrentStep(), topLiteral);
}
}
@@ -764,11 +784,17 @@
/** generate a failure event for the current intention */
private void generateGoalDeletion() throws JasonException {
+ generateGoalDeletion(null);
+ }
+ private boolean generateGoalDeletion(List<Term> failAnnots) throws JasonException {
+ boolean failEeventGenerated = false;
IntendedMeans im = conf.C.SI.peek();
if (im.isGoalAdd()) {
Event failEvent = findEventForFailure(conf.C.SI, im.getTrigger());
if (failEvent != null) {
+ setDefaultFailureAnnots(failEvent, im.getCurrentStep().getBodyTerm(), failAnnots);
confP.C.addEvent(failEvent);
+ failEeventGenerated = true;
if (logger.isLoggable(Level.FINE)) logger.fine("Generating goal deletion " + failEvent.getTrigger() + " from goal: " + im.getTrigger());
} else {
logger.warning("No fail event was generated for " + im.getTrigger());
@@ -784,23 +810,26 @@
} else {
logger.warning("Could not finish intention: " + conf.C.SI);
}
+ return failEeventGenerated;
}
// similar to the one above, but for an Event rather than intention
- private void generateGoalDeletionFromEvent() throws JasonException {
+ private boolean generateGoalDeletionFromEvent(List<Term> failAnnots) throws JasonException {
Event ev = conf.C.SE;
if (ev == null) {
logger.warning("** It is not possible to generate a goal deletion event because SE is null! " + conf.C);
- return;
+ return false;
}
Trigger tevent = ev.trigger;
-
+ boolean failEeventGenerated = false;
if (tevent.isAddition() && tevent.isGoal()) {
Event failEvent = findEventForFailure(ev.intention, tevent);
if (failEvent != null) {
- logger.warning("Generating goal deletion " + failEvent.getTrigger() + " from event: " + ev.getTrigger());
+ setDefaultFailureAnnots(failEvent, tevent.getLiteral(), failAnnots);
confP.C.addEvent(failEvent);
+ failEeventGenerated = true;
+ //logger.warning("Generating goal deletion " + failEvent.getTrigger() + " from event: " + ev.getTrigger());
} else {
logger.warning("No fail event was generated for " + ev.getTrigger());
}
@@ -814,6 +843,7 @@
logger.warning("Requeing external event: " + ev);
} else
logger.warning("Discarding external event: " + ev);
+ return failEeventGenerated;
}
public Event findEventForFailure(Intention i, Trigger tevent) {
@@ -828,11 +858,48 @@
}
// if some failure handling plan is found
if (tevent.isGoal() && getAg().getPL().hasCandidatePlan(failTrigger)) {
- return new Event(failTrigger, i);
+ return new Event(failTrigger.copy(), i);
}
return null;
}
+ private static void setDefaultFailureAnnots(Event failEvent, Term body, List<Term> failAnnots) {
+ // add default failure annots
+ if (failAnnots == null)
+ failAnnots = JasonException.createBasicErrorAnnots("unknown", "");
+
+ // add failure annots in the event related to the code source
+ Literal bodyterm = null;
+ Term codesrc = null;
+ Term codeline = null;
+ if (body != null && body instanceof Literal) {
+ bodyterm = (Literal)body;
+ codesrc = new StringTermImpl(bodyterm.getSrc());
+ codeline = new NumberTermImpl(bodyterm.getSrcLine());
+ } else {
+ bodyterm = new Atom("no_code");
+ codesrc = new Atom("no_code");
+ codeline = new Atom("no_code");
+
+ }
+
+ // code
+ Structure code = new Structure("code");
+ code.addTerm(bodyterm);
+ failAnnots.add(code);
+
+ // ASL source
+ Structure src = new Structure("code_src");
+ src.addTerm(codesrc);
+ failAnnots.add(src);
+
+ // line in the source
+ Structure line = new Structure("code_line");
+ line.addTerm(codeline);
+ failAnnots.add(line);
+ failEvent.getTrigger().getLiteral().addAnnots(failAnnots);
+ }
+
public boolean canSleep() {
return !conf.C.hasEvent() && !conf.C.hasIntention() &&
conf.C.MB.isEmpty() && !conf.C.hasFeedbackAction() &&
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSyntax/Literal.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -163,7 +163,7 @@
while (ruleIt != null && ruleIt.hasNext()) {
// unifies the rule head with the result of rule evaluation
Unifier ruleUn = ruleIt.next(); // evaluation result
- Literal rhead = rule.headClone();
+ Literal rhead = rule.headCopy();
rhead.apply(ruleUn);
rhead.makeVarsAnnon(ruleUn);
Modified: trunk/src/jason/asSyntax/Plan.java
===================================================================
--- trunk/src/jason/asSyntax/Plan.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSyntax/Plan.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -208,8 +208,13 @@
return p;
}
+ /** @deprecated use copyOnlyBody */
+ public Plan cloneOnlyBody() {
+ return copyOnlyBody();
+ }
+
/** used to create a plan clone in a new IM */
- public Plan cloneOnlyBody() {
+ public Plan copyOnlyBody() {
Plan p = new Plan();
if (label != null) {
p.label = label;
Modified: trunk/src/jason/asSyntax/Rule.java
===================================================================
--- trunk/src/jason/asSyntax/Rule.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSyntax/Rule.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -82,6 +82,10 @@
return r;
}
+ public Literal headCopy() {
+ return (Literal)super.clone();
+ }
+ /** @deprecated use headCopy */
public Literal headClone() {
return (Literal)super.clone();
}
Modified: trunk/src/jason/asSyntax/Trigger.java
===================================================================
--- trunk/src/jason/asSyntax/Trigger.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSyntax/Trigger.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -124,11 +124,14 @@
}
public Object clone() {
- Trigger c = new Trigger(operator, type, (Literal)literal.clone());
+ return copy();
+ }
+
+ public Trigger copy() {
+ Trigger c = new Trigger(operator, type, literal.copy());
c.piCache = this.piCache;
return c;
- }
-
+ }
/** return [+|-][!|?] super.getPredicateIndicator */
public PredicateIndicator getPredicateIndicator() {
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-09-13 19:09:17 UTC (rev 1370)
@@ -270,7 +270,7 @@
if (config.getBoolean(Config.WARN_SING_VAR) && !parsedFiles.contains(asSource)) {
List<VarTerm> singletonVars = h.getSingletonVars();
if (singletonVars.size() > 0) {
- logger.warning(getSourceRef(h)+" warning: the rule with head '"+((Rule)h).headClone()+"' has the following singleton variables: "+singletonVars);
+ logger.warning(getSourceRef(h)+" warning: the rule with head '"+((Rule)h).headCopy()+"' has the following singleton variables: "+singletonVars);
}
}
}
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -289,7 +289,7 @@
if (config.getBoolean(Config.WARN_SING_VAR) && !parsedFiles.contains(asSource)) {
List<VarTerm> singletonVars = h.getSingletonVars();
if (singletonVars.size() > 0) {
- logger.warning(getSourceRef(h)+" warning: the rule with head '"+((Rule)h).headClone()+"' has the following singleton variables: "+singletonVars);
+ logger.warning(getSourceRef(h)+" warning: the rule with head '"+((Rule)h).headCopy()+"' has the following singleton variables: "+singletonVars);
}
}
break;
Modified: trunk/src/jason/asSyntax/patterns/goal/DG.java
===================================================================
--- trunk/src/jason/asSyntax/patterns/goal/DG.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSyntax/patterns/goal/DG.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -32,7 +32,7 @@
// add ?g in the end of all inner plans
for (Plan p: innerContent.getPL()) {
- PlanBody b = new PlanBodyImpl(BodyType.test, (Literal)goal.clone());
+ PlanBody b = new PlanBodyImpl(BodyType.test, goal.copy());
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-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSyntax/patterns/goal/EBDG.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -56,7 +56,7 @@
PlanBody b1 = new PlanBodyImpl(BodyType.addBel, pi);
p.getBody().add(0, b1);
// add ?g
- PlanBody b2 = new PlanBodyImpl(BodyType.test, (Literal)goal.clone());
+ PlanBody b2 = new PlanBodyImpl(BodyType.test, goal.copy());
p.getBody().add(b2);
newAg.getPL().add(p);
}
Modified: trunk/src/jason/asSyntax/patterns/goal/MG.java
===================================================================
--- trunk/src/jason/asSyntax/patterns/goal/MG.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/asSyntax/patterns/goal/MG.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -35,7 +35,7 @@
Agent newAg = sd.process(subDir, outerContent, innerContent);
if (newAg != null) {
// add bel g
- Literal ig = (Literal)goal.clone();
+ Literal ig = goal.copy();
ig.addAnnot(BeliefBase.TPercept);
newAg.addInitialBel(goal);
Modified: trunk/src/jason/bb/DefaultBeliefBase.java
===================================================================
--- trunk/src/jason/bb/DefaultBeliefBase.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/bb/DefaultBeliefBase.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -255,7 +255,7 @@
public Object clone() {
DefaultBeliefBase bb = new DefaultBeliefBase();
for (Literal b: this) {
- bb.add(1,(Literal)b.clone());
+ bb.add(1, b.copy());
}
return bb;
}
@@ -308,7 +308,7 @@
protected Object clone() {
BelEntry be = new BelEntry();
for (Literal l: list) {
- be.add((Literal)l.clone(), false);
+ be.add(l.copy(), false);
}
return be;
}
Modified: trunk/src/jason/stdlib/abolish.java
===================================================================
--- trunk/src/jason/stdlib/abolish.java 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/jason/stdlib/abolish.java 2008-09-13 19:09:17 UTC (rev 1370)
@@ -27,6 +27,7 @@
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
+import jason.asSyntax.Atom;
import jason.asSyntax.Literal;
import jason.asSyntax.Term;
@@ -55,9 +56,7 @@
ts.getAg().abolish((Literal)args[0], un);
return true;
} catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'abolish' has not received the required argument.");
- } catch (Exception e) {
- throw new JasonException("Error in internal action 'abolish': " + e, e);
+ throw new JasonException("The internal action 'abolish' has not received the required argument.", new Atom("wrong_arguments"));
}
}
}
Modified: trunk/src/templates/ia
===================================================================
--- trunk/src/templates/ia 2008-09-12 17:05:14 UTC (rev 1369)
+++ trunk/src/templates/ia 2008-09-13 19:09:17 UTC (rev 1370)
@@ -2,6 +2,7 @@
package <PCK>;
+import jason.*;
import jason.asSemantics.*;
import jason.asSyntax.*;
import java.util.logging.*;
@@ -12,12 +13,8 @@
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- try {
- logger.info("not implemented!");
- return true;
- } catch (Exception e) {
- logger....
[truncated message content] |
|
From: <jom...@us...> - 2008-09-14 14:55:05
|
Revision: 1372
http://jason.svn.sourceforge.net/jason/?rev=1372&view=rev
Author: jomifred
Date: 2008-09-14 14:54:57 +0000 (Sun, 14 Sep 2008)
Log Message:
-----------
use the new features (related to error annotations) in the standard internal action of Jason
Modified Paths:
--------------
trunk/examples/gold-miners-II/jia/random.java
trunk/src/jason/JasonException.java
trunk/src/jason/asSemantics/DefaultInternalAction.java
trunk/src/jason/stdlib/abolish.java
trunk/src/jason/stdlib/add_annot.java
trunk/src/jason/stdlib/add_nested_source.java
trunk/src/jason/stdlib/add_plan.java
trunk/src/jason/stdlib/at.java
trunk/src/jason/stdlib/atom.java
trunk/src/jason/stdlib/broadcast.java
trunk/src/jason/stdlib/concat.java
trunk/src/jason/stdlib/count.java
trunk/src/jason/stdlib/create_agent.java
trunk/src/jason/stdlib/current_intention.java
trunk/src/jason/stdlib/date.java
trunk/src/jason/stdlib/delete.java
trunk/src/jason/stdlib/desire.java
trunk/src/jason/stdlib/difference.java
trunk/src/jason/stdlib/drop_all_desires.java
trunk/src/jason/stdlib/drop_all_events.java
trunk/src/jason/stdlib/drop_all_intentions.java
trunk/src/jason/stdlib/drop_desire.java
trunk/src/jason/stdlib/drop_event.java
trunk/src/jason/stdlib/drop_intention.java
trunk/src/jason/stdlib/fail.java
trunk/src/jason/stdlib/fail_goal.java
trunk/src/jason/stdlib/findall.java
trunk/src/jason/stdlib/foreach.java
trunk/src/jason/stdlib/ground.java
trunk/src/jason/stdlib/if_then_else.java
trunk/src/jason/stdlib/intend.java
trunk/src/jason/stdlib/intersection.java
trunk/src/jason/stdlib/kill_agent.java
trunk/src/jason/stdlib/length.java
trunk/src/jason/stdlib/list.java
trunk/src/jason/stdlib/literal.java
trunk/src/jason/stdlib/loop.java
trunk/src/jason/stdlib/member.java
trunk/src/jason/stdlib/min.java
trunk/src/jason/stdlib/my_name.java
trunk/src/jason/stdlib/nth.java
trunk/src/jason/stdlib/number.java
trunk/src/jason/stdlib/perceive.java
trunk/src/jason/stdlib/plan_label.java
trunk/src/jason/stdlib/random.java
trunk/src/jason/stdlib/range.java
trunk/src/jason/stdlib/relevant_plans.java
trunk/src/jason/stdlib/remove_plan.java
trunk/src/jason/stdlib/resume.java
trunk/src/jason/stdlib/reverse.java
trunk/src/jason/stdlib/send.java
trunk/src/jason/stdlib/sort.java
trunk/src/jason/stdlib/stopMAS.java
trunk/src/jason/stdlib/string.java
trunk/src/jason/stdlib/structure.java
trunk/src/jason/stdlib/substring.java
trunk/src/jason/stdlib/succeed_goal.java
trunk/src/jason/stdlib/suspend.java
trunk/src/jason/stdlib/term2string.java
trunk/src/jason/stdlib/time.java
trunk/src/jason/stdlib/union.java
trunk/src/jason/stdlib/wait.java
trunk/src/templates/ia
Modified: trunk/examples/gold-miners-II/jia/random.java
===================================================================
--- trunk/examples/gold-miners-II/jia/random.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/examples/gold-miners-II/jia/random.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -38,7 +38,7 @@
public Unifier next() {
i++;
- Unifier c = un.copy();
+ Unifier c = un.clone();
c.unifies(args[0], new NumberTermImpl(random.nextInt(max)));
return c;
}
Modified: trunk/src/jason/JasonException.java
===================================================================
--- trunk/src/jason/JasonException.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/JasonException.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -24,6 +24,8 @@
package jason;
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.InternalAction;
import jason.asSyntax.Atom;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
@@ -35,6 +37,8 @@
public class JasonException extends java.lang.Exception {
private static final long serialVersionUID = 1L;
+
+ public static final Term WRONG_ARGS = new Atom("wrong_arguments");
private static final Term defaultError = new Atom("internal_action");
private Term error = defaultError;
@@ -80,6 +84,24 @@
return createBasicErrorAnnots(error, getMessage());
}
+ @SuppressWarnings("unchecked")
+ public static JasonException createWrongArgumentNb(DefaultInternalAction ia) {
+ String msg;
+ if (ia.getMinArgs() == ia.getMaxArgs())
+ if (ia.getMinArgs() == 1)
+ msg = " One argument is expected.";
+ else
+ msg = " "+ia.getMinArgs()+" arguments are expected.";
+ else
+ msg = " From "+ia.getMinArgs()+" to "+ia.getMaxArgs()+" arguments are expected.";
+ return new JasonException("The internal action '"+ia.getClass().getSimpleName()+"' has not received the required number of argument(s)."+msg , WRONG_ARGS);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static JasonException createWrongArgument(InternalAction ia, String reason) {
+ return new JasonException("Wrong argument for internal action '"+ia.getClass().getSimpleName()+"': "+reason, WRONG_ARGS);
+ }
+
public static ListTerm createBasicErrorAnnots(String id, String msg) {
return createBasicErrorAnnots(new Atom(id), msg);
}
Modified: trunk/src/jason/asSemantics/DefaultInternalAction.java
===================================================================
--- trunk/src/jason/asSemantics/DefaultInternalAction.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/asSemantics/DefaultInternalAction.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -1,5 +1,6 @@
package jason.asSemantics;
+import jason.JasonException;
import jason.asSyntax.Term;
import java.io.Serializable;
@@ -16,12 +17,15 @@
private static final long serialVersionUID = 1L;
- public boolean suspendIntention() {
- return false;
- }
+ public boolean suspendIntention() { return false; }
+ public boolean canBeUsedInContext() { return true; }
+
+ public int getMinArgs() { return 0; }
+ public int getMaxArgs() { return Integer.MAX_VALUE; }
- public boolean canBeUsedInContext() {
- return true;
+ protected void checkArguments(Term[] args) throws JasonException {
+ if (args.length < getMinArgs() || args.length > getMaxArgs())
+ throw JasonException.createWrongArgumentNb(this);
}
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
Modified: trunk/src/jason/stdlib/abolish.java
===================================================================
--- trunk/src/jason/stdlib/abolish.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/stdlib/abolish.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -27,7 +27,6 @@
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
-import jason.asSyntax.Atom;
import jason.asSyntax.Literal;
import jason.asSyntax.Term;
@@ -50,13 +49,20 @@
*/
public class abolish extends DefaultInternalAction {
- @Override
- public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- try {
- ts.getAg().abolish((Literal)args[0], un);
- return true;
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'abolish' has not received the required argument.", new Atom("wrong_arguments"));
- }
+ @Override public int getMinArgs() { return 1; }
+ @Override public int getMaxArgs() { return 1; }
+
+ @Override protected void checkArguments(Term[] args) throws JasonException {
+ super.checkArguments(args); // check number of arguments
+ if (!args[0].isLiteral())
+ throw JasonException.createWrongArgument(this,"first argument must be a literal");
}
+
+ @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ checkArguments(args);
+
+ ts.getAg().abolish((Literal)args[0], un);
+ return true;
+ }
+
}
Modified: trunk/src/jason/stdlib/add_annot.java
===================================================================
--- trunk/src/jason/stdlib/add_annot.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/stdlib/add_annot.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -77,18 +77,17 @@
singleton = new add_annot();
return singleton;
}
+
+ @Override public int getMinArgs() { return 3; }
+ @Override public int getMaxArgs() { return 3; }
- @Override
- public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- try {
- Term result = addAnnotToList(un, args[0], args[1]);
- return un.unifies(result,args[2]);
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'add_annot' requires three arguments.");
- }
+ @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ checkArguments(args);
+ Term result = addAnnotToList(un, args[0], args[1]);
+ return un.unifies(result,args[2]);
}
- public Term addAnnotToList(Unifier unif, Term l, Term annot) {
+ public Term addAnnotToList(Unifier unif, Term l, Term annot) throws JasonException {
if (l.isList()) {
ListTerm result = new ListTermImpl();
for (Term lTerm: (ListTerm)l) {
@@ -98,21 +97,15 @@
}
}
return result;
- } else {
- try {
- // if it can be parsed as a literal and is not an atom, OK to add annot
- Literal result;
- if (l.isAtom())
- result = new Literal(((Structure)l).getFunctor());
- else
- result = Literal.parseLiteral(l.toString());
- result.addAnnot(annot);
- return result;
- } catch (Exception e) {
- // no problem, the content is not a pred (it is a number,
- // string, ....) received in a message, for instance
- }
+ } else if (l.isLiteral()) {
+ Literal result;
+ if (l.isAtom())
+ result = new Literal(((Structure)l).getFunctor());
+ else
+ result = Literal.parseLiteral(l.toString());
+ result.addAnnot(annot);
+ return result;
}
- return null;
+ return l;
}
}
Modified: trunk/src/jason/stdlib/add_nested_source.java
===================================================================
--- trunk/src/jason/stdlib/add_nested_source.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/stdlib/add_nested_source.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -24,7 +24,6 @@
package jason.stdlib;
-import jason.JasonException;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.InternalAction;
import jason.asSemantics.TransitionSystem;
@@ -62,7 +61,7 @@
<li> <code>.add_nested_source(a[source(bob)],jomi,B)</code>: <code>B</code>
unifies with <code>a[source(jomi)[source(bob)]]</code>.</li>
- <li> <code>.add_annot([a1,a2], jomi, B)</code>: <code>B</code>
+ <li> <code>.add_nested_source([a1,a2], jomi, B)</code>: <code>B</code>
unifies with <code>[a1[source(jomi)], a2[source(jomi)]]</code>.</li>
</ul>
@@ -78,15 +77,14 @@
singleton = new add_nested_source();
return singleton;
}
+
+ @Override public int getMinArgs() { return 3; }
+ @Override public int getMaxArgs() { return 3; }
- @Override
- public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- try {
- Term result = addAnnotToList(un, args[0], (Structure)args[1].clone());
- return un.unifies(result,args[2]);
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'add_nested_source' requires three arguments.");
- }
+ @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ checkArguments(args);
+ Term result = addAnnotToList(un, args[0], args[1].clone());
+ return un.unifies(result,args[2]);
}
public Term addAnnotToList(Unifier unif, Term l, Term source) {
@@ -99,28 +97,23 @@
}
}
return result;
+ } else if (l.isLiteral()) {
+ Literal result;
+ if (l.isAtom())
+ result = new Literal(((Structure)l).getFunctor());
+ else
+ result = (Literal)l.clone();
+
+ // create the source annots
+ Pred ts = new Pred("source",1);
+ ts.addTerm(source);
+ ts.addAnnots(result.getAnnots("source"));
+
+ result.delSources();
+ result.addAnnot(ts);
+ return result;
} else {
- try {
- // if it can be parsed as a literal and is not an atom, OK to add annot
- Literal result;
- if (l.isAtom())
- result = new Literal(((Structure)l).getFunctor());
- else
- result = Literal.parseLiteral(l.toString());
-
- // create the source annots
- Pred ts = new Pred("source",1);
- ts.addTerm(source);
- ts.addAnnots(result.getAnnots("source"));
-
- result.delSources();
- result.addAnnot(ts);
- return result;
- } catch (Exception e) {
- // no problem, the content is not a pred (it is a number,
- // string, ....) received in a message, for instance
- }
+ return l;
}
- return null;
}
}
Modified: trunk/src/jason/stdlib/add_plan.java
===================================================================
--- trunk/src/jason/stdlib/add_plan.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/stdlib/add_plan.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -23,7 +23,6 @@
package jason.stdlib;
-import jason.JasonException;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
@@ -75,28 +74,27 @@
*/
public class add_plan extends DefaultInternalAction {
+ @Override public int getMinArgs() { return 1; }
+ @Override public int getMaxArgs() { return 2; }
+
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- try {
- Term plans = DefaultTerm.parse(args[0].toString());
+ checkArguments(args);
- Structure source = new Atom("self");
- if (args.length > 1) {
- source = (Structure) args[1];
- }
+ Term plans = DefaultTerm.parse(args[0].toString());
- if (plans.isList()) { // arg[0] is a list of strings
- for (Term t: (ListTerm) plans) {
- ts.getAg().getPL().add((StringTerm) t, source);
- }
- } else { // args[0] is a plan
- ts.getAg().getPL().add((StringTerm) plans, source);
+ Structure source = new Atom("self");
+ if (args.length > 1) {
+ source = (Structure) args[1];
+ }
+
+ if (plans.isList()) { // arg[0] is a list of strings
+ for (Term t: (ListTerm) plans) {
+ ts.getAg().getPL().add((StringTerm) t, source);
}
- return true;
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'add_plan' has not received two arguments (a plan as a string and the source).");
- } catch (Exception e) {
- throw new JasonException("Error in internal action 'add_plan': " + e, e);
+ } else { // args[0] is a plan
+ ts.getAg().getPL().add((StringTerm) plans, source);
}
+ return true;
}
}
Modified: trunk/src/jason/stdlib/at.java
===================================================================
--- trunk/src/jason/stdlib/at.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/stdlib/at.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -72,59 +72,60 @@
public class at extends DefaultInternalAction {
public static final String atAtom = ".at";
+
+ @Override public int getMinArgs() { return 2; }
+ @Override public int getMaxArgs() { return 2; }
@Override
public Object execute(final TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- try {
- StringTerm time = (StringTerm)args[0];
- String stime = time.getString();
- StringTerm sevent = (StringTerm)args[1];
+ checkArguments(args);
+
+ StringTerm time = (StringTerm)args[0];
+ String stime = time.getString();
+ StringTerm sevent = (StringTerm)args[1];
- // parse time
- long deadline = -1;
+ // parse time
+ long deadline = -1;
- // if it starts with now
- if (stime.startsWith("now")) {
- // it is something like "now +3 minutes"
- stime = stime.substring(3).trim();
- // get the amount of time
- if (stime.startsWith("+")) {
- stime = stime.substring(1).trim();
- int pos = stime.indexOf(" ");
- if (pos > 0) {
- deadline = Integer.parseInt(stime.substring(0,pos));
- // get the time unit
- stime = stime.substring(pos).trim();
- if (stime.equals("s") || stime.startsWith("second")) {
- deadline *= 1000;
- }
- if (stime.equals("m") || stime.startsWith("minute")) {
- deadline *= 1000 * 60;
- }
- if (stime.equals("h") || stime.startsWith("hour")) {
- deadline *= 1000 * 60 * 60;
- }
- if (stime.equals("d") || stime.startsWith("day")) {
- deadline *= 1000 * 60 * 60 * 24;
- }
+ // if it starts with now
+ if (stime.startsWith("now")) {
+ // it is something like "now +3 minutes"
+ stime = stime.substring(3).trim();
+ // get the amount of time
+ if (stime.startsWith("+")) {
+ stime = stime.substring(1).trim();
+ int pos = stime.indexOf(" ");
+ if (pos > 0) {
+ deadline = Integer.parseInt(stime.substring(0,pos));
+ // get the time unit
+ stime = stime.substring(pos).trim();
+ if (stime.equals("s") || stime.startsWith("second")) {
+ deadline *= 1000;
}
+ if (stime.equals("m") || stime.startsWith("minute")) {
+ deadline *= 1000 * 60;
+ }
+ if (stime.equals("h") || stime.startsWith("hour")) {
+ deadline *= 1000 * 60 * 60;
+ }
+ if (stime.equals("d") || stime.startsWith("day")) {
+ deadline *= 1000 * 60 * 60 * 24;
+ }
}
-
- } else {
- throw new JasonException("The time parameter ('"+stime+"') of the internal action 'at' is not implemented!");
- }
-
- if (deadline == -1) {
- throw new JasonException("The time parameter ('"+time+"') of the internal action 'at' did not parse correctly!");
}
-
- Trigger te = Trigger.parseTrigger(sevent.getString());
+
+ } else {
+ throw new JasonException("The time parameter ('"+stime+"') of the internal action 'at' is not implemented!");
+ }
- ts.getAg().getScheduler().schedule(new CheckDeadline(te, ts), deadline, TimeUnit.MILLISECONDS);
- return true;
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'at' has not received two arguments.");
- }
+ if (deadline == -1) {
+ throw new JasonException("The time parameter ('"+time+"') of the internal action 'at' did not parse correctly!");
+ }
+
+ Trigger te = Trigger.parseTrigger(sevent.getString());
+
+ ts.getAg().getScheduler().schedule(new CheckDeadline(te, ts), deadline, TimeUnit.MILLISECONDS);
+ return true;
}
private static int idCount = 0;
Modified: trunk/src/jason/stdlib/atom.java
===================================================================
--- trunk/src/jason/stdlib/atom.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/stdlib/atom.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -1,6 +1,5 @@
package jason.stdlib;
-import jason.JasonException;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.InternalAction;
import jason.asSemantics.TransitionSystem;
@@ -48,14 +47,12 @@
return singleton;
}
+ @Override public int getMinArgs() { return 1; }
+ @Override public int getMaxArgs() { return 1; }
+
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- try {
- return args[0].isAtom();
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'atom' has not received the required argument.");
- } catch (Exception e) {
- throw new JasonException("Error in internal action 'atom': " + e, e);
- }
+ checkArguments(args);
+ return args[0].isAtom();
}
}
Modified: trunk/src/jason/stdlib/broadcast.java
===================================================================
--- trunk/src/jason/stdlib/broadcast.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/stdlib/broadcast.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -57,34 +57,32 @@
*/
public class broadcast extends DefaultInternalAction {
+ @Override public int getMinArgs() { return 2; }
+ @Override public int getMaxArgs() { return 2; }
+
@Override
+ protected void checkArguments(Term[] args) throws JasonException {
+ super.checkArguments(args);
+ if (!args[0].isAtom()) {
+ throw JasonException.createWrongArgument(this,"illocutionary force argument must be an atom");
+ }
+ }
+
+ @Override
public boolean canBeUsedInContext() {
return false;
}
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- Term ilf = null;
- Term pcnt = null;
+ checkArguments(args);
- try {
- ilf = args[0];
- if (!ilf.isAtom()) {
- throw new JasonException("The illocutionary force parameter of the internal action 'broadcast' is not an atom!");
- }
+ Term ilf = args[0];
+ Term pcnt = args[1];
- pcnt = args[1];
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'broadcast' has not received two arguments.");
- }
Message m = new Message(ilf.toString(), ts.getUserAgArch().getAgName(), null, pcnt);
-
- try {
- ts.getUserAgArch().broadcast(m);
- return true;
- } catch (Exception e) {
- throw new JasonException("Error broadcasting message " + pcnt, e);
- }
+ ts.getUserAgArch().broadcast(m);
+ return true;
}
}
Modified: trunk/src/jason/stdlib/concat.java
===================================================================
--- trunk/src/jason/stdlib/concat.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/stdlib/concat.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -88,7 +88,7 @@
ListTerm result = (ListTerm)args[0].clone();
for (int i=1; i<args.length-1; i++) {
if (!args[i].isList())
- throw new JasonException("arg["+i+"] is not a list in concat.");
+ throw JasonException.createWrongArgument(this,"arg["+i+"] is not a list");
result.concat((ListTerm)args[i].clone());
}
return un.unifies(result, args[args.length-1]);
@@ -97,7 +97,7 @@
} else {
// string concat
if (!args[args.length-1].isVar() && !args[args.length-1].isString()) {
- throw new JasonException("Last argument of concat '"+args[args.length-1]+"' is not a string nor a variable.");
+ throw JasonException.createWrongArgument(this,"Last argument '"+args[args.length-1]+"' is not a string nor a variable.");
}
String vl = args[0].toString();
if (args[0].isString()) {
Modified: trunk/src/jason/stdlib/count.java
===================================================================
--- trunk/src/jason/stdlib/count.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/stdlib/count.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -70,21 +70,26 @@
*/
public class count extends DefaultInternalAction {
+ @Override public int getMinArgs() { return 2; }
+ @Override public int getMaxArgs() { return 2; }
+
+ @Override protected void checkArguments(Term[] args) throws JasonException {
+ super.checkArguments(args); // check number of arguments
+ if (!(args[0] instanceof LogicalFormula))
+ throw JasonException.createWrongArgument(this,"first argument must be a formula");
+ }
+
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- try {
- LogicalFormula logExpr = (LogicalFormula)args[0];
- int n = 0;
- Iterator<Unifier> iu = logExpr.logicalConsequence(ts.getAg(), un);
- while (iu.hasNext()) {
- iu.next();
- n++;
- }
- return un.unifies(args[1], new NumberTermImpl(n));
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'count' has not received two arguments.");
- } catch (Exception e) {
- throw new JasonException("Error in internal action 'count': " + e, e);
+ checkArguments(args);
+
+ LogicalFormula logExpr = (LogicalFormula)args[0];
+ int n = 0;
+ Iterator<Unifier> iu = logExpr.logicalConsequence(ts.getAg(), un);
+ while (iu.hasNext()) {
+ iu.next();
+ n++;
}
+ return un.unifies(args[1], new NumberTermImpl(n));
}
}
Modified: trunk/src/jason/stdlib/create_agent.java
===================================================================
--- trunk/src/jason/stdlib/create_agent.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/stdlib/create_agent.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -82,46 +82,51 @@
*/
public class create_agent extends DefaultInternalAction {
+ @Override public int getMinArgs() { return 2; }
+ @Override public int getMaxArgs() { return 3; }
+
+ @Override protected void checkArguments(Term[] args) throws JasonException {
+ super.checkArguments(args); // check number of arguments
+ if (!args[1].isString())
+ throw JasonException.createWrongArgument(this,"second argument must be a string");
+ if (args.length == 3 && !args[2].isString())
+ throw JasonException.createWrongArgument(this,"third argument must be a list");
+ }
+
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ checkArguments(args);
+
+ Term name = args[0];
+ StringTerm source = (StringTerm)args[1];
- try {
- Term name = args[0];
- StringTerm source = (StringTerm)args[1];
+ File fSource = new File(source.getString());
+ if (!fSource.exists()) {
+ throw new JasonException("The source file " + source + " was not found!");
+ }
- File fSource = new File(source.getString());
- if (!fSource.exists()) {
- throw new JasonException("The source file " + source + " was not found!");
- }
-
- String agClass = null;
- String agArchClass = null;
- ClassParameters bbPars = null;
- if (args.length > 2) { // optional parameter
- // get the parameters
- for (Term t: (ListTerm)args[2]) {
- if (t.isStructure()) {
- Structure s = (Structure)t;
- if (s.getFunctor().equals("beliefBaseClass")) {
- bbPars = new ClassParameters(testString(s.getTerm(0)));
- } else if (s.getFunctor().equals("agentClass")) {
- agClass = testString(s.getTerm(0)).toString();
- } else if (s.getFunctor().equals("agentArchClass")) {
- agArchClass = testString(s.getTerm(0)).toString();
- }
+ String agClass = null;
+ String agArchClass = null;
+ ClassParameters bbPars = null;
+ if (args.length > 2) { // optional parameter
+ // get the parameters
+ for (Term t: (ListTerm)args[2]) {
+ if (t.isStructure()) {
+ Structure s = (Structure)t;
+ if (s.getFunctor().equals("beliefBaseClass")) {
+ bbPars = new ClassParameters(testString(s.getTerm(0)));
+ } else if (s.getFunctor().equals("agentClass")) {
+ agClass = testString(s.getTerm(0)).toString();
+ } else if (s.getFunctor().equals("agentArchClass")) {
+ agArchClass = testString(s.getTerm(0)).toString();
}
}
-
}
- RuntimeServicesInfraTier rs = ts.getUserAgArch().getArchInfraTier().getRuntimeServices();
- return rs.createAgent(name.toString(), fSource.getAbsolutePath(), agClass, agArchClass, bbPars, ts.getSettings());
+ }
- } catch (IndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'create_agent' received a wrong number of arguments.");
- } catch (Exception e) {
- throw new JasonException("Error in internal action 'create_agent': " + e, e);
- }
+ RuntimeServicesInfraTier rs = ts.getUserAgArch().getArchInfraTier().getRuntimeServices();
+ return rs.createAgent(name.toString(), fSource.getAbsolutePath(), agClass, agArchClass, bbPars, ts.getSettings());
}
private Structure testString(Term t) {
Modified: trunk/src/jason/stdlib/current_intention.java
===================================================================
--- trunk/src/jason/stdlib/current_intention.java 2008-09-14 10:34:29 UTC (rev 1371)
+++ trunk/src/jason/stdlib/current_intention.java 2008-09-14 14:54:57 UTC (rev 1372)
@@ -23,7 +23,6 @@
package jason.stdlib;
-import jason.JasonException;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.Event;
import jason.asSemantics.Intention;
@@ -93,27 +92,25 @@
*/
public class current_intention extends DefaultInternalAction {
+ @Override public int getMinArgs() { return 1; }
+ @Override public int getMaxArgs() { return 1; }
+
@...
[truncated message content] |
|
From: <jom...@us...> - 2008-09-18 10:42:56
|
Revision: 1374
http://jason.svn.sourceforge.net/jason/?rev=1374&view=rev
Author: jomifred
Date: 2008-09-18 17:42:52 +0000 (Thu, 18 Sep 2008)
Log Message:
-----------
add the option to include plans in the begin for the .add_plan internal action
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestAll.java
trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSyntax/PlanLibrary.java
trunk/src/jason/stdlib/add_plan.java
Added Paths:
-----------
trunk/applications/as-unit-test/src/jason/tests/TestIA.java
Modified: trunk/applications/as-unit-test/src/jason/tests/TestAll.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestAll.java 2008-09-16 17:43:27 UTC (rev 1373)
+++ trunk/applications/as-unit-test/src/jason/tests/TestAll.java 2008-09-18 17:42:52 UTC (rev 1374)
@@ -7,13 +7,15 @@
@RunWith(Suite.class)
@SuiteClasses({
BugListReturnUnification.class,
+ BugVarsAsArg.class,
BugVarsInInitBels.class,
- BugVarsAsArg.class,
TestAddLogExprInBB.class,
- TestGoalSource.class,
+ TestGoalSource.class,
+ TestIA.class,
+ TestIAdelete.class,
TestIF.class,
+ TestKQML.class,
TestLoop.class,
- TestKQML.class,
TestPlanbodyAsTerm.class,
TestPlanFailure.class,
TestVarInContext.class
Added: trunk/applications/as-unit-test/src/jason/tests/TestIA.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestIA.java (rev 0)
+++ trunk/applications/as-unit-test/src/jason/tests/TestIA.java 2008-09-18 17:42:52 UTC (rev 1374)
@@ -0,0 +1,33 @@
+package jason.tests;
+
+import jason.asunit.TestAgent;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestIA {
+
+ @Test
+ public void testAddPlan() {
+ TestAgent ag = new TestAgent();
+
+ // defines the agent's AgentSpeak code
+ ag.parseAScode(
+ "+!test <- act1. \n"+
+ "+!add <- .add_plan(\"@l0 +!test <- act0.\", bob, begin). "+
+ "+!remove <- .remove_plan(l0, bob). "
+ );
+ ag.addGoal("test");
+ ag.assertAct("act1", 10);
+ ag.addGoal("add");
+ ag.addGoal("test");
+ ag.assertAct("act0", 10);
+ ag.addGoal("remove");
+ int size = ag.getPL().size();
+ ag.assertIdle(30);
+ Assert.assertEquals(size-1, ag.getPL().size());
+ ag.addGoal("test");
+ ag.assertAct("act1", 10);
+ }
+
+}
Modified: trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java
===================================================================
--- trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java 2008-09-16 17:43:27 UTC (rev 1373)
+++ trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java 2008-09-18 17:42:52 UTC (rev 1374)
@@ -39,7 +39,7 @@
// add in the end of plan
p.getBody().add(endofplan);
- newAg.getPL().add(p);
+ newAg.getPL().add(p, false);
}
// add failure plan:
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-09-16 17:43:27 UTC (rev 1373)
+++ trunk/src/jason/asSemantics/Agent.java 2008-09-18 17:42:52 UTC (rev 1374)
@@ -390,7 +390,7 @@
this.addInitialGoal(g);
}
for (Plan p: a.getPL()) {
- this.getPL().add(p);
+ this.getPL().add(p, false);
}
}
}
Modified: trunk/src/jason/asSyntax/PlanLibrary.java
===================================================================
--- trunk/src/jason/asSyntax/PlanLibrary.java 2008-09-16 17:43:27 UTC (rev 1373)
+++ trunk/src/jason/asSyntax/PlanLibrary.java 2008-09-18 17:42:52 UTC (rev 1374)
@@ -62,15 +62,33 @@
private Logger logger = Logger.getLogger(PlanLibrary.class.getName());
+ /**
+ * Add a new plan written as a String. The source
+ * normally is "self" or the agent that sent this plan.
+ * If the already has a plan equals to "stPlan", only a
+ * new source is added.
+ *
+ * The plan is added in the end of the PlanLibrary.
+ *
+ * returns the plan added, null if it does not work.
+ */
+ public Plan add(StringTerm stPlan, Structure tSource) {
+ return add(stPlan, tSource, false);
+ }
+
/**
- * Add a new plan based on a String. The source
+ * Add a new plan written as a String. The source
* normally is "self" or the agent that sent this plan.
* If the already has a plan equals to "stPlan", only a
* new source is added.
+ *
+ * If <i>before</i> is true, the plan will be added in the
+ * begin of the PlanLibrary; otherwise, it is added in
+ * the end.
*
* returns the plan added, null if it does not work.
*/
- public Plan add(StringTerm stPlan, Structure tSource) {
+ public Plan add(StringTerm stPlan, Structure tSource, boolean before) {
String sPlan = stPlan.getString();
try {
// remove quotes \" -> "
@@ -90,9 +108,9 @@
p.setLabel(getUniqueLabel());
}
p.getLabel().addSource(tSource);
- add(p);
+ add(p, before);
} else {
- p = (Plan) plans.get(i);
+ p = plans.get(i);
p.getLabel().addSource(tSource);
}
return p;
@@ -175,13 +193,13 @@
public void addAll(PlanLibrary pl) throws JasonException {
for (Plan p: pl) {
- add(p);
+ add(p, false);
}
}
public void addAll(List<Plan> plans) throws JasonException {
for (Plan p: plans) {
- add(p);
+ add(p, false);
}
}
@@ -199,6 +217,10 @@
return planLabels.get(label);
}
+ public int size() {
+ return plans.size();
+ }
+
public List<Plan> getPlans() {
return plans;
}
Modified: trunk/src/jason/stdlib/add_plan.java
===================================================================
--- trunk/src/jason/stdlib/add_plan.java 2008-09-16 17:43:27 UTC (rev 1373)
+++ trunk/src/jason/stdlib/add_plan.java 2008-09-18 17:42:52 UTC (rev 1374)
@@ -49,8 +49,15 @@
<li><i>+ source</i> (atom [optional]): the source of the
plan(s). The default value for the source is <code>self</code>.<br/>
+ <li><i>+ position</i> (atom [optional]): if value is "before" the plan
+ will be added in the begin of the plan library.
+ The default value is <code>end</code>.<br/>
+
</ul>
+ Note that if only two parameter is informed, the second will be the source and not
+ the position.
+
<p>Examples:<ul>
<li> <code>.add_plan("+b : true <- .print(b).")</code>: adds the plan
@@ -61,6 +68,9 @@
the previous example, but the source of the plan is agent
"rafa".</li>
+ <li> <code>.add_plan("+b : true <- .print(b).", rafa, begin)</code>: same as
+ the previous example, but the plan is added in the begin of the plan library.</li>
+
<li> <code>.add_plan(["+b : true <- .print(b).", "+b : bel <-
.print(bel)."], rafa)</code>: adds both plans with "rafa" as their
sources.</li>
@@ -75,7 +85,7 @@
public class add_plan extends DefaultInternalAction {
@Override public int getMinArgs() { return 1; }
- @Override public int getMaxArgs() { return 2; }
+ @Override public int getMaxArgs() { return 3; }
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
@@ -84,16 +94,18 @@
Term plans = DefaultTerm.parse(args[0].toString());
Structure source = new Atom("self");
- if (args.length > 1) {
+ if (args.length > 1)
source = (Structure) args[1];
- }
+ boolean before = false;
+ if (args.length > 2)
+ before = args[2].toString().equals("begin");
+
if (plans.isList()) { // arg[0] is a list of strings
- for (Term t: (ListTerm) plans) {
+ for (Term t: (ListTerm) plans)
ts.getAg().getPL().add((StringTerm) t, source);
- }
} else { // args[0] is a plan
- ts.getAg().getPL().add((StringTerm) plans, source);
+ ts.getAg().getPL().add((StringTerm) plans, source, before);
}
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-09-21 19:45:05
|
Revision: 1375
http://jason.svn.sourceforge.net/jason/?rev=1375&view=rev
Author: jomifred
Date: 2008-09-21 19:45:01 +0000 (Sun, 21 Sep 2008)
Log Message:
-----------
use UMLGraph to produce UML diagrams in api doc
Modified Paths:
--------------
trunk/build.xml
trunk/doc/index.html
trunk/src/jason/bb/BeliefBase.java
trunk/src/jason/bb/ChainBBAdapter.java
Added Paths:
-----------
trunk/lib/UmlGraph.jar
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-09-18 17:42:52 UTC (rev 1374)
+++ trunk/build.xml 2008-09-21 19:45:01 UTC (rev 1375)
@@ -220,12 +220,28 @@
use="true"
version="true"
author="true"
- windowtitle="Jason - AgentSpeak Java Interpreter">
+ windowtitle="Jason - AgentSpeak Java Interpreter"
+ stylesheetfile="doc/faq.css">
<classpath refid="project.classpath" />
+ <doclet name="org.umlgraph.doclet.UmlGraphDoc" path="lib/UMLGraph.jar">
+ <!--param name="-inferrel"/ -->
+ <!--param name="-inferdep"/-->
+ <param name="-hide" value="java.*"/>
+ <!--param name="-collpackages" value="java.util.*"/-->
+ <param name="-qualify"/>
+ <!--param name="-collapsible"/-->
+ <param name="-postfixpackage"/>
+ <param name="-nodefontsize" value="16"/>
+ <param name="-nodefontpackagesize" value="12"/>
+ <param name="-edgefontsize" value="14"/>
+
+ <param name="-link" value="http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/doclet/spec"/>
+ <param name="-link" value="http://java.sun.com/j2se/1.5/docs/api"/>
+ </doclet>
</javadoc>
- <exec executable="doxygen">
+ <!--exec executable="doxygen">
<arg line="doc/jason.doxygen"/>
- </exec>
+ </exec-->
</target>
<target name="dist" depends="cleanExamples,plugin" description="Build distribution.">
@@ -263,7 +279,6 @@
<delete dir="${distDir}/bin/classes" />
<delete dir="${distDir}/bin/classes-eclipse" />
<delete dir="${distDir}/doc/faq" />
- <delete dir="${distDir}/doc/api" />
<delete dir="${distDir}/doc/mini-tutorial/src" />
<tar compression="gzip" tarfile="${distFile}.tgz" longfile="gnu">
Modified: trunk/doc/index.html
===================================================================
--- trunk/doc/index.html 2008-09-18 17:42:52 UTC (rev 1374)
+++ trunk/doc/index.html 2008-09-21 19:45:01 UTC (rev 1375)
@@ -17,10 +17,10 @@
<li><a href="faq.html">FAQ</a> (html)</li><br/>
-<li><a href="api-doxygen/html/namespacejason_1_1stdlib.html">Stantard internal actions</a> (html)</li>
-<li><a href="api-doxygen/html/namespacejason_1_1functions.html">Stantard arithmetic functions</a> (html)</li>
+<li><a href="api/jason/stdlib/package-summary.html#package_description">Stantard internal actions</a> (html)</li>
+<li><a href="api/jason/functions/package-summary.html">Stantard arithmetic functions</a> (html)</li>
-<li><a href="api-doxygen/html/index.html">API of all classes</a> (html)</li><br>
+<li>API of all classes: generated by <a href="api/index.html">JavaDoc</a> or by <a href="api-doxygen/html/index.html">Doxygen</a>.</li><br>
<li><a href="AS2JavaParser.html">Syntax of AgentSpeak</a> as
interpreted by <a href="http://jason.sf.net"><b><i>Jason</i></b></a> (html
Property changes on: trunk/lib/UmlGraph.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/jason/bb/BeliefBase.java
===================================================================
--- trunk/src/jason/bb/BeliefBase.java 2008-09-18 17:42:52 UTC (rev 1374)
+++ trunk/src/jason/bb/BeliefBase.java 2008-09-21 19:45:01 UTC (rev 1375)
@@ -43,8 +43,14 @@
*/
public interface BeliefBase extends Iterable<Literal>, Cloneable {
- public static final Term TPercept = Pred.createSource(new Atom("percept"));
- public static final Term TSelf = Pred.createSource(new Atom("self"));
+ public static final Term ASelf = new Atom("self");
+ public static final Term APercept = new Atom("percept");
+
+ /** represents the structure 'source(percept)' */
+ public static final Term TPercept = Pred.createSource(APercept);
+
+ /** represents the structure 'source(self)' */
+ public static final Term TSelf = Pred.createSource(ASelf);
/**
* Called before the MAS execution with the agent that uses this
Modified: trunk/src/jason/bb/ChainBBAdapter.java
===================================================================
--- trunk/src/jason/bb/ChainBBAdapter.java 2008-09-18 17:42:52 UTC (rev 1374)
+++ trunk/src/jason/bb/ChainBBAdapter.java 2008-09-21 19:45:01 UTC (rev 1375)
@@ -46,6 +46,8 @@
}
</pre>
+ @navassoc - nextBB - BeliefBase
+
@author Jomi
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-09-27 12:49:07
|
Revision: 1380
http://jason.svn.sourceforge.net/jason/?rev=1380&view=rev
Author: jomifred
Date: 2008-09-27 12:48:55 +0000 (Sat, 27 Sep 2008)
Log Message:
-----------
Add annotations in the java classes to help the generation of UML diagrams in the apidoc (using UMLGraph)
Implement the new hierarchy of classes related to Literal and Atom -- as discussed in the jason-developers
list.
To create a new literal, the previous
method
Literal.parseLiteral(....)
still works, but the constructor
new Literal(...)
has to be used as
new LiteralImpl(....)
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/asunit/TestArch.java
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-team/src/java/arch/ACProxy.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/build.xml
trunk/demos/sync-environment/EnvSync.java
trunk/examples/game-of-life/LifeEnvironment.java
trunk/examples/gold-miners-II/arch/MinerArch.java
trunk/examples/gold-miners-II/env/MiningEnvironment.java
trunk/examples/sniffer/comm/SnifferCentralised.java
trunk/release-notes.txt
trunk/src/jason/JasonException.java
trunk/src/jason/asSemantics/ActionExec.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSemantics/Unifier.java
trunk/src/jason/asSyntax/ArithExpr.java
trunk/src/jason/asSyntax/Atom.java
trunk/src/jason/asSyntax/BinaryStructure.java
trunk/src/jason/asSyntax/InternalActionLiteral.java
trunk/src/jason/asSyntax/ListTermImpl.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/LogExpr.java
trunk/src/jason/asSyntax/NumberTermImpl.java
trunk/src/jason/asSyntax/Plan.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
trunk/src/jason/asSyntax/PlanLibrary.java
trunk/src/jason/asSyntax/Pred.java
trunk/src/jason/asSyntax/RelExpr.java
trunk/src/jason/asSyntax/Rule.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/asSyntax/Trigger.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/patterns/goal/BC.java
trunk/src/jason/asSyntax/patterns/goal/EBDG.java
trunk/src/jason/asSyntax/patterns/goal/MG.java
trunk/src/jason/asSyntax/patterns/goal/OMC.java
trunk/src/jason/asSyntax/patterns/goal/RC.java
trunk/src/jason/asSyntax/patterns/goal/SMC.java
trunk/src/jason/bb/DefaultBeliefBase.java
trunk/src/jason/bb/JDBCPersistentBB.java
trunk/src/jason/functions/RuleToFunction.java
trunk/src/jason/stdlib/add_annot.java
trunk/src/jason/stdlib/add_nested_source.java
trunk/src/jason/stdlib/add_plan.java
trunk/src/jason/stdlib/desire.java
trunk/src/jason/stdlib/remove_plan.java
trunk/src/test/BeliefBaseTest.java
trunk/src/test/ExprTermTest.java
trunk/src/test/PlanTest.java
trunk/src/test/TermTest.java
trunk/src/test/VarTermTest.java
Added Paths:
-----------
trunk/src/jason/stdlib/package.html
Removed Paths:
-------------
trunk/src/jason/stdlib/package.dox
Modified: trunk/applications/as-unit-test/src/jason/asunit/TestArch.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/asunit/TestArch.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/applications/as-unit-test/src/jason/asunit/TestArch.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -4,7 +4,6 @@
import jason.architecture.AgArch;
import jason.asSemantics.ActionExec;
import jason.asSyntax.Literal;
-import jason.asSyntax.Structure;
import jason.environment.Environment;
import jason.infra.centralised.CentralisedAgArch;
import jason.infra.centralised.CentralisedEnvironment;
@@ -20,7 +19,7 @@
private Condition condition;
private int cycle = 0;
- private List<Structure> actions = new ArrayList<Structure>();
+ private List<Literal> actions = new ArrayList<Literal>();
StringBuilder output = new StringBuilder();
@@ -40,7 +39,7 @@
return cycle;
}
- public List<Structure> getActions() {
+ public List<Literal> getActions() {
return actions;
}
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -13,6 +13,7 @@
import jason.asSyntax.DefaultTerm;
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.PlanBody;
import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Pred;
@@ -216,7 +217,7 @@
}
- private void generateObligationPermissionEvents(Pred m) throws RevisionFailedException {
+ private void generateObligationPermissionEvents(Literal m) throws RevisionFailedException {
// computes this agent obligations in the scheme
String schId = m.getTerm(0).toString();
String grId = m.getTerm(1).toString();
@@ -255,7 +256,7 @@
Structure giAnnot = new Structure("group");
giAnnot.addTerm(gr);
- Literal obl = new Literal(type);
+ Literal obl = new LiteralImpl(type);
obl.addTerms(sch,new UnnamedVar());
obl.addAnnot(giAnnot);
@@ -367,7 +368,7 @@
}
private Literal buildLiteralToCleanBB(Atom aSchId, PredicateIndicator pred, boolean schInEnd) {
- Literal l = new Literal(pred.getFunctor());
+ Literal l = new LiteralImpl(pred.getFunctor());
if (!schInEnd) {
l.addTerm(aSchId);
}
@@ -434,7 +435,7 @@
// create the literal to be added
VarTerm S = new VarTerm("S");
- Literal gil = new Literal("goal_state");
+ Literal gil = new LiteralImpl("goal_state");
gil.addTerms(new Atom(gi.getScheme().getId()), gap, S);
gil.addAnnot(managerSource);
Modified: trunk/applications/jason-team/src/java/arch/ACProxy.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -1,6 +1,7 @@
package arch;
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Structure;
import jason.environment.grid.Location;
@@ -151,7 +152,7 @@
arq.setScore(score);
// add location in perception
- Literal lpos = new Literal("pos");
+ Literal lpos = new LiteralImpl("pos");
lpos.addTerms(new NumberTermImpl(agx), new NumberTermImpl(agy), new NumberTermImpl(step));
percepts.add(lpos);
@@ -188,7 +189,7 @@
// ignore cows in the border, they complicate all :-)
if (absx < arq.getModel().getWidth()-1 && absx != 0 && absy != 00 && absy < arq.getModel().getHeight()-1) {
int cowId = Integer.parseInt(type.getAttribute("ID"));
- Literal lc = new Literal("cow");
+ Literal lc = new LiteralImpl("cow");
lc.addTerms(new NumberTermImpl( cowId ), new NumberTermImpl( absx), new NumberTermImpl(absy));
Structure stepannot = new Structure("step",1);
stepannot.addTerm(new NumberTermImpl(step));
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -7,6 +7,7 @@
import jason.asSemantics.Message;
import jason.asSyntax.Atom;
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.NumberTerm;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Term;
@@ -18,7 +19,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import jmoise.OrgAgent;
import agent.SelectEvent;
import env.ACViewer;
import env.WorldModel;
@@ -235,7 +235,7 @@
try {
logger.info("** Arch adding restart for "+getAgName());
//getTS().getC().create(); // it is terrible for pending intentions of cowboys!
- getTS().getC().addAchvGoal(new Literal("restart"), Intention.EmptyInt);
+ getTS().getC().addAchvGoal(new LiteralImpl("restart"), Intention.EmptyInt);
lo2 = new Location(-1,-1); // to not restart again in the next cycle
} catch (Exception e) {
logger.info("Error in restart!"+ e);
@@ -243,7 +243,7 @@
}
public static Literal createCellPerception(int x, int y, Term obj) {
- Literal l = new Literal("cell");
+ Literal l = new LiteralImpl("cell");
l.addTerms(new NumberTermImpl(x),
new NumberTermImpl(y),
obj);
@@ -358,7 +358,7 @@
if (acView != null) acView.getModel().setAgPos(agid, x, y);
model.incVisited(x, y);
//getTS().getAg().getLogger().info("ag pos "+getMinerId(m.getSender())+" = "+x+","+y);
- Literal tAlly = new Literal("ally_pos");
+ Literal tAlly = new LiteralImpl("ally_pos");
tAlly.addTerms(new Atom(m.getSender()), new NumberTermImpl(x), new NumberTermImpl(y));
getTS().getAg().addBel( tAlly );
} catch (Exception e) {
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/build.xml 2008-09-27 12:48:55 UTC (rev 1380)
@@ -15,7 +15,7 @@
<property name="dist.properties" value="${basedir}/bin/dist.properties" />
<property name="version" value="1" />
- <property name="release" value="1.3" />
+ <property name="release" value="2.0" />
<property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" />
<property name="distFile" value="${env.HOME}/Jason-${version}.${release}" />
Modified: trunk/demos/sync-environment/EnvSync.java
===================================================================
--- trunk/demos/sync-environment/EnvSync.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/demos/sync-environment/EnvSync.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -1,6 +1,7 @@
// Environment code for project act-sync.mas2j
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Structure;
import jason.environment.SteppedEnvironment;
@@ -24,7 +25,7 @@
@Override
public boolean executeAction(String agName, Structure action) {
actionCount++;
- Literal p = new Literal("executed_actions");
+ Literal p = new LiteralImpl("executed_actions");
p.addTerm(new NumberTermImpl(actionCount));
clearPercepts();
addPercept(p);
Modified: trunk/examples/game-of-life/LifeEnvironment.java
===================================================================
--- trunk/examples/game-of-life/LifeEnvironment.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/examples/game-of-life/LifeEnvironment.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -1,6 +1,7 @@
// Environment code for project game-of-life.mas2j
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Structure;
import jason.environment.grid.Location;
@@ -43,7 +44,7 @@
@Override
protected void stepStarted(int step) {
//logger.info("start step "+step);
- lstep = new Literal("step");
+ lstep = new LiteralImpl("step");
lstep.addTerm(new NumberTermImpl(step+1));
}
@@ -109,7 +110,7 @@
if (model.isAlive(l.x + 1, l.y - 1)) alive++;
if (model.isAlive(l.x + 1, l.y)) alive++;
if (model.isAlive(l.x + 1, l.y + 1)) alive++;
- Literal lAlive = new Literal("alive_neighbors");
+ Literal lAlive = new LiteralImpl("alive_neighbors");
lAlive.addTerm(new NumberTermImpl(alive));
addPercept(agName, lAlive);
Modified: trunk/examples/gold-miners-II/arch/MinerArch.java
===================================================================
--- trunk/examples/gold-miners-II/arch/MinerArch.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/examples/gold-miners-II/arch/MinerArch.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -5,6 +5,7 @@
import jason.architecture.AgArch;
import jason.asSemantics.Message;
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.NumberTerm;
import jason.asSyntax.PredicateIndicator;
import jason.environment.grid.Location;
@@ -151,9 +152,9 @@
//logger.info("** Arch adding restart for "+getAgName()+", TS="+getTS().getCurrentTask()+", "+getTS().getC());
getTS().getC().create();
- getTS().getAg().getBB().abolish(new Literal("restart").getPredicateIndicator());
+ getTS().getAg().getBB().abolish(new LiteralImpl("restart").getPredicateIndicator());
getTS().getAg().getBB().abolish(new PredicateIndicator("gold",2)); // tira os ouros
- getTS().getAg().addBel(new Literal("restart"));
+ getTS().getAg().addBel(new LiteralImpl("restart"));
lo2 = new Location(-1,-1); // to not restart again in the next cycle
//getTS().stopCycle();
Modified: trunk/examples/gold-miners-II/env/MiningEnvironment.java
===================================================================
--- trunk/examples/gold-miners-II/env/MiningEnvironment.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/examples/gold-miners-II/env/MiningEnvironment.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -3,6 +3,7 @@
import jason.asSyntax.Atom;
import jason.asSyntax.DefaultTerm;
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
@@ -179,7 +180,7 @@
logger.warning("Error creating world "+e);
}
}
- public static Literal aCAP = new Literal("container_has_space");
+ public static Atom aCAP = new LiteralImpl("container_has_space");
public static Atom aOBSTACLE = new Atom("obstacle");
public static Atom aGOLD = new Atom("gold");
@@ -202,11 +203,11 @@
clearPercepts(agName);
// its location
Location l = model.getAgPos(ag);
- Literal p = new Literal("pos");
+ Literal p = new LiteralImpl("pos");
p.addTerms(new NumberTermImpl(l.x), new NumberTermImpl(l.y), new NumberTermImpl(getStep()));
addPercept(agName, p);
- Literal cg = new Literal("carrying_gold");
+ Literal cg = new LiteralImpl("carrying_gold");
cg.addTerm(new NumberTermImpl(model.getGoldsWithAg(ag)));
addPercept(agName, cg);
@@ -255,7 +256,7 @@
}
public static Literal createCellPerception(int x, int y, Atom obj) {
- Literal l = new Literal("cell");
+ Literal l = new LiteralImpl("cell");
l.addTerms(new NumberTermImpl(x),
new NumberTermImpl(y),
obj);
Modified: trunk/examples/sniffer/comm/SnifferCentralised.java
===================================================================
--- trunk/examples/sniffer/comm/SnifferCentralised.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/examples/sniffer/comm/SnifferCentralised.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -6,6 +6,7 @@
import jason.asSemantics.Message;
import jason.asSyntax.Atom;
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.StringTermImpl;
import jason.asSyntax.Structure;
@@ -39,7 +40,7 @@
// add a belief in the agent mind
// format: msgSent(time(YY,MM,DD,HH,MM,SS),id,irt,ilf,sender,receiver,content)
- Literal e = new Literal("msg_sent");
+ Literal e = new LiteralImpl("msg_sent");
Calendar now = new GregorianCalendar();
Structure p = new Structure("time");
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/release-notes.txt 2008-09-27 12:48:55 UTC (rev 1380)
@@ -1,5 +1,5 @@
-------------
-version 1.1.3
+version 1.2.0
-------------
New features
@@ -38,6 +38,18 @@
. .math.average: returns the average of a list of numbers
+API changes
+. the most significant change is in the Literal class, that
+ is abstract now. To create a new literal, the previous
+ method
+ Literal.parseLiteral(....)
+ still works, but
+ new Literal(...)
+ have to be written as
+ new LiteralImpl(....)
+ see API doc for more details.
+ see discussion about the Literal class in the
+ jason-developers list.
-------------
version 1.1.2
Modified: trunk/src/jason/JasonException.java
===================================================================
--- trunk/src/jason/JasonException.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/src/jason/JasonException.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -38,7 +38,8 @@
private static final long serialVersionUID = 1L;
- public static final Term WRONG_ARGS = new Atom("wrong_arguments");
+ public static final Term WRONG_ARGS = new Atom("wrong_arguments");
+ public static final Term UNKNOW_ERROR = new Atom("unknown");
private static final Term defaultError = new Atom("internal_action");
private Term error = defaultError;
Modified: trunk/src/jason/asSemantics/ActionExec.java
===================================================================
--- trunk/src/jason/asSemantics/ActionExec.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/src/jason/asSemantics/ActionExec.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -24,6 +24,7 @@
package jason.asSemantics;
+import jason.asSyntax.Literal;
import jason.asSyntax.Pred;
import jason.asSyntax.Structure;
@@ -37,11 +38,11 @@
private static final long serialVersionUID = 1L;
- private Structure action;
+ private Literal action;
private Intention intention;
private boolean result;
- public ActionExec(Pred ac, Intention i) {
+ public ActionExec(Literal ac, Intention i) {
action = ac;
intention = i;
result = false;
@@ -61,7 +62,10 @@
}
public Structure getActionTerm() {
- return action;
+ if (action.isAtom())
+ return new Structure(action.getFunctor());
+ else
+ return (Structure)action;
}
public Intention getIntention() {
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -31,6 +31,7 @@
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.LogicalFormula;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Plan;
@@ -186,7 +187,7 @@
} else if (conf.ag.socAcc(m)) {
// generate an event
- Literal received = new Literal("kqml_received");
+ Literal received = new LiteralImpl("kqml_received");
received.addTerms(
new Atom(m.getSender()),
new Atom(m.getIlForce()),
@@ -863,10 +864,11 @@
return null;
}
+ private static final Term aNOCODE = new Atom("no_code");
private static void setDefaultFailureAnnots(Event failEvent, Term body, List<Term> failAnnots) {
// add default failure annots
if (failAnnots == null)
- failAnnots = JasonException.createBasicErrorAnnots("unknown", "");
+ failAnnots = JasonException.createBasicErrorAnnots( JasonException.UNKNOW_ERROR, "");
// add failure annots in the event related to the code source
Literal bodyterm = null;
@@ -878,9 +880,8 @@
codeline = new NumberTermImpl(bodyterm.getSrcLine());
} else {
bodyterm = new Atom("no_code");
- codesrc = new Atom("no_code");
- codeline = new Atom("no_code");
-
+ codesrc = aNOCODE;
+ codeline = aNOCODE;
}
// code
Modified: trunk/src/jason/asSemantics/Unifier.java
===================================================================
--- trunk/src/jason/asSemantics/Unifier.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/src/jason/asSemantics/Unifier.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -23,6 +23,7 @@
package jason.asSemantics;
+import jason.asSyntax.Atom;
import jason.asSyntax.Literal;
import jason.asSyntax.Pred;
import jason.asSyntax.Structure;
@@ -214,6 +215,14 @@
// both terms are not vars
+ // if the first is an Atom and the second pred, they must have the same functor
+ // and no terms in the pred
+ if (t1g.isAtom() && t2g.isPred()) {
+ Atom t1a = (Atom)t1g;
+ Pred t2p = (Pred)t2g;
+ return t2p.getArity() == 0 && t1a.getFunctor().equals(t2p.getFunctor());
+ }
+
// if any of the terms is not a structure (is a number or a
// string), they must be equal
if (!t1g.isStructure() || !t2g.isStructure())
@@ -249,7 +258,7 @@
return false;
// different functor
- if (t1s.getFunctor() != null && !t1s.getFunctor().equals(t2s.getFunctor()))
+ if (!t1s.getFunctor().equals(t2s.getFunctor())) // t1a.getFunctor() != null &&
return false;
// unify inner terms
Modified: trunk/src/jason/asSyntax/ArithExpr.java
===================================================================
--- trunk/src/jason/asSyntax/ArithExpr.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/src/jason/asSyntax/ArithExpr.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -34,14 +34,16 @@
import org.w3c.dom.Element;
/**
- * Represents and solve arithmetic expressions like "10 + 30".
+ Represents and solve arithmetic expressions like "10 + 30".
+
+ @navassoc - op - ArithmeticOp
*/
public class ArithExpr extends ArithFunctionTerm implements NumberTerm {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(ArithExpr.class.getName());
-
- public enum ArithmeticOp {
+
+ public enum ArithmeticOp {
none {
double eval(double x, double y) {
return 0;
@@ -121,23 +123,23 @@
private ArithmeticOp op = ArithmeticOp.none;
public ArithExpr(NumberTerm t1, ArithmeticOp oper, NumberTerm t2) {
- super(oper.toString(),2);
- addTerms(t1, t2);
+ super(oper.toString(),2);
+ addTerms(t1, t2);
op = oper;
- if (t1 instanceof SourceInfo) setSrc((SourceInfo)t1);
- else if (t2 instanceof SourceInfo) setSrc((SourceInfo)t2);
+ if (t1 instanceof SourceInfo) setSrc((SourceInfo)t1);
+ else if (t2 instanceof SourceInfo) setSrc((SourceInfo)t2);
}
public ArithExpr(ArithmeticOp oper, NumberTerm t1) {
- super(oper.toString(),1);
- addTerm(t1);
+ super(oper.toString(),1);
+ addTerm(t1);
op = oper;
- setSrc(t1);
+ setSrc(t1);
}
private ArithExpr(ArithExpr ae) { // for clone
- super(ae);
- op = ae.op;
+ super(ae);
+ op = ae.op;
}
/** returns some Term that can be evaluated as Number */
@@ -170,9 +172,9 @@
}
@Override
- public boolean checkArity(int a) {
+ public boolean checkArity(int a) {
return a == 1 || a == 2;
- }
+ }
/** make a hard copy of the terms */
public NumberTerm clone() {
Modified: trunk/src/jason/asSyntax/Atom.java
===================================================================
--- trunk/src/jason/asSyntax/Atom.java 2008-09-27 08:16:20 UTC (rev 1379)
+++ trunk/src/jason/asSyntax/Atom.java 2008-09-27 12:48:55 UTC (rev 1380)
@@ -23,142 +23,102 @@
package jason.asSyntax;
-import jason.JasonException;
-import jason.asSemantics.Unifier;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
/**
- * Represents an atom (a structure with no arguments, e.g. "tell", "a"), it is an
- * immutable object. It extends Literal, so can be used in place of a
- * Literal, but does not allow operations on terms/annots and can not be negated.
+ * Represents an atom (a positive literal with no arguments and no annotations, e.g. "tell", "a").
*/
-public final class Atom extends Literal {
+public class Atom extends Literal {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(Atom.class.getName());
+ private final String functor; // immutable field
+
public Atom(String functor) {
- super(functor, 0);
+ if (functor == null)
+ logger.log(Level.WARNING, "A structure functor should not be null!", new Exception());
+ this.functor = functor;
}
- public Atom clone() {
- return this; // since this object is immutable
+ public Atom(Literal l) {
+ this.functor = l.getFunctor();
+ predicateIndicatorCache = l.predicateIndicatorCache;
+ hashCodeCache = l.hashCodeCache;
+ setSrc(l);
}
-
- @Override
- public boolean apply(Unifier u) {
- return false;
- }
- //
- // override structure methods
- //
-
- @Override
- public void addTerm(Term t) {
- logger.log(Level.SEVERE, "atom error!",new JasonException("atom has no terms!"));
+ public String getFunctor() {
+ return functor;
}
-
- @Override
- public void addTerms(List<Term> l) {
- logger.log(Level.SEVERE, "atom error!",new JasonException("atom has no terms!"));
+
+ public Term clone() {
+ return this; // since this object is immutable
}
@Override
- public void setTerms(List<Term> l) {
- logger.log(Level.SEVERE, "atom error!",new JasonException("atom has no terms!"));
- }
-
- @Override
- public void setTerm(int i, Term t) {
- logger.log(Level.SEVERE, "atom error!",new JasonException("atom has no terms!"));
- }
-
- @Override
- public int getArity() {
- return 0;
- }
-
- @Override
public boolean isAtom() {
return true;
}
- @Override
- public boolean isGround() {
- return true;
- }
-
- @Override
- public boolean hasTerm() {
- return false;
- }
-
- @Override
- public boolean hasVar(VarTerm t) {
- return false;
- }
-
- @Override
- public void countVars(Map<VarTerm, Integer> c) {}
-
- @Override
- protected List<Term> getDeepCopyOfTerms() {
- // this method exists to make the Structure(Structure) constructor to work with
- // an Atom as parameter
- return new ArrayList<Term>(2);
- }
-
- @Override
- public List<Term> getTerms() {
- return emptyTermList;
- }
-
- @Override
- public Term[] getTermsArray() {
- return emptyTermArray;
- }
-
- @Override
- public void setNegated(boolean b) {
- logger.log(Level.SEVERE, "You should not negate the atom "+this+"\n",new Exception());
- super.setNegated(b);
- }
-
@Override
public boolean equals(Object o) {
if (o == null) return false;
if (o == this) return true;
- if (o instanceof Structure) {
- Structure s = (Structure)o;
- return s.isAtom() && getFunctor().equals(s.getFunctor());
+ if (o instanceof Atom) {
+ Atom a = (Atom)o;
+ //System.out.println(getFunctor() +" ==== " + a.getFunctor() + " is "+ (a.isAtom())); // && getFunctor().equals(a.getFunctor())));
+ return a.isAtom() && getFunctor().equals(a.getFunctor());
}
return false;
}
- @Override
- public boolean addAnnot(Term t) {
- logger.log(Level.SEVERE, "You should not add annot '"+t+"' in atom "+this+"\n",new Exception());
- return super.addAnnot(t);
+ public int compareTo(Term t) {
+ if (t.isNumeric()) return 1;
+
+ // this is a list and the other not
+ if (isList() && !t.isList()) return 1;
+
+ // this is not a list and the other is
+ if (!isList() && t.isList()) return -1;
+
+ // both are lists, check the size
+ if (isList() && t.isList()) {
+ ListTerm l1 = (ListTerm)this;
+ ListTerm l2 = (ListTerm)t;
+ final int l1s = l1.size();
+ final int l2s = l2.size();
+ if (l1s > l2s) return 1;
+ if (l2s > l1s) return -1;
+ return 0; // need to check elements (in Structure class)
+ }
+
+ if (t instanceof Atom) {
+ Atom tAsAtom = (Atom)t;
+ return getFunctor().compareTo(tAsAtom.getFunctor());
+ }
+
+ return super.compareTo(t);
}
@Override
- public void addAnnots(List<Term> l) {
- logger.log(Level.SEVERE, "You should not add annots '"+l+"' in atom "+this+"\n",new Exception());
- super.addAnnots(l);
+ protected int calcHashCode() {
+ return getFunctor().hashCode();
}
- @Override public void makeTermsAnnon() { }
- @Override public void makeVarsAnnon() { }
- @Override public void makeVarsAnnon(Unifier un) { }
-
@Override
- protected int calcHashCode() {
- return getFunctor().hashCode();
+ public String toS...
[truncated message content] |
|
From: <jom...@us...> - 2008-09-27 13:56:25
|
Revision: 1381
http://jason.svn.sourceforge.net/jason/?rev=1381&view=rev
Author: jomifred
Date: 2008-09-27 13:56:22 +0000 (Sat, 27 Sep 2008)
Log Message:
-----------
try to fix problems of new API in jasdl/jmca/owl2mas
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/ui/customer/CustomerUIPanel.java
trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/protocol/ProtocolProcessor.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
trunk/applications/jmca/build.xml
trunk/applications/owl2mas/.classpath
trunk/applications/owl2mas/src/owl2mas/OWL2MAS.java
trunk/src/jason/asSemantics/ActionExec.java
trunk/src/jason/bb/DefaultBeliefBase.java
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/ui/customer/CustomerUIPanel.java
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/ui/customer/CustomerUIPanel.java 2008-09-27 12:48:55 UTC (rev 1380)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/ui/customer/CustomerUIPanel.java 2008-09-27 13:56:22 UTC (rev 1381)
@@ -21,6 +21,8 @@
import jasdl.util.JASDLCommon;
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
+import jason.asSyntax.Structure;
import java.awt.Dimension;
import java.awt.FlowLayout;
@@ -224,7 +226,7 @@
// strip newlines
productDescription = productDescription.replace("\n", " ");
shopDescription = shopDescription.replace("\n", " ");
- env.executeAction(customer.getId().toString(), Literal.parseLiteral(
+ env.executeAction(customer.getId().toString(), Structure.parse(
"request_product(\""+productDescription+"\","+"\""+shopDescription+"\","+qty.getValue()+")"));
lastQty = qty.getValue();
@@ -233,7 +235,7 @@
class ConfirmOrderButtonActionListener implements ActionListener{
public void actionPerformed(ActionEvent event) {
- env.executeAction(customer.getId().toString(), Literal.parseLiteral("confirm_order"));
+ env.executeAction(customer.getId().toString(), new LiteralImpl("confirm_order"));
ordersModel.clear();
}
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java 2008-09-27 12:48:55 UTC (rev 1380)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java 2008-09-27 13:56:22 UTC (rev 1381)
@@ -24,6 +24,7 @@
import jasdl.util.JASDLCommon;
import jason.asSemantics.Unifier;
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.Plan;
import jason.asSyntax.PlanBody;
import jason.asSyntax.Structure;
@@ -64,7 +65,7 @@
// create a new literal with functor of trigger
- Literal newLiteral = new Literal( !oldLiteral.negated(), trigger.getFunctor());
+ Literal newLiteral = new LiteralImpl( !oldLiteral.negated(), trigger.getFunctor());
// add the terms from the old literal
newLiteral.addTerms(oldLiteral.getTerms());
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java 2008-09-27 12:48:55 UTC (rev 1380)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java 2008-09-27 13:56:22 UTC (rev 1381)
@@ -31,6 +31,7 @@
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
@@ -109,7 +110,7 @@
* </ul>
*/
public SELiteral construct(boolean sign, Atom functor, Term[] terms, Term[] annots, Atom label) throws JASDLInvalidSELiteralException {
- Literal l = new Literal(sign, functor);
+ Literal l = new LiteralImpl(sign, functor);
// add "o"
Structure o = new Structure(JASDLParams.ONTOLOGY_ANNOTATION_FUNCTOR);
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/protocol/ProtocolProcessor.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/protocol/ProtocolProcessor.java 2008-09-27 12:48:55 UTC (rev 1380)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/protocol/ProtocolProcessor.java 2008-09-27 13:56:22 UTC (rev 1381)
@@ -37,12 +37,18 @@
this.outgoingStrategy = outgoingStrategy;
}
- public Structure processIncomingStructure(Structure struct) throws JASDLMessageContentException {
- return processStructure(struct, incomingStrategy);
+ public Structure processIncomingStructure(Literal struct) throws JASDLMessageContentException {
+ if (struct instanceof Structure)
+ return processStructure((Structure)struct, incomingStrategy);
+ else
+ return processStructure(new Structure(struct), incomingStrategy);
}
- public Structure processOutgoingStructure(Structure struct) throws JASDLMessageContentException {
- return processStructure(struct, outgoingStrategy);
+ public Structure processOutgoingStructure(Literal struct) throws JASDLMessageContentException {
+ if (struct instanceof Structure)
+ return processStructure((Structure)struct, outgoingStrategy);
+ else
+ return processStructure(new Structure(struct), outgoingStrategy);
}
private Structure processStructure(Structure struct, ProtocolProcessingStrategy strategy) throws JASDLMessageContentException {
@@ -51,9 +57,10 @@
if (struct.getArity() > 0) { // if we have any terms to process!
// Process outer SE-enriched content
if (struct.isLiteral()) { // processing strategies only apply to Literals
+ // TODO: (by Jomi): shouldn't the above test be instanceof LiteralImpl? (since for jason 1.2.0 even an Atom is considered a Literal)
Literal l = (Literal) struct;
try {
- struct = strategy.process(l, jom);
+ struct = (Structure)strategy.process(l, jom);
} catch (JASDLException e) {
e.printStackTrace();
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-09-27 12:48:55 UTC (rev 1380)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-09-27 13:56:22 UTC (rev 1381)
@@ -31,6 +31,7 @@
import jason.asSyntax.Atom;
import jason.asSyntax.ListTerm;
import jason.asSyntax.Literal;
+import jason.asSyntax.LiteralImpl;
import jason.asSyntax.StringTermImpl;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
@@ -225,7 +226,7 @@
* @return
*/
public void mutateFunctor(String newFunctor) throws JASDLException {
- Literal mutated = new Literal(!literal.negated(), newFunctor); // negation dealt with by ~ prefix
+ Literal mutated = new LiteralImpl(!literal.negated(), newFunctor); // negation dealt with by ~ prefix
mutated.addTerms(literal.getTerms());
mutated.addAnnots(literal.getAnnots());
literal = mutated;
Modified: trunk/applications/jmca/build.xml
===================================================================
--- trunk/applications/jmca/build.xml 2008-09-27 12:48:55 UTC (rev 1380)
+++ trunk/applications/jmca/build.xml 2008-09-27 13:56:22 UTC (rev 1381)
@@ -11,6 +11,9 @@
<path id="project.classpath">
<pathelement location="../../lib/jason.jar"/>
+ <pathelement location="../owl2mas/lib/owl2mas.jar"/>
+ <pathelement location="lib/owlapi-bin.jar"/>
+ <pathelement location="lib/pellet.jar"/>
</path>
<target name="init">
Modified: trunk/applications/owl2mas/.classpath
===================================================================
--- trunk/applications/owl2mas/.classpath 2008-09-27 12:48:55 UTC (rev 1380)
+++ trunk/applications/owl2mas/.classpath 2008-09-27 13:56:22 UTC (rev 1381)
@@ -4,15 +4,9 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/owlapi-bin.jar"/>
<classpathentry kind="lib" path="lib/pellet.jar"/>
- <classpathentry kind="lib" path="/home/tom/workspace/jason/lib/jason.jar" sourcepath="/home/tom/workspace/jason/src">
- <attributes>
- <attribute name="javadoc_location" value="file:/home/tom/workspace/jason/doc/api/"/>
- </attributes>
- </classpathentry>
<classpathentry kind="lib" path="lib/commons-logging-1.1.jar"/>
<classpathentry kind="lib" path="lib/relaxngDatatype.jar"/>
<classpathentry kind="lib" path="lib/xsdlib.jar"/>
- <classpathentry kind="lib" path="/home/tom/Protege_4.0_alpha/org.protege.editor.core.application.jar"/>
- <classpathentry kind="lib" path="/home/tom/Protege_4.0_alpha/plugins/org.protege.editor.owl.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/Jason"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/applications/owl2mas/src/owl2mas/OWL2MAS.java
===================================================================
--- trunk/applications/owl2mas/src/owl2mas/OWL2MAS.java 2008-09-27 12:48:55 UTC (rev 1380)
+++ trunk/applications/owl2mas/src/owl2mas/OWL2MAS.java 2008-09-27 13:56:22 UTC (rev 1381)
@@ -169,9 +169,9 @@
agentParams.options = optionMap;
- try{agentParams.setArchClass(loadClass(agent, factory.getOWLObjectProperty(URI.create(MAS_NS + "hasAgentArchClass"))).className); }catch(OWL2MASParameterNotSetException e){}
+ try{agentParams.setArchClass(loadClass(agent, factory.getOWLObjectProperty(URI.create(MAS_NS + "hasAgentArchClass"))).getClassName()); }catch(OWL2MASParameterNotSetException e){}
try{agentParams.setBB(loadClass(agent, factory.getOWLObjectProperty(URI.create(MAS_NS + "hasBeliefBaseClass")))); }catch(OWL2MASParameterNotSetException e){}
- try{agentParams.setAgClass(loadClass(agent, factory.getOWLObjectProperty(URI.create(MAS_NS + "hasAgentClass"))).className); }catch(OWL2MASParameterNotSetException e){}
+ try{agentParams.setAgClass(loadClass(agent, factory.getOWLObjectProperty(URI.create(MAS_NS + "hasAgentClass"))).getClassName()); }catch(OWL2MASParameterNotSetException e){}
// Force #1
agentParams.qty = 1;
Modified: trunk/src/jason/asSemantics/ActionExec.java
===================================================================
--- trunk/src/jason/asSemantics/ActionExec.java 2008-09-27 12:48:55 UTC (rev 1380)
+++ trunk/src/jason/asSemantics/ActionExec.java 2008-09-27 13:56:22 UTC (rev 1381)
@@ -62,10 +62,10 @@
}
public Structure getActionTerm() {
- if (action.isAtom())
- return new Structure(action.getFunctor());
+ if (action instanceof Structure)
+ return (Structure)action;
else
- return (Structure)action;
+ return new Structure(action);
}
public Intention getIntention() {
Modified: trunk/src/jason/bb/DefaultBeliefBase.java
===================================================================
--- trunk/src/jason/bb/DefaultBeliefBase.java 2008-09-27 12:48:55 UTC (rev 1380)
+++ trunk/src/jason/bb/DefaultBeliefBase.java 2008-09-27 13:56:22 UTC (rev 1381)
@@ -59,7 +59,7 @@
private int size = 0;
/** set of beliefs with percept annot, used to improve performance of buf */
- private Set<Literal> percepts = new HashSet<Literal>();
+ protected Set<Literal> percepts = new HashSet<Literal>();
public void init(Agent ag, String[] args) {
if (ag != null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-09-29 08:39:22
|
Revision: 1386
http://jason.svn.sourceforge.net/jason/?rev=1386&view=rev
Author: jomifred
Date: 2008-09-29 08:38:52 +0000 (Mon, 29 Sep 2008)
Log Message:
-----------
replace all tabs for 4 spaces in sources
Modified Paths:
--------------
trunk/build.xml
trunk/src/jason/JasonException.java
trunk/src/jason/ReceiverNotFoundException.java
trunk/src/jason/architecture/AgArch.java
trunk/src/jason/asSemantics/ActionExec.java
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/Circumstance.java
trunk/src/jason/asSemantics/CircumstanceListener.java
trunk/src/jason/asSemantics/Event.java
trunk/src/jason/asSemantics/IntendedMeans.java
trunk/src/jason/asSemantics/Intention.java
trunk/src/jason/asSemantics/Message.java
trunk/src/jason/asSemantics/Option.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSemantics/Unifier.java
trunk/src/jason/asSyntax/ArithFunctionTerm.java
trunk/src/jason/asSyntax/Atom.java
trunk/src/jason/asSyntax/BinaryStructure.java
trunk/src/jason/asSyntax/DefaultTerm.java
trunk/src/jason/asSyntax/ListTerm.java
trunk/src/jason/asSyntax/ListTermImpl.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/LiteralImpl.java
trunk/src/jason/asSyntax/LogExpr.java
trunk/src/jason/asSyntax/NumberTermImpl.java
trunk/src/jason/asSyntax/ObjectTermImpl.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
trunk/src/jason/asSyntax/PlanLibrary.java
trunk/src/jason/asSyntax/Pred.java
trunk/src/jason/asSyntax/RelExpr.java
trunk/src/jason/asSyntax/SourceInfo.java
trunk/src/jason/asSyntax/StringTerm.java
trunk/src/jason/asSyntax/StringTermImpl.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/asSyntax/Trigger.java
trunk/src/jason/asSyntax/UnnamedVar.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/jason/asSyntax/directives/FunctionRegister.java
trunk/src/jason/asSyntax/directives/Include.java
trunk/src/jason/asSyntax/patterns/goal/BDG.java
trunk/src/jason/asSyntax/patterns/goal/EBDG.java
trunk/src/jason/asSyntax/patterns/goal/MG.java
trunk/src/jason/asSyntax/patterns/goal/RC.java
trunk/src/jason/asSyntax/patterns/goal/SMC.java
trunk/src/jason/bb/DefaultBeliefBase.java
trunk/src/jason/bb/IndexedBB.java
trunk/src/jason/control/ExecutionControl.java
trunk/src/jason/control/ExecutionControlGUI.java
trunk/src/jason/control/ExecutionControlInfraTier.java
trunk/src/jason/environment/Environment.java
trunk/src/jason/environment/SteppedEnvironment.java
trunk/src/jason/environment/grid/GridWorldModel.java
trunk/src/jason/environment/grid/GridWorldView.java
trunk/src/jason/environment/grid/Location.java
trunk/src/jason/functions/Abs.java
trunk/src/jason/functions/Average.java
trunk/src/jason/functions/Count.java
trunk/src/jason/functions/Length.java
trunk/src/jason/functions/Max.java
trunk/src/jason/functions/Min.java
trunk/src/jason/functions/Random.java
trunk/src/jason/functions/Round.java
trunk/src/jason/functions/RuleToFunction.java
trunk/src/jason/functions/Sqrt.java
trunk/src/jason/functions/Sum.java
trunk/src/jason/functions/ceil.java
trunk/src/jason/functions/e.java
trunk/src/jason/functions/floor.java
trunk/src/jason/functions/log.java
trunk/src/jason/functions/pi.java
trunk/src/jason/functions/time.java
trunk/src/jason/infra/InfrastructureFactory.java
trunk/src/jason/infra/centralised/BaseDialogGUI.java
trunk/src/jason/infra/centralised/CentralisedAgArch.java
trunk/src/jason/infra/centralised/CentralisedEnvironment.java
trunk/src/jason/infra/centralised/CentralisedExecutionControl.java
trunk/src/jason/infra/centralised/CentralisedFactory.java
trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java
trunk/src/jason/infra/centralised/CentralisedRuntimeServices.java
trunk/src/jason/infra/centralised/CreateJNLP.java
trunk/src/jason/infra/centralised/KillAgentGUI.java
trunk/src/jason/infra/centralised/RunCentralisedMAS.java
trunk/src/jason/infra/centralised/StartNewAgentGUI.java
trunk/src/jason/infra/jade/JadeAg.java
trunk/src/jason/infra/jade/JadeAgArch.java
trunk/src/jason/infra/jade/JadeExecutionControl.java
trunk/src/jason/infra/jade/JadeFactory.java
trunk/src/jason/infra/jade/RunJadeMAS.java
trunk/src/jason/infra/saci/SaciAgArch.java
trunk/src/jason/infra/saci/SaciEnvironment.java
trunk/src/jason/infra/saci/SaciExecutionControl.java
trunk/src/jason/infra/saci/SaciFactory.java
trunk/src/jason/infra/saci/StartSaci.java
trunk/src/jason/jeditplugin/AboutGUI.java
trunk/src/jason/jeditplugin/AgentSpeakSideKickParser.java
trunk/src/jason/jeditplugin/CheckVersion.java
trunk/src/jason/jeditplugin/Config.java
trunk/src/jason/jeditplugin/JasonID.java
trunk/src/jason/jeditplugin/JasonIDOptionPanel.java
trunk/src/jason/jeditplugin/JasonIDPlugin.java
trunk/src/jason/jeditplugin/JasonProjectImporter.java
trunk/src/jason/jeditplugin/JasonProjectSideKickParser.java
trunk/src/jason/jeditplugin/MASLauncherInfraTier.java
trunk/src/jason/jeditplugin/NewAgentGUI.java
trunk/src/jason/jeditplugin/NewEnvironmentGUI.java
trunk/src/jason/jeditplugin/NewInternalActionGUI.java
trunk/src/jason/jeditplugin/NewProjectGUI.java
trunk/src/jason/jeditplugin/RunProjectListener.java
trunk/src/jason/mas2j/AgentParameters.java
trunk/src/jason/mas2j/MAS2JProject.java
trunk/src/jason/runtime/MASConsoleGUI.java
trunk/src/jason/runtime/MASConsoleLogFormatter.java
trunk/src/jason/runtime/MASConsoleLogHandler.java
trunk/src/jason/runtime/OutputStreamAdapter.java
trunk/src/jason/runtime/Settings.java
trunk/src/jason/stdlib/add_annot.java
trunk/src/jason/stdlib/add_nested_source.java
trunk/src/jason/stdlib/at.java
trunk/src/jason/stdlib/atom.java
trunk/src/jason/stdlib/broadcast.java
trunk/src/jason/stdlib/concat.java
trunk/src/jason/stdlib/create_agent.java
trunk/src/jason/stdlib/date.java
trunk/src/jason/stdlib/delete.java
trunk/src/jason/stdlib/difference.java
trunk/src/jason/stdlib/dropGoal.java
trunk/src/jason/stdlib/drop_desire.java
trunk/src/jason/stdlib/fail.java
trunk/src/jason/stdlib/foreach.java
trunk/src/jason/stdlib/ground.java
trunk/src/jason/stdlib/if_then_else.java
trunk/src/jason/stdlib/intend.java
trunk/src/jason/stdlib/intersection.java
trunk/src/jason/stdlib/length.java
trunk/src/jason/stdlib/list.java
trunk/src/jason/stdlib/literal.java
trunk/src/jason/stdlib/loop.java
trunk/src/jason/stdlib/max.java
trunk/src/jason/stdlib/member.java
trunk/src/jason/stdlib/min.java
trunk/src/jason/stdlib/nth.java
trunk/src/jason/stdlib/number.java
trunk/src/jason/stdlib/print.java
trunk/src/jason/stdlib/println.java
trunk/src/jason/stdlib/random.java
trunk/src/jason/stdlib/range.java
trunk/src/jason/stdlib/resume.java
trunk/src/jason/stdlib/reverse.java
trunk/src/jason/stdlib/sort.java
trunk/src/jason/stdlib/string.java
trunk/src/jason/stdlib/structure.java
trunk/src/jason/stdlib/substring.java
trunk/src/jason/stdlib/succeed_goal.java
trunk/src/jason/stdlib/suspend.java
trunk/src/jason/stdlib/term2string.java
trunk/src/jason/stdlib/time.java
trunk/src/jason/stdlib/union.java
trunk/src/jason/stdlib/wait.java
trunk/src/jason/util/asl2html.java
trunk/src/jason/util/asl2tex.java
trunk/src/jason/util/asl2xml.java
trunk/src/test/BeliefBaseTest.java
trunk/src/test/ExprTermTest.java
trunk/src/test/ListTermTest.java
trunk/src/test/MAS2JParserTest.java
trunk/src/test/PlanTest.java
trunk/src/test/RuleTest.java
trunk/src/test/StdLibTest.java
trunk/src/test/StringTermTest.java
trunk/src/test/TermTest.java
trunk/src/test/VarTermTest.java
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-09-28 13:28:57 UTC (rev 1385)
+++ trunk/build.xml 2008-09-29 08:38:52 UTC (rev 1386)
@@ -2,389 +2,391 @@
<project basedir="." default="run" name="Jason">
- <property environment="env" />
+ <property environment="env" />
- <property name="saciJar" value="${basedir}/lib/saci.jar" />
- <property name="jasonJar" value="${basedir}/lib/jason.jar" />
- <property name="jadeJar" value="${basedir}/lib/jade.jar" />
- <property name="jadeHttpJar" value="${basedir}/lib/http.jar" />
- <property name="jadeToolsJar" value="${basedir}/lib/jadeTools.jar" />
- <property name="jasonSJar" value="${basedir}/lib/s-jason.jar" />
+ <property name="saciJar" value="${basedir}/lib/saci.jar" />
+ <property name="jasonJar" value="${basedir}/lib/jason.jar" />
+ <property name="jadeJar" value="${basedir}/lib/jade.jar" />
+ <property name="jadeHttpJar" value="${basedir}/lib/http.jar" />
+ <property name="jadeToolsJar" value="${basedir}/lib/jadeTools.jar" />
+ <property name="jasonSJar" value="${basedir}/lib/s-jason.jar" />
- <property name="build.dir" value="${basedir}/bin/classes" />
+ <property name="build.dir" value="${basedir}/bin/classes" />
- <property name="dist.properties" value="${basedir}/bin/dist.properties" />
- <property name="version" value="1" />
- <property name="release" value="2.0" />
- <property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" />
- <property name="distFile" value="${env.HOME}/Jason-${version}.${release}" />
+ <property name="dist.properties" value="${basedir}/bin/dist.properties" />
+ <property name="version" value="1" />
+ <property name="release" value="2.0" />
+ <property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" />
+ <property name="distFile" value="${env.HOME}/Jason-${version}.${release}" />
- <property name="jedit.install.dir" value="${basedir}/bin/jedit" />
- <property name="plugin.jar.name" value="jason-jedit-plugin.jar" />
+ <property name="jedit.install.dir" value="${basedir}/bin/jedit" />
+ <property name="plugin.jar.name" value="jason-jedit-plugin.jar" />
- <path id="run.classpath">
- <pathelement location="${jedit.install.dir}/jedit.jar" />
- <pathelement location="${saciJar}" />
- <pathelement location="${jadeJar}" />
- <pathelement location="${jadeHttpJar}" />
- <pathelement location="${jadeToolsJar}" />
- </path>
+ <path id="run.classpath">
+ <pathelement location="${jedit.install.dir}/jedit.jar" />
+ <pathelement location="${saciJar}" />
+ <pathelement location="${jadeJar}" />
+ <pathelement location="${jadeHttpJar}" />
+ <pathelement location="${jadeToolsJar}" />
+ </path>
- <path id="project.classpath">
- <path refid="run.classpath" />
- <pathelement location="${basedir}/lib/junit.jar" />
- <pathelement location="${basedir}/lib/ant-launcher.jar" />
- <pathelement location="${basedir}/lib/ant.jar" />
- <pathelement location="${basedir}/demos/persistent-belief-base/lib/hsqldb.jar" />
- <pathelement location="${basedir}/lib/jedit/ErrorList.jar" />
- <pathelement location="${basedir}/lib/jedit/SideKick.jar" />
- <pathelement location="${jasonJar}" />
- </path>
+ <path id="project.classpath">
+ <path refid="run.classpath" />
+ <pathelement location="${basedir}/lib/junit.jar" />
+ <pathelement location="${basedir}/lib/ant-launcher.jar" />
+ <pathelement location="${basedir}/lib/ant.jar" />
+ <pathelement location="${basedir}/demos/persistent-belief-base/lib/hsqldb.jar" />
+ <pathelement location="${basedir}/lib/jedit/ErrorList.jar" />
+ <pathelement location="${basedir}/lib/jedit/SideKick.jar" />
+ <pathelement location="${jasonJar}" />
+ </path>
- <path id="test.classpath">
- <path refid="project.classpath" />
- <pathelement location="${build.dir}" />
- </path>
+ <path id="test.classpath">
+ <path refid="project.classpath" />
+ <pathelement location="${build.dir}" />
+ </path>
- <condition property="jedit-ok" value="ok">
- <or>
- <not>
- <available file="${basedir}/bin/jedit.tgz" />
- </not>
- <uptodate targetfile="${jedit.install.dir}" srcfile="${basedir}/bin/jedit.tgz" />
- </or>
- </condition>
+ <condition property="jedit-ok" value="ok">
+ <or>
+ <not>
+ <available file="${basedir}/bin/jedit.tgz" />
+ </not>
+ <uptodate targetfile="${jedit.install.dir}" srcfile="${basedir}/bin/jedit.tgz" />
+ </or>
+ </condition>
- <target name="untar-jedit" unless="jedit-ok">
- <echo message="Uncompressing jEdit" />
- <delete dir="${jedit.install.dir}" />
- <untar compression="gzip" dest="${basedir}/bin" src="${basedir}/bin/jedit.tgz" />
- </target>
+ <target name="untar-jedit" unless="jedit-ok">
+ <echo message="Uncompressing jEdit" />
+ <delete dir="${jedit.install.dir}" />
+ <untar compression="gzip" dest="${basedir}/bin" src="${basedir}/bin/jedit.tgz" />
+ </target>
- <target name="init" depends="untar-jedit">
- <mkdir dir="${build.dir}" />
- </target>
+ <target name="init" depends="untar-jedit">
+ <mkdir dir="${build.dir}" />
+ </target>
-
- <condition property="parsers-ok" value="ok">
- <and>
- <uptodate property="parsers-ok" targetfile="${basedir}/src/jason/mas2j/parser/mas2j.java" srcfile="${basedir}/src/jason/mas2j/parser/MAS2JavaParser.jcc" />
- <uptodate property="parsers-ok" targetfile="${basedir}/src/jason/asSyntax/parser/as2j.java" srcfile="${basedir}/src/jason/asSyntax/parser/AS2JavaParser.jcc" />
- <uptodate property="parsers-ok" targetfile="${basedir}/doc/AS2JavaParser.html" srcfile="${basedir}/src/jason/asSyntax/parser/AS2JavaParser.jcc" />
- </and>
- </condition>
+
+ <condition property="parsers-ok" value="ok">
+ <and>
+ <uptodate property="parsers-ok" targetfile="${basedir}/src/jason/mas2j/parser/mas2j.java" srcfile="${basedir}/src/jason/mas2j/parser/MAS2JavaParser.jcc" />
+ <uptodate property="parsers-ok" targetfile="${basedir}/src/jason/asSyntax/parser/as2j.java" srcfile="${basedir}/src/jason/asSyntax/parser/AS2JavaParser.jcc" />
+ <uptodate property="parsers-ok" targetfile="${basedir}/doc/AS2JavaParser.html" srcfile="${basedir}/src/jason/asSyntax/parser/AS2JavaParser.jcc" />
+ </and>
+ </condition>
- <target name="parsers" depends="init" unless="parsers-ok">
- <delete failonerror="no">
- <fileset dir="${basedir}/src/jason/mas2j/parser" includes="*.java" />
- <fileset dir="${basedir}/src/jason/asSyntax/parser" includes="*.java" />
- </delete>
+ <target name="parsers" depends="init" unless="parsers-ok">
+ <delete failonerror="no">
+ <fileset dir="${basedir}/src/jason/mas2j/parser" includes="*.java" />
+ <fileset dir="${basedir}/src/jason/asSyntax/parser" includes="*.java" />
+ </delete>
- <java dir="${basedir}/src/jason/mas2j/parser" classname="javacc" fork="yes">
- <classpath location="${basedir}/lib/javacc.jar" />
- <arg line="MAS2JavaParser.jcc" />
- </java>
+ <java dir="${basedir}/src/jason/mas2j/parser" classname="javacc" fork="yes">
+ <classpath location="${basedir}/lib/javacc.jar" />
+ <arg line="MAS2JavaParser.jcc" />
+ </java>
- <java dir="${basedir}/src/jason/asSyntax/parser" classname="javacc" fork="yes">
- <classpath location="${basedir}/lib/javacc.jar" />
- <arg line="AS2JavaParser.jcc" />
- </java>
+ <java dir="${basedir}/src/jason/asSyntax/parser" classname="javacc" fork="yes">
+ <classpath location="${basedir}/lib/javacc.jar" />
+ <arg line="AS2JavaParser.jcc" />
+ </java>
- <java dir="${basedir}/src/jason/mas2j/parser" classname="jjdoc" fork="yes">
- <classpath location="${basedir}/lib/javacc.jar" />
- <arg line="MAS2JavaParser.jcc" />
- </java>
- <move file="${basedir}/src/jason/mas2j/parser/MAS2JavaParser.html" todir="${basedir}/doc" />
+ <java dir="${basedir}/src/jason/mas2j/parser" classname="jjdoc" fork="yes">
+ <classpath location="${basedir}/lib/javacc.jar" />
+ <arg line="MAS2JavaParser.jcc" />
+ </java>
+ <move file="${basedir}/src/jason/mas2j/parser/MAS2JavaParser.html" todir="${basedir}/doc" />
- <java dir="${basedir}/src/jason/asSyntax/parser" classname="jjdoc" fork="yes">
- <classpath location="${basedir}/lib/javacc.jar" />
- <arg line="AS2JavaParser.jcc" />
- </java>
- <move file="${basedir}/src/jason/asSyntax/parser/AS2JavaParser.html" todir="${basedir}/doc" />
+ <java dir="${basedir}/src/jason/asSyntax/parser" classname="jjdoc" fork="yes">
+ <classpath location="${basedir}/lib/javacc.jar" />
+ <arg line="AS2JavaParser.jcc" />
+ </java>
+ <move file="${basedir}/src/jason/asSyntax/parser/AS2JavaParser.html" todir="${basedir}/doc" />
- </target>
+ </target>
- <target name="compile" depends="init,parsers">
- <javac srcdir="src" destdir="${build.dir}" debug="true" deprecation="true" optimize="true" nowarn="true" source="1.5" target="1.5">
- <classpath refid="project.classpath" />
- </javac>
- </target>
+ <target name="compile" depends="init,parsers">
+ <javac srcdir="src" destdir="${build.dir}" debug="true" deprecation="true" optimize="true" nowarn="true" source="1.5" target="1.5">
+ <classpath refid="project.classpath" />
+ </javac>
+ </target>
- <target name="jar" depends="compile">
- <jar jarfile="${jasonJar}" >
- <fileset dir="${build.dir}">
- <include name="jason/**/*.class" />
- <exclude name="jason/jeditplugin/**/*.class" />
- </fileset>
- <fileset dir="${build.dir}">
- <include name="jason/jeditplugin/Config.class" />
- <include name="jason/jeditplugin/MASLauncherInfraTier*" />
- </fileset>
- <fileset dir="${basedir}/src">
- <include name="images/**/*" />
- <include name="asl/**/*" />
- <include name="xml/**/*" />
- <include name="templates/**/*" />
- <include name="logging.properties" />
- </fileset>
- <fileset dir="${basedir}/bin">
- <include name="dist.properties" />
- </fileset>
- <manifest>
- <attribute name="Main-Class" value="jason.infra.centralised.RunCentralisedMAS"/>
+ <target name="jar" depends="compile">
+ <jar jarfile="${jasonJar}" >
+ <fileset dir="${build.dir}">
+ <include name="jason/**/*.class" />
+ <exclude name="jason/jeditplugin/**/*.class" />
+ </fileset>
+ <fileset dir="${build.dir}">
+ <include name="jason/jeditplugin/Config.class" />
+ <include name="jason/jeditplugin/MASLauncherInfraTier*" />
+ </fileset>
+ <fileset dir="${basedir}/src">
+ <include name="images/**/*" />
+ <include name="asl/**/*" />
+ <include name="xml/**/*" />
+ <include name="templates/**/*" />
+ <include name="logging.properties" />
+ </fileset>
+ <fileset dir="${basedir}/bin">
+ <include name="dist.properties" />
+ </fileset>
+ <manifest>
+ <attribute name="Main-Class" value="jason.infra.centralised.RunCentralisedMAS"/>
</manifest>
- </jar>
+ </jar>
<copy file="${jasonJar}" todir="applications/jason-eclipse-plugin/lib" />
- </target>
+ </target>
- <target name="signjar" depends="jar">
- <copy file="${jasonJar}" tofile="${jasonSJar}" />
- <signjar jar="${jasonSJar}" alias="jason" storepass="rbjhja" keypass="rbjhja" keystore="${basedir}/src/jasonKeystore" />
- </target>
-
- <target name="plugin" depends="compile, jar">
- <propertyfile file="${dist.properties}">
- <entry key="version" value="${version}" />
- <entry key="release" value="${release}" />
- <!-- entry default="0" key="build" operation="+" type="int" /-->
- <entry key="build.date" type="date" value="now" />
- </propertyfile>
- <property file="${dist.properties}" />
+ <target name="signjar" depends="jar">
+ <copy file="${jasonJar}" tofile="${jasonSJar}" />
+ <signjar jar="${jasonSJar}" alias="jason" storepass="rbjhja" keypass="rbjhja" keystore="${basedir}/src/jasonKeystore" />
+ </target>
+
+ <target name="plugin" depends="compile, jar">
+ <propertyfile file="${dist.properties}">
+ <entry key="version" value="${version}" />
+ <entry key="release" value="${release}" />
+ <!-- entry default="0" key="build" operation="+" type="int" /-->
+ <entry key="build.date" type="date" value="now" />
+ </propertyfile>
+ <property file="${dist.properties}" />
- <jar jarfile="${jedit.install.dir}/jars/${plugin.jar.name}">
- <fileset dir="${basedir}/src/jeditPlugin">
- <include name="Jason.props" />
- <include name="index.html" />
- <include name="actions.xml" />
- <include name="dockables.xml" />
- <include name="services.xml" />
- <include name="xmode.dtd" />
- </fileset>
- <fileset dir="${build.dir}">
- <include name="jason/**/*.class" />
- </fileset>
- <fileset dir="${basedir}/src">
- <include name="images/**/*" />
- <include name="xml/**/*" />
- <include name="templates/**/*" />
- <include name="logging.properties" />
- </fileset>
- <fileset dir="${basedir}/bin">
- <include name="dist.properties" />
- </fileset>
- </jar>
- <copy todir="${jedit.install.dir}/modes">
- <fileset dir="${basedir}/src/jeditPlugin">
- <include name="agentSpeak.xml" />
- <include name="jasonProject.xml" />
- <include name="catalog" />
- </fileset>
- </copy>
- <copy todir="${jedit.install.dir}/properties">
- <fileset dir="${basedir}/src/jeditPlugin">
- <include name="jedit-initial.props" />
- </fileset>
- </copy>
- </target>
+ <jar jarfile="${jedit.install.dir}/jars/${plugin.jar.name}">
+ <fileset dir="${basedir}/src/jeditPlugin">
+ <include name="Jason.props" />
+ <include name="index.html" />
+ <include name="actions.xml" />
+ <include name="dockables.xml" />
+ <include name="services.xml" />
+ <include name="xmode.dtd" />
+ </fileset>
+ <fileset dir="${build.dir}">
+ <include name="jason/**/*.class" />
+ </fileset>
+ <fileset dir="${basedir}/src">
+ <include name="images/**/*" />
+ <include name="xml/**/*" />
+ <include name="templates/**/*" />
+ <include name="logging.properties" />
+ </fileset>
+ <fileset dir="${basedir}/bin">
+ <include name="dist.properties" />
+ </fileset>
+ </jar>
+ <copy todir="${jedit.install.dir}/modes">
+ <fileset dir="${basedir}/src/jeditPlugin">
+ <include name="agentSpeak.xml" />
+ <include name="jasonProject.xml" />
+ <include name="catalog" />
+ </fileset>
+ </copy>
+ <copy todir="${jedit.install.dir}/properties">
+ <fileset dir="${basedir}/src/jeditPlugin">
+ <include name="jedit-initial.props" />
+ </fileset>
+ </copy>
+ </target>
- <target name="run" depends="jar,plugin">
- <java dir="bin" classname="org.gjt.sp.jedit.jEdit" fork="yes">
- <classpath refid="run.classpath" />
- </java>
- </target>
+ <target name="run" depends="jar,plugin">
+ <java dir="bin" classname="org.gjt.sp.jedit.jEdit" fork="yes">
+ <classpath refid="run.classpath" />
+ </java>
+ </target>
- <target name="test" depends="jar">
- <junit printsummary="yes" failureProperty="test.failure">
- <classpath refid="test.classpath" />
- <formatter type="plain" usefile="false" />
- <batchtest>
- <fileset dir="${basedir}/src" includes="**/test/*Test.java" />
- </batchtest>
- </junit>
- <fail message="test failed" if="test.failure" />
- <delete failonerror="no" verbose="false">
- <fileset dir="${basedir}" includes="bookstore.*" />
- </delete>
- </target>
+ <target name="test" depends="jar">
+ <junit printsummary="yes" failureProperty="test.failure">
+ <classpath refid="test.classpath" />
+ <formatter type="plain" usefile="false" />
+ <batchtest>
+ <fileset dir="${basedir}/src" includes="**/test/*Test.java" />
+ </batchtest>
+ </junit>
+ <fail message="test failed" if="test.failure" />
+ <delete failonerror="no" verbose="false">
+ <fileset dir="${basedir}" includes="bookstore.*" />
+ </delete>
+ </target>
- <!-- apidoc related tasks- -->
+ <!-- apidoc related tasks- -->
- <target name="apidoc" depends="compile,apidocsimple,apidocuml,apidoxygen" />
-
- <condition property="dot-ok" value="true">
- <or>
- <available file="dot" filepath="${env.PATH}" />
- <available file="dot.exe" filepath="${env.PATH}" />
- </or>
- </condition>
- <condition property="dot-nok" value="true">
- <not>
- <or>
- <available file="dot" filepath="${env.PATH}" />
- <available file="dot.exe" filepath="${env.PATH}" />
- </or>
- </not>
- </condition>
- <condition property="doxygen-nok" value="true">
- <not>
- <or>
- <available file="doxygen" filepath="${env.PATH}" />
- <available file="doxygen.exe" filepath="${env.PATH}" />
- </or>
- </not>
- </condition>
-
- <target name="apidocsimple" unless="dot-ok" >
- <javadoc
- destdir="${basedir}/doc/api"
- packagenames="jason.*"
- sourcepath="${basedir}/src"
- excludepackagenames="jason.asSyntax.parser,jason.mas2j.parser"
- use="true"
- version="true"
- author="true"
- windowtitle="Jason - AgentSpeak Java Interpreter"
- stylesheetfile="doc/faq/faq.css">
- <classpath refid="project.classpath" />
- </javadoc>
- </target>
-
- <target name="apidocuml" unless="dot-nok" >
- <javadoc
- destdir="${basedir}/doc/api"
- packagenames="jason.*"
- sourcepath="${basedir}/src"
- excludepackagenames="jason.asSyntax.parser,jason.mas2j.parser"
- use="true"
- version="true"
- author="true"
- windowtitle="Jason - AgentSpeak Java Interpreter"
- stylesheetfile="doc/faq/faq.css">
- <classpath refid="project.classpath" />
- <doclet name="org.umlgraph.doclet.UmlGraphDoc" path="lib/UMLGraph.jar">
- <!--param name="-inferrel"/ -->
- <!--param name="-inferdep"/-->
- <param name="-hide" value="java.*"/>
- <param name="-enumconstants" />
- <!--param name="-collpackages" value="java.util.*"/-->
- <param name="-qualify"/>
- <!--param name="-collapsible"/-->
- <param name="-postfixpackage"/>
- <param name="-nodefontsize" value="16"/>
- <param name="-nodefontpackagesize" value="12"/>
- <param name="-edgefontsize" value="14"/>
- <param name="-link" value="http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/doclet/spec"/>
- <param name="-link" value="http://java.sun.com/j2se/1.5/docs/api"/>
- </doclet>
- </javadoc>
- </target>
- <target name="apidoxygen" unless="doxygen-nok" >
- <exec executable="doxygen">
- <arg line="doc/jason.doxygen"/>
- </exec>
- </target>
+ <target name="apidoc" depends="compile,apidocsimple,apidocuml,apidoxygen" />
+
+ <condition property="dot-ok" value="true">
+ <or>
+ <available file="dot" filepath="${env.PATH}" />
+ <available file="dot.exe" filepath="${env.PATH}" />
+ </or>
+ </condition>
+ <condition property="dot-nok" value="true">
+ <not>
+ <or>
+ <available file="dot" filepath="${env.PATH}" />
+ <available file="dot.exe" filepath="${env.PATH}" />
+ </or>
+ </not>
+ </condition>
+ <condition property="doxygen-nok" value="true">
+ <not>
+ <or>
+ <available file="doxygen" filepath="${env.PATH}" />
+ <available file="doxygen.exe" filepath="${env.PATH}" />
+ </or>
+ </not>
+ </condition>
+
+ <target name="apidocsimple" unless="dot-ok" >
+ <javadoc
+ destdir="${basedir}/doc/api"
+ packagenames="jason.*"
+ sourcepath="${basedir}/src"
+ excludepackagenames="jason.asSyntax.parser,jason.mas2j.parser"
+ use="true"
+ version="true"
+ author="true"
+ windowtitle="Jason - AgentSpeak Java Interpreter"
+ stylesheetfile="doc/faq/faq.css">
+ <classpath refid="project.classpath" />
+ </javadoc>
+ </target>
+
+ <target name="apidocuml" unless="dot-nok" >
+ <javadoc
+ destdir="${basedir}/doc/api"
+ packagenames="jason.*"
+ sourcepath="${basedir}/src"
+ excludepackagenames="jason.asSyntax.parser,jason.mas2j.parser"
+ use="true"
+ version="true"
+ author="true"
+ windowtitle="Jason - AgentSpeak Java Interpreter"
+ stylesheetfile="doc/faq/faq.css">
+ <classpath refid="project.classpath" />
+ <doclet name="org.umlgraph.doclet.UmlGraphDoc" path="lib/UMLGraph.jar">
+ <!--param name="-inferrel"/ -->
+ <!--param name="-inferdep"/-->
+ <param name="-hide" value="java.*"/>
+ <param name="-enumconstants" />
+ <!--param name="-collpackages" value="java.util.*"/-->
+ <param name="-qual...
[truncated message content] |
|
From: <jom...@us...> - 2008-09-29 14:34:55
|
Revision: 1388
http://jason.svn.sourceforge.net/jason/?rev=1388&view=rev
Author: jomifred
Date: 2008-09-29 14:34:41 +0000 (Mon, 29 Sep 2008)
Log Message:
-----------
add a factory (class ASSyntax) to create and parse terms and literals,
see API doc of ASSyntax for more info.
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java
trunk/build.xml
trunk/src/jason/asSyntax/ListTermImpl.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/asSyntax/Trigger.java
trunk/src/test/ASParserTest.java
Added Paths:
-----------
trunk/src/jason/asSyntax/ASSyntax.java
Modified: trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java 2008-09-29 10:41:26 UTC (rev 1387)
+++ trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java 2008-09-29 14:34:41 UTC (rev 1388)
@@ -9,6 +9,7 @@
import jason.asSemantics.Intention;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Literal;
import jason.asSyntax.LogExpr;
import jason.asSyntax.LogicalFormula;
@@ -89,7 +90,7 @@
public void addGoal(String g) {
try {
- addGoal(Literal.tryParsingLiteral(g));
+ addGoal(ASSyntax.parseLiteral(g));
} catch (Exception e) {
fail("Parsing '"+g+"' as literal for a goal failed!");
}
@@ -100,7 +101,7 @@
public void addBel(String bel) {
try {
- super.addBel(Literal.tryParsingLiteral(bel));
+ super.addBel(ASSyntax.parseLiteral(bel));
} catch (ParseException e) {
fail("Parsing '"+bel+"' as a belief!");
} catch (RevisionFailedException e) {
@@ -109,7 +110,7 @@
}
public void delBel(String bel) {
try {
- Literal l = Literal.tryParsingLiteral(bel);
+ Literal l = ASSyntax.parseLiteral(bel);
if (!l.hasSource()) {
l.addAnnot(BeliefBase.TSelf);
}
@@ -145,7 +146,7 @@
public void assertEvt(String te, int maxCycles) {
try {
- assertEvt(Trigger.tryParsingTrigger(te), maxCycles);
+ assertEvt(ASSyntax.parseTrigger(te), maxCycles);
} catch (ParseException e) {
fail("Parsing '"+te+"' as trigger failed!");
}
@@ -164,7 +165,7 @@
public void assertAct(String act, int maxCycles) {
try {
- assertAct(Structure.tryParsingStructure(act), maxCycles);
+ assertAct(ASSyntax.parseStructure(act), maxCycles);
} catch (ParseException e) {
fail("Parsing '"+act+"' as action failed!");
}
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-09-29 10:41:26 UTC (rev 1387)
+++ trunk/build.xml 2008-09-29 14:34:41 UTC (rev 1388)
@@ -239,7 +239,7 @@
</not>
</condition>
- <target name="apidocsimple" unless="dot-ok" >
+ <target name="apidocsimple" unless="dot-ok" > <!-- stylesheetfile="doc/faq/faq.css" -->
<javadoc
destdir="${basedir}/doc/api"
packagenames="jason.*"
@@ -249,7 +249,7 @@
version="true"
author="true"
windowtitle="Jason - AgentSpeak Java Interpreter"
- stylesheetfile="doc/faq/faq.css">
+ >
<classpath refid="project.classpath" />
</javadoc>
</target>
@@ -264,7 +264,7 @@
version="true"
author="true"
windowtitle="Jason - AgentSpeak Java Interpreter"
- stylesheetfile="doc/faq/faq.css">
+ >
<classpath refid="project.classpath" />
<doclet name="org.umlgraph.doclet.UmlGraphDoc" path="lib/UMLGraph.jar">
<!--param name="-inferrel"/ -->
Added: trunk/src/jason/asSyntax/ASSyntax.java
===================================================================
--- trunk/src/jason/asSyntax/ASSyntax.java (rev 0)
+++ trunk/src/jason/asSyntax/ASSyntax.java 2008-09-29 14:34:41 UTC (rev 1388)
@@ -0,0 +1,150 @@
+package jason.asSyntax;
+
+import jason.asSyntax.parser.ParseException;
+import jason.asSyntax.parser.as2j;
+
+import java.io.StringReader;
+
+
+/**
+ Factory for objects used in Jason AgentSpeak syntax.
+
+ <p><b>Examples of Term</b>:
+ <pre>
+ import static jason.asSyntax.ASSyntax.*;
+
+ ...
+ Atom a = createAtom("a");
+ NumberTerm n = createNumber(3);
+ StringTerm s = createString("s");
+ Structure t = createStructure("p", createAtom("a")); // t = p(a)
+ ListTerm l = createList(); // empty list
+ ListTerm f = createList(createAtom("a"), createStructure("b", createNumber(5))); // f = [a,b(5)]
+
+ // or use a parsing (easier but slow)
+ Term n = parseTerm("5");
+ Term t = parseTerm("p(a)");
+ Term l = parseTerm("[a,b(5)]");
+ </pre>
+
+ <p><b>Examples of Literal</b>:
+ <pre>
+ import static jason.asSyntax.ASSyntax.*;
+
+ ...
+ // create the literal 'p'
+ Literal l1 = createLiteral("p");
+
+ // create the literal 'p(a,3)'
+ Literal l2 = createLiteral("p", createAtom("a"), createNumber(3));
+
+ // create the literal 'p(a,3)[s,"s"]'
+ Literal l3 = createLiteral("p", createAtom("a"), createNumber(3))
+ .addAnnots(createAtom("s"), createString("s"));
+
+ // create the literal '~p(a,3)[s,"s"]'
+ Literal l4 = createLiteral("p", createAtom("a"), createNumber(3))
+ .addAnnots(createAtom("s"), createString("s"))
+ .setNegated(Literal.LNeg);
+
+ // or use a parsing (easier but slow)
+ Literal l4 = parseLiteral("~p(a,3)[s]");
+ </pre>
+
+ @author Jomi
+
+ */
+public class ASSyntax {
+
+ /**
+ * Creates a new literal, the first argument is the functor (a string)
+ * and the n remainder arguments are terms. see documentation of this
+ * class for examples of use.
+ */
+ public static Literal createLiteral(String functor, Term... terms) {
+ return new LiteralImpl(functor).addTerms(terms);
+ }
+
+ /**
+ * Creates a new literal, the first argument is either Literal.LPos or Literal.LNeg,
+ * the second is the functor (a string),
+ * and the n remainder arguments are terms. see documentation of this
+ * class for examples of use.
+ */
+ public static Literal createLiteral(boolean positive, String functor, Term... terms) {
+ return new LiteralImpl(positive, functor).addTerms(terms);
+ }
+
+ /**
+ * Creates a new structure term, is the functor (a string),
+ * and the n remainder arguments are terms.
+ */
+ public static Literal createStructure(String functor, Term... terms) {
+ return new Structure(functor).addTerms(terms);
+ }
+
+ /** creates a new Atom term */
+ public static Atom createAtom(String functor) {
+ return new Atom(functor);
+ }
+
+ /** creates a new number term */
+ public static NumberTerm createNumber(double vl) {
+ return new NumberTermImpl(vl);
+ }
+
+ /** creates a new string term */
+ public static StringTerm createString(String s) {
+ return new StringTermImpl(s);
+ }
+
+ /** creates a new variable term */
+ public static VarTerm createVar(String functor) {
+ return new VarTerm(functor);
+ }
+
+ /** Creates a new list with n elements, n can be 0 */
+ public static ListTerm createList(Term... terms) {
+ ListTerm l = new ListTermImpl();
+ ListTerm tail = l;
+ for (Term t: terms)
+ tail = tail.append(t);
+ return l;
+ }
+
+
+ /** creates a new literal by parsing a string */
+ public static Literal parseLiteral(String sLiteral) throws ParseException {
+ return new as2j(new StringReader(sLiteral)).literal();
+ }
+
+ /** creates a new structure (a kind of term) by parsing a string */
+ public static Structure parseStructure(String sTerm) throws ParseException {
+ Term t = new as2j(new StringReader(sTerm)).term();
+ if (t instanceof Structure)
+ return (Structure)t;
+ else
+ return new Structure((Literal)t);
+ }
+
+ /** creates a new term by parsing a string */
+ public static Term parseTerm(String sTerm) throws ParseException {
+ return new as2j(new StringReader(sTerm)).term();
+ }
+
+ /** creates a new plan by parsing a string */
+ public static Plan parsePlan(String sPlan) throws ParseException {
+ return new as2j(new StringReader(sPlan)).plan();
+ }
+
+ /** creates a new trigger by parsing a string */
+ public static Trigger parseTrigger(String sTe) throws ParseException {
+ return new as2j(new StringReader(sTe)).trigger();
+ }
+
+ /** creates a new list by parsing a string */
+ public static ListTerm parseList(String sList) throws ParseException {
+ return new as2j(new StringReader(sList)).list();
+ }
+
+}
Modified: trunk/src/jason/asSyntax/ListTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/ListTermImpl.java 2008-09-29 10:41:26 UTC (rev 1387)
+++ trunk/src/jason/asSyntax/ListTermImpl.java 2008-09-29 14:34:41 UTC (rev 1388)
@@ -75,7 +75,7 @@
public static ListTerm parseList(String sList) {
as2j parser = new as2j(new StringReader(sList));
try {
- return (ListTerm)parser.list();
+ return parser.list();
} catch (Exception e) {
logger.log(Level.SEVERE,"Error parsing list "+sList,e);
return null;
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-09-29 10:41:26 UTC (rev 1387)
+++ trunk/src/jason/asSyntax/Literal.java 2008-09-29 14:34:41 UTC (rev 1388)
@@ -27,7 +27,6 @@
import jason.architecture.AgArch;
import jason.asSemantics.Agent;
import jason.asSemantics.Unifier;
-import jason.asSyntax.parser.ParseException;
import jason.asSyntax.parser.as2j;
import java.io.StringReader;
@@ -48,28 +47,12 @@
LiteralImpl -- Pred + negation. This latter class supports all the operations of
the Literal interface.
- There are useful static methods in this class to create Literals.
+ <p>There are useful static methods in class {@link ASSyntax} to create Literals.
- Examples:
- <pre>
- // create the literal 'p'
- Literal l1 = Literal.create("p");
-
- // create the literal 'p(a,3)'
- Literal l2 = Literal.create("p", new Atom(a), new NumberTermImpl(3));
-
- // create the literal 'p(a,3)[s,"s"]'
- Literal l3 = Literal.create("p", new Atom("a"), new NumberTermImpl(3))
- .addAnnots(new Atom("s"), new StringTermImpl("s"));
-
- // create the literal '~p(a,3)[s,"s"]'
- Literal l4 = Literal.create("p", new Atom("a"), new NumberTermImpl(3))
- .addAnnots(new Atom("s"), new StringTermImpl("s"))
- .setNegated(Literal.LNeg);
- </pre>
@author jomi
+ @see ASSyntax
@see Atom
@see Structure
@see Pred
@@ -88,23 +71,7 @@
protected PredicateIndicator predicateIndicatorCache = null; // to not compute it all the time (is is called many many times)
- /** creates a literal copying data from other literal */
- public static Literal create(Literal l) {
- return new LiteralImpl(l);
- }
-
- /**
- * Creates a new literal, the first argument is the functor (a string)
- * and the n remainder arguments are terms. see documentation of this
- * class for example of use.
- */
- public static Literal create(String functor, Term... terms) {
- Literal l = new LiteralImpl(functor);
- l.addTerms(terms);
- return l;
- }
-
- /** creates a new literal by parsing a string */
+ /** creates a new literal by parsing a string -- ASSyntax.parseLiteral is preferred. */
public static Literal parseLiteral(String sLiteral) {
try {
as2j parser = new as2j(new StringReader(sLiteral));
@@ -115,10 +82,6 @@
}
}
- public static Literal tryParsingLiteral(String sLiteral) throws ParseException {
- return new as2j(new StringReader(sLiteral)).literal();
- }
-
public Literal copy() {
return (Literal)clone(); // should call the clone, that is overridden in subclasses
}
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-09-29 10:41:26 UTC (rev 1387)
+++ trunk/src/jason/asSyntax/Structure.java 2008-09-29 14:34:41 UTC (rev 1388)
@@ -24,7 +24,6 @@
package jason.asSyntax;
import jason.asSemantics.Unifier;
-import jason.asSyntax.parser.ParseException;
import jason.asSyntax.parser.as2j;
import java.io.StringReader;
@@ -86,22 +85,15 @@
as2j parser = new as2j(new StringReader(sTerm));
try {
Term t = parser.term();
- if (t.isAtom())
- return new Structure((Atom)t);
- else
+ if (t instanceof Structure)
return (Structure)t;
+ else
+ return new Structure((Atom)t);
} catch (Exception e) {
logger.log(Level.SEVERE,"Error parsing structure " + sTerm,e);
return null;
}
}
- public static Structure tryParsingStructure(String sTerm) throws ParseException {
- Term t = new as2j(new StringReader(sTerm)).term();
- if (t.isAtom())
- return new Structure((Atom)t);
- else
- return (Structure)t;
- }
@Override
protected int calcHashCode() {
Modified: trunk/src/jason/asSyntax/Trigger.java
===================================================================
--- trunk/src/jason/asSyntax/Trigger.java 2008-09-29 10:41:26 UTC (rev 1387)
+++ trunk/src/jason/asSyntax/Trigger.java 2008-09-29 14:34:41 UTC (rev 1388)
@@ -25,7 +25,6 @@
package jason.asSyntax;
import jason.asSemantics.Unifier;
-import jason.asSyntax.parser.ParseException;
import jason.asSyntax.parser.as2j;
import java.io.StringReader;
@@ -85,10 +84,6 @@
}
}
- public static Trigger tryParsingTrigger(String sTe) throws ParseException {
- return new as2j(new StringReader(sTe)).trigger();
- }
-
public void setTrigOp(TEOperator op) {
operator = op;
piCache = null;
Modified: trunk/src/test/ASParserTest.java
===================================================================
--- trunk/src/test/ASParserTest.java 2008-09-29 10:41:26 UTC (rev 1387)
+++ trunk/src/test/ASParserTest.java 2008-09-29 14:34:41 UTC (rev 1388)
@@ -1,9 +1,15 @@
package test;
+import static jason.asSyntax.ASSyntax.createAtom;
+import static jason.asSyntax.ASSyntax.createLiteral;
+import static jason.asSyntax.ASSyntax.createNumber;
+import static jason.asSyntax.ASSyntax.createString;
import jason.architecture.AgArch;
import jason.asSemantics.Agent;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ASSyntax;
+import jason.asSyntax.ListTerm;
import jason.asSyntax.Literal;
import jason.asSyntax.LogExpr;
import jason.asSyntax.LogicalFormula;
@@ -11,6 +17,7 @@
import jason.asSyntax.Plan;
import jason.asSyntax.PlanBody;
import jason.asSyntax.RelExpr;
+import jason.asSyntax.parser.ParseException;
import jason.asSyntax.parser.as2j;
import jason.infra.centralised.CentralisedAgArch;
import jason.mas2j.MAS2JProject;
@@ -214,4 +221,35 @@
}
}
}
+
+ public void testFactory() throws ParseException {
+ // create the literal 'p'
+ Literal l = createLiteral("p");
+ assertEquals("p", l.toString());
+
+ // create the literal 'p(a,3)'
+ l = createLiteral("p", createAtom("a"), createNumber(3));
+ assertEquals("p(a,3)", l.toString());
+
+ // create the literal 'p(a,3)[s,"s"]'
+ l = createLiteral("p", createAtom("a"), createNumber(3))
+ .addAnnots(createAtom("s"), createString("s"));
+ assertEquals("p(a,3)[s,\"s\"]", l.toString());
+
+ // create the literal '~p(a,3)[s,"s"]'
+ l = createLiteral(Literal.LNeg, "p", createAtom("a"), createNumber(3))
+ .addAnnots(createAtom("s"), createString("s"));
+ assertEquals("~p(a,3)[s,\"s\"]", l.toString());
+ l = ASSyntax.parseLiteral(l.toString());
+ assertEquals("~p(a,3)[s,\"s\"]", l.toString());
+
+ ListTerm ll = ASSyntax.createList(); // empty list
+ assertEquals("[]", ll.toString());
+
+ ll = ASSyntax.createList(createAtom("a"), createLiteral("b", createNumber(5)));
+ assertEquals("[a,b(5)]", ll.toString());
+
+ ll = ASSyntax.parseList(ll.toString());
+ assertEquals("[a,b(5)]", ll.toString());
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-10-02 07:24:55
|
Revision: 1390
http://jason.svn.sourceforge.net/jason/?rev=1390&view=rev
Author: jomifred
Date: 2008-10-02 07:24:44 +0000 (Thu, 02 Oct 2008)
Log Message:
-----------
start using the new ASSyntax class in some other classes
Modified Paths:
--------------
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/src/jason/asSemantics/Message.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/ASSyntax.java
trunk/src/jason/asSyntax/DefaultTerm.java
trunk/src/jason/asSyntax/InternalActionLiteral.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/Plan.java
trunk/src/jason/asSyntax/Term.java
trunk/src/jason/asSyntax/Trigger.java
trunk/src/jason/asSyntax/patterns/goal/SGA.java
trunk/src/jason/bb/JDBCPersistentBB.java
trunk/src/jason/stdlib/add_plan.java
trunk/src/jason/stdlib/at.java
trunk/src/jason/stdlib/relevant_plans.java
trunk/src/jason/stdlib/term2string.java
trunk/src/jason/stdlib/wait.java
trunk/src/test/PlanTest.java
trunk/src/test/StdLibTest.java
trunk/src/test/TSTest.java
trunk/src/test/TermTest.java
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -11,7 +11,6 @@
import jason.asSemantics.Unifier;
import jason.asSyntax.ASSyntax;
import jason.asSyntax.Atom;
-import jason.asSyntax.DefaultTerm;
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.Literal;
import jason.asSyntax.LiteralImpl;
@@ -27,6 +26,7 @@
import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
+import jason.asSyntax.parser.ParseException;
import jason.mas2j.ClassParameters;
import jason.runtime.Settings;
@@ -211,7 +211,11 @@
// if the last arg of body is a free var
Term lastTerm = body.getTerm(body.getArity()-1);
if (!lastTerm.isGround()) {
- pi.peek().getUnif().unifies(lastTerm, DefaultTerm.parse(content));
+ try {
+ pi.peek().getUnif().unifies(lastTerm, ASSyntax.parseTerm(content));
+ } catch (ParseException e) {
+ // no problem, the content is not a term
+ }
//System.out.println("un = "+pi.peek().getUnif());
}
}
Modified: trunk/src/jason/asSemantics/Message.java
===================================================================
--- trunk/src/jason/asSemantics/Message.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/asSemantics/Message.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -24,7 +24,8 @@
package jason.asSemantics;
-import jason.asSyntax.DefaultTerm;
+import jason.asSyntax.ASSyntax;
+import jason.asSyntax.parser.ParseException;
import java.io.Serializable;
@@ -135,7 +136,7 @@
* @param msg the string message
* @return the parsed Message
*/
- public static Message parseMsg(String msg) {
+ public static Message parseMsg(String msg) throws ParseException {
int one, two;
Message newmsg = new Message();
if (msg.startsWith("<")) {
@@ -155,7 +156,7 @@
newmsg.receiver = msg.substring(one + 1, two);
one = msg.indexOf(">", two + 1);
String content = msg.substring(two + 1, one);
- newmsg.propCont = DefaultTerm.parse(content);
+ newmsg.propCont = ASSyntax.parseTerm(content);
}
return newmsg;
}
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -26,8 +26,8 @@
import jason.JasonException;
import jason.RevisionFailedException;
import jason.architecture.AgArch;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Atom;
-import jason.asSyntax.DefaultTerm;
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
@@ -43,6 +43,7 @@
import jason.asSyntax.Trigger;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
+import jason.asSyntax.parser.ParseException;
import jason.bb.BeliefBase;
import jason.runtime.Settings;
@@ -152,7 +153,12 @@
if (m.getPropCont() instanceof Term) {
content = (Term)m.getPropCont();
} else {
- content = DefaultTerm.parse(m.getPropCont().toString());
+ try {
+ content = ASSyntax.parseTerm(m.getPropCont().toString());
+ } catch (ParseException e) {
+ logger.warning("The content of the message '"+m.getPropCont()+"' is not a term!");
+ return;
+ }
}
// check if an intention was suspended waiting this message
Modified: trunk/src/jason/asSyntax/ASSyntax.java
===================================================================
--- trunk/src/jason/asSyntax/ASSyntax.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/asSyntax/ASSyntax.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -79,8 +79,8 @@
* Creates a new structure term, is the functor (a string),
* and the n remainder arguments are terms.
*/
- public static Literal createStructure(String functor, Term... terms) {
- return new Structure(functor).addTerms(terms);
+ public static Structure createStructure(String functor, Term... terms) {
+ return (Structure)new Structure(functor).addTerms(terms);
}
/** creates a new Atom term */
Modified: trunk/src/jason/asSyntax/DefaultTerm.java
===================================================================
--- trunk/src/jason/asSyntax/DefaultTerm.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/asSyntax/DefaultTerm.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -34,6 +34,8 @@
/**
* Base class for all terms.
+ *
+ * (this class may be renamed to AbstractTerm infuture releases of Jason)
*/
public abstract class DefaultTerm extends SourceInfo implements Term, Serializable {
@@ -42,6 +44,7 @@
protected Integer hashCodeCache = null;
+ /** @deprecated it is preferable to use ASSyntax.parseTerm */
public static Term parse(String sTerm) {
as2j parser = new as2j(new StringReader(sTerm));
try {
Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -100,7 +100,7 @@
// count the vars of first arg
if (getTerm(0).isString()) {
try {
- Trigger te = Trigger.parseTrigger( ((StringTerm)getTerm(0)).getString() );
+ Trigger te = ASSyntax.parseTrigger( ((StringTerm)getTerm(0)).getString() );
te.getLiteral().countVars(c);
} catch (Exception e) {
e.printStackTrace();
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/asSyntax/Literal.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -71,7 +71,7 @@
protected PredicateIndicator predicateIndicatorCache = null; // to not compute it all the time (is is called many many times)
- /** creates a new literal by parsing a string -- ASSyntax.parseLiteral is preferred. */
+ /** creates a new literal by parsing a string -- ASSyntax.parseLiteral or createLiteral are preferred. */
public static Literal parseLiteral(String sLiteral) {
try {
as2j parser = new as2j(new StringReader(sLiteral));
@@ -106,7 +106,7 @@
/** returns the number of terms of this literal */
public int getArity() { return 0; }
- /** returns trus if this literal has some term */
+ /** returns true if this literal has some term */
public boolean hasTerm() { return false; }
/** returns all terms of this literal */
public List<Term> getTerms() { return Structure.emptyTermList; }
Modified: trunk/src/jason/asSyntax/Plan.java
===================================================================
--- trunk/src/jason/asSyntax/Plan.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/asSyntax/Plan.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -50,9 +50,9 @@
public class Plan extends SourceInfo implements Cloneable, Serializable {
private static final long serialVersionUID = 1L;
- private static final Term TAtomic = DefaultTerm.parse("atomic");
- private static final Term TBreakPoint = DefaultTerm.parse("breakpoint");
- private static final Term TAllUnifs = DefaultTerm.parse("all_unifs");
+ private static final Term TAtomic = ASSyntax.createAtom("atomic");
+ private static final Term TBreakPoint = ASSyntax.createAtom("breakpoint");
+ private static final Term TAllUnifs = ASSyntax.createAtom("all_unifs");
private static Logger logger = Logger.getLogger(Plan.class.getName());
Modified: trunk/src/jason/asSyntax/Term.java
===================================================================
--- trunk/src/jason/asSyntax/Term.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/asSyntax/Term.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -33,10 +33,7 @@
public boolean equals(Object o);
- /**
- * Replaces variables by their values in the unifier, returns true
- * if some variable was applied.
- */
+ /** replaces variables by their values in the unifier, returns true if some variable was applied */
public boolean apply(Unifier u);
/** Removes the value cached for hashCode */
Modified: trunk/src/jason/asSyntax/Trigger.java
===================================================================
--- trunk/src/jason/asSyntax/Trigger.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/asSyntax/Trigger.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -74,6 +74,7 @@
setTrigOp(op);
}
+ /** prefer to use ASSyntax.parseTrigger */
public static Trigger parseTrigger(String sTe) {
as2j parser = new as2j(new StringReader(sTe));
try {
@@ -137,8 +138,9 @@
return piCache;
}
- public boolean apply(Unifier u) {
- return literal.apply(u);
+ public Trigger apply(Unifier u) {
+ literal.apply(u);
+ return this;
}
public Literal getLiteral() {
Modified: trunk/src/jason/asSyntax/patterns/goal/SGA.java
===================================================================
--- trunk/src/jason/asSyntax/patterns/goal/SGA.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/asSyntax/patterns/goal/SGA.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -1,6 +1,7 @@
package jason.asSyntax.patterns.goal;
import jason.asSemantics.Agent;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.LogExpr;
import jason.asSyntax.LogicalFormula;
import jason.asSyntax.Plan;
@@ -24,7 +25,7 @@
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
try {
- Trigger trigger = Trigger.parseTrigger(((StringTerm)directive.getTerm(0)).getString());
+ Trigger trigger = ASSyntax.parseTrigger(((StringTerm)directive.getTerm(0)).getString());
LogicalFormula context = LogExpr.parseExpr(((StringTerm)directive.getTerm(1)).getString());
Term goal = directive.getTerm(2);
Modified: trunk/src/jason/bb/JDBCPersistentBB.java
===================================================================
--- trunk/src/jason/bb/JDBCPersistentBB.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/bb/JDBCPersistentBB.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -2,7 +2,7 @@
import jason.asSemantics.Agent;
import jason.asSemantics.Unifier;
-import jason.asSyntax.DefaultTerm;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
@@ -13,6 +13,7 @@
import jason.asSyntax.StringTermImpl;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
+import jason.asSyntax.parser.ParseException;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -209,6 +210,8 @@
}
} catch (SQLException e) {
logger.log(Level.SEVERE, "SQL Error", e);
+ } catch (ParseException e) {
+ logger.log(Level.SEVERE, "Parser Error", e);
} finally {
try {
stmt.close();
@@ -377,8 +380,8 @@
hasNext = rs.next();
if (!hasNext) rs.close();
return l;
- } catch (SQLException e) {
- logger.log(Level.SEVERE, "SQL Error", e);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "Error", e);
}
return null;
}
@@ -441,8 +444,8 @@
}
}
}
- } catch (SQLException e) {
- logger.log(Level.SEVERE, "SQL Error", e);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "Error", e);
} finally {
try {
stmt.close();
@@ -455,7 +458,7 @@
/** translates the current line of a result set into a Literal */
- protected Literal resultSetToLiteral(ResultSet rs, PredicateIndicator pi) throws SQLException {
+ protected Literal resultSetToLiteral(ResultSet rs, PredicateIndicator pi) throws SQLException, ParseException {
ResultSetMetaData meta = belsDB.get(pi);
boolean isJasonTable = isCreatedByJason(pi);
Literal ldb = new LiteralImpl(pi.getFunctor());
@@ -482,11 +485,11 @@
// there is no var at BB
parsed = new StringTermImpl(sc);
} else {
- parsed = DefaultTerm.parse(sc);
+ parsed = ASSyntax.parseTerm(sc);
// if the parsed term is not equals to sc, try it as string
if (!parsed.toString().equals(sc))
- parsed = DefaultTerm.parse(sc = "\"" + sc + "\"");
+ parsed = ASSyntax.parseTerm(sc = "\"" + sc + "\"");
}
break;
}
Modified: trunk/src/jason/stdlib/add_plan.java
===================================================================
--- trunk/src/jason/stdlib/add_plan.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/stdlib/add_plan.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -26,7 +26,7 @@
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
-import jason.asSyntax.DefaultTerm;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.ListTerm;
import jason.asSyntax.StringTerm;
import jason.asSyntax.Term;
@@ -91,7 +91,7 @@
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
- Term plans = DefaultTerm.parse(args[0].toString());
+ Term plans = ASSyntax.parseTerm(args[0].toString());
Term source = BeliefBase.ASelf;
if (args.length > 1)
Modified: trunk/src/jason/stdlib/at.java
===================================================================
--- trunk/src/jason/stdlib/at.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/stdlib/at.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -30,6 +30,7 @@
import jason.asSemantics.Intention;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.StringTerm;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
@@ -122,7 +123,7 @@
throw new JasonException("The time parameter ('"+time+"') of the internal action 'at' did not parse correctly!");
}
- Trigger te = Trigger.parseTrigger(sevent.getString());
+ Trigger te = ASSyntax.parseTrigger(sevent.getString());
ts.getAg().getScheduler().schedule(new CheckDeadline(te, ts), deadline, TimeUnit.MILLISECONDS);
return true;
Modified: trunk/src/jason/stdlib/relevant_plans.java
===================================================================
--- trunk/src/jason/stdlib/relevant_plans.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/stdlib/relevant_plans.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -28,6 +28,7 @@
import jason.asSemantics.Option;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Plan;
@@ -35,6 +36,7 @@
import jason.asSyntax.StringTermImpl;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
+import jason.asSyntax.parser.ParseException;
import java.util.List;
@@ -73,13 +75,21 @@
@Override public int getMaxArgs() { return 2; }
@Override
+ protected void checkArguments(Term[] args) throws JasonException {
+ super.checkArguments(args);
+ if (!args[0].isString())
+ throw JasonException.createWrongArgument(this,"first argument must be a string");
+ }
+
+ @Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
- StringTerm sTe = (StringTerm) args[0];
- Trigger te = Trigger.parseTrigger(sTe.getString());
- if (te == null) {
- throw new JasonException("The first argument of the 'relevant_plans' internal action is not a triggering event.");
+ Trigger te;
+ try {
+ te = ASSyntax.parseTrigger(((StringTerm) args[0]).getString());
+ } catch (ParseException e) {
+ throw JasonException.createWrongArgument(this,"first argument '"+args[0]+"' must follow the syntax of a trigger.");
}
ListTerm lt = new ListTermImpl();
List<Option> rp = ts.relevantPlans(te);
Modified: trunk/src/jason/stdlib/term2string.java
===================================================================
--- trunk/src/jason/stdlib/term2string.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/stdlib/term2string.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -6,7 +6,7 @@
import jason.asSemantics.InternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
-import jason.asSyntax.DefaultTerm;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.StringTerm;
import jason.asSyntax.StringTermImpl;
import jason.asSyntax.Term;
@@ -61,7 +61,7 @@
// case 3, first is var
if (args[0].isVar() && args[1].isString()) {
- return un.unifies(args[0], DefaultTerm.parse( ((StringTerm)args[1]).getString() ));
+ return un.unifies(args[0], ASSyntax.parseTerm( ((StringTerm)args[1]).getString() ));
}
throw new JasonException("invalid case of term2string");
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/jason/stdlib/wait.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -30,6 +30,7 @@
import jason.asSemantics.Intention;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.NumberTerm;
import jason.asSyntax.NumberTermImpl;
@@ -108,10 +109,9 @@
timeout = (long) time.solve();
} else if (args[0].isString()) {
// wait for event
- StringTerm st = (StringTerm) args[0];
- st.apply(un);
- te = Trigger.parseTrigger(st.getString());
-
+ te = ASSyntax.parseTrigger( ((StringTerm) args[0]).getString());
+ te.getLiteral().apply(un);
+
if (args.length >= 2)
timeout = (long) ((NumberTerm) args[1]).solve();
if (args.length == 3)
Modified: trunk/src/test/PlanTest.java
===================================================================
--- trunk/src/test/PlanTest.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/test/PlanTest.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -2,12 +2,12 @@
import jason.JasonException;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.LiteralImpl;
import jason.asSyntax.Plan;
import jason.asSyntax.PlanBody;
import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.PlanLibrary;
-import jason.asSyntax.Trigger;
import jason.asSyntax.VarTerm;
import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.parser.ParseException;
@@ -42,16 +42,16 @@
pl.add(Plan.parse("+!X <- .print(a)."));
- List<Plan> pls = pl.getCandidatePlans(Trigger.parseTrigger("+p(3)"));
+ List<Plan> pls = pl.getCandidatePlans(ASSyntax.parseTrigger("+p(3)"));
assertEquals(2, pls.size());
- pls = pl.getCandidatePlans(Trigger.parseTrigger("+!p(3)"));
+ pls = pl.getCandidatePlans(ASSyntax.parseTrigger("+!p(3)"));
assertEquals(3, pls.size());
- pls = pl.getCandidatePlans(Trigger.parseTrigger("+!bla"));
+ pls = pl.getCandidatePlans(ASSyntax.parseTrigger("+!bla"));
assertEquals(1, pls.size());
- pls = pl.getCandidatePlans(Trigger.parseTrigger("+bla"));
+ pls = pl.getCandidatePlans(ASSyntax.parseTrigger("+bla"));
assertEquals(0, pls.size());
}
Modified: trunk/src/test/StdLibTest.java
===================================================================
--- trunk/src/test/StdLibTest.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/test/StdLibTest.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -9,6 +9,7 @@
import jason.asSemantics.Option;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.DefaultTerm;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
@@ -271,7 +272,7 @@
public void testDropGoal1() throws ParseException {
assertEquals(intention1.size(), 4);
- Trigger g = Trigger.parseTrigger("+!g1");
+ Trigger g = ASSyntax.parseTrigger("+!g1");
assertTrue(intention1.dropGoal(g, new Unifier()));
assertEquals(intention1.size(), 1);
}
Modified: trunk/src/test/TSTest.java
===================================================================
--- trunk/src/test/TSTest.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/test/TSTest.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -5,6 +5,7 @@
import jason.asSemantics.Intention;
import jason.asSemantics.Option;
import jason.asSemantics.TransitionSystem;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Literal;
import jason.asSyntax.StringTerm;
import jason.asSyntax.StringTermImpl;
@@ -36,7 +37,7 @@
Literal content = Literal.parseLiteral("~alliance");
content.addSource(new Structure("ag1"));
- Trigger te1 = Trigger.parseTrigger("+a(10)");
+ Trigger te1 = ASSyntax.parseTrigger("+a(10)");
try {
List<Option> rp = ts.relevantPlans(te1);
@@ -54,7 +55,7 @@
e.printStackTrace();
}
- Trigger te2 = Trigger.parseTrigger("+a(20)");
+ Trigger te2 = ASSyntax.parseTrigger("+a(20)");
try {
List<Option> rp = ts.relevantPlans(te2);
Modified: trunk/src/test/TermTest.java
===================================================================
--- trunk/src/test/TermTest.java 2008-09-30 16:33:33 UTC (rev 1389)
+++ trunk/src/test/TermTest.java 2008-10-02 07:24:44 UTC (rev 1390)
@@ -1,8 +1,8 @@
package test;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Atom;
-import jason.asSyntax.DefaultTerm;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
@@ -107,9 +107,9 @@
assertEquals(x1.hashCode(), ta.hashCode());
}
- public void testUnifies() {
+ public void testUnifies() throws ParseException {
assertTrue(new Unifier().unifies(new Structure("a"), new Structure("a")));
- assertTrue(new Unifier().unifies(DefaultTerm.parse("a"), DefaultTerm.parse("a")));
+ assertTrue(new Unifier().unifies(ASSyntax.parseTerm("a"), ASSyntax.parseTerm("a")));
assertTrue(new Unifier().unifies(new Structure("a"), new VarTerm("X")));
Unifier u = new Unifier();
@@ -316,10 +316,10 @@
assertTrue(u.unifies(a,Pred.parsePred("s[b]")));
}
- public void testAnnotsUnify7() {
+ public void testAnnotsUnify7() throws ParseException {
// p[a,b,c,d] = p[a,c|R] - ok and R=[b,d]
- Term t1 = DefaultTerm.parse("p[a,b,c,d]");
- Term t2 = DefaultTerm.parse("p[a,c|R]");
+ Term t1 = ASSyntax.parseTerm("p[a,b,c,d]");
+ Term t2 = ASSyntax.parseTerm("p[a,c|R]");
Unifier u = new Unifier();
assertTrue(u.unifies(t1, t2));
assertEquals(u.get("R").toString(),"[b,d]");
@@ -330,25 +330,25 @@
assertEquals(u.get("R").toString(),"[b,d]");
// p[H|R] = p[a,b,c,d] - ok and R=[b,c,d], H=a
- Term t3 = DefaultTerm.parse("p[H|R]");
+ Term t3 = ASSyntax.parseTerm("p[H|R]");
u = new Unifier();
assertTrue(u.unifies(t1, t3));
assertEquals(u.get("H").toString(),"a");
assertEquals(u.get("R").toString(),"[b,c,d]");
}
- public void testApplyAnnots() {
- Term t1 = DefaultTerm.parse("p[a,X,c,d]");
+ public void testApplyAnnots() throws ParseException {
+ Term t1 = ASSyntax.parseTerm("p[a,X,c,d]");
Unifier u = new Unifier();
u.unifies(new VarTerm("X"), new Atom("z"));
t1.apply(u);
assertEquals("p[a,z,c,d]",t1.toString());
- t1 = DefaultTerm.parse("p[X,b,c,d]");
+ t1 = ASSyntax.parseTerm("p[X,b,c,d]");
t1.apply(u);
assertEquals("p[z,b,c,d]",t1.toString());
- t1 = DefaultTerm.parse("p[a,b,c,X]");
+ t1 = ASSyntax.parseTerm("p[a,b,c,X]");
t1.apply(u);
assertEquals("p[a,b,c,z]",t1.toString());
}
@@ -389,8 +389,8 @@
assertEquals(t1.toString(), t2.toString());
- Trigger t3 = Trigger.parseTrigger("+!bid_normally(1)");
- Trigger t4 = Trigger.parseTrigger("+!bid_normally(N)");
+ Trigger t3 = ASSyntax.parseTrigger("+!bid_normally(1)");
+ Trigger t4 = ASSyntax.parseTrigger("+!bid_normally(N)");
u = new Unifier();
u.unifies(t3,t4);
//System.out.println("u="+u);
@@ -533,9 +533,9 @@
assertEquals("[5,10,b,c,casa,f(4),f(10),g,[3,4],[3,10],[1,1,1]]",l.toString());
}
- public void testUnify4() {
- Term a1 = DefaultTerm.parse("a(1)");
- Term a2 = DefaultTerm.parse("a(X+1)");
+ public void testUnify4() throws ParseException {
+ Term a1 = ASSyntax.parseTerm("a(1)");
+ Term a2 = ASSyntax.parseTerm("a(X+1)");
Unifier u = new Unifier();
u.unifies(new VarTerm("X"),new NumberTermImpl(0));
assertFalse(a1.equals(a2));
@@ -677,10 +677,6 @@
assertEquals(8,p2.getAnnots().size());
}
- public static void main(String[] a) {
- new TermTest().testAnnotsUnify7();
- }
-
public void testGetTermsArray() {
Structure s2 = Structure.parse("a(1,2,3)");
Term[] a = s2.getTermsArray();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-09-30 16:34:05
|
Revision: 1389
http://jason.svn.sourceforge.net/jason/?rev=1389&view=rev
Author: jomifred
Date: 2008-09-30 16:33:33 +0000 (Tue, 30 Sep 2008)
Log Message:
-----------
use new constructors from ASSyntax in jason team/jmoise
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-team/src/java/arch/ACProxy.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/ASSyntax.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/LogExpr.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/stdlib/add_nested_source.java
Modified: trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -11,7 +11,6 @@
import jason.asSemantics.Unifier;
import jason.asSyntax.ASSyntax;
import jason.asSyntax.Literal;
-import jason.asSyntax.LogExpr;
import jason.asSyntax.LogicalFormula;
import jason.asSyntax.Structure;
import jason.asSyntax.Trigger;
@@ -128,7 +127,7 @@
public void assertBel(String formula, int maxCycles) {
try {
- assertBel(LogExpr.tryParsingLogExpr(formula), maxCycles);
+ assertBel(ASSyntax.parseFormula(formula), maxCycles);
} catch (ParseException e) {
fail("Parsing '"+formula+"' as a formula failed!");
}
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -9,6 +9,7 @@
import jason.asSemantics.Intention;
import jason.asSemantics.Message;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Atom;
import jason.asSyntax.DefaultTerm;
import jason.asSyntax.InternalActionLiteral;
@@ -256,9 +257,7 @@
Structure giAnnot = new Structure("group");
giAnnot.addTerm(gr);
- Literal obl = new LiteralImpl(type);
- obl.addTerms(sch,new UnnamedVar());
- obl.addAnnot(giAnnot);
+ Literal obl = ASSyntax.createLiteral(type, sch, new UnnamedVar()).addAnnots(giAnnot);
// find obligation(sch,_)[group(id)]
Unifier un = new Unifier();
Modified: trunk/applications/jason-team/src/java/arch/ACProxy.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -1,5 +1,8 @@
package arch;
+import static jason.asSyntax.ASSyntax.createLiteral;
+import static jason.asSyntax.ASSyntax.createNumber;
+
import jason.asSyntax.Literal;
import jason.asSyntax.LiteralImpl;
import jason.asSyntax.NumberTermImpl;
@@ -152,8 +155,7 @@
arq.setScore(score);
// add location in perception
- Literal lpos = new LiteralImpl("pos");
- lpos.addTerms(new NumberTermImpl(agx), new NumberTermImpl(agy), new NumberTermImpl(step));
+ Literal lpos = createLiteral("pos", createNumber(agx), createNumber(agy), createNumber(step));
percepts.add(lpos);
arq.initKnownCows();
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -1,5 +1,7 @@
package arch;
+import static jason.asSyntax.ASSyntax.createLiteral;
+import static jason.asSyntax.ASSyntax.createNumber;
import jason.JasonException;
import jason.ReceiverNotFoundException;
import jason.RevisionFailedException;
@@ -9,7 +11,6 @@
import jason.asSyntax.Literal;
import jason.asSyntax.LiteralImpl;
import jason.asSyntax.NumberTerm;
-import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Term;
import jason.environment.grid.Location;
import jason.mas2j.ClassParameters;
@@ -243,11 +244,7 @@
}
public static Literal createCellPerception(int x, int y, Term obj) {
- Literal l = new LiteralImpl("cell");
- l.addTerms(new NumberTermImpl(x),
- new NumberTermImpl(y),
- obj);
- return l;
+ return createLiteral("cell", createNumber(x), createNumber(y), obj);
}
void initKnownCows() {
@@ -358,8 +355,7 @@
if (acView != null) acView.getModel().setAgPos(agid, x, y);
model.incVisited(x, y);
//getTS().getAg().getLogger().info("ag pos "+getMinerId(m.getSender())+" = "+x+","+y);
- Literal tAlly = new LiteralImpl("ally_pos");
- tAlly.addTerms(new Atom(m.getSender()), new NumberTermImpl(x), new NumberTermImpl(y));
+ Literal tAlly = createLiteral("ally_pos", new Atom(m.getSender()), createNumber(x), createNumber(y));
getTS().getAg().addBel( tAlly );
} catch (Exception e) {
e.printStackTrace();
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -187,8 +187,7 @@
} else if (conf.ag.socAcc(m)) {
// generate an event
- Literal received = new LiteralImpl("kqml_received");
- received.addTerms(
+ Literal received = new LiteralImpl("kqml_received").addTerms(
new Atom(m.getSender()),
new Atom(m.getIlForce()),
content,
Modified: trunk/src/jason/asSyntax/ASSyntax.java
===================================================================
--- trunk/src/jason/asSyntax/ASSyntax.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/src/jason/asSyntax/ASSyntax.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -43,9 +43,8 @@
.addAnnots(createAtom("s"), createString("s"));
// create the literal '~p(a,3)[s,"s"]'
- Literal l4 = createLiteral("p", createAtom("a"), createNumber(3))
- .addAnnots(createAtom("s"), createString("s"))
- .setNegated(Literal.LNeg);
+ Literal l4 = createLiteral(Literal.LNeg, "p", createAtom("a"), createNumber(3))
+ .addAnnots(createAtom("s"), createString("s"));
// or use a parsing (easier but slow)
Literal l4 = parseLiteral("~p(a,3)[s]");
@@ -56,8 +55,9 @@
*/
public class ASSyntax {
+
/**
- * Creates a new literal, the first argument is the functor (a string)
+ * Creates a new positive literal, the first argument is the functor (a string)
* and the n remainder arguments are terms. see documentation of this
* class for examples of use.
*/
@@ -147,4 +147,9 @@
return new as2j(new StringReader(sList)).list();
}
+ /** creates a new logical formula by parsing a string */
+ public static LogicalFormula parseFormula(String sExpr) throws ParseException {
+ return (LogicalFormula)new as2j(new StringReader(sExpr)).log_expr();
+ }
+
}
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/src/jason/asSyntax/Literal.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -193,7 +193,8 @@
public Literal addTerms(List<Term> l) { logger.log(Level.SEVERE, "addTerms is not implemented in the class "+this.getClass().getSimpleName(), new Exception()); return null; }
/** returns the i-th term (first term is 0) */
public Term getTerm(int i) { logger.log(Level.SEVERE, "getTerm(i) is not implemented in the class "+this.getClass().getSimpleName(), new Exception()); return null; }
- public void setTerms(List<Term> l) { logger.log(Level.SEVERE, "setTerms is not implemented in the class "+this.getClass().getSimpleName(), new Exception()); }
+ /** set all terms of the literal and return this */
+ public Literal setTerms(List<Term> l) { logger.log(Level.SEVERE, "setTerms is not implemented in the class "+this.getClass().getSimpleName(), new Exception()); return null; }
public void setTerm(int i, Term t) { logger.log(Level.SEVERE, "setTerm is not implemented in the class "+this.getClass().getSimpleName(), new Exception()); }
// pred
Modified: trunk/src/jason/asSyntax/LogExpr.java
===================================================================
--- trunk/src/jason/asSyntax/LogExpr.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/src/jason/asSyntax/LogExpr.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -25,7 +25,6 @@
import jason.asSemantics.Agent;
import jason.asSemantics.Unifier;
-import jason.asSyntax.parser.ParseException;
import jason.asSyntax.parser.as2j;
import java.io.StringReader;
@@ -210,9 +209,6 @@
}
return null;
}
- public static LogicalFormula tryParsingLogExpr(String sExpr) throws ParseException {
- return (LogicalFormula)new as2j(new StringReader(sExpr)).log_expr();
- }
/** make a hard copy of the terms */
public LogicalFormula clone() {
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/src/jason/asSyntax/Structure.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -212,10 +212,11 @@
}
@Override
- public void setTerms(List<Term> l) {
+ public Literal setTerms(List<Term> l) {
terms = l;
predicateIndicatorCache = null;
resetHashCodeCache();
+ return this;
}
@Override
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -290,9 +290,11 @@
}
@Override
- public void setTerms(List<Term> l) {
+ public Literal setTerms(List<Term> l) {
if (value != null && value.isStructure()) {
- ((Structure)getValue()).setTerms(l);
+ return ((Structure)getValue()).setTerms(l);
+ } else {
+ return this;
}
}
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-09-30 16:33:33 UTC (rev 1389)
@@ -99,9 +99,7 @@
private Term changeToAtom(Object o) {
Term u = (Term)o;
if (u.isAtom()) {
- Atom a = new Atom( ((Structure)u).getFunctor());
- a.setSrc(u);
- return a;
+ return new Atom( (Literal)u);
} else {
return u;
}
@@ -403,17 +401,11 @@
]
F=pred() {
if (F.getFunctor().equals("if")) {
- Pred c = new Pred(".if_then_else");
- c.setTerms(F.getTerms());
- F = c;
+ F = (Pred)new Pred(".if_then_else").setTerms(F.getTerms());
} else if (F.getFunctor().equals("while")) {
- Pred c = new Pred(".loop");
- c.setTerms(F.getTerms());
- F = c;
+ F = (Pred)new Pred(".loop").setTerms(F.getTerms());
} else if (F.getFunctor().equals("for")) {
- Pred c = new Pred(".foreach");
- c.setTerms(F.getTerms());
- F = c;
+ F = (Pred)new Pred(".foreach").setTerms(F.getTerms());
}
if (F.getFunctor().indexOf(".") >= 0) {
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -69,9 +69,7 @@
private Term changeToAtom(Object o) {
Term u = (Term)o;
if (u.isAtom()) {
- Atom a = new Atom( ((Structure)u).getFunctor());
- a.setSrc(u);
- return a;
+ return new Atom( (Literal)u);
} else {
return u;
}
@@ -548,17 +546,11 @@
}
F = pred();
if (F.getFunctor().equals("if")) {
- Pred c = new Pred(".if_then_else");
- c.setTerms(F.getTerms());
- F = c;
+ F = (Pred)new Pred(".if_then_else").setTerms(F.getTerms());
} else if (F.getFunctor().equals("while")) {
- Pred c = new Pred(".loop");
- c.setTerms(F.getTerms());
- F = c;
+ F = (Pred)new Pred(".loop").setTerms(F.getTerms());
} else if (F.getFunctor().equals("for")) {
- Pred c = new Pred(".foreach");
- c.setTerms(F.getTerms());
- F = c;
+ F = (Pred)new Pred(".foreach").setTerms(F.getTerms());
}
if (F.getFunctor().indexOf(".") >= 0) {
@@ -1211,11 +1203,16 @@
finally { jj_save(0, xla); }
}
- final private boolean jj_3R_15() {
- if (jj_3R_17()) return true;
+ final private boolean jj_3R_14() {
+ if (jj_3R_16()) return true;
return false;
}
+ final private boolean jj_3R_17() {
+ if (jj_scan_token(42)) return true;
+ return false;
+ }
+
final private boolean jj_3_1() {
if (jj_scan_token(27)) return true;
if (jj_scan_token(TK_BEGIN)) return true;
@@ -1224,26 +1221,16 @@
return false;
}
- final private boolean jj_3R_16() {
- if (jj_scan_token(27)) return true;
+ final private boolean jj_3R_13() {
+ if (jj_scan_token(39)) return true;
return false;
}
- final private boolean jj_3R_14() {
- if (jj_3R_16()) return true;
+ final private boolean jj_3R_16() {
+ if (jj_scan_token(27)) return true;
return false;
}
- final private boolean jj_3R_17() {
- if (jj_scan_token(42)) return true;
- return false;
- }
-
- final private boolean jj_3R_13() {
- if (jj_scan_token(39)) return true;
- return false;
- }
-
final private boolean jj_3R_12() {
Token xsp;
xsp = jj_scanpos;
@@ -1265,6 +1252,11 @@
return false;
}
+ final private boolean jj_3R_15() {
+ if (jj_3R_17()) return true;
+ return false;
+ }
+
public as2jTokenManager token_source;
SimpleCharStream jj_input_stream;
public Token token, jj_nt;
Modified: trunk/src/jason/stdlib/add_nested_source.java
===================================================================
--- trunk/src/jason/stdlib/add_nested_source.java 2008-09-29 14:34:41 UTC (rev 1388)
+++ trunk/src/jason/stdlib/add_nested_source.java 2008-09-30 16:33:33 UTC (rev 1389)
@@ -100,15 +100,13 @@
return result;
} else if (l.isLiteral()) {
Literal result;
- if (l.isAtom())
- result = new LiteralImpl(((Atom)l).getFunctor());
- else
+ if (l instanceof LiteralImpl)
result = (Literal)l.clone();
+ else
+ result = new LiteralImpl((Atom)l);
// create the source annots
- Pred ts = new Pred("source",1);
- ts.addTerm(source);
- ts.addAnnots(result.getAnnots("source"));
+ Literal ts = new Pred("source",1).addTerms(source).addAnnots(result.getAnnots("source"));
result.delSources();
result.addAnnot(ts);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-10-05 16:38:46
|
Revision: 1392
http://jason.svn.sourceforge.net/jason/?rev=1392&view=rev
Author: jomifred
Date: 2008-10-05 16:34:24 +0000 (Sun, 05 Oct 2008)
Log Message:
-----------
SourceInfo is a "delegated" object of terms and not a super class.
Modified Paths:
--------------
trunk/build.xml
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/ArithExpr.java
trunk/src/jason/asSyntax/Atom.java
trunk/src/jason/asSyntax/BinaryStructure.java
trunk/src/jason/asSyntax/DefaultTerm.java
trunk/src/jason/asSyntax/InternalActionLiteral.java
trunk/src/jason/asSyntax/NumberTermImpl.java
trunk/src/jason/asSyntax/Plan.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
trunk/src/jason/asSyntax/SourceInfo.java
trunk/src/jason/asSyntax/StringTermImpl.java
trunk/src/jason/asSyntax/Term.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/patterns/goal/OMC.java
trunk/src/jason/jeditplugin/AgentSpeakSideKickParser.java
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/build.xml 2008-10-05 16:34:24 UTC (rev 1392)
@@ -378,7 +378,7 @@
<fileset defaultexcludes="no" dir="${basedir}" includes="**/*~" />
<fileset dir="${basedir}" includes="**/*.class" excludes="applications/**/*"/>
<fileset dir="${basedir}" includes="**/core" />
- <fileset dir="${basedir}/doc/api" includes="**/*" />
+ <!-- fileset dir="${basedir}/doc/api" includes="**/*" /-->
<fileset dir="${basedir}" includes="**/.nbattrs" />
<fileset dir="${basedir}" includes="**/*.backup" />
<fileset dir="${basedir}" includes="bin/*.old" />
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -476,7 +476,7 @@
im.unif = iu.next();
updateIntention();
} else {
- String msg = "Constraint "+h+" was not satisfied ("+h.getErrorMsg()+").";
+ String msg = "Constraint "+h+" was not satisfied ("+h.getSrcInfo().getErrorMsg()+").";
generateGoalDeletion(JasonException.createBasicErrorAnnots(new Atom("constraint_failed"), msg));
logger.fine(msg);
}
@@ -531,7 +531,7 @@
}
}
if (fail) {
- if (logger.isLoggable(Level.FINE)) logger.fine("Test '"+h+"' failed ("+h.getErrorMsg()+").");
+ if (logger.isLoggable(Level.FINE)) logger.fine("Test '"+h+"' failed ("+h.getSrcInfo().getErrorMsg()+").");
generateGoalDeletion();
}
}
@@ -881,7 +881,7 @@
Term codeline = null;
if (body != null && body instanceof Literal) {
bodyterm = (Literal)body;
- codesrc = new StringTermImpl(bodyterm.getSrc());
+ codesrc = new StringTermImpl(bodyterm.getSrcFile());
codeline = new NumberTermImpl(bodyterm.getSrcLine());
} else {
bodyterm = new Atom("no_code");
@@ -890,17 +890,17 @@
}
// code
- Structure code = new Structure("code");
+ Structure code = new Structure("code", 1);
code.addTerm(bodyterm);
failAnnots.add(code);
// ASL source
- Structure src = new Structure("code_src");
+ Structure src = new Structure("code_src", 1);
src.addTerm(codesrc);
failAnnots.add(src);
// line in the source
- Structure line = new Structure("code_line");
+ Structure line = new Structure("code_line", 1);
line.addTerm(codeline);
failAnnots.add(line);
failEvent.getTrigger().getLiteral().addAnnots(failAnnots);
Modified: trunk/src/jason/asSyntax/ArithExpr.java
===================================================================
--- trunk/src/jason/asSyntax/ArithExpr.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/ArithExpr.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -126,15 +126,17 @@
super(oper.toString(),2);
addTerms(t1, t2);
op = oper;
- if (t1 instanceof SourceInfo) setSrc((SourceInfo)t1);
- else if (t2 instanceof SourceInfo) setSrc((SourceInfo)t2);
+ if (t1.getSrcInfo() != null)
+ srcInfo = t1.getSrcInfo();
+ else
+ srcInfo = t2.getSrcInfo();
}
public ArithExpr(ArithmeticOp oper, NumberTerm t1) {
super(oper.toString(),1);
addTerm(t1);
op = oper;
- setSrc(t1);
+ srcInfo = t1.getSrcInfo();
}
private ArithExpr(ArithExpr ae) { // for clone
Modified: trunk/src/jason/asSyntax/Atom.java
===================================================================
--- trunk/src/jason/asSyntax/Atom.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/Atom.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -49,7 +49,7 @@
this.functor = l.getFunctor();
predicateIndicatorCache = l.predicateIndicatorCache;
hashCodeCache = l.hashCodeCache;
- setSrc(l);
+ srcInfo = l.srcInfo;
}
public String getFunctor() {
Modified: trunk/src/jason/asSyntax/BinaryStructure.java
===================================================================
--- trunk/src/jason/asSyntax/BinaryStructure.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/BinaryStructure.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -40,15 +40,17 @@
public BinaryStructure(Term t1, String id, Term t2) {
super(id,2);
addTerms( t1, t2 );
- if (t1 instanceof SourceInfo) setSrc((SourceInfo)t1);
- else if (t2 instanceof SourceInfo) setSrc((SourceInfo)t2);
+ if (t1.getSrcInfo() != null)
+ srcInfo = t1.getSrcInfo();
+ else
+ srcInfo = t2.getSrcInfo();
}
/** Constructor for unary operator */
public BinaryStructure(String id, Term arg) {
super(id,1);
addTerm( arg );
- setSrc(arg);
+ srcInfo = arg.getSrcInfo();
}
public boolean isUnary() {
Modified: trunk/src/jason/asSyntax/DefaultTerm.java
===================================================================
--- trunk/src/jason/asSyntax/DefaultTerm.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/DefaultTerm.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -35,14 +35,20 @@
/**
* Base class for all terms.
*
- * (this class may be renamed to AbstractTerm infuture releases of Jason)
+ * (this class may be renamed to AbstractTerm in future releases of Jason, so
+ * avoid using it -- use ASSyntax class to create new terms)
+ *
+ * @navassoc - source - SourceInfo
+ *
+ * @see ASSyntax
*/
-public abstract class DefaultTerm extends SourceInfo implements Term, Serializable {
+public abstract class DefaultTerm implements Term, Serializable {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(Term.class.getName());
- protected Integer hashCodeCache = null;
+ protected Integer hashCodeCache = null;
+ protected SourceInfo srcInfo = null;
/** @deprecated it is preferable to use ASSyntax.parseTerm */
public static Term parse(String sTerm) {
@@ -93,4 +99,33 @@
public boolean apply(Unifier u) {
return false;
}
+
+ public SourceInfo getSrcInfo() {
+ return srcInfo;
+ }
+
+ public void setSrcInfo(SourceInfo s) {
+ srcInfo = s;
+ }
+
+ public String getSrcFile() {
+ if (srcInfo == null)
+ return null;
+ else
+ return srcInfo.getSrcFile();
+ }
+
+ public int getSrcLine() {
+ if (srcInfo == null)
+ return 0;
+ else
+ return srcInfo.getSrcLine();
+ }
+
+ public String getErrorMsg() {
+ if (srcInfo == null)
+ return "";
+ else
+ return srcInfo.getErrorMsg();
+ }
}
Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -143,7 +143,7 @@
@Override
public String getErrorMsg() {
String line = (getSrcLine() >= 0 ? ":"+getSrcLine() : "");
- return "Error in internal action '"+this+"' ("+ getSrc() + line + ")";
+ return "Error in internal action '"+this+"' ("+ getSrcFile() + line + ")";
}
public InternalActionLiteral clone() {
Modified: trunk/src/jason/asSyntax/NumberTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/NumberTermImpl.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/NumberTermImpl.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -57,7 +57,8 @@
}
public NumberTermImpl(NumberTermImpl t) {
- value = t.solve();
+ value = t.solve();
+ srcInfo = t.srcInfo;
}
public double solve() {
Modified: trunk/src/jason/asSyntax/Plan.java
===================================================================
--- trunk/src/jason/asSyntax/Plan.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/Plan.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -44,10 +44,10 @@
@navassoc - event - Trigger
@navassoc - context - LogicalFormula
@navassoc - body - PlanBody
+ @navassoc - source - SourceInfo
-
*/
-public class Plan extends SourceInfo implements Cloneable, Serializable {
+public class Plan implements Cloneable, Serializable {
private static final long serialVersionUID = 1L;
private static final Term TAtomic = ASSyntax.createAtom("atomic");
@@ -61,6 +61,7 @@
private LogicalFormula context;
private PlanBody body;
+ protected SourceInfo srcInfo = null;
private boolean isAtomic = false;
private boolean isAllUnifs = false;
@@ -211,7 +212,7 @@
p.body = (PlanBody)body.clone();
- p.setSrc(this);
+ p.setSrcInfo(srcInfo);
return p;
}
@@ -230,11 +231,20 @@
p.context = context;
p.body = body.clonePB();
- p.setSrc(this);
+ p.setSrcInfo(srcInfo);
return p;
}
+
+ public SourceInfo getSrcInfo() {
+ return srcInfo;
+ }
+
+ public void setSrcInfo(SourceInfo s) {
+ srcInfo = s;
+ }
+
public String toString() {
return toASString();
}
Modified: trunk/src/jason/asSyntax/PlanBodyImpl.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -40,7 +40,7 @@
super(BODY_PLAN_FUNCTOR, 0);
term = b;
formType = t;
- setSrc(b);
+ setSrcInfo(b.getSrcInfo());
}
public void setBodyNext(PlanBody next) {
Modified: trunk/src/jason/asSyntax/SourceInfo.java
===================================================================
--- trunk/src/jason/asSyntax/SourceInfo.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/SourceInfo.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -1,65 +1,56 @@
package jason.asSyntax;
/**
- * Store information about the file source of some data.
+ * Store information about the file source of some term (atom, literal, etc).
+ * (immutable objects)
*/
public class SourceInfo {
- private String source = null;
- private int beginSrcLine = -1; // the line this literal appears in the source
- private int endSrcLine = -1;
+ private final String source;
+ private final int beginSrcLine; // the line this literal appears in the source
+ private final int endSrcLine;
- public SourceInfo() {
+ public SourceInfo(String file, int beginLine) {
+ source = file;
+ beginSrcLine = beginLine;
+ endSrcLine = beginLine;
}
-
- public SourceInfo(SourceInfo o) {
- setSrc(o);
+ public SourceInfo(String file, int beginLine, int endLine) {
+ source = file;
+ beginSrcLine = beginLine;
+ endSrcLine = endLine;
}
-
- public void setSrc(SourceInfo o) {
+ public SourceInfo(SourceInfo o) {
source = o.source;
beginSrcLine = o.beginSrcLine;
endSrcLine = o.endSrcLine;
}
- public void setSrc(Object o) {
- if (o instanceof SourceInfo)
- setSrc((SourceInfo)o);
+ public SourceInfo(DefaultTerm o) {
+ this(o.getSrcInfo());
}
-
- public void setSrc(String asSource) {
- source = asSource;
+
+ public SourceInfo clone() {
+ return this;
}
- public String getSrc() {
+
+ public String getSrcFile() {
return source;
}
- public void setSrcLine(int i) {
- beginSrcLine = i;
- }
public int getSrcLine() {
return beginSrcLine;
}
- public void setSrcLines(int b, int e) {
- beginSrcLine = b;
- endSrcLine = e;
- }
-
- public void setBeginSrcLine(int i) {
- beginSrcLine = i;
- }
public int getBeginSrcLine() {
return beginSrcLine;
}
- public void setEndSrcLine(int i) {
- endSrcLine = i;
- }
public int getEndSrcLine() {
return endSrcLine;
}
public String getErrorMsg() {
- return getSrc() + (getSrcLine() >= 0 ? ":"+getSrcLine() : "");
+ return (source == null ? "nofile" : source)
+ + (beginSrcLine >= 0 ? ":"+beginSrcLine : "");
}
}
Modified: trunk/src/jason/asSyntax/StringTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/StringTermImpl.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/StringTermImpl.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -54,7 +54,8 @@
}
public StringTermImpl(StringTermImpl t) {
- value = t.getString();
+ value = t.getString();
+ srcInfo = t.srcInfo;
}
public String getString() {
Modified: trunk/src/jason/asSyntax/Term.java
===================================================================
--- trunk/src/jason/asSyntax/Term.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/Term.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -8,6 +8,8 @@
/**
* Common interface for all kind of terms
+ *
+ * @opt nodefillcolor lightgoldenrodyellow
*/
public interface Term extends Cloneable, Comparable<Term>, Serializable, ToDOM {
@@ -37,10 +39,7 @@
public boolean apply(Unifier u);
/** Removes the value cached for hashCode */
- public void resetHashCodeCache();
+ //public void resetHashCodeCache();
- public int getSrcLine();
- public String getSrc();
- public String getErrorMsg(); // info for error messages
-
+ public SourceInfo getSrcInfo();
}
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -82,7 +82,7 @@
} else {
// do not call constructor with term parameter!
VarTerm t = new VarTerm(super.getFunctor());
- t.setSrc(this);
+ t.srcInfo = this.srcInfo;
if (hasAnnot())
t.setAnnots(getAnnots().cloneLT());
return t;
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-10-05 16:34:24 UTC (rev 1392)
@@ -58,14 +58,23 @@
public void setAg(Agent ag) { curAg = ag; }
- private String getSourceRef(Object o) {
- if (o instanceof SourceInfo) {
- SourceInfo s = (SourceInfo)o;
- return "["+s.getSrc()+":"+s.getBeginSrcLine()+"]";
- } else {
- return "";
- }
+ private String getSourceRef(SourceInfo s) {
+ if (s == null)
+ return "[]";
+ else
+ return "["+s.getSrcFile()+":"+s.getBeginSrcLine()+"]";
}
+ private String getSourceRef(DefaultTerm t) {
+ return getSourceRef( ((DefaultTerm)t).getSrcInfo());
+ }
+ private String getSourceRef(Object t) {
+ if (t instanceof DefaultTerm)
+ return getSourceRef((DefaultTerm)t);
+ else if (t instanceof SourceInfo)
+ return getSourceRef((SourceInfo)t);
+ else
+ return "[]";
+ }
private InternalActionLiteral checkInternalActionsInContext(LogicalFormula f, Agent ag) throws Exception {
if (f != null) {
@@ -99,7 +108,7 @@
private Term changeToAtom(Object o) {
Term u = (Term)o;
if (u.isAtom()) {
- return new Atom( (Literal)u);
+ return new Atom((Literal)u);
} else {
return u;
}
@@ -192,7 +201,7 @@
if (config.getBoolean(Config.WARN_SING_VAR) && !parsedFiles.contains(asSource)) {
List<VarTerm> singletonVars = p.getSingletonVars();
if (singletonVars.size() > 0) {
- logger.warning(getSourceRef(p)+" warning: the plan for event '"+p.getTrigger()+"' has the following singleton variables: "+singletonVars);
+ logger.warning(getSourceRef(p.getSrcInfo())+" warning: the plan for event '"+p.getTrigger()+"' has the following singleton variables: "+singletonVars);
}
}
}
@@ -305,8 +314,7 @@
if (B != null && B.getBodyTerm().equals(Literal.LTrue))
B = (PlanBody)B.getBodyNext();
Plan p = new Plan(L,T,(LogicalFormula)C, B);
- p.setSrcLines(start,end);
- p.setSrc(asSource);
+ p.setSrcInfo(new SourceInfo(asSource,start,end));
return p;
}
}
@@ -434,8 +442,7 @@
|
K=<TK_END>
) { p = new Pred(K.image);
- p.setSrcLine(K.beginLine);
- p.setSrc(asSource);
+ p.setSrcInfo(new SourceInfo(asSource, K.beginLine));
}
[
@@ -477,7 +484,7 @@
{
"["
[
- f=term_in_list() { last = lt.append(f); lt.setSrcLine(f.getSrcLine()); lt.setSrc(f.getSrc());}
+ f=term_in_list() { last = lt.append(f); lt.setSrcInfo(f.getSrcInfo()); }
( "," f=term_in_list() { last = last.append(f); }
)*
[ "|" ( K=<VAR> { last.setNext(new VarTerm(K.image)); }
@@ -631,8 +638,7 @@
{ Token K; Object t; VarTerm v; }
{
( K = <NUMBER> { NumberTermImpl ni = new NumberTermImpl(K.image);
- ni.setSrcLine(K.beginLine);
- ni.setSrc(asSource);
+ ni.setSrcInfo(new SourceInfo(asSource, K.beginLine));
return ni;
}
| "-" t = arithm_expr_simple() { if (!(t instanceof NumberTerm)) {
@@ -654,7 +660,7 @@
return l;
} else {
ArithFunctionTerm at = new ArithFunctionTerm(af);
- at.setSrc(l);
+ at.setSrcInfo(l.getSrcInfo());
at.setTerms(l.getTerms());
at.setAgent(curAg);
return at;
@@ -665,7 +671,7 @@
VarTerm var(): { Token K; VarTerm v; ListTerm lt; }
{
- ( K = <VAR> { v = new VarTerm(K.image); v.setSrcLine(K.beginLine); v.setSrc(asSource);}
+ ( K = <VAR> { v = new VarTerm(K.image); v.setSrcInfo(new SourceInfo(asSource, K.beginLine));}
| K = <UNNAMEDVAR> { v = new UnnamedVar(K.image); }
)
[
@@ -677,8 +683,7 @@
StringTerm string():{ Token k; StringTermImpl s; }
{
k = <STRING> { s = new StringTermImpl(k.image.substring(1,k.image.length()-1));
- s.setSrcLine(k.beginLine);
- s.setSrc(asSource);
+ s.setSrcInfo(new SourceInfo(asSource,k.beginLine));
return s;
}
}
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -28,14 +28,23 @@
public void setAg(Agent ag) { curAg = ag; }
- private String getSourceRef(Object o) {
- if (o instanceof SourceInfo) {
- SourceInfo s = (SourceInfo)o;
- return "["+s.getSrc()+":"+s.getBeginSrcLine()+"]";
- } else {
- return "";
- }
+ private String getSourceRef(SourceInfo s) {
+ if (s == null)
+ return "[]";
+ else
+ return "["+s.getSrcFile()+":"+s.getBeginSrcLine()+"]";
}
+ private String getSourceRef(DefaultTerm t) {
+ return getSourceRef( ((DefaultTerm)t).getSrcInfo());
+ }
+ private String getSourceRef(Object t) {
+ if (t instanceof DefaultTerm)
+ return getSourceRef((DefaultTerm)t);
+ else if (t instanceof SourceInfo)
+ return getSourceRef((SourceInfo)t);
+ else
+ return "[]";
+ }
private InternalActionLiteral checkInternalActionsInContext(LogicalFormula f, Agent ag) throws Exception {
if (f != null) {
@@ -69,7 +78,7 @@
private Term changeToAtom(Object o) {
Term u = (Term)o;
if (u.isAtom()) {
- return new Atom( (Literal)u);
+ return new Atom((Literal)u);
} else {
return u;
}
@@ -178,7 +187,7 @@
if (config.getBoolean(Config.WARN_SING_VAR) && !parsedFiles.contains(asSource)) {
List<VarTerm> singletonVars = p.getSingletonVars();
if (singletonVars.size() > 0) {
- logger.warning(getSourceRef(p)+" warning: the plan for event '"+p.getTrigger()+"' has the following singleton variables: "+singletonVars);
+ logger.warning(getSourceRef(p.getSrcInfo())+" warning: the plan for event '"+p.getTrigger()+"' has the following singleton variables: "+singletonVars);
}
}
}
@@ -359,8 +368,7 @@
if (B != null && B.getBodyTerm().equals(Literal.LTrue))
B = (PlanBody)B.getBodyNext();
Plan p = new Plan(L,T,(LogicalFormula)C, B);
- p.setSrcLines(start,end);
- p.setSrc(asSource);
+ p.setSrcInfo(new SourceInfo(asSource,start,end));
{if (true) return p;}
throw new Error("Missing return statement in function");
}
@@ -598,8 +606,7 @@
throw new ParseException();
}
p = new Pred(K.image);
- p.setSrcLine(K.beginLine);
- p.setSrc(asSource);
+ p.setSrcInfo(new SourceInfo(asSource, K.beginLine));
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 39:
jj_consume_token(39);
@@ -712,7 +719,7 @@
case 39:
case 42:
f = term_in_list();
- last = lt.append(f); lt.setSrcLine(f.getSrcLine()); lt.setSrc(f.getSrc());
+ last = lt.append(f); lt.setSrcInfo(f.getSrcInfo());
label_11:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -1101,8 +1108,7 @@
case NUMBER:
K = jj_consume_token(NUMBER);
NumberTermImpl ni = new NumberTermImpl(K.image);
- ni.setSrcLine(K.beginLine);
- ni.setSrc(asSource);
+ ni.setSrcInfo(new SourceInfo(asSource, K.beginLine));
{if (true) return ni;}
break;
case 35:
@@ -1149,7 +1155,7 @@
{if (true) return l;}
} else {
ArithFunctionTerm at = new ArithFunctionTerm(af);
- at.setSrc(l);
+ at.setSrcInfo(l.getSrcInfo());
at.setTerms(l.getTerms());
at.setAgent(curAg);
{if (true) return at;}
@@ -1162,7 +1168,7 @@
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case VAR:
K = jj_consume_token(VAR);
- v = new VarTerm(K.image); v.setSrcLine(K.beginLine); v.setSrc(asSource);
+ v = new VarTerm(K.image); v.setSrcInfo(new SourceInfo(asSource, K.beginLine));
break;
case UNNAMEDVAR:
K = jj_consume_token(UNNAMEDVAR);
@@ -1190,8 +1196,7 @@
Token k; StringTermImpl s;
k = jj_consume_token(STRING);
s = new StringTermImpl(k.image.substring(1,k.image.length()-1));
- s.setSrcLine(k.beginLine);
- s.setSrc(asSource);
+ s.setSrcInfo(new SourceInfo(asSource,k.beginLine));
{if (true) return s;}
throw new Error("Missing return statement in function");
}
@@ -1203,13 +1208,13 @@
finally { jj_save(0, xla); }
}
- final private boolean jj_3R_14() {
- if (jj_3R_16()) return true;
+ final private boolean jj_3R_15() {
+ if (jj_3R_17()) return true;
return false;
}
- final private boolean jj_3R_17() {
- if (jj_scan_token(42)) return true;
+ final private boolean jj_3R_14() {
+ if (jj_3R_16()) return true;
return false;
}
@@ -1221,6 +1226,11 @@
return false;
}
+ final private boolean jj_3R_17() {
+ if (jj_scan_token(42)) return true;
+ return false;
+ }
+
final private boolean jj_3R_13() {
if (jj_scan_token(39)) return true;
return false;
@@ -1252,11 +1262,6 @@
return false;
}
- final private boolean jj_3R_15() {
- if (jj_3R_17()) return true;
- return false;
- }
-
public as2jTokenManager token_source;
SimpleCharStream jj_input_stream;
public Token token, jj_nt;
Modified: trunk/src/jason/asSyntax/patterns/goal/OMC.java
===================================================================
--- trunk/src/jason/asSyntax/patterns/goal/OMC.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/asSyntax/patterns/goal/OMC.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -3,6 +3,7 @@
import jason.asSemantics.Agent;
import jason.asSyntax.Plan;
import jason.asSyntax.Pred;
+import jason.asSyntax.SourceInfo;
import jason.asSyntax.Term;
import jason.asSyntax.directives.Directive;
import jason.asSyntax.directives.DirectiveProcessor;
@@ -32,12 +33,12 @@
if (newAg != null) {
// add +f : true <- .fail_goal(g).
Plan pf = Plan.parse("+"+fail+" <- .fail_goal("+goal+").");
- pf.setSrc(outerContent+"/"+directive);
+ pf.setSrcInfo(new SourceInfo(outerContent+"/"+directive, 0));
newAg.getPL().add(pf);
// add -m : true <- .succeed_goal(g).
Plan pm = Plan.parse("-"+motivation+" <- .succeed_goal("+goal+").");
- pm.setSrc(outerContent+"/"+directive);
+ pm.setSrcInfo(new SourceInfo(outerContent+"/"+directive, 0));
newAg.getPL().add(pm);
return newAg;
Modified: trunk/src/jason/jeditplugin/AgentSpeakSideKickParser.java
===================================================================
--- trunk/src/jason/jeditplugin/AgentSpeakSideKickParser.java 2008-10-02 18:50:17 UTC (rev 1391)
+++ trunk/src/jason/jeditplugin/AgentSpeakSideKickParser.java 2008-10-05 16:34:24 UTC (rev 1392)
@@ -84,8 +84,8 @@
//super(((p.getLabel() == null) ? "" : "@" + p.getLabel() + " ") + p.getTriggerEvent());
super(p.getTrigger().toString());
this.plan = p;
- this.start = toPos(buf, p.getBeginSrcLine());
- this.end = toPos(buf, p.getEndSrcLine());
+ this.start = toPos(buf, p.getSrcInfo().getBeginSrcLine());
+ this.end = toPos(buf, p.getSrcInfo().getEndSrcLine());
}
public Icon getIcon() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-10-07 00:29:52
|
Revision: 1393
http://jason.svn.sourceforge.net/jason/?rev=1393&view=rev
Author: jomifred
Date: 2008-10-06 23:54:26 +0000 (Mon, 06 Oct 2008)
Log Message:
-----------
fix problems in add_annot when argument is an Atom
improve UML annots in some classes
Modified Paths:
--------------
trunk/applications/jason-moise/src/jmoise/MoiseBaseIA.java
trunk/build.xml
trunk/demos/big/BEnv.java
trunk/examples/cleaning-robots/MarsEnv.java
trunk/examples/gold-miners-II/env/MiningEnvironment.java
trunk/examples/mining-robots/env/planetEnv.java
trunk/examples/room/RoomEnv.java
trunk/release-notes.txt
trunk/src/jason/asSemantics/IntendedMeans.java
trunk/src/jason/asSyntax/ASSyntax.java
trunk/src/jason/asSyntax/BinaryStructure.java
trunk/src/jason/asSyntax/BodyLiteral.java
trunk/src/jason/asSyntax/DefaultTerm.java
trunk/src/jason/asSyntax/ListTerm.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/LogicalFormula.java
trunk/src/jason/asSyntax/NumberTerm.java
trunk/src/jason/asSyntax/ObjectTerm.java
trunk/src/jason/asSyntax/PlanBody.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
trunk/src/jason/asSyntax/StringTerm.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/bb/ChainBBAdapter.java
trunk/src/jason/stdlib/add_annot.java
trunk/src/jason/stdlib/add_nested_source.java
trunk/src/jason/stdlib/drop_intention.java
trunk/src/jason/stdlib/wait.java
trunk/src/test/StdLibTest.java
Modified: trunk/applications/jason-moise/src/jmoise/MoiseBaseIA.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/MoiseBaseIA.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/applications/jason-moise/src/jmoise/MoiseBaseIA.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -1,6 +1,5 @@
package jmoise;
-import jason.JasonException;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.Intention;
import jason.asSemantics.Message;
@@ -34,23 +33,16 @@
if (logger.isLoggable(Level.FINE)) logger.fine("sending: "+acTerm);
// send acTerm as message to OrgManager
- try {
- OrgAgent oag = (OrgAgent)ts.getUserAgArch();
- Message m = new Message("achieve", null, oag.getOrgManagerName(), acTerm);
- oag.sendMsg(m);
-
- if (suspendIntention()) {
- Intention i = ts.getC().getSelectedIntention();
- i.setSuspended(true);
- ts.getC().getPendingIntentions().put("om/"+m.getMsgId(), i);
- }
- return true;
- } catch (JasonException e) {
- throw e;
- } catch (Exception e) {
- logger.log(Level.SEVERE, "Error sending "+acTerm+" to OrgManager.",e);
- }
- return false;
+ OrgAgent oag = (OrgAgent)ts.getUserAgArch();
+ Message m = new Message("achieve", null, oag.getOrgManagerName(), acTerm);
+ oag.sendMsg(m);
+
+ if (suspendIntention()) {
+ Intention i = ts.getC().getSelectedIntention();
+ i.setSuspended(true);
+ ts.getC().getPendingIntentions().put("om/"+m.getMsgId(), i);
+ }
+ return true;
}
@Override
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/build.xml 2008-10-06 23:54:26 UTC (rev 1393)
@@ -269,7 +269,7 @@
<doclet name="org.umlgraph.doclet.UmlGraphDoc" path="lib/UMLGraph.jar">
<!--param name="-inferrel"/ -->
<!--param name="-inferdep"/-->
- <param name="-hide" value="java.*"/>
+ <!--param name="-hide" value="java.*"/-->
<param name="-enumconstants" />
<!--param name="-collpackages" value="java.util.*"/-->
<param name="-qualify"/>
@@ -278,8 +278,8 @@
<param name="-nodefontsize" value="16"/>
<param name="-nodefontpackagesize" value="12"/>
<param name="-edgefontsize" value="14"/>
- <param name="-link" value="http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/doclet/spec"/>
- <param name="-link" value="http://java.sun.com/j2se/1.5/docs/api"/>
+ <!--param name="-link" value="http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/doclet/spec"/>
+ <param name="-link" value="http://java.sun.com/j2se/1.5/docs/api"/-->
</doclet>
</javadoc>
</target>
@@ -289,6 +289,29 @@
</exec>
</target>
+ <!-- generate only the UML diagrams in PDF format -->
+ <target name="uml" unless="dot-nok" >
+ <property name="uml.dir" value="${basedir}/doc/uml"/>
+ <property name="src.uml.dir" value="${src.dir}/doc/uml"/>
+ <mkdir dir="${uml.dir}"/>
+ <javadoc sourcepath="src" packagenames="jason.asSyntax" package="true" >
+ <doclet name="org.umlgraph.doclet.UmlGraph" path="${basedir}/lib/UMLGraph.jar">
+ <param name="-hide" value="java.*"/>
+ <param name="-enumconstants" />
+ <param name="-d" value="${uml.dir}"/>
+ </doclet>
+ </javadoc>
+ <move file="${uml.dir}/graph.dot" tofile="${uml.dir}/syntax.dot" />
+ <apply executable="dot" dest="${uml.dir}" parallel="false">
+ <arg value="-Tpdf"/>
+ <arg value="-o"/>
+ <targetfile/>
+ <srcfile/>
+ <fileset dir="${uml.dir}" includes="*.dot"/>
+ <mapper type="glob" from="*.dot" to="*.pdf"/>
+ </apply>
+ </target>
+
<!-- distribution related tasks -->
Modified: trunk/demos/big/BEnv.java
===================================================================
--- trunk/demos/big/BEnv.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/demos/big/BEnv.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -1,9 +1,9 @@
// Environment code for project big.mas2j
-import jason.asSyntax.*;
-import jason.environment.*;
-import java.util.logging.*;
+import jason.asSyntax.Structure;
+import java.util.logging.Logger;
+
public class BEnv extends jason.environment.Environment {
private Logger logger = Logger.getLogger("big.mas2j."+BEnv.class.getName());
Modified: trunk/examples/cleaning-robots/MarsEnv.java
===================================================================
--- trunk/examples/cleaning-robots/MarsEnv.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/examples/cleaning-robots/MarsEnv.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -15,10 +15,10 @@
public static final int GSize = 7; // grid size
public static final int GARB = 16; // garbage code in grid model
- public static final Term ns = DefaultTerm.parse("next(slot)");
- public static final Term pg = DefaultTerm.parse("pick(garb)");
- public static final Term dg = DefaultTerm.parse("drop(garb)");
- public static final Term bg = DefaultTerm.parse("burn(garb)");
+ public static final Term ns = Literal.parseLiteral("next(slot)");
+ public static final Term pg = Literal.parseLiteral("pick(garb)");
+ public static final Term dg = Literal.parseLiteral("drop(garb)");
+ public static final Term bg = Literal.parseLiteral("burn(garb)");
public static final Literal g1 = Literal.parseLiteral("garbage(r1)");
public static final Literal g2 = Literal.parseLiteral("garbage(r2)");
Modified: trunk/examples/gold-miners-II/env/MiningEnvironment.java
===================================================================
--- trunk/examples/gold-miners-II/env/MiningEnvironment.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/examples/gold-miners-II/env/MiningEnvironment.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -1,7 +1,6 @@
package env;
import jason.asSyntax.Atom;
-import jason.asSyntax.DefaultTerm;
import jason.asSyntax.Literal;
import jason.asSyntax.LiteralImpl;
import jason.asSyntax.NumberTermImpl;
@@ -34,13 +33,13 @@
Random random = new Random();
- Term up = DefaultTerm.parse("do(up)");
- Term down = DefaultTerm.parse("do(down)");
- Term right = DefaultTerm.parse("do(right)");
- Term left = DefaultTerm.parse("do(left)");
- Term skip = DefaultTerm.parse("do(skip)");
- Term pick = DefaultTerm.parse("do(pick)");
- Term drop = DefaultTerm.parse("do(drop)");
+ Term up = Literal.parseLiteral("do(up)");
+ Term down = Literal.parseLiteral("do(down)");
+ Term right = Literal.parseLiteral("do(right)");
+ Term left = Literal.parseLiteral("do(left)");
+ Term skip = Literal.parseLiteral("do(skip)");
+ Term pick = Literal.parseLiteral("do(pick)");
+ Term drop = Literal.parseLiteral("do(drop)");
boolean hasGUI = true;
int windowSize = 800;
Modified: trunk/examples/mining-robots/env/planetEnv.java
===================================================================
--- trunk/examples/mining-robots/env/planetEnv.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/examples/mining-robots/env/planetEnv.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -3,7 +3,6 @@
import jason.asSyntax.Literal;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
-import jason.asSyntax.DefaultTerm;
import jason.environment.Environment;
import java.util.Random;
@@ -45,7 +44,7 @@
public final String bs = new String("build_using");
public final String mr = new String("mine");
public final String dr = new String("drop");
- public final Term nc = DefaultTerm.parse("move_to(next_cell)");
+ public final Term nc = Literal.parseLiteral("move_to(next_cell)");
public int b1res;
public int c1res;
Modified: trunk/examples/room/RoomEnv.java
===================================================================
--- trunk/examples/room/RoomEnv.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/examples/room/RoomEnv.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -1,7 +1,6 @@
-import java.util.*;
-import jason.*;
-import jason.asSyntax.*;
-import jason.environment.*;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Structure;
+import jason.environment.Environment;
public class RoomEnv extends Environment {
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/release-notes.txt 2008-10-06 23:54:26 UTC (rev 1393)
@@ -46,7 +46,7 @@
still works, but
new Literal(...)
have to be written as
- new LiteralImpl(....)
+ ASSyntax.createLiteral(....)
see API doc for more details.
see discussion about the Literal class in the
jason-developers list.
Modified: trunk/src/jason/asSemantics/IntendedMeans.java
===================================================================
--- trunk/src/jason/asSemantics/IntendedMeans.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSemantics/IntendedMeans.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -51,25 +51,11 @@
plan = opt.getPlan().cloneOnlyBody();
unif = opt.getUnifier(); //(Unifier)opt.getUnifier().clone();
- // REMOVED: experimental
- /*
- Literal planLiteral = plan.getTrigger().getLiteral();
- if (planLiteral.hasAnnot()) {
- planLiteral.getAnnots().apply(unif);
- // TODO: why?
- }
- */
if (te == null) {
trigger = plan.getTrigger();
} else {
trigger = (Trigger)te.clone();
trigger.getLiteral().apply(unif);
- // add annots of the trigger into the plan's te
- // so that the event +!g[source(ag1)] will add source(ag1)
- // in the TE of the plan
- // TODO: why?
- // REMOVED: experimental
- //planLiteral.addAnnots(trigger.getLiteral().getAnnots());
}
}
Modified: trunk/src/jason/asSyntax/ASSyntax.java
===================================================================
--- trunk/src/jason/asSyntax/ASSyntax.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/ASSyntax.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -5,7 +5,6 @@
import java.io.StringReader;
-
/**
Factory for objects used in Jason AgentSpeak syntax.
@@ -49,6 +48,8 @@
// or use a parsing (easier but slow)
Literal l4 = parseLiteral("~p(a,3)[s]");
</pre>
+
+ @hidden
@author Jomi
Modified: trunk/src/jason/asSyntax/BinaryStructure.java
===================================================================
--- trunk/src/jason/asSyntax/BinaryStructure.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/BinaryStructure.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -29,6 +29,8 @@
/**
Represents a binary/unary logical/relational operator.
+
+ @opt nodefillcolor lightgoldenrodyellow
@navassoc - left - Term
@navassoc - right - Term
Modified: trunk/src/jason/asSyntax/BodyLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/BodyLiteral.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/BodyLiteral.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -3,6 +3,8 @@
/**
* @deprecated use PlanBodyImpl instead.
+ *
+ * @hidden
*/
public class BodyLiteral extends PlanBodyImpl {
Modified: trunk/src/jason/asSyntax/DefaultTerm.java
===================================================================
--- trunk/src/jason/asSyntax/DefaultTerm.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/DefaultTerm.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -39,6 +39,7 @@
* avoid using it -- use ASSyntax class to create new terms)
*
* @navassoc - source - SourceInfo
+ * @opt nodefillcolor lightgoldenrodyellow
*
* @see ASSyntax
*/
Modified: trunk/src/jason/asSyntax/ListTerm.java
===================================================================
--- trunk/src/jason/asSyntax/ListTerm.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/ListTerm.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -5,6 +5,8 @@
/**
* The interface for lists of the AgentSpeak language
+ *
+ * @opt nodefillcolor lightgoldenrodyellow
*
* @author Jomi
*/
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/Literal.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -49,7 +49,9 @@
<p>There are useful static methods in class {@link ASSyntax} to create Literals.
-
+ @navassoc - type - PredicateIndicator
+ @opt nodefillcolor lightgoldenrodyellow
+
@author jomi
@see ASSyntax
Modified: trunk/src/jason/asSyntax/LogicalFormula.java
===================================================================
--- trunk/src/jason/asSyntax/LogicalFormula.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/LogicalFormula.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -9,6 +9,8 @@
* Represents a logical formula (p, p & q, not p, 3 > X, ...) which can be
* evaluated into a truth value.
*
+ * @opt nodefillcolor lightgoldenrodyellow
+ *
* @author Jomi
*/
public interface LogicalFormula extends Term, Cloneable {
Modified: trunk/src/jason/asSyntax/NumberTerm.java
===================================================================
--- trunk/src/jason/asSyntax/NumberTerm.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/NumberTerm.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -1,7 +1,10 @@
package jason.asSyntax;
-/** The interface for numeric terms of AgentSpeak language */
+/** The interface for numeric terms of AgentSpeak language
+ *
+ * @opt nodefillcolor lightgoldenrodyellow
+ */
public interface NumberTerm extends Term {
/** returns the numeric value of the term */
Modified: trunk/src/jason/asSyntax/ObjectTerm.java
===================================================================
--- trunk/src/jason/asSyntax/ObjectTerm.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/ObjectTerm.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -1,6 +1,9 @@
package jason.asSyntax;
-/** Interface for terms that encapsulate java objects */
+/** Interface for terms that encapsulate java objects
+ *
+ * @opt nodefillcolor lightgoldenrodyellow
+ */
public interface ObjectTerm extends Term {
public Object getObject();
}
Modified: trunk/src/jason/asSyntax/PlanBody.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBody.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/PlanBody.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -1,5 +1,10 @@
package jason.asSyntax;
+/**
+ * Interface for elements of a plans's body.
+ *
+ * @opt nodefillcolor lightgoldenrodyellow
+ */
public interface PlanBody extends Term {
public enum BodyType {
Modified: trunk/src/jason/asSyntax/PlanBodyImpl.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -40,7 +40,8 @@
super(BODY_PLAN_FUNCTOR, 0);
term = b;
formType = t;
- setSrcInfo(b.getSrcInfo());
+ if (b != null)
+ srcInfo = b.getSrcInfo();
}
public void setBodyNext(PlanBody next) {
Modified: trunk/src/jason/asSyntax/StringTerm.java
===================================================================
--- trunk/src/jason/asSyntax/StringTerm.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/StringTerm.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -1,6 +1,9 @@
package jason.asSyntax;
-/** The interface for string terms of the AgentSpeak language */
+/** The interface for string terms of the AgentSpeak language
+ *
+ * @opt nodefillcolor lightgoldenrodyellow
+ */
public interface StringTerm extends Term {
public String getString();
public int length();
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/asSyntax/Structure.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -44,7 +44,6 @@
* <i>n</i> can be 0, so this class also represents atoms.
*
* @composed - terms 0..* Term
- *
*/
public class Structure extends Atom {
Modified: trunk/src/jason/bb/ChainBBAdapter.java
===================================================================
--- trunk/src/jason/bb/ChainBBAdapter.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/bb/ChainBBAdapter.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -140,8 +140,7 @@
@Override
public Object clone() {
- // TODO Auto-generated method stub
- return null;
+ return this;
}
@Override
Modified: trunk/src/jason/stdlib/add_annot.java
===================================================================
--- trunk/src/jason/stdlib/add_annot.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/stdlib/add_annot.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -100,10 +100,11 @@
return result;
} else if (l.isLiteral()) {
Literal result;
- if (l.isAtom())
- result = new LiteralImpl(((Atom)l).getFunctor());
- else
- result = Literal.parseLiteral(l.toString());
+ if (l.isAtom()) {
+ result = new LiteralImpl((Atom)l);
+ } else {
+ result = (Literal)l.clone();
+ }
result.addAnnot(annot);
return result;
}
Modified: trunk/src/jason/stdlib/add_nested_source.java
===================================================================
--- trunk/src/jason/stdlib/add_nested_source.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/stdlib/add_nested_source.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -100,11 +100,12 @@
return result;
} else if (l.isLiteral()) {
Literal result;
- if (l instanceof LiteralImpl)
- result = (Literal)l.clone();
- else
+ if (l.isAtom()) {
result = new LiteralImpl((Atom)l);
-
+ } else {
+ result = (Literal)l.clone();
+ }
+
// create the source annots
Literal ts = new Pred("source",1).addTerms(source).addAnnots(result.getAnnots("source"));
Modified: trunk/src/jason/stdlib/drop_intention.java
===================================================================
--- trunk/src/jason/stdlib/drop_intention.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/stdlib/drop_intention.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -73,8 +73,8 @@
@Override protected void checkArguments(Term[] args) throws JasonException {
super.checkArguments(args); // check number of arguments
- if (!args[0].isLiteral())
- throw JasonException.createWrongArgument(this,"first argument must be a literal");
+ if (!args[0].isLiteral() && !args[0].isVar())
+ throw JasonException.createWrongArgument(this,"first argument '"+args[0]+"' must be a literal or variable");
}
@Override
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/jason/stdlib/wait.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -93,7 +93,7 @@
@Override public boolean suspendIntention() { return true; }
@Override public int getMinArgs() { return 1; }
- @Override public int getMaxArgs() { return 2; }
+ @Override public int getMaxArgs() { return 3; }
@Override
public Object execute(final TransitionSystem ts, Unifier un, Term[] args) throws Exception {
Modified: trunk/src/test/StdLibTest.java
===================================================================
--- trunk/src/test/StdLibTest.java 2008-10-05 16:34:24 UTC (rev 1392)
+++ trunk/src/test/StdLibTest.java 2008-10-06 23:54:26 UTC (rev 1393)
@@ -10,7 +10,7 @@
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.ASSyntax;
-import jason.asSyntax.DefaultTerm;
+import jason.asSyntax.Atom;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
@@ -27,6 +27,7 @@
import jason.bb.BeliefBase;
import jason.infra.centralised.CentralisedAgArch;
import jason.stdlib.add_annot;
+import jason.stdlib.add_nested_source;
import jason.stdlib.add_plan;
import jason.stdlib.fail_goal;
import jason.stdlib.relevant_plans;
@@ -66,13 +67,13 @@
ag.getPL().add(Plan.parse("-!g1 : true <- j."));
}
- public void testAddAnnot() {
+ public void testAddAnnot() throws ParseException {
add_annot aa = new add_annot();
Unifier u = new Unifier();
Literal msg = Literal.parseLiteral("ok(10)");
VarTerm X = new VarTerm("X");
- Term annot = DefaultTerm.parse("source(jomi)");
+ Term annot = ASSyntax.parseTerm("source(jomi)");
try {
aa.execute(null, u, new Term[] { msg, annot, X });
} catch (Exception e) {
@@ -83,21 +84,33 @@
assertTrue(((Pred) u.get("X")).hasAnnot(annot));
// testing addAnnot with list
- ListTerm msgL = (ListTerm) DefaultTerm.parse("[ok(10),[ok(20),ok(30),[ok(40)|[ok(50),ok(60)]]]]");
+ ListTerm msgL = ASSyntax.parseList("[a,ok(10),[ok(20),ok(30),[ok(40)|[ok(50),ok(60)]]]]");
VarTerm Y = new VarTerm("Y");
- Term annotL = DefaultTerm.parse("source(rafa)");
- assertEquals(msgL.toString(), "[ok(10),[ok(20),ok(30),[ok(40),ok(50),ok(60)]]]");
+ Term annotL = ASSyntax.parseTerm("source(rafa)");
+ assertEquals(msgL.toString(), "[a,ok(10),[ok(20),ok(30),[ok(40),ok(50),ok(60)]]]");
try {
- aa.execute(null, u, new Term[] { (Term) msgL, annotL, Y });
+ aa.execute(null, u, new Term[] { msgL, annotL, Y });
} catch (Exception e) {
e.printStackTrace();
}
- // System.out.println("u="+u);
- assertEquals(((ListTerm) u.get("Y")).toString(),
- "[ok(10)[source(rafa)],[ok(20)[source(rafa)],ok(30)[source(rafa)],[ok(40)[source(rafa)],ok(50)[source(rafa)],ok(60)[source(rafa)]]]]");
+ assertEquals("[a[source(rafa)],ok(10)[source(rafa)],[ok(20)[source(rafa)],ok(30)[source(rafa)],[ok(40)[source(rafa)],ok(50)[source(rafa)],ok(60)[source(rafa)]]]]",
+ ((ListTerm) u.get("Y")).toString());
}
- public void testFindAll() throws RevisionFailedException {
+ public void testAddNestedSource() throws Exception {
+ add_nested_source aa = new add_nested_source();
+ Unifier u = new Unifier();
+ VarTerm x = new VarTerm("X");
+ u.unifies(x, new Atom("a"));
+ x.apply(u);
+ Term annot = ASSyntax.parseTerm("jomi");
+ VarTerm r = new VarTerm("R");
+ aa.execute(null, u, new Term[] { x, annot, r });
+ r.apply(u);
+ assertEquals("a[source(jomi)]", r.toString());
+ }
+
+ public void testFindAll() throws RevisionFailedException, ParseException {
Agent ag = new Agent();
ag.setLogger(null);
AgArch arch = new AgArch();
@@ -112,7 +125,7 @@
assertEquals(ag.getBB().size(),3);
Unifier u = new Unifier();
- Term X = DefaultTerm.parse("f(X)");
+ Term X = ASSyntax.parseTerm("f(X)");
Literal c = Literal.parseLiteral("a(X,x)");
c.addAnnot(BeliefBase.TSelf);
VarTerm L = new VarTerm("L");
@@ -249,8 +262,8 @@
StringTerm s1 = new StringTermImpl("a");
StringTerm s2 = new StringTermImpl("bbacca");
- Term t1 = DefaultTerm.parse("a(10)");
- Term t2 = DefaultTerm.parse("[1,b(xxx,a(10))]");
+ Term t1 = ASSyntax.parseTerm("a(10)");
+ Term t2 = ASSyntax.parseTerm("[1,b(xxx,a(10))]");
VarTerm X = new VarTerm("X");
@@ -300,8 +313,8 @@
@SuppressWarnings("unchecked")
public void testMember() throws Exception {
ListTerm l1 = ListTermImpl.parseList("[a,b,c]");
- Term ta = DefaultTerm.parse("a");
- Term td = DefaultTerm.parse("d");
+ Term ta = ASSyntax.parseTerm("a");
+ Term td = ASSyntax.parseTerm("d");
// test member(a,[a,b,c])
Unifier u = new Unifier();
@@ -316,8 +329,8 @@
assertFalse(i.hasNext());
// test member(b(X),[a(1),b(2),c(3)])
- Term l2 = DefaultTerm.parse("[a(1),b(2),c(3)]");
- Term tb = DefaultTerm.parse("b(X)");
+ Term l2 = ASSyntax.parseTerm("[a(1),b(2),c(3)]");
+ Term tb = ASSyntax.parseTerm("b(X)");
u = new Unifier();
i = (Iterator<Unifier>)new jason.stdlib.member().execute(null, u, new Term[] { tb, l2});
assertTrue(i != null);
@@ -328,7 +341,7 @@
assertEquals(ru.get("X").toString(), "2");
// test member(X,[a,b,c])
- Term tx = DefaultTerm.parse("X");
+ Term tx = ASSyntax.parseTerm("X");
u = new Unifier();
i = (Iterator<Unifier>)new jason.stdlib.member().execute(null, u, new Term[] { tx, l1});
assertTrue(iteratorSize(i) == 3);
@@ -339,7 +352,7 @@
assertFalse(i.hasNext());
// test member(b(X),[a(1),b(2),c(3),b(4)])
- l2 = DefaultTerm.parse("[a(1),b(2),c(3),b(4)]");
+ l2 = ASSyntax.parseTerm("[a(1),b(2),c(3),b(4)]");
u = new Unifier();
i = (Iterator<Unifier>)new jason.stdlib.member().execute(null, u, new Term[] { tb, l2});
assertTrue(i != null);
@@ -351,7 +364,7 @@
public void testDelete() throws Exception {
ListTerm l1 = ListTermImpl.parseList("[a,b,a,c,a]");
- Term ta = DefaultTerm.parse("a");
+ Term ta = ASSyntax.parseTerm("a");
VarTerm v = new VarTerm("X");
// test delete(a,[a,b,a,c,a])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-10-15 17:38:45
|
Revision: 1396
http://jason.svn.sourceforge.net/jason/?rev=1396&view=rev
Author: jomifred
Date: 2008-10-15 16:38:37 +0000 (Wed, 15 Oct 2008)
Log Message:
-----------
change the OrgArch to update some bels
Modified Paths:
--------------
trunk/applications/jason-moise/build.xml
trunk/applications/jason-moise/example/auction/orgAuction.mas2j
trunk/applications/jason-moise/example/writePaper/writePaper.mas2j
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-moise/src/jmoise/OrgManager.java
trunk/src/jason/asSyntax/SourceInfo.java
trunk/src/templates/build-template.xml
trunk/src/test/MAS2JParserTest.java
Modified: trunk/applications/jason-moise/build.xml
===================================================================
--- trunk/applications/jason-moise/build.xml 2008-10-15 13:50:49 UTC (rev 1395)
+++ trunk/applications/jason-moise/build.xml 2008-10-15 16:38:37 UTC (rev 1396)
@@ -9,7 +9,7 @@
<property name="version" value="1"/>
<property name="release" value="1.2"/>
- <property name="moiseDir" value="${env.HOME}/svn-moise" />
+ <property name="moiseDir" value="${env.HOME}/Moise/svn-moise" />
<property name="distDir" value="${env.HOME}/tmp/jmoise-${version}.${release}" />
<property name="distFile" value="${env.HOME}/jason-moise-${version}.${release}" />
<property name="doc-src-dir" value="${env.HOME}/programming/Moise-doc" />
Modified: trunk/applications/jason-moise/example/auction/orgAuction.mas2j
===================================================================
--- trunk/applications/jason-moise/example/auction/orgAuction.mas2j 2008-10-15 13:50:49 UTC (rev 1395)
+++ trunk/applications/jason-moise/example/auction/orgAuction.mas2j 2008-10-15 16:38:37 UTC (rev 1396)
@@ -9,7 +9,7 @@
MAS auction {
infrastructure: Centralised
agents:
- orgManager [osfile="auction-os.xml",gui=no]
+ orgManager [osfile="auction-os.xml",gui=yes]
agentArchClass jmoise.OrgManager;
bob auctioneer agentArchClass jmoise.OrgAgent;
Modified: trunk/applications/jason-moise/example/writePaper/writePaper.mas2j
===================================================================
--- trunk/applications/jason-moise/example/writePaper/writePaper.mas2j 2008-10-15 13:50:49 UTC (rev 1395)
+++ trunk/applications/jason-moise/example/writePaper/writePaper.mas2j 2008-10-15 16:38:37 UTC (rev 1396)
@@ -1,7 +1,7 @@
MAS write_paper {
infrastructure: Centralised
agents:
- orgManager [osfile="wp-os.xml",gui=no]
+ orgManager [osfile="wp-os.xml",gui=yes]
agentArchClass jmoise.OrgManager;
jaime agentArchClass jmoise.OrgAgent;
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-15 13:50:49 UTC (rev 1395)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-15 16:38:37 UTC (rev 1396)
@@ -105,6 +105,7 @@
// check if content is and OE
if (m.getPropCont() instanceof OE) {
currentOE = (OE) m.getPropCont();
+ updateBB();
i.remove();
} else if (m.getSender().equals(getOrgManagerName())) {
// the content is a normal predicate
@@ -181,6 +182,25 @@
logger.log(Level.SEVERE, "Error!", e);
}
}
+
+ /** update the bel base according to the current OE */
+ void updateBB() throws RevisionFailedException {
+ Agent ag = getTS().getAg();
+ // add players
+ for (RolePlayer myrole: getMyOEAgent().getRoles()) { // for all my groups
+ for (RolePlayer rp: myrole.getGroup().getPlayers()) { // for player of the group I play some role
+ Literal l = rolePlayer2literal(rp);
+ l.addAnnot(managerSource);
+ ag.addBel(l);
+ }
+ }
+ // remove old players
+ }
+
+ Literal rolePlayer2literal(RolePlayer rp) {
+ return ASSyntax.createLiteral("play", new Atom(rp.getPlayer().getId()), new Atom(rp.getRole().getId()), new Atom(rp.getGroup().getId()));
+ }
+
private Literal addAsBel(String b) throws RevisionFailedException {
Literal l = Literal.parseLiteral(b);
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-10-15 13:50:49 UTC (rev 1395)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-10-15 16:38:37 UTC (rev 1396)
@@ -191,20 +191,26 @@
sender.adoptRole(roleId, grId);
GroupInstance gr = currentOE.findGroup(grId);
+ // send new OE to the members of the group
+ updateMembersOE(gr.getAgents(true), null, true, true);
+
+ /*
// notify others in the group about this new player
- updateMembersOE(gr.getAgents(true), "play(" + sender + "," + roleId + "," + grId + ")", true, true);
+ updateMembersOE(gr.getAgents(true), rolePlayer2str(nrp), true, true);
// send players of the group to the sender
for (RolePlayer rp : gr.getPlayers(null, true)) {
if (!rp.getPlayer().equals(sender)) {
- updateMembersOE(sender, "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + grId + ")", false, true);
+ updateMembersOE(sender, rolePlayer2str(rp), false, true);
}
}
+ */
// send schemes of this group to sender
for (SchemeInstance sch : gr.getRespSchemes()) {
updateMembersOE(sender, "scheme_group(" + sch.getId() + "," + grId + ")", false, true);
}
+
sendReply(sender, mId, "ok");
}
}
@@ -217,11 +223,11 @@
String roleId = command.getTerm(0).toString();
String grId = command.getTerm(1).toString();
- sender.removeRole(roleId, grId);
+ RolePlayer orp = sender.removeRole(roleId, grId);
GroupInstance gr = currentOE.findGroup(grId);
// notify other players
- updateMembersOE(gr.getAgents(true), "play(" + sender + "," + roleId + "," + grId + ")", false, false);
+ updateMembersOE(gr.getAgents(true), rolePlayer2str(orp), false, false);
// and the sender
updateMembersOE(sender, "play(" + sender + "," + roleId + "," + grId + ")", true, false);
@@ -229,7 +235,7 @@
// if the agent is not member of the group anymore, remove other informations of the group
if (!gr.getAgents(false).contains(sender)) {
for (RolePlayer rp : gr.getPlayers()) {
- updateMembersOE(sender, "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + gr.getId() + ")", false, false);
+ updateMembersOE(sender, rolePlayer2str(rp), false, false);
}
for (SchemeInstance sch : gr.getRespSchemes()) {
updateMembersOE(sender, "scheme_group(" + sch.getId() + "," + grId + ")", false, false);
@@ -246,17 +252,17 @@
public void process(OE currentOE, Pred command, OEAgent sender, String mId) throws MoiseException {
String misId = command.getTerm(0).toString();
String schId = command.getTerm(1).toString();
- sender.commitToMission(misId, schId);
+ MissionPlayer nmp = sender.commitToMission(misId, schId);
SchemeInstance sch = currentOE.findScheme(schId);
// notify to the scheme players the new player
- updateMembersOE(sch.getPlayers(), "commitment(" + sender + "," + misId + "," + sch.getId() + ")", true, true);
+ updateMembersOE(sch.getPlayers(), missionPlayer2str(nmp), true, true);
// notify to the sender the other commitments of the scheme
for (MissionPlayer mp : sch.getPlayers()) {
if (!mp.getPlayer().equals(sender)) {
- updateMembersOE(sender, "commitment(" + mp.getPlayer().getId() + "," + mp.getMission().getId() + "," + sch.getId() + ")", false, true);
+ updateMembersOE(sender, missionPlayer2str(mp), false, true);
}
}
@@ -290,7 +296,7 @@
MissionPlayer mp = mpi.next();
sender.removeMission(mp.getMission().getId(), schId);
mpi = sender.getMissions().iterator();
- String evUnCom = "commitment(" + sender + "," + mp.getMission().getId() + "," + sch.getId() + ")";
+ String evUnCom = missionPlayer2str(mp);
updateMembersOE(sch.getPlayers(), evUnCom, false, false);
//if (!sch.isPlayer(sender)) {
updateMembersOE(sender, evUnCom, false, false);
@@ -298,8 +304,8 @@
}
} else {
sch = currentOE.findScheme(schId);
- sender.removeMission(misId, schId);
- String evUnCom = "commitment(" + sender + "," + misId + "," + sch.getId() + ")";
+ MissionPlayer omp = sender.removeMission(misId, schId);
+ String evUnCom = missionPlayer2str(omp);
updateMembersOE(sender, evUnCom, false, false);
//if (!sch.isPlayer(sender)) {
updateMembersOE(sch.getPlayers(), evUnCom, false, false);
@@ -323,7 +329,6 @@
public void process(OE currentOE, Pred command, OEAgent sender, String mId) throws MoiseException {
boolean isNewRoot = command.getArity() == 1;
GroupInstance newGr;
- String annot = "root";
String specId = command.getTerm(0).toString();
if (isNewRoot) {
newGr = currentOE.addGroup(specId);
@@ -335,15 +340,15 @@
return;
}
newGr = superGr.addSubGroup(specId);
- annot = "super_gr(" + superGr.getId() + ")";
}
newGr.setOwner(sender);
- updateMembersOE(currentOE.getAgents(), "group(" + specId + "," + newGr.getId() + ")[owner(" + sender + ")," + annot + "]", false, true);
+ updateMembersOE(currentOE.getAgents(), group2str(newGr), false, true);
sendReply(sender, mId, newGr.getId());
}
}
+
class RemoveGroup implements OrgManagerCommand {
public String getId() {
return "remove_group";
@@ -367,19 +372,19 @@
}
// untell players
for (RolePlayer rp: gr.getPlayers()) {
- updateMembersOE(gr.getAgents(true), "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + gr.getId() + ")", false, false);
+ updateMembersOE(gr.getAgents(true), rolePlayer2str(rp), false, false);
}
// send changes for subgroups of gr
for (GroupInstance sg: gr.getAllSubGroupsTree()) {
- updateMembersOE(currentOE.getAgents(), "group(" + sg.getGrSpec().getId() + "," + sg.getId() + ")", false, false);
+ updateMembersOE(currentOE.getAgents(), group2str(sg), false, false);
// also send untell scheme_group (if it is the case)
for (SchemeInstance sch: sg.getRespSchemes()) {
updateMembersOE(sg.getPlayers(), "scheme_group(" + sch.getId() + "," + sg.getId() + ")", false, false);
}
// untell players
for (RolePlayer rp: sg.getPlayers()) {
- updateMembersOE(sg.getAgents(true), "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + sg.getId() + ")", false, false);
+ updateMembersOE(sg.getAgents(true), rolePlayer2str(rp), false, false);
}
}
@@ -387,7 +392,7 @@
currentOE.removeGroup(grId);
// sent a new copy of OE
- updateMembersOE(currentOE.getAgents(), "group(" + gr.getGrSpec().getId() + "," + gr.getId() + ")", true, false);
+ updateMembersOE(currentOE.getAgents(), group2str(gr), true, false);
sendReply(sender, mId, "ok");
}
}
@@ -402,9 +407,14 @@
// send created groups
for (GroupInstance gr: currentOE.getGroups()) {
- updateMembersOE(sender, "group(" + gr.getGrSpec().getId() + "," + gr.getId() + ")[owner(" + gr.getOwner().getId() + ")]", false, true);
+ sendGr(sender, gr);
}
}
+ private void sendGr(OEAgent to, GroupInstance gr) {
+ updateMembersOE(to, group2str(gr), false, true);
+ for (GroupInstance sg: gr.getSubGroups())
+ sendGr(to, sg);
+ }
}
class CreateScheme implements OrgManagerCommand {
@@ -415,7 +425,7 @@
String schSpecId = command.getTerm(0).toString();
SchemeInstance sch = currentOE.startScheme(schSpecId.toString());
sch.setOwner(sender);
- updateMembersOE(currentOE.getAgents(), "scheme(" + schSpecId + "," + sch.getId() + ")[owner(" + sender + ")]", true, true);
+ updateMembersOE(currentOE.getAgents(), scheme2str(sch), true, true);
if (command.getArity() > 1) {
// set the initial groups
@@ -480,7 +490,7 @@
act(currentOE, sch);
// send untell to agents
- updateMembersOE(currentOE.getAgents(), "scheme(" + sch.getSpec().getId() + "," + sch.getId() + ")[owner(" + sch.getOwner() + ")]", false, false);
+ updateMembersOE(currentOE.getAgents(), scheme2str(sch), false, false);
sendReply(sender, mId, "ok");
}
protected void act(OE currentOE, SchemeInstance sch) throws MoiseException {
@@ -573,6 +583,26 @@
}
}
+ String group2str(GroupInstance gr) {
+ String sga = "root";
+ if (gr.getSuperGroup() != null)
+ sga = "super_gr("+gr.getSuperGroup().getId()+")";
+ return "group(" + gr.getGrSpec().getId() + "," + gr.getId() + ")[owner(" + gr.getOwner().getId() +"),"+sga+"]";
+ }
+
+ String rolePlayer2str(RolePlayer rp) {
+ return "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + rp.getGroup().getId() + ")";
+ }
+
+ String scheme2str(SchemeInstance sch) {
+ return "scheme(" + sch.getSpec().getId() + "," + sch.getId() + ")[owner(" + sch.getOwner().getId() + ")]";
+ }
+
+ String missionPlayer2str(MissionPlayer mp) {
+ return "commitment(" + mp.getPlayer().getId() + "," + mp.getMission().getId() + "," + mp.getScheme().getId() + ")";
+ }
+
+
void sendReply(OEAgent to, String mId, String content) {
try {
Message r = new Message("tell", null, to.getId(), content);
Modified: trunk/src/jason/asSyntax/SourceInfo.java
===================================================================
--- trunk/src/jason/asSyntax/SourceInfo.java 2008-10-15 13:50:49 UTC (rev 1395)
+++ trunk/src/jason/asSyntax/SourceInfo.java 2008-10-15 16:38:37 UTC (rev 1396)
@@ -1,10 +1,12 @@
package jason.asSyntax;
+import java.io.Serializable;
+
/**
* Store information about the file source of some term (atom, literal, etc).
* (immutable objects)
*/
-public class SourceInfo {
+public class SourceInfo implements Serializable {
private final String source;
private final int beginSrcLine; // the line this literal appears in the source
Modified: trunk/src/templates/build-template.xml
===================================================================
--- trunk/src/templates/build-template.xml 2008-10-15 13:50:49 UTC (rev 1395)
+++ trunk/src/templates/build-template.xml 2008-10-15 16:38:37 UTC (rev 1396)
@@ -90,7 +90,7 @@
failonerror="true" fork="yes" dir="${basedir}" >
<classpath refid="project.classpath"/>
<arg line="${mas2j.project.file} ${debug} <RUN-ARGS>"/>
- <jvmarg line="-Xmx750M"/>
+ <jvmarg line="-Xmx500M"/>
</java>
<antcall target="user-end" />
</target>
Modified: trunk/src/test/MAS2JParserTest.java
===================================================================
--- trunk/src/test/MAS2JParserTest.java 2008-10-15 13:50:49 UTC (rev 1395)
+++ trunk/src/test/MAS2JParserTest.java 2008-10-15 16:38:37 UTC (rev 1396)
@@ -2,7 +2,9 @@
import jason.asSyntax.Literal;
import jason.bb.ChainBB;
+import jason.mas2j.ClassParameters;
import jason.mas2j.MAS2JProject;
+import jason.mas2j.parser.ParseException;
import jason.mas2j.parser.mas2j;
import java.io.StringReader;
@@ -81,5 +83,11 @@
bb.add(Literal.parseLiteral("b(1)"));
}
-
+ public void testClassDef() throws ParseException {
+ String archClass = "my.Arch(test)";
+ mas2j parser = new mas2j(new StringReader(archClass));
+ ClassParameters c = parser.classDef();
+ assertEquals("my.Arch", c.getClassName());
+ assertEquals(1,c.getParametersArray().length);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|