- /** parse <tt>input</tt>, and return the shared packed parse forest (or throw an exception) */
- public Forest<Result> parse(Input<Tok> input) throws IOException, ParseFailed {
- GSS gss = new GSS();
- Input.Location loc = input.getLocation();
- GSS.Phase current = gss.new Phase<Tok>(null, this, null, input.next(), loc, null);
- current.newNode(null, Forest.create(null, null, null, false), pt.start, true);
- int count = 1;
- for(int idx=0;;idx++) {
- Input.Location oldloc = loc;
- loc = input.getLocation();
- current.reduce();
- Forest forest = current.token==null ? null : shiftToken((Tok)current.token, loc);
- GSS.Phase next = gss.new Phase<Tok>(current, this, current, input.next(), loc, forest);
- if (!helpgc) {
- FileOutputStream fos = new FileOutputStream("out-"+idx+".dot");
- PrintWriter p = new PrintWriter(new OutputStreamWriter(fos));
- GraphViz gv = new GraphViz();
- for(Object n : next)
- ((GSS.Phase.Node)n).toGraphViz(gv);
- gv.dump(p);
- p.flush();
- p.close();
- }
- count = next.size();
- if (current.isDone()) return (Forest<Result>)gss.finalResult;
- current = next;
+ private boolean verbose = false;;
+ private static final char[] spin = new char[] { '-', '\\', '|', '/' };
+ private int spinpos = 0;
+ private long last = 0;
+ void spin() {
+ if (verbose) {
+ long now = System.currentTimeMillis();
+ if (now-last < 100) return;
+ last = now;
+ System.err.print("\r " + spin[spinpos++ % (spin.length)]+ANSI.clreol()+"\r");