Code example for StreamTokenizer

Methods: lineno, pushBack

0
        return result;
    } 
 
    private void parseListStart(int tt) throws ParseException {
        if (tt != '(') {
            tokenizer.pushBack();
            fail("'(' expected"); 
        } 
    } 
 
    private boolean parseListEnd() throws IOException, 
                                          ParseException { 
        int tt = tokenizer.nextToken();
        if (tt == ')') {
            return true; 
        } else if (tt != ',') {
            tokenizer.pushBack();
            fail("',' or ')' expected"); 
        } 
        return false; 
    } 
 
    private void initTokenizer(String wkt) {
        StringReader r = new StringReader(wkt);
        tokenizer = new StreamTokenizer(r);
        tokenizer.resetSyntax();
        tokenizer.parseNumbers();
        tokenizer.whitespaceChars(0, 32);
        tokenizer.eolIsSignificant(false);
        tokenizer.wordChars('a', 'z');
        tokenizer.wordChars('A', 'Z');
        tokenizer.wordChars('_', '_');
        tokenizer.quoteChar('"');
    } 
 
    private void disposeTokenizer() { 
        tokenizer = null;
    } 
 
    private void fail(String message) throws ParseException {
        throw new ParseException(message, tokenizer.lineno());
    } 
}