* Parses a list of statements from the ssi stream.
*/
private void parse(ReadStream is, ArrayList<Statement> statements)
throws IOException
{
ByteBuffer bb = new ByteBuffer();
int ch;
while ((ch = is.read()) >= 0) {
if (ch != '<') {
if (ch == '\n')
_line++;
bb.append(ch);
}
else if ((ch = is.read()) != '!') {
bb.append('<');
is.unread();
}
else if ((ch = is.read()) != '-') {
bb.append('<');
bb.append('!');
is.unread();
}
else if ((ch = is.read()) != '-') {
bb.append('<');
bb.append('!');
bb.append('-');
is.unread();
}
else if ((ch = is.read()) != '#') {
bb.append('<');
bb.append('!');
bb.append('-');
bb.append('-');
is.unread();
}
else {
if (bb.getLength() > 0) {
TextStatement text;
text = new TextStatement(bb.getBuffer(), 0, bb.getLength());
statements.add(text);
bb.clear();
}
Statement stmt = parseCommand(is);
statements.add(stmt);
if (stmt instanceof IfStatement) {
parseIf(is, (IfStatement) stmt);
}
if (stmt instanceof ElifStatement) {
return;
}
else if (stmt instanceof ElseStatement) {
return;
}
else if (stmt instanceof EndifStatement) {
return;
}
}
}
if (bb.getLength() > 0) {
statements.add(new TextStatement(bb.getBuffer(), 0, bb.getLength()));
bb.clear();
}
}