- ret.append(justify(line.toString(), indent, justificationLimit));
- return ret.toString();
- }
-
- private static class Root extends Block {
- public Root() { super(0, Integer.MIN_VALUE); }
- public Block close() { throw new InternalException("attempted to close top block"); }
- public String toString(int justificationLimit) { return toString(-2, justificationLimit); }
- }
-
- private static class Brace extends Block {
- public Brace(Block parent, int row, int col) { super(parent, row, col); }
- public Block closeBrace() { return super.close(); }
- }
-
- private static class Indent extends Block {
- public Indent(Block parent, int row, int col) { super(parent, row, col); }
- public Block closeIndent() { return super.close(); }
- }
-
- private static class Literal extends Block {
- private StringBuffer content = new StringBuffer();
- public final int braceCol;
- public Literal(Block parent, int row, int col, int braceCol) { super(parent,row,col); this.braceCol = braceCol; }
- public boolean isLiteral() { return true; }
- public int size() { return 1; }
- public Object child(int i) { return i==0 ? content.toString() : null; }
- public Block close() { return parent; }
- public Block closeIndent() { return close(); }
- public void add(String s) { if (content.length()>0) content.append('\n'); content.append(s); }
- public String text() { return content.toString(); }
- protected String toString(int indent, int justificationLimit) {
- StringBuffer ret = new StringBuffer();
- String s = content.toString();
- while(s.length() > 0) {
- int nl = s.indexOf('\n');
- if (nl==-1) nl = s.length();
- ret.append(spaces(indent));
- ret.append("{} ");
- ret.append(s.substring(0, nl));
- s = s.substring(Math.min(s.length(),nl+1));
- ret.append('\n');
+ c = (char)i;
+ }
+ if (c=='\n') { _row++; _col=0; }
+ else _col++;
+ if (indenting) {
+ if (c==' ') { indentation++; return done(c); }
+ if (c=='\n') { indentation = 0; if (blank) return nextc(numstates, resets); blank = true; waiting = true; waitingChar='\n'; return '\n'; }
+ int last = istack.size()==0 ? -1 : istack.get(istack.size()-1);
+ if (indentation==last) {
+ if (blank) {
+ indenting = false;
+ waitingChar = c;
+ waiting = true;
+ waitingBrace = left;
+ return right;
+ //return nextc(numstates);