當前位置: 首頁>>代碼示例>>Java>>正文


Java StreamTokenizer.TT_EOL屬性代碼示例

本文整理匯總了Java中java.io.StreamTokenizer.TT_EOL屬性的典型用法代碼示例。如果您正苦於以下問題:Java StreamTokenizer.TT_EOL屬性的具體用法?Java StreamTokenizer.TT_EOL怎麽用?Java StreamTokenizer.TT_EOL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.io.StreamTokenizer的用法示例。


在下文中一共展示了StreamTokenizer.TT_EOL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseBenchArgs

String[] parseBenchArgs(StreamTokenizer tokens)
    throws IOException, ConfigFormatException
{
    Vector vec = new Vector();
    for (;;) {
        switch (tokens.ttype) {
            case StreamTokenizer.TT_EOF:
            case StreamTokenizer.TT_EOL:
                return (String[]) vec.toArray(new String[vec.size()]);

            case StreamTokenizer.TT_WORD:
            case '"':
                vec.add(tokens.sval);
                tokens.nextToken();
                break;

            default:
                throw new ConfigFormatException("unrecognized arg token " +
                        "on line " + tokens.lineno());
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:Harness.java

示例2: next

Token next() throws IOException {
  int type = tok.nextToken();
  switch (type) {
    case StreamTokenizer.TT_EOF:
    case StreamTokenizer.TT_EOL:
      return null;
    case StreamTokenizer.TT_NUMBER:
      return new NumToken(tok.nval);
    case StreamTokenizer.TT_WORD:
      return new StrToken(TType.IDENT, tok.sval);
    case '"':
      return new StrToken(TType.QUOT, tok.sval);
    default:
      switch (type) {
        case ',':
          return new Token(TType.COMMA);
        case '(':
          return new Token(TType.LPAREN);
        case ')':
          return new Token(TType.RPAREN);
        default:
          throw new IOException("Unexpected: " + type);
      }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:Parser.java

示例3: toMessage

public String toMessage() {
    switch(ttype) {
    case StreamTokenizer.TT_EOL:
        return "\"EOL\"";
    case StreamTokenizer.TT_EOF:
        return "\"EOF\"";
    case StreamTokenizer.TT_NUMBER:
        return "NUMBER";
    case StreamTokenizer.TT_WORD:
        if (sval == null) {
            return "IDENTIFIER";
        } else {
            return "IDENTIFIER " + sval;
        }
    default:
        if (ttype == (int)'"') {
            String msg = "QUOTED STRING";
            if (sval != null)
                msg = msg + " \"" + sval + "\"";
            return msg;
        } else {
            return "CHARACTER \'" + (char)ttype + "\'";
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:Token.java

示例4: parse

@Override
public ParserState parse(StreamTokenizer st) throws IOException, ParseException
{
    ParserState nextState = null;
    while (nextState == null && st.ttype != StreamTokenizer.TT_EOF)
    {
        int nextToken = st.nextToken();
        if (nextToken != StreamTokenizer.TT_EOL && nextToken != StreamTokenizer.TT_EOF)
        {
            if (nextValueIs(ExpectedResultsParser.SECTION_IDENTIFIER, st, nextToken))
            {
                nextState = this.getParser().getSectionReaderState();
            }
            else if (nextValueIs(ExpectedResultsParser.METADATA_IDENTIFIER, st, nextToken))
            {
                nextState = this.getParser().getMetadataReaderState();
            }
            else
            {
                nextState = this.getParser().getDataReaderState();
            }
        }
    }
    return nextState;
}
 
開發者ID:goldmansachs,項目名稱:tablasco,代碼行數:25,代碼來源:BeginningOfLineState.java

示例5: parse

public ParserState parse(StreamTokenizer st) throws IOException
{
    ParserState nextState = null;
    while(nextState == null && st.ttype != StreamTokenizer.TT_EOF)
    {
        int nextToken = st.nextToken();
        if (nextToken != StreamTokenizer.TT_EOL && nextToken != StreamTokenizer.TT_EOF)
        {
            if (nextToken == StreamTokenizer.TT_WORD && st.sval.equals(AbstractMithraDataFileParser.CLASS_IDENTIFIER))
            {
                nextState = this.getParser().getClassReaderState();
            }
            else
            {
                nextState = this.getParser().getDataReaderState();
            }
        }
    }
    return nextState;
}
 
開發者ID:goldmansachs,項目名稱:reladomo,代碼行數:20,代碼來源:BeginningOfLineState.java

示例6: test

private static void test(StreamTokenizer st) throws Exception {
    st.eolIsSignificant(true);
    int tt = st.nextToken();
    if (tt != StreamTokenizer.TT_WORD) fail("expected TT_WORD");
    if (!st.sval.equals("foo")) fail("expected word token \"foo\"");
    tt = st.nextToken();
    if (tt != StreamTokenizer.TT_EOL) fail("expected TT_EOL");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:ReadAhead.java

示例7: getNextToken

/** Delivers the next token and checks for an unexpected end of line or file. */
public static void getNextToken(StreamTokenizer tokenizer) throws IOException {
	if (tokenizer.nextToken() == StreamTokenizer.TT_EOL) {
		throw new IOException("unexpected end of line " + tokenizer.lineno());
	}

	if (tokenizer.ttype == StreamTokenizer.TT_EOF) {
		throw new IOException("unexpected end of file in line " + tokenizer.lineno());
	} else if (tokenizer.ttype == '\'' || tokenizer.ttype == '"') {
		tokenizer.ttype = StreamTokenizer.TT_WORD;
	} else if (tokenizer.ttype == StreamTokenizer.TT_WORD && tokenizer.sval.equals("?")) {
		tokenizer.ttype = '?';
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:14,代碼來源:Tools.java

示例8: waitForEOL

/** 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();
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:8,代碼來源:Tools.java

示例9: getFirstToken

/**
 * Gets next token, skipping empty lines.
 *
 * @throws IOException if reading the next token fails
 */
private void getFirstToken(StreamTokenizer tokenizer) throws IOException {
    while (tokenizer.nextToken() == StreamTokenizer.TT_EOL) {
    }

    if ((tokenizer.ttype == '\'') || (tokenizer.ttype == '"')) {
        tokenizer.ttype = StreamTokenizer.TT_WORD;
    } else if ((tokenizer.ttype == StreamTokenizer.TT_WORD) && (tokenizer.sval.equals("?"))) {
        tokenizer.ttype = '?';
    }
}
 
開發者ID:takun2s,項目名稱:smile_1.5.0_java7,代碼行數:15,代碼來源:ArffParser.java

示例10: getNextToken

/**
 * Gets next token, checking for a premature and of line.
 *
 * @throws IllegalStateException if it finds a premature end of line
 */
private void getNextToken(StreamTokenizer tokenizer) throws IOException, ParseException {
    if (tokenizer.nextToken() == StreamTokenizer.TT_EOL) {
        throw new ParseException("premature end of line", tokenizer.lineno());
    }
    if (tokenizer.ttype == StreamTokenizer.TT_EOF) {
        throw new ParseException(PREMATURE_END_OF_FILE, tokenizer.lineno());
    } else if ((tokenizer.ttype == '\'') || (tokenizer.ttype == '"')) {
        tokenizer.ttype = StreamTokenizer.TT_WORD;
    } else if ((tokenizer.ttype == StreamTokenizer.TT_WORD) && (tokenizer.sval.equals("?"))) {
        tokenizer.ttype = '?';
    }
}
 
開發者ID:takun2s,項目名稱:smile_1.5.0_java7,代碼行數:17,代碼來源:ArffParser.java

示例11: parseBenchInfo

BenchInfo parseBenchInfo(StreamTokenizer tokens)
    throws IOException, ConfigFormatException
{
    float weight = parseBenchWeight(tokens);
    String name = parseBenchName(tokens);
    Benchmark bench = parseBenchClass(tokens);
    String[] args = parseBenchArgs(tokens);
    if (tokens.ttype == StreamTokenizer.TT_EOL)
        tokens.nextToken();
    return new BenchInfo(bench, name, weight, args);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:Harness.java

示例12: parse

@Override
public ParserState parse(StreamTokenizer st) throws IOException, ParseException
{
    int token = st.ttype;
    if (token != StreamTokenizer.TT_WORD || !st.sval.equals(ExpectedResultsParser.SECTION_IDENTIFIER))
    {
        throw new ParseException("expected line " + st.lineno() + " to begin with Section", st.lineno());
    }
    token = st.nextToken();
    if (token != StreamTokenizer.TT_WORD && token != '"')
    {
        throw new ParseException("expected a section name on line " + st.lineno(), st.lineno());
    }
    String testName = st.sval;

    token = st.nextToken();
    String tableName = null;
    if (token == StreamTokenizer.TT_WORD || token == '"')
    {
        tableName = st.sval;
        token = st.nextToken();
    }

    this.getParser().startNewSection(testName, tableName);

    if (token != StreamTokenizer.TT_EOL)
    {
        throw new ParseException("invalid data after the class name on line " + st.lineno(), st.lineno());
    }

    return this.getParser().getHeaderState();
}
 
開發者ID:goldmansachs,項目名稱:tablasco,代碼行數:32,代碼來源:SectionReaderState.java

示例13: toString

public String toString() {
    StringBuilder sb = new StringBuilder();
    switch(ttype) {
    case StreamTokenizer.TT_EOL:
        sb.append("ttype=TT_EOL");
        break;
    case StreamTokenizer.TT_EOF:
        sb.append("ttype=TT_EOF");
        break;
    case StreamTokenizer.TT_NUMBER:
        sb.append("ttype=TT_NUM,").append("nval="+nval);
        break;
    case StreamTokenizer.TT_WORD:
        if (sval == null) {
            sb.append("ttype=TT_WORD:IDENTIFIER");
        } else {
            sb.append("ttype=TT_WORD:").append("sval="+sval);
        }
        break;
    default:
        if (ttype == (int)'"') {
            sb.append("ttype=TT_STRING:").append("sval="+sval);
        } else {
            sb.append("ttype=TT_CHAR:").append((char)ttype);
        }
        break;
    }
    return sb.toString();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:29,代碼來源:Token.java

示例14: parseAttributes

private void parseAttributes(StreamTokenizer st) throws IOException, ParseException
{
    int token = st.nextToken();
    boolean wantAttribute = true;
    while (token != StreamTokenizer.TT_EOL)
    {
        if (wantAttribute)
        {
            if (token != StreamTokenizer.TT_WORD && token != QUOTE_TOKEN)
            {
                throw new ParseException("expected an column name on line " + st.lineno(), st.lineno());
            }
            this.getParser().getExpectedTable().addColumnHeader(st.sval);
        }
        else
        {
            if (token != ',')
            {
                throw new ParseException("Expected a comma on line " + st.lineno(), st.lineno());
            }
        }
        wantAttribute = !wantAttribute;
        token = st.nextToken();
    }
    if (wantAttribute)
    {
        throw new ParseException("extra comma at the end of line " + st.lineno(), st.lineno());
    }
}
 
開發者ID:goldmansachs,項目名稱:tablasco,代碼行數:29,代碼來源:HeaderParserState.java

示例15: getToken

/**
 * Gets token.
 * 
 * @param tokenizer the stream tokenizer
 * @throws IOException if reading the next token fails
 */
public static void getToken(StreamTokenizer tokenizer) throws IOException {

  tokenizer.nextToken();
  if (tokenizer.ttype == StreamTokenizer.TT_EOL) {
    return;
  }

  if ((tokenizer.ttype == '\'') || (tokenizer.ttype == '"')) {
    tokenizer.ttype = StreamTokenizer.TT_WORD;
  } else if ((tokenizer.ttype == StreamTokenizer.TT_WORD)
      && (tokenizer.sval.equals("?"))) {
    tokenizer.ttype = '?';
  }
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:20,代碼來源:StreamTokenizerUtils.java


注:本文中的java.io.StreamTokenizer.TT_EOL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。