X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FParser.java;h=95e3ba52a024c8e31223bf4271aee5b55d1450dd;hp=2fc0691e3dc4d307060b74a81fefd528d91c97e2;hb=c805010980fc22bcd66c1684a772f66563cd6b72;hpb=b12c78430aa088df4d951f9bf323171c57bfd1c9 diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 2fc0691..95e3ba5 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -24,22 +24,79 @@ public abstract class Parser implements Serializable { /** parse input, and return the shared packed parse forest (or throw an exception) */ public Forest parse(Input input) throws IOException, ParseFailed { + long start = System.currentTimeMillis(); verbose = System.getProperty("sbp.verbose", null) != null; spinpos = 0; GSS gss = new GSS(input, this); + int idmax = 0; + int[][] count = new int[1024*1024][]; + HashMap ids = new HashMap(); try { for(GSS.Phase current = gss.new Phase(pt.start); ;) { if (verbose) debug(current.token, gss, input); if (current.isDone()) return (Forest)current.finalResult; Input.Region region = current.getLocation().createRegion(current.getNextLocation()); Forest forest = shiftToken((Token)current.token, region); + /* + int maxid = 0; + for(Reduction r : gss.finishedReductions) + if (ids.get(r.reduction())==null) + ids.put(r.reduction(), idmax++); + count[current.pos] = new int[idmax]; + for(Reduction r : gss.finishedReductions) + count[current.pos][ids.get(r.reduction())]++; + */ current = gss.new Phase(current, forest); } } finally { if (verbose) { - System.err.print("\r"+ANSI.clreol()); + long time = System.currentTimeMillis() - start; + System.err.println("\r parse time: " + time +"ms "+ ANSI.clreol()); debug(null, gss, input); } + /* + PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream("out.plot"))); + boolean[] use = new boolean[idmax]; + for(int i=0; i20) + use[j] = true; + for(int i=0; i=count[i].length ? 0 : count[i][j])); + } + pw.println(); + } + pw.close(); + pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream("test.plot"))); + pw.println("set terminal postscript enhanced color"); + pw.println("set output \"out.ps\""); + pw.println("set pm3d map"); + pw.println("set autoscale"); + pw.println("set view 0,0"); + pw.println("set ytics (\\"); + int q = -1; + for(int j=0; j