// Read from stream a "string". Skips the trailing close-quote private String str() { int q = skipWS().qget(); if (q != '"' && q != '\'') throw new ParseException("Expected one of ' or \" but found '" + (char) q + "'"); StringBuilder sb = new StringBuilder(); int b = get(); while (b != q) { sb.append((char) b); b = qget(); } return sb.toString(); }
// Read from stream a valid PMML token public String token() { int b = get(); if (!Character.isJavaIdentifierStart(b)) throw new ParseException("Expected token start but found '" + (char) b + "'"); StringBuilder sb = new StringBuilder(); sb.append((char) b); b = get(); while (Character.isJavaIdentifierPart(b) || b == ':') { sb.append((char) b); b = get(); } push(b); return sb.toString(); }
public PMMLParser barf(char tok, char c) { StringBuilder sb = new StringBuilder(); sb.append("Expected '").append(tok).append("' but found '").append(c).append("'"); int line = 0; for (int i = 0; i < 512; i++) { try { c = (char) get(); } catch (ParseException ioe) { break; } sb.append(c); if (c == '\n' && line++ > 2) break; } throw new ParseException(sb.toString()); }