本文整理匯總了Java中nars.language.SetInt類的典型用法代碼示例。如果您正苦於以下問題:Java SetInt類的具體用法?Java SetInt怎麽用?Java SetInt使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SetInt類屬於nars.language包,在下文中一共展示了SetInt類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseTerm
import nars.language.SetInt; //導入依賴的package包/類
/**
* Top-level method that parse a Term in general, which may recursively call
* itself.
* <p>
* There are 5 valid cases: 1. (Op, A1, ..., An) is a CompoundTerm if Op is
* a built-in operator 2. {A1, ..., An} is an SetExt; 3. [A1, ..., An] is an
* SetInt; 4. <T1 Re T2> is a Statement (including higher-order Statement);
* 5. otherwise it is a simple term.
*
* @param s0 the String to be parsed
* @param memory Reference to the memory
* @return the Term generated from the String
*/
public static Term parseTerm(String s0, Memory memory) throws InvalidInputException {
String s = s0.trim();
try {
if (s.length() == 0) {
throw new InvalidInputException("missing content");
}
Term t = memory.nameToListedTerm(s); // existing constant or operator
if (t != null) {
return t;
} // existing Term
int index = s.length() - 1;
char first = s.charAt(0);
char last = s.charAt(index);
switch (first) {
case COMPOUND_TERM_OPENER:
if (last == COMPOUND_TERM_CLOSER) {
return parseCompoundTerm(s.substring(1, index), memory);
} else {
throw new InvalidInputException("missing CompoundTerm closer");
}
case SET_EXT_OPENER:
if (last == SET_EXT_CLOSER) {
return SetExt.make(parseArguments(s.substring(1, index) + ARGUMENT_SEPARATOR, memory), memory);
} else {
throw new InvalidInputException("missing ExtensionSet closer");
}
case SET_INT_OPENER:
if (last == SET_INT_CLOSER) {
return SetInt.make(parseArguments(s.substring(1, index) + ARGUMENT_SEPARATOR, memory), memory);
} else {
throw new InvalidInputException("missing IntensionSet closer");
}
case STATEMENT_OPENER:
if (last == STATEMENT_CLOSER) {
return parseStatement(s.substring(1, index), memory);
} else {
throw new InvalidInputException("missing Statement closer");
}
default:
return parseAtomicTerm(s);
}
} catch (InvalidInputException e) {
throw new InvalidInputException(" !!! INVALID INPUT: parseTerm: " + s + " --- " + e.getMessage());
}
}