本文整理匯總了Java中java.io.StreamTokenizer.pushBack方法的典型用法代碼示例。如果您正苦於以下問題:Java StreamTokenizer.pushBack方法的具體用法?Java StreamTokenizer.pushBack怎麽用?Java StreamTokenizer.pushBack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.StreamTokenizer
的用法示例。
在下文中一共展示了StreamTokenizer.pushBack方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: skipBackSlash
import java.io.StreamTokenizer; //導入方法依賴的package包/類
/**
* Skips the back slash in the next token if it's followed by a new line.
*/
private static void skipBackSlash(StreamTokenizer tokenizer) throws IOException
{
tokenizer.ordinaryChar('\\');
if (tokenizer.nextToken() == '\\')
{
if (tokenizer.nextToken() != StreamTokenizer.TT_EOL)
{
throw new IncorrectFormatException("Expected new line after \\ character");
}
}
else
{
tokenizer.pushBack();
}
tokenizer.wordChars('\\', '\\');
}
示例2: waitForEOL
import java.io.StreamTokenizer; //導入方法依賴的package包/類
/** Skips all tokens before next end of line (EOL). */
public static void waitForEOL(StreamTokenizer tokenizer) throws IOException {
// skip everything until EOL
while (tokenizer.nextToken() != StreamTokenizer.TT_EOL) {
}
;
tokenizer.pushBack();
}
示例3: readTillEOL
import java.io.StreamTokenizer; //導入方法依賴的package包/類
/**
* Reads and skips all tokens before next end of line token.
*
* @throws IOException in case something goes wrong
*/
private void readTillEOL(StreamTokenizer tokenizer) throws IOException {
while (tokenizer.nextToken() != StreamTokenizer.TT_EOL) {
}
tokenizer.pushBack();
}
示例4: parseBuiltInPredicate
import java.io.StreamTokenizer; //導入方法依賴的package包/類
private static Expr parseBuiltInPredicate(String lhs, StreamTokenizer scan) throws DatalogException {
try {
String operator;
scan.nextToken();
if(scan.ttype == StreamTokenizer.TT_WORD) {
// At some point I was going to have "eq" and "ne" for string comparisons, but it wasn't a good idea.
operator = scan.sval;
} else {
operator = Character.toString((char)scan.ttype);
scan.nextToken();
if(scan.ttype == '=' || scan.ttype == '>') {
operator = operator + Character.toString((char)scan.ttype);
} else {
scan.pushBack();
}
}
if(!validOperators.contains(operator)) {
throw new DatalogException("Invalid operator '" + operator + "'");
}
String rhs = null;
scan.nextToken();
if(scan.ttype == StreamTokenizer.TT_WORD) {
rhs = scan.sval;
} else if(scan.ttype == '"' || scan.ttype == '\'') {
rhs = scan.sval;
} else if(scan.ttype == StreamTokenizer.TT_NUMBER) {
rhs = numberToString(scan.nval);
} else {
throw new DatalogException("[line " + scan.lineno() + "] Right hand side of expression expected");
}
return new Expr(operator, lhs, rhs);
} catch (IOException e) {
throw new DatalogException(e);
}
}
示例5: executeAll
import java.io.StreamTokenizer; //導入方法依賴的package包/類
/**
* Executes all the statements in a file/string or another object wrapped by a {@link java.io.Reader}.
* <p>
* An optional {@link QueryOutput} object can be supplied as a parameter to output the results of multiple queries.
* </p><p>
* This is how to interpret the returned {@code Collection<Map<String, String>>}, assuming you store it in a variable
* called {@code answers}:
* </p>
* <ul>
* <li> If {@code answers} is {@code null}, the statement didn't produce any results; i.e. it was a fact or a rule, not a query.
* <li> If {@code answers} is empty, then it was a query that doesn't have any answers, so the output is "No."
* <li> If {@code answers} is a list of empty maps, then it was the type of query that only wanted a yes/no
* answer, like {@code siblings(alice,bob)?} and the answer is "Yes."
* <li> Otherwise {@code answers} is a list of all bindings that satisfy the query.
* </ul>
* @param reader The reader from which the statements are read.
* @param output The object through which output should be written. Can be {@code null} in which case no output will be written.
* @return The answer of the last statement in the file, as a Collection of variable mappings.
* @throws DatalogException on syntax and I/O errors encountered while executing.
* @see QueryOutput
*/
public Collection<Map<String, String>> executeAll(Reader reader, QueryOutput output) throws DatalogException {
try {
StreamTokenizer scan = getTokenizer(reader);
// Tracks the last query's answers
Collection<Map<String, String>> answers = null;
scan.nextToken();
while(scan.ttype != StreamTokenizer.TT_EOF) {
scan.pushBack();
answers = executeSingleStatement(scan, reader, output);
scan.nextToken();
}
return answers;
} catch (IOException e) {
throw new DatalogException(e);
}
}
示例6: nodeStmt
import java.io.StreamTokenizer; //導入方法依賴的package包/類
protected void nodeStmt(StreamTokenizer tk, final int nindex)
throws Exception {
tk.nextToken();
GraphNode temp = m_nodes.get(nindex);
if (tk.ttype == ']' || tk.ttype == StreamTokenizer.TT_EOF) {
return;
} else if (tk.ttype == StreamTokenizer.TT_WORD) {
if (tk.sval.equalsIgnoreCase("label")) {
tk.nextToken();
if (tk.ttype == '=') {
tk.nextToken();
if (tk.ttype == StreamTokenizer.TT_WORD || tk.ttype == '"') {
temp.lbl = tk.sval;
} else {
System.err.println("couldn't find label at line " + tk.lineno());
tk.pushBack();
}
} else {
System.err.println("couldn't find label at line " + tk.lineno());
tk.pushBack();
}
}
else if (tk.sval.equalsIgnoreCase("color")) {
tk.nextToken();
if (tk.ttype == '=') {
tk.nextToken();
if (tk.ttype == StreamTokenizer.TT_WORD || tk.ttype == '"') {
;
} else {
System.err.println("couldn't find color at line " + tk.lineno());
tk.pushBack();
}
} else {
System.err.println("couldn't find color at line " + tk.lineno());
tk.pushBack();
}
}
else if (tk.sval.equalsIgnoreCase("style")) {
tk.nextToken();
if (tk.ttype == '=') {
tk.nextToken();
if (tk.ttype == StreamTokenizer.TT_WORD || tk.ttype == '"') {
;
} else {
System.err.println("couldn't find style at line " + tk.lineno());
tk.pushBack();
}
} else {
System.err.println("couldn't find style at line " + tk.lineno());
tk.pushBack();
}
}
}
nodeStmt(tk, nindex);
}
示例7: edgeStmt
import java.io.StreamTokenizer; //導入方法依賴的package包/類
protected void edgeStmt(StreamTokenizer tk, final int nindex)
throws Exception {
tk.nextToken();
GraphEdge e = null;
if (tk.ttype == '>') {
tk.nextToken();
if (tk.ttype == '{') {
while (true) {
tk.nextToken();
if (tk.ttype == '}') {
break;
} else {
nodeID(tk);
e = new GraphEdge(nindex, m_nodes.indexOf(new GraphNode(tk.sval,
null)), DIRECTED);
if (m_edges != null && !(m_edges.contains(e))) {
m_edges.add(e);
// System.out.println("Added edge from "+
// ((GraphNode)(m_nodes.get(nindex))).ID+
// " to "+
// ((GraphNode)(m_nodes.get(e.dest))).ID);
}
}
}
} else {
nodeID(tk);
e = new GraphEdge(nindex,
m_nodes.indexOf(new GraphNode(tk.sval, null)), DIRECTED);
if (m_edges != null && !(m_edges.contains(e))) {
m_edges.add(e);
// System.out.println("Added edge from "+
// ((GraphNode)(m_nodes.get(nindex))).ID+" to "+
// ((GraphNode)(m_nodes.get(e.dest))).ID);
}
}
} else if (tk.ttype == '-') {
System.err.println("Error at line " + tk.lineno()
+ ". Cannot deal with undirected edges");
if (tk.ttype == StreamTokenizer.TT_WORD) {
tk.pushBack();
}
return;
} else {
System.err.println("Error at line " + tk.lineno() + " in edgeStmt");
if (tk.ttype == StreamTokenizer.TT_WORD) {
tk.pushBack();
}
return;
}
tk.nextToken();
if (tk.ttype == '[') {
edgeAttrib(tk, e);
} else {
tk.pushBack();
}
}
示例8: edgeAttrib
import java.io.StreamTokenizer; //導入方法依賴的package包/類
protected void edgeAttrib(StreamTokenizer tk, final GraphEdge e)
throws Exception {
tk.nextToken();
if (tk.ttype == ']' || tk.ttype == StreamTokenizer.TT_EOF) {
return;
} else if (tk.ttype == StreamTokenizer.TT_WORD) {
if (tk.sval.equalsIgnoreCase("label")) {
tk.nextToken();
if (tk.ttype == '=') {
tk.nextToken();
if (tk.ttype == StreamTokenizer.TT_WORD || tk.ttype == '"') {
System.err.println("found label " + tk.sval);// e.lbl = tk.sval;
} else {
System.err.println("couldn't find label at line " + tk.lineno());
tk.pushBack();
}
} else {
System.err.println("couldn't find label at line " + tk.lineno());
tk.pushBack();
}
} else if (tk.sval.equalsIgnoreCase("color")) {
tk.nextToken();
if (tk.ttype == '=') {
tk.nextToken();
if (tk.ttype == StreamTokenizer.TT_WORD || tk.ttype == '"') {
;
} else {
System.err.println("couldn't find color at line " + tk.lineno());
tk.pushBack();
}
} else {
System.err.println("couldn't find color at line " + tk.lineno());
tk.pushBack();
}
}
else if (tk.sval.equalsIgnoreCase("style")) {
tk.nextToken();
if (tk.ttype == '=') {
tk.nextToken();
if (tk.ttype == StreamTokenizer.TT_WORD || tk.ttype == '"') {
;
} else {
System.err.println("couldn't find style at line " + tk.lineno());
tk.pushBack();
}
} else {
System.err.println("couldn't find style at line " + tk.lineno());
tk.pushBack();
}
}
}
edgeAttrib(tk, e);
}