
jason.stdlib.literal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jason Show documentation
Show all versions of jason Show documentation
Jason is a fully-fledged interpreter for an extended version of AgentSpeak, a BDI agent-oriented logic programming language.
package jason.stdlib;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.InternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.Term;
/**
Internal action: .literal
.
Description: checks whether the argument is a literal,
e.g.: "p", "p(1)", "p(1)[a,b]", "~p(1)[a,b]".
Parameter:
- + argument (any term): the term to be checked.
Examples:
-
.literal(b(10))
: true.
-
.literal(b)
: true.
-
.literal(10)
: false.
-
.literal("Jason")
: false.
-
.literal(X)
: false if X is free, true if X is bound to a literal.
-
.literal(a(X))
: true.
-
.literal([a,b,c])
: false.
-
.literal([a,b,c(X)])
: false.
@see jason.stdlib.atom
@see jason.stdlib.list
@see jason.stdlib.number
@see jason.stdlib.string
@see jason.stdlib.structure
@see jason.stdlib.ground
*/
public class literal extends DefaultInternalAction {
private static InternalAction singleton = null;
public static InternalAction create() {
if (singleton == null)
singleton = new literal();
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 {
checkArguments(args);
return args[0].isLiteral();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy