|
From: <jom...@us...> - 2008-04-10 07:17:12
|
Revision: 1211
http://jason.svn.sourceforge.net/jason/?rev=1211&view=rev
Author: jomifred
Date: 2008-04-10 00:17:08 -0700 (Thu, 10 Apr 2008)
Log Message:
-----------
use / instead of File.separator in Include class.
Modified Paths:
--------------
trunk/applications/as-unit-test/src/example/TestExample.java
trunk/applications/jason-moise/build.xml
trunk/applications/jason-moise/readme.txt
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSyntax/directives/Include.java
trunk/src/jason/bb/TextPersistentBB.java
trunk/src/jason/util/asl2xml.java
trunk/src/test/ASParserTest.java
Modified: trunk/applications/as-unit-test/src/example/TestExample.java
===================================================================
--- trunk/applications/as-unit-test/src/example/TestExample.java 2008-04-09 19:05:06 UTC (rev 1210)
+++ trunk/applications/as-unit-test/src/example/TestExample.java 2008-04-10 07:17:08 UTC (rev 1211)
@@ -23,9 +23,9 @@
}
@Test
- public void testBels() {
- ag.assertBel("b(20)",0);
- ag.assertBel("not b",0);
+ public void testInitialBels() {
+ ag.assertBel("b(20)",0); // agent must believe "b(20)" without any reasoning
+ ag.assertBel("not b",0);
ag.assertBel("not b(5)",0);
ag.assertBel("b(10) & b(20) & not b(60)",0);
}
Modified: trunk/applications/jason-moise/build.xml
===================================================================
--- trunk/applications/jason-moise/build.xml 2008-04-09 19:05:06 UTC (rev 1210)
+++ trunk/applications/jason-moise/build.xml 2008-04-10 07:17:08 UTC (rev 1211)
@@ -8,7 +8,7 @@
<property environment="env"/>
<property name="version" value="1"/>
- <property name="release" value="0.1"/>
+ <property name="release" value="1"/>
<property name="moiseDir" value="${env.HOME}/Moise/Moise-svn" />
<property name="distDir" value="${env.HOME}/tmp/jmoise-${version}.${release}" />
<property name="distFile" value="${env.HOME}/jason-moise-${version}.${release}" />
Modified: trunk/applications/jason-moise/readme.txt
===================================================================
--- trunk/applications/jason-moise/readme.txt 2008-04-09 19:05:06 UTC (rev 1210)
+++ trunk/applications/jason-moise/readme.txt 2008-04-10 07:17:08 UTC (rev 1211)
@@ -9,4 +9,4 @@
and start it. The chapter 4 of doc/tutorial.pdf explains in details
the examples.
-Note: Jason 1.0.1 is required.
+Note: Jason 1.1 is required.
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-04-09 19:05:06 UTC (rev 1210)
+++ trunk/src/jason/asSemantics/Agent.java 2008-04-10 07:17:08 UTC (rev 1211)
@@ -127,18 +127,18 @@
boolean parsingOk = true;
if (asSrc != null) {
+ asSrc = asSrc.replaceAll("\\\\", "/");
setASLSrc(asSrc);
if (asSrc.startsWith(Include.CRPrefix)) {
// loads the class from a jar file (for example)
- asSrc = asSrc.replaceAll("\\\\", "/");
parseAS(Agent.class.getResource(asSrc.substring(Include.CRPrefix.length())).openStream());
} else {
// check whether source is an URL string
try {
parsingOk = parseAS(new URL(asSrc));
} catch (MalformedURLException e) {
- parsingOk = parseAS(asSrc);
+ parsingOk = parseAS(new File(asSrc));
}
}
}
@@ -192,7 +192,7 @@
}
public void setASLSrc(String file) {
- if (file != null && file.startsWith("."+File.separator))
+ if (file != null && file.startsWith("./"))
file = file.substring(2);
aslSource = file;
}
@@ -214,17 +214,17 @@
}
/** Adds beliefs and plans form a file */
- public boolean parseAS(String asFileName) {
+ public boolean parseAS(File asFile) {
try {
- parseAS(new FileInputStream(asFileName));
- logger.fine("as2j: AgentSpeak program '" + asFileName + "' parsed successfully!");
+ parseAS(new FileInputStream(asFile));
+ logger.fine("as2j: AgentSpeak program '" + asFile + "' parsed successfully!");
return true;
} catch (FileNotFoundException e) {
- logger.log(Level.SEVERE, "as2j: the AgentSpeak source file '"+asFileName+"' was not found!");
+ logger.log(Level.SEVERE, "as2j: the AgentSpeak source file '"+asFile+"' was not found!");
} catch (ParseException e) {
logger.log(Level.SEVERE, "as2j: parsing error:" + e.getMessage());
} catch (Exception e) {
- logger.log(Level.SEVERE, "as2j: error parsing \"" + asFileName + "\"", e);
+ logger.log(Level.SEVERE, "as2j: error parsing \"" + asFile + "\"", e);
}
return false;
}
Modified: trunk/src/jason/asSyntax/directives/Include.java
===================================================================
--- trunk/src/jason/asSyntax/directives/Include.java 2008-04-09 19:05:06 UTC (rev 1210)
+++ trunk/src/jason/asSyntax/directives/Include.java 2008-04-10 07:17:08 UTC (rev 1211)
@@ -27,7 +27,7 @@
public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
if (outerContent == null)
return null;
- String file = ((StringTerm)directive.getTerm(0)).getString();
+ String file = ((StringTerm)directive.getTerm(0)).getString().replaceAll("\\\\", "/");
try {
String outerPrefix = outerContent.getASLSrc(); // the source file that has the include directive
InputStream in;
@@ -38,7 +38,7 @@
file = checkPathAndFixWithSourcePath(file, aslSourcePath, outerPrefix);
in = new URL(file).openStream();
- } if (outerPrefix.startsWith(CRPrefix)) {
+ } if (outerPrefix.startsWith(CRPrefix)) {
// outer is loaded from a resource ("application".jar) file, used for java web start
int posSlash = outerPrefix.lastIndexOf("/");
@@ -89,7 +89,7 @@
return f;
} else if (srcpath != null) {
for (String path: srcpath) {
- File newname = new File(path + File.separator + f.toString());
+ File newname = new File(path + "/" + f.toString());
if (newname.exists()) {
try {
return newname.getCanonicalFile().toString();
@@ -104,7 +104,7 @@
return urlPrefix + f;
} else if (srcpath != null) {
for (String path: srcpath) {
- String newname = urlPrefix + path + File.separator + f;
+ String newname = urlPrefix + path + "/" + f;
if (testURLSrc(newname)) {
return newname;
}
Modified: trunk/src/jason/bb/TextPersistentBB.java
===================================================================
--- trunk/src/jason/bb/TextPersistentBB.java 2008-04-09 19:05:06 UTC (rev 1210)
+++ trunk/src/jason/bb/TextPersistentBB.java 2008-04-10 07:17:08 UTC (rev 1211)
@@ -26,7 +26,7 @@
file = new File(ag.getTS().getUserAgArch().getAgName() + ".bb");
logger.fine("reading from file " + file);
if (file.exists()) {
- ag.parseAS(file.getAbsolutePath());
+ ag.parseAS(file.getAbsoluteFile());
ag.addInitialBelsInBB();
}
} catch (RevisionFailedException e) {
Modified: trunk/src/jason/util/asl2xml.java
===================================================================
--- trunk/src/jason/util/asl2xml.java 2008-04-09 19:05:06 UTC (rev 1210)
+++ trunk/src/jason/util/asl2xml.java 2008-04-10 07:17:08 UTC (rev 1211)
@@ -2,6 +2,7 @@
import jason.asSemantics.Agent;
+import java.io.File;
import java.io.StringReader;
import java.io.StringWriter;
@@ -43,7 +44,7 @@
Agent loadAg(String file) throws Exception {
Agent ag = new Agent();
- if (ag.parseAS(file)) {
+ if (ag.parseAS(new File(file))) {
ag.setASLSrc(file);
ag.addInitialBelsInBB();
return ag;
Modified: trunk/src/test/ASParserTest.java
===================================================================
--- trunk/src/test/ASParserTest.java 2008-04-09 19:05:06 UTC (rev 1210)
+++ trunk/src/test/ASParserTest.java 2008-04-10 07:17:08 UTC (rev 1211)
@@ -36,13 +36,13 @@
arch.setArchInfraTier(new CentralisedAgArch());
ag.setTS(new TransitionSystem(ag, null, null, arch));
- assertTrue(ag.parseAS("src/asl/kqmlPlans.asl"));
- assertTrue(ag.parseAS("examples/auction/ag1.asl"));
+ assertTrue(ag.parseAS(new File("src/asl/kqmlPlans.asl")));
+ assertTrue(ag.parseAS(new File("examples/auction/ag1.asl")));
Plan p = ag.getPL().get("l__0");
assertEquals(p.getBody().getPlanSize(), 1);
assertEquals(((PlanBody)p.getBody()).getBodyType(), PlanBody.BodyType.internalAction);
- assertTrue(ag.parseAS("examples/auction/ag2.asl"));
- assertTrue(ag.parseAS("examples/auction/ag3.asl"));
+ assertTrue(ag.parseAS(new File("examples/auction/ag2.asl")));
+ assertTrue(ag.parseAS(new File("examples/auction/ag3.asl")));
}
public void testLogicalExpr() throws Exception {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|