change in the multicore version runtime. now it is able to choose which cores to...
[IRC.git] / Robust / src / Main / Main.java
1 package Main;
2
3 import java.io.FileOutputStream;
4 import java.io.PrintStream;
5 import java.io.Reader;
6 import java.io.BufferedReader;
7 import java.io.FileReader;
8 import java.io.FileInputStream;
9 import java.util.Hashtable;
10 import java.util.Iterator;
11 import java.util.Set;
12 import java.util.Vector;
13
14 import IR.Tree.ParseNode;
15 import IR.Tree.BuildIR;
16 import IR.Tree.SemanticCheck;
17 import IR.Flat.BuildCodeMultiCore;
18 import IR.Flat.BuildFlat;
19 import IR.Flat.BuildCode;
20 import IR.Flat.Inliner;
21 import IR.ClassDescriptor;
22 import IR.State;
23 import IR.TaskDescriptor;
24 import IR.TypeUtil;
25 import Analysis.Scheduling.MCImplSynthesis;
26 import Analysis.Scheduling.Schedule;
27 import Analysis.Scheduling.ScheduleAnalysis;
28 import Analysis.Scheduling.ScheduleSimulator;
29 import Analysis.TaskStateAnalysis.TaskAnalysis;
30 import Analysis.TaskStateAnalysis.TaskTagAnalysis;
31 import Analysis.TaskStateAnalysis.TaskGraph;
32 import Analysis.CallGraph.CallGraph;
33 import Analysis.TaskStateAnalysis.FEdge;
34 import Analysis.TaskStateAnalysis.FlagState;
35 import Analysis.TaskStateAnalysis.TagAnalysis;
36 import Analysis.TaskStateAnalysis.GarbageAnalysis;
37 import Analysis.TaskStateAnalysis.ExecutionGraph;
38 import Analysis.TaskStateAnalysis.SafetyAnalysis;
39 import Analysis.Locality.LocalityAnalysis;
40 import Analysis.Locality.GenerateConversions;
41 import Analysis.Prefetch.PrefetchAnalysis;
42 import Analysis.FlatIRGraph.FlatIRGraph;
43 import Analysis.OwnershipAnalysis.OwnershipAnalysis;
44 import Analysis.Disjoint.DisjointAnalysis;
45 import Analysis.MLP.MLPAnalysis;
46 import Analysis.Loops.*;
47 import Analysis.Liveness;
48 import Analysis.ArrayReferencees;
49 import IR.MethodDescriptor;
50 import IR.Flat.FlatMethod;
51 import Interface.*;
52 import Util.GraphNode;
53 import Util.GraphNode.DFS;
54 import Util.GraphNode.SCC;
55
56 public class Main {
57
58   /** Main method for the compiler.  */
59
60   public static void main(String args[]) throws Exception {
61     String ClassLibraryPrefix="./ClassLibrary/";
62     State state=new State();
63     Vector sourcefiles=new Vector();
64     state.classpath.add(".");
65
66     String outputdir = null;
67     boolean isDistributeInfo = false;
68     boolean isDisAll = false;
69     int startnum = 0;
70
71     for(int i=0; i<args.length; i++) {
72       String option=args[i];
73       if (option.equals("-precise"))
74         IR.Flat.BuildCode.GENERATEPRECISEGC=true;
75       else if (option.equals("-prefetch"))
76         state.PREFETCH=true;
77       else if (option.equals("-dir"))
78         IR.Flat.BuildCode.PREFIX=args[++i]+"/";
79       else if (option.equals("-fastcheck"))
80         state.FASTCHECK=true;
81       else if (option.equals("-selfloop"))
82         state.selfloops.add(args[++i]);
83           else if (option.equals("-outputdir"))
84         state.outputdir = args[++i];
85       else if (option.equals("-excprefetch"))
86         state.excprefetch.add(args[++i]);
87       else if (option.equals("-classlibrary"))
88         state.classpath.add(args[++i]);
89       else if (option.equals("-inlineatomic")) {
90         state.INLINEATOMIC=true;
91         state.inlineatomicdepth=Integer.parseInt(args[++i]);
92       } else if(option.equals("-numcore")) {
93         ++i;
94         state.CORENUM = Integer.parseInt(args[i]);
95       } else if(option.equals("-numcore4gc")) {
96         ++i;
97         state.CORENUM4GC = Integer.parseInt(args[i]);
98       } else if (option.equals("-mainclass"))
99         state.main=args[++i];
100       else if (option.equals("-trueprob")) {
101         state.TRUEPROB=Double.parseDouble(args[++i]);
102       } else if (option.equals("-printflat"))
103         State.PRINTFLAT=true;
104       else if (option.equals("-printscheduling"))
105         State.PRINTSCHEDULING=true;
106       else if (option.equals("-minimize"))
107         state.MINIMIZE=true;
108       else if (option.equals("-printschedulesim"))
109         State.PRINTSCHEDULESIM=true;
110       else if (option.equals("-printcriticalpath"))
111           State.PRINTCRITICALPATH=true;
112       else if (option.equals("-struct"))
113         state.structfile=args[++i];
114       else if (option.equals("-conscheck"))
115         state.CONSCHECK=true;
116       else if (option.equals("-task"))
117         state.TASK=true;
118       else if (option.equals("-abortreaders"))
119         state.ABORTREADERS=true;
120       else if (option.equals("-sandbox"))
121         state.SANDBOX=true;
122       else if (option.equals("-taskstate"))
123         state.TASKSTATE=true;
124       else if (option.equals("-tagstate"))
125         state.TAGSTATE=true;
126       else if (option.equals("-stmarray"))
127         state.STMARRAY=true;
128       else if (option.equals("-eventmonitor"))
129         state.EVENTMONITOR=true;
130       else if (option.equals("-dualview"))
131         state.DUALVIEW=true;
132       else if (option.equals("-hybrid"))
133         state.HYBRID=true;
134       else if (option.equals("-flatirtasks")) {
135         state.FLATIRGRAPH=true;
136         state.FLATIRGRAPHTASKS=true;
137       } else if (option.equals("-flatirusermethods")) {
138         state.FLATIRGRAPH=true;
139         state.FLATIRGRAPHUSERMETHODS=true;
140       } else if (option.equals("-flatirlibmethods")) {
141         state.FLATIRGRAPH=true;
142         state.FLATIRGRAPHLIBMETHODS=true;
143       } else if (option.equals("-multicore"))
144         state.MULTICORE=true;
145       else if (option.equals("-multicoregc"))
146         state.MULTICOREGC=true;
147       else if (option.equals("-ownership"))
148         state.OWNERSHIP=true;
149       else if (option.equals("-ownallocdepth")) {
150         state.OWNERSHIPALLOCDEPTH=Integer.parseInt(args[++i]);
151       } else if (option.equals("-ownwritedots")) {
152         state.OWNERSHIPWRITEDOTS=true;
153         if (args[++i].equals("all")) {
154           state.OWNERSHIPWRITEALL=true;
155         }
156       } else if (option.equals("-ownaliasfile")) {
157         state.OWNERSHIPALIASFILE=args[++i];
158       } else if (option.equals("-ownaliasfiletab")) {
159         state.OWNERSHIPALIASFILE=args[++i];
160         state.OWNERSHIPALIASTAB=true;      
161       } else if (option.equals("-owndebugcallee")) {
162         state.OWNERSHIPDEBUGCALLEE=args[++i];
163       } else if (option.equals("-owndebugcaller")) {
164         state.OWNERSHIPDEBUGCALLER=args[++i];
165       } else if (option.equals("-owndebugcallcount")) {
166         state.OWNERSHIPDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
167       }
168       else if (option.equals("-disjoint"))
169         state.DISJOINT=true;
170       else if (option.equals("-disjoint-k")) {
171         state.DISJOINTALLOCDEPTH=Integer.parseInt(args[++i]);
172       } else if (option.equals("-disjoint-write-dots")) {
173         state.DISJOINTWRITEDOTS = true;
174         String arg = args[++i];
175         if( arg.equals("all") ) {
176           state.DISJOINTWRITEALL = true;
177         } else if( arg.equals("final") ) {
178           state.DISJOINTWRITEALL = false;
179         } else {
180           throw new Error("disjoint-write-dots requires argument <all/final>");
181         }
182       } else if (option.equals("-disjoint-alias-file")) {
183         state.DISJOINTALIASFILE = args[++i];
184         String arg = args[++i];
185         if( arg.equals("normal") ) {
186           state.DISJOINTALIASTAB = false;
187         } else if( arg.equals("tabbed") ) {
188           state.DISJOINTALIASTAB = true;
189         } else {
190           throw new Error("disjoint-alias-file requires arguments <filename> <normal/tabbed>");
191         }
192       } else if (option.equals("-disjoint-debug-callsite")) {
193         state.DISJOINTDEBUGCALLEE=args[++i];
194         state.DISJOINTDEBUGCALLER=args[++i];
195         state.DISJOINTDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
196       }
197       else if (option.equals("-optional"))
198         state.OPTIONAL=true;
199       else if (option.equals("-optimize"))
200         state.OPTIMIZE=true;
201       else if (option.equals("-dcopts"))
202         state.DCOPTS=true;
203       else if (option.equals("-arraypad"))
204         state.ARRAYPAD=true;
205       else if (option.equals("-delaycomp"))
206         state.DELAYCOMP=true;
207       else if (option.equals("-raw"))
208         state.RAW=true;
209       else if (option.equals("-scheduling"))
210         state.SCHEDULING=true;
211       else if (option.equals("-distributioninfo"))
212         isDistributeInfo=true;
213       else if (option.equals("-disall"))
214         isDisAll=true;
215       else if (option.equals("-disstart"))
216         startnum = Integer.parseInt(args[++i]);
217       else if (option.equals("-useprofile")) {
218         state.USEPROFILE=true;
219     state.profilename = args[++i];
220       }
221       else if (option.equals("-thread"))
222         state.THREAD=true;
223       else if (option.equals("-dsm"))
224         state.DSM=true;
225       else if (option.equals("-recoverystats"))
226   state.DSMRECOVERYSTATS=true;
227       else if (option.equals("-dsmtask"))
228   state.DSMTASK=true;
229       else if (option.equals("-singleTM"))
230         state.SINGLETM=true;
231       else if (option.equals("-readset"))
232         state.READSET=true;
233       else if (option.equals("-webinterface"))
234         state.WEBINTERFACE=true;
235       else if (option.equals("-instructionfailures"))
236         state.INSTRUCTIONFAILURE=true;
237       else if (option.equals("-abcclose"))
238         state.ARRAYBOUNDARYCHECK=false;
239
240       else if (option.equals("-mlp")) {
241         state.MLP            = true;
242         state.OWNERSHIP      = true;
243         state.MLP_NUMCORES   = Integer.parseInt( args[++i] );
244         state.MLP_MAXSESEAGE = Integer.parseInt( args[++i] );
245
246       } else if (option.equals("-mlpdebug")) {
247         state.MLPDEBUG=true;
248
249       } else if (option.equals("-methodeffects")) {
250         state.METHODEFFECTS=true;
251       }else if (option.equals("-help")) {
252         System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
253         System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
254         System.out.println("-dir outputdirectory -- output code in outputdirectory");
255         System.out.println("-struct structfile -- output structure declarations for repair tool");
256         System.out.println("-mainclass -- main function to call");
257         System.out.println("-dsm -- distributed shared memory support");
258         System.out.println("-singleTM -- single machine committing transactions");
259         System.out.println("-abortreaders -- abort readers");
260         System.out.println("-precise -- use precise garbage collection");
261         System.out.println("-conscheck -- turn on consistency checking");
262         System.out.println("-task -- compiler for tasks");
263         System.out.println("-fastcheck -- fastcheckpointing for Bristlecone");
264         System.out.println("-thread -- threads");
265         System.out.println("-trueprob <d> -- probability of true branch");
266         System.out.println("-printflat -- print out flat representation");
267         System.out.println("-instructionfailures -- insert code for instruction level failures");
268         System.out.println("-taskstate -- do task state analysis");
269         System.out.println("-flatirtasks -- create dot files for flat IR graphs of tasks");
270         System.out.println("-flatirusermethods -- create dot files for flat IR graphs of user methods");
271         System.out.println("-flatirlibmethods -- create dot files for flat IR graphs of library class methods");
272         System.out.println("  note: -flatirusermethods or -flatirlibmethods currently generate all class method flat IR graphs");
273         System.out.println("-ownership -- do ownership analysis");
274         System.out.println("-ownallocdepth <d> -- set allocation depth for ownership analysis");
275         System.out.println("-ownwritedots <all/final> -- write ownership graphs; can be all results or just final results");
276         System.out.println("-ownaliasfile <filename> -- write a text file showing all detected aliases in program tasks");
277         System.out.println("-optimize -- enable optimizations");
278         System.out.println("-optional -- enable optional arguments");
279         System.out.println("-abcclose close the array boundary check");
280         System.out.println("-scheduling do task scheduling");
281         System.out.println("-mlp <num cores> <max sese age> build mlp code");
282         System.out.println("-mlpdebug if mlp, report progress and interim results");
283         System.out.println("-multicore generate multi-core version binary");
284         System.out.println("-numcore set the number of cores (should be used together with -multicore), defaultly set as 1");
285         System.out.println("-interrupt generate raw version binary with interruption (should be used togethere with -raw)");
286         System.out.println("-rawconfig config raw simulator as 4xn (should be used together with -raw)");
287         System.out.println("-rawpath print out execute path information for raw version (should be used together with -raw)");
288         System.out.println("-useprofile use profiling data for scheduling (should be used together with -raw)");
289         System.out.println("-threadsimulate generate multi-thread simulate version binary");
290         System.out.println("-rawuseio use standard io to output profiling data (should be used together with -raw and -profile), it only works with single core version");
291         System.out.println("-printscheduling -- print out scheduling graphs");
292         System.out.println("-printschedulesim -- print out scheduling simulation result graphs");
293         System.out.println("-webinterface -- enable web interface");
294         System.out.println("-help -- print out help");
295         System.exit(0);
296       } else {
297         sourcefiles.add(args[i]);
298       }
299     }
300     
301     //add default classpath
302     if (state.classpath.size()==1)
303       state.classpath.add(ClassLibraryPrefix);
304
305     BuildIR bir=new BuildIR(state);
306     TypeUtil tu=new TypeUtil(state, bir);
307     
308
309     SemanticCheck sc=new SemanticCheck(state,tu);
310
311     for(int i=0;i<sourcefiles.size();i++)
312       loadClass(state, bir,(String)sourcefiles.get(i));
313
314     //Stuff the runtime wants to see
315     sc.getClass("String");
316     sc.getClass("Math");
317     sc.getClass("File");
318     sc.getClass("Socket");
319     sc.getClass("ServerSocket");
320     sc.getClass("FileInputStream");
321     sc.getClass("FileOutputStream");
322     if (state.TASK) {
323       sc.getClass("TagDescriptor");
324     }
325     if (state.THREAD||state.DSM||state.SINGLETM) {
326       sc.getClass("Thread");
327     }
328
329     sc.semanticCheck();
330
331     tu.createFullTable();
332
333     BuildFlat bf=new BuildFlat(state,tu);
334     bf.buildFlat();
335     SafetyAnalysis sa=null;
336     PrefetchAnalysis pa=null;
337     MLPAnalysis mlpa=null;
338     if (state.INLINEATOMIC) {
339       Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
340       while(classit.hasNext()) {
341         ClassDescriptor cn=(ClassDescriptor)classit.next();
342         Iterator methodit=cn.getMethods();
343         while(methodit.hasNext()) {
344           // do inlining
345           MethodDescriptor md=(MethodDescriptor)methodit.next();
346           FlatMethod fm=state.getMethodFlat(md);
347           Inliner.inlineAtomic(state, tu, fm, state.inlineatomicdepth);
348         }
349       }
350     }
351
352
353     if (state.OPTIMIZE) {
354       CallGraph callgraph=new CallGraph(state);
355       CopyPropagation cp=new CopyPropagation();
356       DeadCode dc=new DeadCode();
357       GlobalFieldType gft=new GlobalFieldType(callgraph, state, tu.getMain());
358       CSE cse=new CSE(gft, tu);
359       localCSE lcse=new localCSE(gft, tu);
360       LoopOptimize lo=new LoopOptimize(gft, tu);
361       Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
362       while(classit.hasNext()) {
363         ClassDescriptor cn=(ClassDescriptor)classit.next();
364         Iterator methodit=cn.getMethods();
365         while(methodit.hasNext()) {
366           /* Classify parameters */
367           MethodDescriptor md=(MethodDescriptor)methodit.next();
368           FlatMethod fm=state.getMethodFlat(md);
369           cp.optimize(fm);
370           dc.optimize(fm);
371           lo.optimize(fm);
372           cp.optimize(fm);
373           dc.optimize(fm);
374           lcse.doAnalysis(fm);
375           cse.doAnalysis(fm);
376           cp.optimize(fm);
377           dc.optimize(fm);
378           cp.optimize(fm);
379           dc.optimize(fm);
380         }
381       }
382     }
383
384     if (state.FLATIRGRAPH) {
385       FlatIRGraph firg = new FlatIRGraph(state,
386                                          state.FLATIRGRAPHTASKS,
387                                          state.FLATIRGRAPHUSERMETHODS,
388                                          state.FLATIRGRAPHLIBMETHODS);
389     }
390     
391     if (state.OWNERSHIP && !state.MLP) {
392       CallGraph callGraph = new CallGraph(state);
393       Liveness liveness = new Liveness();
394       ArrayReferencees ar = new ArrayReferencees(state);
395       OwnershipAnalysis oa = new OwnershipAnalysis(state,
396                                                    tu,
397                                                    callGraph,
398                                                    liveness,
399                                                    ar,
400                                                    state.OWNERSHIPALLOCDEPTH,
401                                                    state.OWNERSHIPWRITEDOTS,
402                                                    state.OWNERSHIPWRITEALL,
403                                                    state.OWNERSHIPALIASFILE,
404                                                    state.METHODEFFECTS);
405     }
406
407     if (state.MLP) {
408       CallGraph callGraph = new CallGraph(state);
409       Liveness liveness = new Liveness();
410       ArrayReferencees ar = new ArrayReferencees(state);
411       OwnershipAnalysis oa = new OwnershipAnalysis(state,
412                                                    tu,
413                                                    callGraph,
414                                                    liveness,
415                                                    ar,
416                                                    state.OWNERSHIPALLOCDEPTH,
417                                                    state.OWNERSHIPWRITEDOTS,
418                                                    state.OWNERSHIPWRITEALL,
419                                                    state.OWNERSHIPALIASFILE,
420                                                    state.METHODEFFECTS);
421       mlpa = new MLPAnalysis(state,
422                              tu,
423                              callGraph,
424                              oa);
425     }    
426
427     if (state.DISJOINT) {
428       CallGraph        cg = new CallGraph(state);
429       Liveness         l  = new Liveness();
430       ArrayReferencees ar = new ArrayReferencees(state);
431       DisjointAnalysis oa = new DisjointAnalysis(state, tu, cg, l, ar);
432     }
433
434     if (state.TAGSTATE) {
435       CallGraph callgraph=new CallGraph(state);
436       TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
437       TaskTagAnalysis tta=new TaskTagAnalysis(state, taganalysis, tu);
438     }
439
440     if (state.TASKSTATE) {
441       CallGraph callgraph=new CallGraph(state);
442       TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
443       TaskAnalysis ta=new TaskAnalysis(state, taganalysis, tu);
444       ta.taskAnalysis();
445       TaskGraph tg=new TaskGraph(state, ta);
446       tg.createDOTfiles();
447
448       if (state.OPTIONAL) {
449         ExecutionGraph et=new ExecutionGraph(state, ta);
450         et.createExecutionGraph();
451         sa = new SafetyAnalysis(et.getExecutionGraph(), state, ta);
452         sa.doAnalysis();
453         state.storeAnalysisResult(sa.getResult());
454         state.storeOptionalTaskDescriptors(sa.getOptionalTaskDescriptors());
455       }
456
457       if (state.WEBINTERFACE) {
458         GarbageAnalysis ga=new GarbageAnalysis(state, ta);
459         WebInterface wi=new WebInterface(state, ta, tg, ga, taganalysis);
460         JhttpServer serve=new JhttpServer(8000,wi);
461         serve.run();
462       }
463
464       if (state.SCHEDULING) {
465         // Use ownership analysis to get alias information
466         CallGraph callGraph = new CallGraph(state);
467         Liveness liveness = new Liveness();
468         ArrayReferencees ar = new ArrayReferencees(state);
469         OwnershipAnalysis oa = new OwnershipAnalysis(state,
470                                                      tu,
471                                                      callGraph,
472                                                      liveness,
473                                                      ar,
474                                                      state.OWNERSHIPALLOCDEPTH,
475                                                      state.OWNERSHIPWRITEDOTS,
476                                                      state.OWNERSHIPWRITEALL,
477                                                      state.OWNERSHIPALIASFILE);
478         
479         // synthesis a layout according to target multicore processor
480         MCImplSynthesis mcImplSynthesis = new MCImplSynthesis(state,
481                                                               ta,
482                                                               oa);
483         if(isDistributeInfo) {
484             mcImplSynthesis.distribution(isDisAll, startnum);
485         } else {
486             //double timeStartAnalysis = (double) System.nanoTime();
487             mcImplSynthesis.setScheduleThreshold(20);
488             mcImplSynthesis.setProbThreshold(0);
489             mcImplSynthesis.setGenerateThreshold(30);
490             Vector<Schedule> scheduling = mcImplSynthesis.synthesis();
491             
492             //double timeEndAnalysis = (double) System.nanoTime();
493             //double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
494             //System.err.println("The analysis took" + dt +  "sec.");
495         //System.exit(0);
496
497             // generate multicore codes
498             if(state.MULTICORE) {
499                 BuildCodeMultiCore bcm=new BuildCodeMultiCore(state,
500                                                               bf.getMap(),
501                                                               tu,
502                                                               sa,
503                                                               scheduling,
504                                                               mcImplSynthesis.getCoreNum(),
505                                                   state.CORENUM4GC,
506                                                               pa);
507                 bcm.setOwnershipAnalysis(oa);
508                 bcm.buildCode();
509             }
510             scheduling.clear();
511             scheduling = null;
512         }
513       }
514     }
515     if(!state.MULTICORE) {
516       if (state.DSM||state.SINGLETM) {
517         CallGraph callgraph=new CallGraph(state);
518         if (state.PREFETCH) {
519           //speed up prefetch generation using locality analysis results
520           LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
521           pa=new PrefetchAnalysis(state, callgraph, tu, la);
522         }
523         LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
524         GenerateConversions gc=new GenerateConversions(la, state);
525         BuildCode bc=new BuildCode(state, bf.getMap(), tu, la, pa, mlpa);
526         bc.buildCode();
527       } else {
528         BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa, pa, mlpa);
529         bc.buildCode();
530       }
531     }
532
533     System.out.println("Lines="+state.lines);
534     System.exit(0);
535   }
536
537   public static void loadClass(State state, BuildIR bir, String sourcefile) {
538     try {
539       ParseNode pn=readSourceFile(state, sourcefile);
540       bir.buildtree(pn, null);
541     } catch (Exception e) {
542       System.out.println("Error in sourcefile:"+sourcefile);
543       e.printStackTrace();
544       System.exit(-1);
545     } catch (Error e) {
546       System.out.println("Error in sourcefile:"+sourcefile);
547       e.printStackTrace();
548       System.exit(-1);
549     }
550   }
551
552   /** Reads in a source file and adds the parse tree to the state object. */
553
554   public static ParseNode readSourceFile(State state, String sourcefile) {
555     try {
556       Reader fr= new BufferedReader(new FileReader(sourcefile));
557       Lex.Lexer l = new Lex.Lexer(fr);
558       java_cup.runtime.lr_parser g;
559       g = new Parse.Parser(l);
560       ParseNode p=null;
561       try {
562         p=(ParseNode) g./*debug_*/parse().value;
563       } catch (Exception e) {
564         System.err.println("Error parsing file:"+sourcefile);
565         e.printStackTrace();
566         System.exit(-1);
567       }
568       state.addParseNode(p);
569       if (l.numErrors()!=0) {
570         System.out.println("Error parsing "+sourcefile);
571         System.exit(l.numErrors());
572       }
573       state.lines+=l.line_num;
574       return p;
575
576     } catch (Exception e) {
577       throw new Error(e);
578     }
579   }
580 }