本文整理汇总了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());
}
}