Package jason.asSyntax
Class ASSyntax
java.lang.Object
jason.asSyntax.ASSyntax
Factory for objects used in Jason AgentSpeak syntax.
Examples of Term:
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 slower)
Term n = parseTerm("5");
Term t = parseTerm("p(a)");
Term l = parseTerm("[a,b(5)]");
Examples of Literal:
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(Literal.LNeg, "p", createAtom("a"), createNumber(3))
.addAnnots(createAtom("s"), createString("s"));
// or use the parser (easier but slower)
Literal l4 = parseLiteral("~p(a,3)[s]");
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic AtomcreateAtom(String functor) creates a new Atom term (an atom is a structure with 0-arity)static ListTermcreateList(Term... terms) Creates a new list with n elements, n can be 0static ListTermcreateList(Collection<Term> terms) Creates a new list from a collection of terms (each element of the collection is cloned)static LiteralcreateLiteral(boolean positive, String functor, Term... 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.static LiteralcreateLiteral(Atom namespace, boolean positive, String functor, Term... terms) Creates a new literal, the first argument is the namespace, the second is either Literal.LPos or Literal.LNeg, the third is the functor (a string), and the n remainder arguments are terms.static LiteralcreateLiteral(Atom namespace, String functor, Term... terms) static LiteralcreateLiteral(String functor, Term... terms) Creates a new positive literal, the first argument is the functor (a string) and the n remainder arguments are terms.static NumberTermcreateNumber(double vl) creates a new number termstatic RulecreateRule(Literal head, LogicalFormula body) Creates a new rule with a head and a bodystatic StringTermcreates a new string term using .toString() of the parameterstatic StringTermcreates a new string termstatic StructurecreateStructure(String functor, Term... terms) Creates a new structure (compound) term, the first argument is the functor (a string), and the n remainder arguments are terms.static VarTermcreates a new anonymous (or unnamed) variablestatic VarTermcreates a new variable term (possibly negated)static VarTermcreates a new variable term in a namespacestatic VarTermcreates a new variable termstatic booleanstatic LogicalFormulaparseFormula(String sExpr) creates a new logical formula by parsing a stringstatic ListTermcreates a new list by parsing a stringstatic LiteralparseLiteral(String sLiteral) creates a new literal by parsing a stringstatic NumberTermparseNumber(String sNumber) creates a new number term by parsing a stringstatic Plancreates a new plan by parsing a stringstatic PlanBodyparsePlanBody(String sPlanBody) creates a new plan body by parsing a stringstatic Rulecreates a new rule by parsing a stringstatic StructureparseStructure(String sStructure) creates a new structure (a kind of term) by parsing a stringstatic Termcreates a new term by parsing a stringstatic TriggerparseTrigger(String sTe) creates a new trigger by parsing a stringstatic VarTermcreates a new variable by parsing a stringstatic ObjecttermToObject(Term t) Convert a Jason term into a Java Object
-
Field Details
-
hardDeadLineStr
- See Also:
-
-
Constructor Details
-
ASSyntax
public ASSyntax()
-
-
Method Details
-
addKeyword
-
isKeyword
-
createLiteral
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. -
createLiteral
-
createLiteral
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. -
createLiteral
public static Literal createLiteral(Atom namespace, boolean positive, String functor, Term... terms) Creates a new literal, the first argument is the namespace, the second is either Literal.LPos or Literal.LNeg, the third is the functor (a string), and the n remainder arguments are terms. see documentation of this class for examples of use. -
createStructure
Creates a new structure (compound) term, the first argument is the functor (a string), and the n remainder arguments are terms. -
createAtom
creates a new Atom term (an atom is a structure with 0-arity) -
createNumber
creates a new number term -
createString
creates a new string term -
createString
creates a new string term using .toString() of the parameter -
createVar
creates a new variable term -
createVar
creates a new variable term in a namespace -
createVar
creates a new variable term (possibly negated) -
createVar
creates a new anonymous (or unnamed) variable -
createList
Creates a new list with n elements, n can be 0 -
createList
Creates a new list from a collection of terms (each element of the collection is cloned) -
createRule
Creates a new rule with a head and a body -
parseLiteral
creates a new literal by parsing a string- Throws:
ParseExceptionTokenMgrError
-
parseNumber
creates a new number term by parsing a string- Throws:
NumberFormatException
-
parseStructure
creates a new structure (a kind of term) by parsing a string- Throws:
ParseExceptionTokenMgrError
-
parseVar
creates a new variable by parsing a string- Throws:
ParseExceptionTokenMgrError
-
parseTerm
creates a new term by parsing a string- Throws:
ParseExceptionTokenMgrError
-
parsePlan
creates a new plan by parsing a string- Throws:
ParseExceptionTokenMgrError
-
parsePlanBody
creates a new plan body by parsing a string- Throws:
ParseExceptionTokenMgrError
-
parseTrigger
creates a new trigger by parsing a string- Throws:
ParseExceptionTokenMgrError
-
parseList
creates a new list by parsing a string- Throws:
ParseExceptionTokenMgrError
-
parseFormula
creates a new logical formula by parsing a string- Throws:
ParseExceptionTokenMgrError
-
parseRule
creates a new rule by parsing a string- Throws:
ParseExceptionTokenMgrError
-
termToObject
Convert a Jason term into a Java Object- Parameters:
t- Jason term
-