private static String parseId(final ATermReader reader) throws IOException { int c = reader.getLastChar(); final StringBuilder buf = new StringBuilder(32); do { buf.append((char) c); c = reader.read(); } while (Character.isLetterOrDigit(c) || c == '_' || c == '-' || c == '+' || c == '*' || c == '$'); return buf.toString(); }
@Override public ATerm readFromSharedTextFile(final InputStream stream) throws IOException { final ATermReader reader = new ATermReader(new BufferedReader(new InputStreamReader(stream))); reader.readSkippingWS(); if (reader.getLastChar() != '!') throw new IOException("not a openllet.shared.hash text file!"); reader.readSkippingWS(); return readFromSharedTextFile(reader); }
private ATerm[] parseATermsArray(final ATermReader reader) throws IOException { final List<ATerm> list = new ArrayList<>(); ATerm term = parseFromReader(reader); list.add(term); while (reader.getLastChar() == ',') { reader.readSkippingWS(); term = parseFromReader(reader); list.add(term); } final ATerm[] array = new ATerm[list.size()]; final ListIterator<ATerm> iter = list.listIterator(); int index = 0; while (iter.hasNext()) array[index++] = iter.next(); return array; }
final int lastChar = reader.getLastChar(); if (lastChar == -1) throw new ParseError("Unterminated quoted function symbol: " + str); break; default: str.append('\\').append((char) reader.getLastChar()); } while (escaped || reader.getLastChar() != '"');
str.append((char) reader.getLastChar()); while (Character.isDigit(reader.read())); if (reader.getLastChar() != '.' && reader.getLastChar() != 'e' && reader.getLastChar() != 'E' && reader.getLastChar() != 'l' && reader.getLastChar() != 'L') if (reader.getLastChar() == 'l' || reader.getLastChar() == 'L') if (reader.getLastChar() == '.') if (!Character.isDigit(reader.getLastChar())) throw new ParseError("digit expected"); do str.append((char) reader.getLastChar()); while (Character.isDigit(reader.read())); if (reader.getLastChar() == 'e' || reader.getLastChar() == 'E') str.append((char) reader.getLastChar()); reader.read(); if (reader.getLastChar() == '-' || reader.getLastChar() == '+') str.append((char) reader.getLastChar()); reader.read(); if (!Character.isDigit(reader.getLastChar())) throw new ParseError("digit expected!"); do str.append((char) reader.getLastChar()); while (Character.isDigit(reader.read()));
switch (reader.getLastChar()) if (reader.getLastChar() != ']') throw new ParseError("expected ']' but got '" + (char) reader.getLastChar() + "'"); c = reader.readSkippingWS(); if (reader.getLastChar() != '>') throw new ParseError("expected '>' but got '" + (char) reader.getLastChar() + "'"); if (reader.getLastChar() == '(') if (reader.getLastChar() == ')') result = makeAppl(makeAFun(funname, 0, true)); else if (reader.getLastChar() != ')') throw new ParseError("_expected ')' but got '" + reader.getLastChar() + "'"); result = makeAppl(makeAFun(funname, list.length, true), list); if (c == -1) throw new ParseError("premature EOF encountered."); if (reader.getLastChar() == ')') result = makeAppl(makeAFun("", 0, false)); else if (reader.getLastChar() != ')') throw new ParseError("_expected ')' but got '" + (char) reader.getLastChar() + "'"); result = makeAppl(makeAFun("", list.length, false), list);