Serializable, Parserpublic class Narsese extends Object implements Serializable, Parser
Parser.InvalidInputException| Modifier and Type | Method | Description |
|---|---|---|
private static String |
getBudgetString(StringBuilder s) |
Return the prefix of a task symbol that contains a BudgetValue
|
private static String |
getTruthString(StringBuilder s) |
Return the postfix of a task symbol that contains a TruthValue
|
private static boolean |
isCloser(String s,
int i) |
Check CompoundTerm closer symbol
|
private static boolean |
isOpener(String s,
int i) |
Check CompoundTerm opener symbol
|
private static int |
nextSeparator(String s,
int first) |
Locate the first top-level separator in a CompoundTerm
|
private List<Term> |
parseArguments(String s0) |
Parse a String into the argument get of a CompoundTerm.
|
private Term |
parseAtomicTerm(String s0) |
Parse a term that has no internal structure.
|
private BudgetValue |
parseBudget(String s,
char punctuation,
TruthValue truth) |
react the addInput String into a BudgetValue
|
private Term |
parseCompoundTerm(String s0) |
Parse a String to create a CompoundTerm.
|
private Statement |
parseStatement(String s0) |
Parse a string to create a statement.
|
Task |
parseTask(String s) |
Enter a new Task in String into the memory, called from InputWindow or
locally.
|
static Tense |
parseTense(StringBuilder s) |
Recognize the tense of an addInput sentence
|
Term |
parseTerm(String s) |
Top-level method that react a Term in general, which may recursively call itself.
|
private TruthValue |
parseTruth(String s,
char type) |
react the addInput String into a TruthValue (or DesireValue)
|
static boolean |
possiblyNarsese(String s) |
|
private static int |
topRelation(String s) |
locate the top-level getRelation in a statement
|
public final Memory memory
public Task parseTask(String s) throws Parser.InvalidInputException
parseTask in interface Parsers - the single-line addInput StringParser.InvalidInputExceptionprivate static String getBudgetString(StringBuilder s) throws Parser.InvalidInputException
s - the addInput in a StringBuilderParser.InvalidInputException - if the addInput cannot be parsed into a BudgetValueprivate static String getTruthString(StringBuilder s) throws Parser.InvalidInputException
s - the addInput in a StringBuilderParser.InvalidInputException - if the addInput cannot be parsed into a TruthValueprivate TruthValue parseTruth(String s, char type)
s - addInput Stringtype - Task typeprivate BudgetValue parseBudget(String s, char punctuation, TruthValue truth) throws Parser.InvalidInputException
truth - the TruthValue of the tasks - addInput Stringpunctuation - Task punctuationParser.InvalidInputException - If the String cannot be parsed into a BudgetValuepublic static Tense parseTense(StringBuilder s)
s - the addInput in a StringBuilderpublic Term parseTerm(String s) throws Parser.InvalidInputException
There are 5 valid cases: 1. (Op, A1, ..., An) is a CompoundTerm if Op is a built-in getOperator 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.
s - the String to be parsedParser.InvalidInputException - if the String couldn't get parsed to a termprivate Term parseAtomicTerm(String s0) throws Parser.InvalidInputException
The term can be a constant or a variable.
s0 - the String to be parsedParser.InvalidInputException - if the String couldn't get parsed to a termprivate Statement parseStatement(String s0) throws Parser.InvalidInputException
s0 - The addInput String to be parsedParser.InvalidInputException - if the String couldn't get parsed to a termprivate Term parseCompoundTerm(String s0) throws Parser.InvalidInputException
s0 - The String to be parsedParser.InvalidInputException - if the String couldn't get parsed to a termprivate List<Term> parseArguments(String s0) throws Parser.InvalidInputException
s0 - The String to be parsedParser.InvalidInputException - if the String couldn't get parsed to a termprivate static int nextSeparator(String s, int first)
s - The String to be parsedfirst - The starting indexprivate static int topRelation(String s)
s - The String to be parsedprivate static boolean isOpener(String s, int i)
s - The String to be checkedi - The starting indexprivate static boolean isCloser(String s, int i)
s - The String to be checkedi - The starting indexpublic static boolean possiblyNarsese(String s)
s - string to get checked if it may be narseseCopyright © 2020 OpenNARS. All rights reserved.