From: <jom...@us...> - 2016-02-24 19:59:44
|
Revision: 1873 http://sourceforge.net/p/jason/svn/1873 Author: jomifred Date: 2016-02-24 19:59:41 +0000 (Wed, 24 Feb 2016) Log Message: ----------- include internal action accepts a namespace as parameter Modified Paths: -------------- trunk/demos/directives/myp/LoggerDirective.java trunk/src/jason/asSyntax/InternalActionLiteral.java trunk/src/jason/asSyntax/directives/DirectiveProcessor.java trunk/src/jason/asSyntax/directives/FunctionRegister.java trunk/src/jason/asSyntax/directives/Include.java trunk/src/jason/asSyntax/directives/NameSpace.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/BDG.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/asSyntax/patterns/goal/OMC.java trunk/src/jason/asSyntax/patterns/goal/RC.java trunk/src/jason/asSyntax/patterns/goal/SGA.java trunk/src/jason/asSyntax/patterns/goal/SMC.java trunk/src/jason/mas2j/MAS2JProject.java trunk/src/jason/stdlib/include.java Modified: trunk/demos/directives/myp/LoggerDirective.java =================================================================== --- trunk/demos/directives/myp/LoggerDirective.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/demos/directives/myp/LoggerDirective.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -2,12 +2,13 @@ package myp; import jason.asSemantics.Agent; +import jason.asSyntax.Literal; +import jason.asSyntax.Plan; import jason.asSyntax.PlanBody; +import jason.asSyntax.PlanBody.BodyType; import jason.asSyntax.PlanBodyImpl; -import jason.asSyntax.Literal; -import jason.asSyntax.Plan; import jason.asSyntax.Pred; -import jason.asSyntax.PlanBody.BodyType; +import jason.asSyntax.directives.DefaultDirective; import jason.asSyntax.directives.Directive; import java.util.logging.Level; @@ -18,7 +19,7 @@ * @author jomi */ -public class LoggerDirective implements Directive { +public class LoggerDirective extends DefaultDirective implements Directive { static Logger logger = Logger.getLogger(LoggerDirective.class.getName()); Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java =================================================================== --- trunk/src/jason/asSyntax/InternalActionLiteral.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -56,7 +56,7 @@ // used by clone public InternalActionLiteral(InternalActionLiteral l) { - super(DefaultNS, (Structure) l); + super(l.getNS(), (Structure) l); this.ia = l.ia; } @@ -68,7 +68,10 @@ // used by the parser public InternalActionLiteral(Structure p, Agent ag) throws Exception { - super(p); + this(DefaultNS, p, ag); + } + public InternalActionLiteral(Atom ns, Structure p, Agent ag) throws Exception { + super(ns, p); if (ag != null) ia = ag.getIA(getFunctor()); } Modified: trunk/src/jason/asSyntax/directives/DirectiveProcessor.java =================================================================== --- trunk/src/jason/asSyntax/directives/DirectiveProcessor.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/directives/DirectiveProcessor.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -115,22 +115,4 @@ return null; } - -/* - public Agent process(Pred directive, Agent outerAg, Agent innerAg) { - try { - //logger.fine("Processing directive "+directive); - Directive d = get(directive.getFunctor()); - if (d != null) { - return d.process(directive, outerAg, innerAg); - } else { - logger.log(Level.SEVERE, "Unknown directive "+directive); - } - } catch (Exception e) { - logger.log(Level.SEVERE, "Error processing directive "+directive,e); - } - return null; - } -*/ - } Modified: trunk/src/jason/asSyntax/directives/FunctionRegister.java =================================================================== --- trunk/src/jason/asSyntax/directives/FunctionRegister.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/directives/FunctionRegister.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -100,6 +100,7 @@ } @SuppressWarnings("unchecked") + @Override public Agent process(Pred directive, Agent outerContent, Agent innerContent) { if (outerContent == null) return null; Modified: trunk/src/jason/asSyntax/directives/Include.java =================================================================== --- trunk/src/jason/asSyntax/directives/Include.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/directives/Include.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -1,6 +1,7 @@ package jason.asSyntax.directives; import jason.asSemantics.Agent; +import jason.asSyntax.Atom; import jason.asSyntax.Pred; import jason.asSyntax.StringTerm; import jason.asSyntax.parser.as2j; @@ -28,6 +29,8 @@ public Agent process(Pred directive, Agent outerContent, Agent innerContent) { if (outerContent == null) return null; + + // handles file (arg[0]) String file = ((StringTerm)directive.getTerm(0)).getString().replaceAll("\\\\", "/"); try { InputStream in = null; @@ -73,12 +76,21 @@ in = new FileInputStream(checkPathAndFixWithSourcePath(file, aslSourcePath, null)); } } - + // handles namespace (args[1]) + Atom ns = directive.getNS(); + if (directive.getArity() > 1) { + if (! directive.getTerm(1).isAtom()) { + logger.log(Level.SEVERE, "The second parameter of the directive include (the namespace) should be an atom and not "+directive.getTerm(1)+". It is being ignored!"); + } else { + ns = new Atom( ((Atom)directive.getTerm(1)).getFunctor() ); + } + } Agent ag = new Agent(); ag.initAg(); ag.setASLSrc(file); - as2j parser = new as2j(in); - parser.agent(ag); + as2j sparser = new as2j(in); + sparser.setNS(ns); + sparser.agent(ag); logger.fine("as2j: AgentSpeak program '"+file+"' parsed successfully!"); return ag; } catch (FileNotFoundException e) { Modified: trunk/src/jason/asSyntax/directives/NameSpace.java =================================================================== --- trunk/src/jason/asSyntax/directives/NameSpace.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/directives/NameSpace.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -8,12 +8,14 @@ import java.util.HashMap; import java.util.Map; import java.util.Stack; +import java.util.logging.Level; +import java.util.logging.Logger; /** Implementation of the <code>namespace</code> directive. */ public class NameSpace implements Directive { - //static Logger logger = Logger.getLogger(NameSpace.class.getName()); - + static Logger logger = Logger.getLogger(NameSpace.class.getName()); + private Map<Atom,Atom> localNSs = new HashMap<Atom,Atom>(); @Override @@ -30,23 +32,35 @@ @Override public void begin(Pred directive, as2j parser) { - oldNS.push(parser.getNS()); + if (! directive.getTerm(0).isAtom()) { + logger.log(Level.SEVERE, "The first parameter of the directive namespace should be an atom and not "+directive.getTerm(0)); + return; + } Atom ns = new Atom( ((Atom)directive.getTerm(0)).getFunctor() ); + if (directive.getArity() > 1) { + if (! directive.getTerm(1).isAtom()) { + logger.log(Level.SEVERE, "The second parameter of the directive namespace should be an atom and not "+directive.getTerm(1)); + return; + } String type = ((Atom)directive.getTerm(1)).getFunctor(); + if (!type.equals("local") && !type.equals("global")) { + logger.log(Level.SEVERE, "The second parameter of the directive namespace should be local or global"); + return; + } if (type.equals("local")) { ns = addLocalNS(ns); } } + + oldNS.push(parser.getNS()); parser.setNS(ns); - //return ns; } @Override public void end(Pred directive, as2j parser) { - Atom ns = oldNS.pop(); - if (ns != null) - parser.setNS(ns); + if (!oldNS.isEmpty()) + parser.setNS(oldNS.pop()); } public boolean isLocalNS(Atom ns) { Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc =================================================================== --- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2016-02-24 19:59:41 UTC (rev 1873) @@ -261,19 +261,22 @@ ( LOOKAHEAD(4) <TK_BEGIN> dir = pred() "}" { Agent innerAg = new Agent(); innerAg.initAg(); - directiveProcessor.getInstance(dir).begin(dir,this); + dir = new Pred(namespace, dir); + Directive d = directiveProcessor.getInstance(dir); + d.begin(dir,this); } isEOF = agent(innerAg) { if (isEOF) throw new ParseException(getSourceRef(dir)+" The directive '{ begin "+dir+"}' does not end with '{ end }'."); - resultOfDirective = directiveProcessor.getInstance(dir).process(dir, outerAg, innerAg); - directiveProcessor.getInstance(dir).end(dir,this); + resultOfDirective = d.process(dir, outerAg, innerAg); + d.end(dir,this); } | dir = pred() "}" { if (dir.toString().equals("end")) return true; + dir = new Pred(namespace, dir); Directive d = directiveProcessor.getInstance(dir); d.begin(dir, this); // to declare the namespace as local resultOfDirective = d.process(dir, outerAg, null); @@ -640,21 +643,25 @@ | k=<TK_FALSE> { return Literal.LFalse; } ) { + if (ASSyntax.isKeyword(F)) + NS = Literal.DefaultNS; + NS = nsDirective.map(NS); + if (F.getFunctor().indexOf(".") >= 0) { if (F.hasAnnot()) throw new ParseException(getSourceRef(F)+" Internal actions cannot have annotations."); if (type == Literal.LNeg) throw new ParseException(getSourceRef(F)+" Internal actions cannot be negated."); try { - return new InternalActionLiteral(F, curAg); + if (F.getFunctor().equals(".include")) // .include needs a namespace (see its code) + return new InternalActionLiteral(NS, F, curAg); + else + return new InternalActionLiteral(F, curAg); } catch (Exception e) { if (getArithFunction(F) == null) // it is not a registered function logger.warning(getSourceRef(F)+" warning: The internal action class for '"+F+"' was not loaded! Error: "+e); } } - if (ASSyntax.isKeyword(F)) - NS = Literal.DefaultNS; - NS = nsDirective.map(NS); return new LiteralImpl(NS, type, F); } Modified: trunk/src/jason/asSyntax/parser/as2j.java =================================================================== --- trunk/src/jason/asSyntax/parser/as2j.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/parser/as2j.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -269,13 +269,15 @@ dir = pred(); jj_consume_token(31); Agent innerAg = new Agent(); innerAg.initAg(); - directiveProcessor.getInstance(dir).begin(dir,this); + dir = new Pred(namespace, dir); + Directive d = directiveProcessor.getInstance(dir); + d.begin(dir,this); isEOF = agent(innerAg); if (isEOF) {if (true) throw new ParseException(getSourceRef(dir)+" The directive '{ begin "+dir+"}' does not end with '{ end }'.");} - resultOfDirective = directiveProcessor.getInstance(dir).process(dir, outerAg, innerAg); - directiveProcessor.getInstance(dir).end(dir,this); + resultOfDirective = d.process(dir, outerAg, innerAg); + d.end(dir,this); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TK_BEGIN: @@ -285,6 +287,7 @@ jj_consume_token(31); if (dir.toString().equals("end")) {if (true) return true;} + dir = new Pred(namespace, dir); Directive d = directiveProcessor.getInstance(dir); d.begin(dir, this); // to declare the namespace as local resultOfDirective = d.process(dir, outerAg, null); @@ -971,21 +974,25 @@ jj_consume_token(-1); throw new ParseException(); } + if (ASSyntax.isKeyword(F)) + NS = Literal.DefaultNS; + NS = nsDirective.map(NS); + if (F.getFunctor().indexOf(".") >= 0) { if (F.hasAnnot()) {if (true) throw new ParseException(getSourceRef(F)+" Internal actions cannot have annotations.");} if (type == Literal.LNeg) {if (true) throw new ParseException(getSourceRef(F)+" Internal actions cannot be negated.");} try { - {if (true) return new InternalActionLiteral(F, curAg);} + if (F.getFunctor().equals(".include")) // .include needs a namespace (see its code) + {if (true) return new InternalActionLiteral(NS, F, curAg);} + else + {if (true) return new InternalActionLiteral(F, curAg);} } catch (Exception e) { if (getArithFunction(F) == null) // it is not a registered function logger.warning(getSourceRef(F)+" warning: The internal action class for '"+F+"' was not loaded! Error: "+e); } } - if (ASSyntax.isKeyword(F)) - NS = Literal.DefaultNS; - NS = nsDirective.map(NS); {if (true) return new LiteralImpl(NS, type, F);} throw new Error("Missing return statement in function"); @@ -1643,22 +1650,6 @@ finally { jj_save(3, xla); } } - final private boolean jj_3R_115() { - if (jj_3R_122()) return true; - return false; - } - - final private boolean jj_3R_60() { - if (jj_scan_token(TK_NOT)) return true; - if (jj_3R_52()) return true; - return false; - } - - final private boolean jj_3R_114() { - if (jj_3R_121()) return true; - return false; - } - final private boolean jj_3R_108() { Token xsp; xsp = jj_scanpos; @@ -1684,19 +1675,23 @@ return false; } - final private boolean jj_3R_52() { + final private boolean jj_3R_53() { + if (jj_scan_token(52)) return true; + if (jj_3R_38()) return true; + return false; + } + + final private boolean jj_3R_38() { + if (jj_3R_52()) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_60()) { - jj_scanpos = xsp; - if (jj_3R_61()) return true; - } + if (jj_3R_53()) jj_scanpos = xsp; return false; } - final private boolean jj_3R_53() { - if (jj_scan_token(52)) return true; - if (jj_3R_38()) return true; + final private boolean jj_3R_39() { + if (jj_scan_token(50)) return true; + if (jj_3R_20()) return true; return false; } @@ -1712,14 +1707,6 @@ return false; } - final private boolean jj_3R_38() { - if (jj_3R_52()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_53()) jj_scanpos = xsp; - return false; - } - final private boolean jj_3R_47() { if (jj_scan_token(34)) return true; return false; @@ -1745,9 +1732,11 @@ return false; } - final private boolean jj_3R_39() { - if (jj_scan_token(50)) return true; - if (jj_3R_20()) return true; + final private boolean jj_3R_20() { + if (jj_3R_38()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_39()) jj_scanpos = xsp; return false; } @@ -1783,14 +1772,6 @@ return false; } - final private boolean jj_3R_20() { - if (jj_3R_38()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_39()) jj_scanpos = xsp; - return false; - } - final private boolean jj_3R_29() { if (jj_scan_token(37)) return true; return false; @@ -1912,11 +1893,6 @@ return false; } - final private boolean jj_3R_59() { - if (jj_scan_token(TK_LABEL_AT)) return true; - return false; - } - final private boolean jj_3R_75() { if (jj_scan_token(48)) return true; if (jj_3R_65()) return true; @@ -1928,16 +1904,13 @@ return false; } - final private boolean jj_3R_46() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_59()) jj_scanpos = xsp; - if (jj_3R_16()) return true; + final private boolean jj_3R_54() { + if (jj_scan_token(VAR)) return true; return false; } - final private boolean jj_3R_54() { - if (jj_scan_token(VAR)) return true; + final private boolean jj_3R_59() { + if (jj_scan_token(TK_LABEL_AT)) return true; return false; } @@ -1965,6 +1938,14 @@ return false; } + final private boolean jj_3R_46() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_59()) jj_scanpos = xsp; + if (jj_3R_16()) return true; + return false; + } + final private boolean jj_3R_42() { if (jj_scan_token(49)) return true; Token xsp; @@ -2007,24 +1988,19 @@ return false; } - final private boolean jj_3R_45() { - if (jj_scan_token(34)) return true; - return false; - } - final private boolean jj_3R_79() { if (jj_scan_token(48)) return true; if (jj_3R_57()) return true; return false; } - final private boolean jj_3R_113() { - if (jj_3R_120()) return true; + final private boolean jj_3R_45() { + if (jj_scan_token(34)) return true; return false; } - final private boolean jj_3R_128() { - if (jj_3R_20()) return true; + final private boolean jj_3R_113() { + if (jj_3R_120()) return true; return false; } @@ -2045,6 +2021,17 @@ return false; } + final private boolean jj_3R_128() { + if (jj_3R_20()) return true; + return false; + } + + final private boolean jj_3R_111() { + if (jj_scan_token(37)) return true; + if (jj_3R_102()) return true; + return false; + } + final private boolean jj_3R_136() { if (jj_scan_token(37)) return true; return false; @@ -2060,14 +2047,13 @@ return false; } - final private boolean jj_3R_138() { - if (jj_scan_token(45)) return true; + final private boolean jj_3R_24() { + if (jj_3R_42()) return true; return false; } - final private boolean jj_3R_111() { - if (jj_scan_token(37)) return true; - if (jj_3R_102()) return true; + final private boolean jj_3R_138() { + if (jj_scan_token(45)) return true; return false; } @@ -2084,6 +2070,12 @@ return false; } + final private boolean jj_3R_110() { + if (jj_scan_token(38)) return true; + if (jj_3R_102()) return true; + return false; + } + final private boolean jj_3R_135() { Token xsp; xsp = jj_scanpos; @@ -2097,17 +2089,37 @@ return false; } - final private boolean jj_3R_24() { - if (jj_3R_42()) return true; + final private boolean jj_3R_109() { + if (jj_scan_token(NUMBER)) return true; return false; } - final private boolean jj_3R_110() { - if (jj_scan_token(38)) return true; - if (jj_3R_102()) return true; + final private boolean jj_3R_23() { + if (jj_scan_token(42)) return true; + if (jj_3R_41()) return true; + if (jj_scan_token(43)) return true; return false; } + final private boolean jj_3R_102() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_109()) { + jj_scanpos = xsp; + if (jj_3R_110()) { + jj_scanpos = xsp; + if (jj_3R_111()) { + jj_scanpos = xsp; + if (jj_3R_112()) { + jj_scanpos = xsp; + if (jj_3R_113()) return true; + } + } + } + } + return false; + } + final private boolean jj_3R_133() { if (jj_scan_token(37)) return true; Token xsp; @@ -2121,23 +2133,11 @@ return false; } - final private boolean jj_3R_109() { - if (jj_scan_token(NUMBER)) return true; - return false; - } - final private boolean jj_3R_44() { if (jj_3R_19()) return true; return false; } - final private boolean jj_3R_23() { - if (jj_scan_token(42)) return true; - if (jj_3R_41()) return true; - if (jj_scan_token(43)) return true; - return false; - } - final private boolean jj_3R_131() { if (jj_scan_token(44)) return true; return false; @@ -2167,25 +2167,6 @@ return false; } - final private boolean jj_3R_102() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_109()) { - jj_scanpos = xsp; - if (jj_3R_110()) { - jj_scanpos = xsp; - if (jj_3R_111()) { - jj_scanpos = xsp; - if (jj_3R_112()) { - jj_scanpos = xsp; - if (jj_3R_113()) return true; - } - } - } - } - return false; - } - final private boolean jj_3R_124() { Token xsp; xsp = jj_scanpos; @@ -2258,14 +2239,6 @@ return false; } - final private boolean jj_3_1() { - if (jj_scan_token(TK_BEGIN)) return true; - if (jj_3R_13()) return true; - if (jj_scan_token(31)) return true; - if (jj_3R_14()) return true; - return false; - } - final private boolean jj_3R_98() { Token xsp; xsp = jj_scanpos; @@ -2293,8 +2266,11 @@ return false; } - final private boolean jj_3R_43() { - if (jj_scan_token(30)) return true; + final private boolean jj_3_1() { + if (jj_scan_token(TK_BEGIN)) return true; + if (jj_3R_13()) return true; + if (jj_scan_token(31)) return true; + if (jj_3R_14()) return true; return false; } @@ -2313,11 +2289,26 @@ return false; } + final private boolean jj_3R_43() { + if (jj_scan_token(30)) return true; + return false; + } + final private boolean jj_3R_50() { if (jj_3R_13()) return true; return false; } + final private boolean jj_3R_100() { + if (jj_scan_token(38)) return true; + return false; + } + + final private boolean jj_3R_99() { + if (jj_scan_token(37)) return true; + return false; + } + final private boolean jj_3R_49() { if (jj_scan_token(TK_NEG)) return true; return false; @@ -2332,16 +2323,6 @@ return false; } - final private boolean jj_3R_100() { - if (jj_scan_token(38)) return true; - return false; - } - - final private boolean jj_3R_99() { - if (jj_scan_token(37)) return true; - return false; - } - final private boolean jj_3R_96() { Token xsp; xsp = jj_scanpos; @@ -2353,11 +2334,6 @@ return false; } - final private boolean jj_3R_22() { - if (jj_3R_40()) return true; - return false; - } - final private boolean jj_3R_77() { if (jj_3R_95()) return true; Token xsp; @@ -2368,11 +2344,21 @@ return false; } + final private boolean jj_3R_22() { + if (jj_3R_40()) return true; + return false; + } + final private boolean jj_3R_21() { if (jj_scan_token(ATOM)) return true; return false; } + final private boolean jj_3R_91() { + if (jj_3R_67()) return true; + return false; + } + final private boolean jj_3_4() { Token xsp; xsp = jj_scanpos; @@ -2384,11 +2370,6 @@ return false; } - final private boolean jj_3R_91() { - if (jj_3R_67()) return true; - return false; - } - final private boolean jj_3R_90() { if (jj_3R_42()) return true; return false; @@ -2399,6 +2380,11 @@ return false; } + final private boolean jj_3R_88() { + if (jj_3R_77()) return true; + return false; + } + final private boolean jj_3R_35() { Token xsp; xsp = jj_scanpos; @@ -2413,8 +2399,8 @@ return false; } - final private boolean jj_3R_88() { - if (jj_3R_77()) return true; + final private boolean jj_3R_87() { + if (jj_scan_token(58)) return true; return false; } @@ -2431,16 +2417,6 @@ return false; } - final private boolean jj_3R_87() { - if (jj_scan_token(58)) return true; - return false; - } - - final private boolean jj_3R_129() { - if (jj_scan_token(TK_ELSE)) return true; - return false; - } - final private boolean jj_3R_86() { if (jj_scan_token(57)) return true; return false; @@ -2451,14 +2427,6 @@ return false; } - final private boolean jj_3R_125() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_129()) jj_scanpos = xsp; - if (jj_3R_67()) return true; - return false; - } - final private boolean jj_3R_84() { if (jj_scan_token(55)) return true; return false; @@ -2469,6 +2437,11 @@ return false; } + final private boolean jj_3R_129() { + if (jj_scan_token(TK_ELSE)) return true; + return false; + } + final private boolean jj_3R_82() { if (jj_scan_token(46)) return true; return false; @@ -2479,6 +2452,14 @@ return false; } + final private boolean jj_3R_125() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_129()) jj_scanpos = xsp; + if (jj_3R_67()) return true; + return false; + } + final private boolean jj_3R_80() { if (jj_scan_token(45)) return true; return false; @@ -2523,6 +2504,16 @@ return false; } + final private boolean jj_3R_73() { + if (jj_3R_78()) return true; + return false; + } + + final private boolean jj_3R_72() { + if (jj_3R_77()) return true; + return false; + } + final private boolean jj_3R_121() { if (jj_scan_token(TK_IF)) return true; if (jj_scan_token(42)) return true; @@ -2540,21 +2531,6 @@ return false; } - final private boolean jj_3R_73() { - if (jj_3R_78()) return true; - return false; - } - - final private boolean jj_3R_72() { - if (jj_3R_77()) return true; - return false; - } - - final private boolean jj_3R_27() { - if (jj_3R_45()) return true; - return false; - } - final private boolean jj_3R_66() { Token xsp; xsp = jj_scanpos; @@ -2567,13 +2543,13 @@ return false; } - final private boolean jj_3R_26() { - if (jj_3R_44()) return true; + final private boolean jj_3R_27() { + if (jj_3R_45()) return true; return false; } - final private boolean jj_3R_25() { - if (jj_3R_43()) return true; + final private boolean jj_3R_26() { + if (jj_3R_44()) return true; return false; } @@ -2582,6 +2558,16 @@ return false; } + final private boolean jj_3R_118() { + if (jj_scan_token(41)) return true; + return false; + } + + final private boolean jj_3R_25() { + if (jj_3R_43()) return true; + return false; + } + final private boolean jj_3R_14() { Token xsp; while (true) { @@ -2604,18 +2590,19 @@ return false; } - final private boolean jj_3R_118() { - if (jj_scan_token(41)) return true; + final private boolean jj_3R_61() { + if (jj_3R_66()) return true; return false; } - final private boolean jj_3R_117() { - if (jj_3R_124()) return true; + final private boolean jj_3R_60() { + if (jj_scan_token(TK_NOT)) return true; + if (jj_3R_52()) return true; return false; } - final private boolean jj_3R_61() { - if (jj_3R_66()) return true; + final private boolean jj_3R_117() { + if (jj_3R_124()) return true; return false; } @@ -2624,6 +2611,26 @@ return false; } + final private boolean jj_3R_52() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_60()) { + jj_scanpos = xsp; + if (jj_3R_61()) return true; + } + return false; + } + + final private boolean jj_3R_115() { + if (jj_3R_122()) return true; + return false; + } + + final private boolean jj_3R_114() { + if (jj_3R_121()) return true; + return false; + } + public as2jTokenManager token_source; SimpleCharStream jj_input_stream; public Token token, jj_nt; Modified: trunk/src/jason/asSyntax/patterns/goal/BC.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/BC.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/patterns/goal/BC.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -20,6 +20,7 @@ static Logger logger = Logger.getLogger(BC.class.getName()); + @Override public Agent process(Pred directive, Agent outerContent, Agent innerContent) { try { Term goal = directive.getTerm(0); Modified: trunk/src/jason/asSyntax/patterns/goal/BDG.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/BDG.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/patterns/goal/BDG.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -17,6 +17,7 @@ static Logger logger = Logger.getLogger(BDG.class.getName()); + @Override public Agent process(Pred directive, Agent outerContent, Agent innerContent) { try { // apply DG in the inner plans Modified: trunk/src/jason/asSyntax/patterns/goal/DG.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/DG.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/patterns/goal/DG.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -3,12 +3,12 @@ import jason.asSemantics.Agent; import jason.asSemantics.Unifier; import jason.asSyntax.ASSyntax; +import jason.asSyntax.Literal; +import jason.asSyntax.Plan; import jason.asSyntax.PlanBody; +import jason.asSyntax.PlanBody.BodyType; import jason.asSyntax.PlanBodyImpl; -import jason.asSyntax.Literal; -import jason.asSyntax.Plan; import jason.asSyntax.Pred; -import jason.asSyntax.PlanBody.BodyType; import jason.asSyntax.directives.DefaultDirective; import jason.asSyntax.directives.Directive; @@ -24,6 +24,7 @@ static Logger logger = Logger.getLogger(DG.class.getName()); + @Override public Agent process(Pred directive, Agent outerContent, Agent innerContent) { try { Agent newAg = new Agent(); Modified: trunk/src/jason/asSyntax/patterns/goal/EBDG.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/EBDG.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/patterns/goal/EBDG.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -5,13 +5,13 @@ import jason.asSyntax.ASSyntax; import jason.asSyntax.Literal; import jason.asSyntax.LogExpr; +import jason.asSyntax.LogExpr.LogicalOp; import jason.asSyntax.LogicalFormula; import jason.asSyntax.Plan; import jason.asSyntax.PlanBody; +import jason.asSyntax.PlanBody.BodyType; import jason.asSyntax.PlanBodyImpl; import jason.asSyntax.Pred; -import jason.asSyntax.LogExpr.LogicalOp; -import jason.asSyntax.PlanBody.BodyType; import jason.asSyntax.directives.DefaultDirective; import jason.asSyntax.directives.Directive; @@ -27,6 +27,7 @@ static Logger logger = Logger.getLogger(EBDG.class.getName()); + @Override public Agent process(Pred directive, Agent outerContent, Agent innerContent) { try { Agent newAg = new Agent(); Modified: trunk/src/jason/asSyntax/patterns/goal/MG.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/MG.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/patterns/goal/MG.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -21,6 +21,7 @@ static Logger logger = Logger.getLogger(MG.class.getName()); + @Override public Agent process(Pred directive, Agent outerContent, Agent innerContent) { try { Literal goal = Literal.parseLiteral(directive.getTerm(0).toString()); Modified: trunk/src/jason/asSyntax/patterns/goal/OMC.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/OMC.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/patterns/goal/OMC.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -22,6 +22,7 @@ static Logger logger = Logger.getLogger(OMC.class.getName()); + @Override public Agent process(Pred directive, Agent outerContent, Agent innerContent) { try { Term goal = directive.getTerm(0); Modified: trunk/src/jason/asSyntax/patterns/goal/RC.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/RC.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/patterns/goal/RC.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -20,6 +20,7 @@ static Logger logger = Logger.getLogger(RC.class.getName()); + @Override public Agent process(Pred directive, Agent outerContent, Agent innerContent) { try { Term goal = directive.getTerm(0); Modified: trunk/src/jason/asSyntax/patterns/goal/SGA.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/SGA.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/patterns/goal/SGA.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -23,6 +23,7 @@ static Logger logger = Logger.getLogger(SGA.class.getName()); + @Override public Agent process(Pred directive, Agent outerContent, Agent innerContent) { try { Trigger trigger = ASSyntax.parseTrigger(((StringTerm)directive.getTerm(0)).getString()); Modified: trunk/src/jason/asSyntax/patterns/goal/SMC.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/SMC.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/asSyntax/patterns/goal/SMC.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -20,6 +20,7 @@ static Logger logger = Logger.getLogger(SMC.class.getName()); + @Override public Agent process(Pred directive, Agent outerContent, Agent innerContent) { try { Term goal = directive.getTerm(0); Modified: trunk/src/jason/mas2j/MAS2JProject.java =================================================================== --- trunk/src/jason/mas2j/MAS2JProject.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/mas2j/MAS2JProject.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -24,7 +24,6 @@ package jason.mas2j; import jason.JasonException; -import jason.asSyntax.directives.Directive; import jason.asSyntax.directives.DirectiveProcessor; import jason.infra.InfrastructureFactory; import jason.jeditplugin.Config; @@ -224,7 +223,7 @@ if (directiveClasses != null) { for (String id: directiveClasses.keySet()) { try { - DirectiveProcessor.addDirective(id, (Directive)Class.forName(directiveClasses.get(id)).newInstance()); + DirectiveProcessor.registerDirective(id, Class.forName(directiveClasses.get(id))); } catch (Exception e) { logger.log(Level.SEVERE, "Error registering directives "+directiveClasses,e); } Modified: trunk/src/jason/stdlib/include.java =================================================================== --- trunk/src/jason/stdlib/include.java 2016-02-24 15:55:05 UTC (rev 1872) +++ trunk/src/jason/stdlib/include.java 2016-02-24 19:59:41 UTC (rev 1873) @@ -28,6 +28,8 @@ import jason.asSemantics.DefaultInternalAction; import jason.asSemantics.TransitionSystem; import jason.asSemantics.Unifier; +import jason.asSyntax.Atom; +import jason.asSyntax.Literal; import jason.asSyntax.Pred; import jason.asSyntax.Term; import jason.asSyntax.directives.DirectiveProcessor; @@ -50,7 +52,7 @@ public class include extends DefaultInternalAction { @Override public int getMinArgs() { return 1; } - @Override public int getMaxArgs() { return 1; } + @Override public int getMaxArgs() { return 2; } @Override protected void checkArguments(Term[] args) throws JasonException { super.checkArguments(args); // check number of arguments @@ -58,12 +60,20 @@ throw JasonException.createWrongArgument(this,"first argument must be a string."); } + Atom ns = Literal.DefaultNS; + + @Override + public Term[] prepareArguments(Literal body, Unifier un) { + ns = body.getNS(); + return super.prepareArguments(body, un); + } + @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { checkArguments(args); Agent ag = ts.getAg(); - Pred inc = new Pred("include"); - inc.addTerm(args[0]); + Pred inc = new Pred(ns, "include"); + inc.addTerms(args); Agent result = ((Include)DirectiveProcessor.getDirective("include")).process( inc, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |