3 import java.io.FileOutputStream;
4 import java.io.PrintStream;
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;
12 import java.util.Vector;
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;
23 import IR.TaskDescriptor;
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.MLP.MLPAnalysis;
45 import Analysis.Disjoint.DisjointAnalysis;
46 import Analysis.OoOJava.OoOJavaAnalysis;
47 import Analysis.Loops.*;
48 import Analysis.Liveness;
49 import Analysis.ArrayReferencees;
50 import IR.MethodDescriptor;
51 import IR.Flat.FlatMethod;
53 import Util.GraphNode;
54 import Util.GraphNode.DFS;
55 import Util.GraphNode.SCC;
59 /** Main method for the compiler. */
61 public static void main(String args[]) throws Exception {
62 String ClassLibraryPrefix="./ClassLibrary/";
63 State state=new State();
64 Vector sourcefiles=new Vector();
65 state.classpath.add(".");
67 String outputdir = null;
68 boolean isDistributeInfo = false;
69 boolean isDisAll = false;
72 for(int i=0; i<args.length; i++) {
73 String option=args[i];
74 if (option.equals("-precise"))
75 IR.Flat.BuildCode.GENERATEPRECISEGC=true;
76 else if (option.equals("-prefetch"))
78 else if (option.equals("-dir"))
79 IR.Flat.BuildCode.PREFIX=args[++i]+"/";
80 else if (option.equals("-fastcheck"))
82 else if (option.equals("-selfloop"))
83 state.selfloops.add(args[++i]);
84 else if (option.equals("-outputdir"))
85 state.outputdir = args[++i];
86 else if (option.equals("-excprefetch"))
87 state.excprefetch.add(args[++i]);
88 else if (option.equals("-classlibrary"))
89 state.classpath.add(args[++i]);
90 else if (option.equals("-inlineatomic")) {
91 state.INLINEATOMIC=true;
92 state.inlineatomicdepth=Integer.parseInt(args[++i]);
93 } else if(option.equals("-numcore")) {
95 state.CORENUM = Integer.parseInt(args[i]);
96 } else if(option.equals("-numcore4gc")) {
98 state.CORENUM4GC = Integer.parseInt(args[i]);
99 } else if (option.equals("-mainclass"))
100 state.main=args[++i];
101 else if (option.equals("-trueprob")) {
102 state.TRUEPROB=Double.parseDouble(args[++i]);
103 } else if (option.equals("-printflat"))
104 State.PRINTFLAT=true;
105 else if (option.equals("-printscheduling"))
106 State.PRINTSCHEDULING=true;
107 else if (option.equals("-minimize"))
109 else if (option.equals("-printschedulesim"))
110 State.PRINTSCHEDULESIM=true;
111 else if (option.equals("-printcriticalpath"))
112 State.PRINTCRITICALPATH=true;
113 else if (option.equals("-struct"))
114 state.structfile=args[++i];
115 else if (option.equals("-conscheck"))
116 state.CONSCHECK=true;
117 else if (option.equals("-task"))
119 else if (option.equals("-abortreaders"))
120 state.ABORTREADERS=true;
121 else if (option.equals("-sandbox"))
123 else if (option.equals("-taskstate"))
124 state.TASKSTATE=true;
125 else if (option.equals("-tagstate"))
127 else if (option.equals("-stmarray"))
129 else if (option.equals("-eventmonitor"))
130 state.EVENTMONITOR=true;
131 else if (option.equals("-dualview"))
133 else if (option.equals("-hybrid"))
135 else if (option.equals("-flatirtasks")) {
136 state.FLATIRGRAPH=true;
137 state.FLATIRGRAPHTASKS=true;
138 } else if (option.equals("-flatirusermethods")) {
139 state.FLATIRGRAPH=true;
140 state.FLATIRGRAPHUSERMETHODS=true;
141 } else if (option.equals("-flatirlibmethods")) {
142 state.FLATIRGRAPH=true;
143 state.FLATIRGRAPHLIBMETHODS=true;
144 } else if (option.equals("-bamboocompiletime")) {
145 state.BAMBOOCOMPILETIME = true;
146 } else if (option.equals("-multicore"))
147 state.MULTICORE=true;
148 else if (option.equals("-multicoregc"))
149 state.MULTICOREGC=true;
150 else if (option.equals("-ownership"))
151 state.OWNERSHIP=true;
152 else if (option.equals("-ownallocdepth")) {
153 state.OWNERSHIPALLOCDEPTH=Integer.parseInt(args[++i]);
154 } else if (option.equals("-ownwritedots")) {
155 state.OWNERSHIPWRITEDOTS=true;
156 if (args[++i].equals("all")) {
157 state.OWNERSHIPWRITEALL=true;
159 } else if (option.equals("-ownaliasfile")) {
160 state.OWNERSHIPALIASFILE=args[++i];
161 } else if (option.equals("-ownaliasfiletab")) {
162 state.OWNERSHIPALIASFILE=args[++i];
163 state.OWNERSHIPALIASTAB=true;
164 } else if (option.equals("-owndebugcallee")) {
165 state.OWNERSHIPDEBUGCALLEE=args[++i];
166 } else if (option.equals("-owndebugcaller")) {
167 state.OWNERSHIPDEBUGCALLER=args[++i];
168 } else if (option.equals("-owndebugcallcount")) {
169 state.OWNERSHIPDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
172 else if (option.equals("-disjoint"))
175 else if (option.equals("-disjoint-k")) {
176 state.DISJOINTALLOCDEPTH=Integer.parseInt(args[++i]);
178 } else if (option.equals("-disjoint-write-dots")) {
179 state.DISJOINTWRITEDOTS = true;
180 String arg = args[++i];
181 if( arg.equals("all") ) {
182 state.DISJOINTWRITEALL = true;
183 } else if( arg.equals("final") ) {
184 state.DISJOINTWRITEALL = false;
186 throw new Error("disjoint-write-dots requires argument <all/final>");
189 } else if (option.equals("-disjoint-write-initial-contexts")) {
190 state.DISJOINTWRITEINITCONTEXTS = true;
192 } else if (option.equals("-disjoint-write-ihms")) {
193 state.DISJOINTWRITEIHMS = true;
195 } else if (option.equals("-disjoint-alias-file")) {
196 state.DISJOINTALIASFILE = args[++i];
197 String arg = args[++i];
198 if( arg.equals("normal") ) {
199 state.DISJOINTALIASTAB = false;
200 } else if( arg.equals("tabbed") ) {
201 state.DISJOINTALIASTAB = true;
203 throw new Error("disjoint-alias-file requires arguments: <filename> <normal/tabbed>");
206 } else if (option.equals("-disjoint-debug-callsite")) {
207 state.DISJOINTDEBUGCALLEE=args[++i];
208 state.DISJOINTDEBUGCALLER=args[++i];
209 state.DISJOINTDEBUGCALLVISITTOSTART=Integer.parseInt(args[++i]);
210 state.DISJOINTDEBUGCALLNUMVISITS=Integer.parseInt(args[++i]);
211 String arg = args[++i];
212 if( arg.equals("true") ) {
213 state.DISJOINTDEBUGCALLSTOPAFTER = true;
214 } else if( arg.equals("false") ) {
215 state.DISJOINTDEBUGCALLSTOPAFTER = false;
217 throw new Error("disjoint-debug-callsite requires arguments:\n"+
218 " <callee symbol> <caller symbol> <# visit to start> <# visits to capture> <T/F stop after>");
221 } else if (option.equals("-disjoint-debug-snap-method")) {
222 state.DISJOINTSNAPSYMBOL=args[++i];
223 state.DISJOINTSNAPVISITTOSTART=Integer.parseInt(args[++i]);
224 state.DISJOINTSNAPNUMVISITS=Integer.parseInt(args[++i]);
225 String arg = args[++i];
226 if( arg.equals("true") ) {
227 state.DISJOINTSNAPSTOPAFTER = true;
228 } else if( arg.equals("false") ) {
229 state.DISJOINTSNAPSTOPAFTER = false;
231 throw new Error("disjoint-debug-snap-method requires arguments:\n"+
232 " <method symbol> <# visit to start> <# visits to snap> <T/F stop after>");
235 } else if( option.equals( "-disjoint-release-mode" ) ) {
236 state.DISJOINTRELEASEMODE = true;
238 } else if( option.equals( "-disjoint-dvisit-stack" ) ) {
239 state.DISJOINTDVISITSTACK = true;
240 state.DISJOINTDVISITPQUE = false;
241 state.DISJOINTDVISITSTACKEESONTOP = false;
243 } else if( option.equals( "-disjoint-dvisit-pqueue" ) ) {
244 state.DISJOINTDVISITPQUE = true;
245 state.DISJOINTDVISITSTACK = false;
246 state.DISJOINTDVISITSTACKEESONTOP = false;
248 } else if( option.equals( "-disjoint-dvisit-stack-callees-on-top" ) ) {
249 state.DISJOINTDVISITSTACKEESONTOP = true;
250 state.DISJOINTDVISITPQUE = false;
251 state.DISJOINTDVISITSTACK = false;
253 } else if( option.equals( "-disjoint-desire-determinism" ) ) {
254 state.DISJOINTDETERMINISM = true;
256 // when asking analysis for a deterministic result, force
257 // a stack-based visiting scheme, because the priority queue
258 // requires a non-deterministic topological sort
259 state.DISJOINTDVISITSTACKEESONTOP = true;
260 state.DISJOINTDVISITPQUE = false;
261 state.DISJOINTDVISITSTACK = false;
264 } else if( option.equals( "-disjoint-debug-scheduling" ) ) {
265 state.DISJOINTDEBUGSCHEDULING = true;
269 else if (option.equals("-optional"))
271 else if (option.equals("-optimize"))
273 else if (option.equals("-noloop"))
275 else if (option.equals("-dcopts"))
277 else if (option.equals("-arraypad"))
279 else if (option.equals("-delaycomp"))
280 state.DELAYCOMP=true;
281 else if (option.equals("-raw"))
283 else if (option.equals("-scheduling"))
284 state.SCHEDULING=true;
285 else if (option.equals("-distributioninfo"))
286 isDistributeInfo=true;
287 else if (option.equals("-disall"))
289 else if (option.equals("-disstart"))
290 startnum = Integer.parseInt(args[++i]);
291 else if (option.equals("-useprofile")) {
292 state.USEPROFILE=true;
293 state.profilename = args[++i];
295 else if (option.equals("-thread"))
297 else if (option.equals("-dsm"))
299 else if (option.equals("-recoverystats"))
300 state.DSMRECOVERYSTATS=true;
301 else if (option.equals("-dsmtask"))
303 else if (option.equals("-singleTM"))
305 else if (option.equals("-readset"))
307 else if (option.equals("-webinterface"))
308 state.WEBINTERFACE=true;
309 else if (option.equals("-instructionfailures"))
310 state.INSTRUCTIONFAILURE=true;
311 else if (option.equals("-abcclose"))
312 state.ARRAYBOUNDARYCHECK=false;
314 else if (option.equals("-mlp")) {
316 state.OWNERSHIP = true;
317 state.MLP_NUMCORES = Integer.parseInt( args[++i] );
318 state.MLP_MAXSESEAGE = Integer.parseInt( args[++i] );
320 } else if (option.equals("-mlpdebug")) {
323 } else if (option.equals("-methodeffects")) {
324 state.METHODEFFECTS=true;
326 } else if (option.equals("-coreprof")) {
329 } else if (option.equals("-ooojava")) {
330 state.OOOJAVA = true;
331 state.DISJOINT = true;
332 state.MLP_NUMCORES = Integer.parseInt( args[++i] );
333 state.MLP_MAXSESEAGE = Integer.parseInt( args[++i] );
335 } else if (option.equals("-ooodebug") ){
336 state.OOODEBUG = true;
337 } else if (option.equals("-rcr")){
339 } else if (option.equals("-help")) {
340 System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
341 System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
342 System.out.println("-dir outputdirectory -- output code in outputdirectory");
343 System.out.println("-struct structfile -- output structure declarations for repair tool");
344 System.out.println("-mainclass -- main function to call");
345 System.out.println("-dsm -- distributed shared memory support");
346 System.out.println("-singleTM -- single machine committing transactions");
347 System.out.println("-abortreaders -- abort readers");
348 System.out.println("-precise -- use precise garbage collection");
349 System.out.println("-conscheck -- turn on consistency checking");
350 System.out.println("-task -- compiler for tasks");
351 System.out.println("-fastcheck -- fastcheckpointing for Bristlecone");
352 System.out.println("-thread -- threads");
353 System.out.println("-trueprob <d> -- probability of true branch");
354 System.out.println("-printflat -- print out flat representation");
355 System.out.println("-instructionfailures -- insert code for instruction level failures");
356 System.out.println("-taskstate -- do task state analysis");
357 System.out.println("-flatirtasks -- create dot files for flat IR graphs of tasks");
358 System.out.println("-flatirusermethods -- create dot files for flat IR graphs of user methods");
359 System.out.println("-flatirlibmethods -- create dot files for flat IR graphs of library class methods");
360 System.out.println(" note: -flatirusermethods or -flatirlibmethods currently generate all class method flat IR graphs");
361 System.out.println("-ownership -- do ownership analysis");
362 System.out.println("-ownallocdepth <d> -- set allocation depth for ownership analysis");
363 System.out.println("-ownwritedots <all/final> -- write ownership graphs; can be all results or just final results");
364 System.out.println("-ownaliasfile <filename> -- write a text file showing all detected aliases in program tasks");
365 System.out.println("-optimize -- enable optimizations");
366 System.out.println("-noloop -- disable loop optimizations");
367 System.out.println("-optional -- enable optional arguments");
368 System.out.println("-abcclose close the array boundary check");
369 System.out.println("-scheduling do task scheduling");
370 System.out.println("-mlp <num cores> <max sese age> build mlp code");
371 System.out.println("-mlpdebug if mlp, report progress and interim results");
372 System.out.println("-multicore generate multi-core version binary");
373 System.out.println("-numcore set the number of cores (should be used together with -multicore), defaultly set as 1");
374 System.out.println("-interrupt generate raw version binary with interruption (should be used togethere with -raw)");
375 System.out.println("-rawconfig config raw simulator as 4xn (should be used together with -raw)");
376 System.out.println("-rawpath print out execute path information for raw version (should be used together with -raw)");
377 System.out.println("-useprofile use profiling data for scheduling (should be used together with -raw)");
378 System.out.println("-threadsimulate generate multi-thread simulate version binary");
379 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");
380 System.out.println("-printscheduling -- print out scheduling graphs");
381 System.out.println("-printschedulesim -- print out scheduling simulation result graphs");
382 System.out.println("-webinterface -- enable web interface");
383 System.out.println("-help -- print out help");
386 sourcefiles.add(args[i]);
390 //add default classpath
391 if (state.classpath.size()==1)
392 state.classpath.add(ClassLibraryPrefix);
394 BuildIR bir=new BuildIR(state);
395 TypeUtil tu=new TypeUtil(state, bir);
398 SemanticCheck sc=new SemanticCheck(state,tu);
400 for(int i=0;i<sourcefiles.size();i++)
401 loadClass(state, bir,(String)sourcefiles.get(i));
404 //Stuff the runtime wants to see
405 sc.getClass("String");
408 sc.getClass("Socket");
409 sc.getClass("ServerSocket");
410 sc.getClass("FileInputStream");
411 sc.getClass("FileOutputStream");
413 sc.getClass("TagDescriptor");
415 if (state.THREAD||state.DSM||state.SINGLETM) {
416 sc.getClass("Thread");
422 tu.createFullTable();
424 BuildFlat bf=new BuildFlat(state,tu);
426 SafetyAnalysis sa=null;
427 PrefetchAnalysis pa=null;
428 MLPAnalysis mlpa=null;
429 OoOJavaAnalysis oooa=null;
430 if (state.INLINEATOMIC) {
431 Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
432 while(classit.hasNext()) {
433 ClassDescriptor cn=(ClassDescriptor)classit.next();
434 Iterator methodit=cn.getMethods();
435 while(methodit.hasNext()) {
437 MethodDescriptor md=(MethodDescriptor)methodit.next();
438 FlatMethod fm=state.getMethodFlat(md);
439 Inliner.inlineAtomic(state, tu, fm, state.inlineatomicdepth);
445 if (state.OPTIMIZE) {
446 CallGraph callgraph=new CallGraph(state);
447 CopyPropagation cp=new CopyPropagation();
448 DeadCode dc=new DeadCode();
449 GlobalFieldType gft=new GlobalFieldType(callgraph, state, tu.getMain());
450 CSE cse=new CSE(gft, tu);
451 localCSE lcse=new localCSE(gft, tu);
452 LoopOptimize lo=null;
454 lo=new LoopOptimize(gft, tu);
455 Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
456 while(classit.hasNext()) {
457 ClassDescriptor cn=(ClassDescriptor)classit.next();
458 Iterator methodit=cn.getMethods();
459 while(methodit.hasNext()) {
460 /* Classify parameters */
461 MethodDescriptor md=(MethodDescriptor)methodit.next();
462 FlatMethod fm=state.getMethodFlat(md);
479 if (state.FLATIRGRAPH) {
480 FlatIRGraph firg = new FlatIRGraph(state,
481 state.FLATIRGRAPHTASKS,
482 state.FLATIRGRAPHUSERMETHODS,
483 state.FLATIRGRAPHLIBMETHODS);
486 if (state.OWNERSHIP && !state.MLP) {
487 CallGraph callGraph = new CallGraph(state);
488 Liveness liveness = new Liveness();
489 ArrayReferencees ar = new ArrayReferencees(state);
490 OwnershipAnalysis oa = new OwnershipAnalysis(state,
495 state.OWNERSHIPALLOCDEPTH,
496 state.OWNERSHIPWRITEDOTS,
497 state.OWNERSHIPWRITEALL,
498 state.OWNERSHIPALIASFILE,
499 state.METHODEFFECTS);
503 CallGraph callGraph = new CallGraph(state);
504 Liveness liveness = new Liveness();
505 ArrayReferencees ar = new ArrayReferencees(state);
506 OwnershipAnalysis oa = new OwnershipAnalysis(state,
511 state.OWNERSHIPALLOCDEPTH,
512 state.OWNERSHIPWRITEDOTS,
513 state.OWNERSHIPWRITEALL,
514 state.OWNERSHIPALIASFILE,
515 state.METHODEFFECTS);
516 mlpa = new MLPAnalysis(state,
522 if (state.DISJOINT && !state.OOOJAVA) {
523 CallGraph cg = new CallGraph(state);
524 Liveness l = new Liveness();
525 ArrayReferencees ar = new ArrayReferencees(state);
526 DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar, null, null, null);
530 CallGraph cg = new CallGraph(state);
531 Liveness l = new Liveness();
532 ArrayReferencees ar = new ArrayReferencees(state);
533 oooa = new OoOJavaAnalysis(state, tu, cg, l, ar);
537 if (state.TAGSTATE) {
538 CallGraph callgraph=new CallGraph(state);
539 TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
540 TaskTagAnalysis tta=new TaskTagAnalysis(state, taganalysis, tu);
543 if (state.TASKSTATE) {
544 CallGraph callgraph=new CallGraph(state);
545 TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
546 TaskAnalysis ta=new TaskAnalysis(state, taganalysis, tu);
548 TaskGraph tg=new TaskGraph(state, ta);
551 if (state.OPTIONAL) {
552 ExecutionGraph et=new ExecutionGraph(state, ta);
553 et.createExecutionGraph();
554 sa = new SafetyAnalysis(et.getExecutionGraph(), state, ta);
556 state.storeAnalysisResult(sa.getResult());
557 state.storeOptionalTaskDescriptors(sa.getOptionalTaskDescriptors());
560 if (state.WEBINTERFACE) {
561 GarbageAnalysis ga=new GarbageAnalysis(state, ta);
562 WebInterface wi=new WebInterface(state, ta, tg, ga, taganalysis);
563 JhttpServer serve=new JhttpServer(8000,wi);
567 if (state.SCHEDULING) {
568 // Use ownership analysis to get alias information
569 CallGraph callGraph = new CallGraph(state);
570 Liveness liveness = new Liveness();
571 ArrayReferencees ar = new ArrayReferencees(state);
572 OwnershipAnalysis oa = null; /*new OwnershipAnalysis(state,
577 state.OWNERSHIPALLOCDEPTH,
578 state.OWNERSHIPWRITEDOTS,
579 state.OWNERSHIPWRITEALL,
580 state.OWNERSHIPALIASFILE);*/
582 // synthesis a layout according to target multicore processor
583 MCImplSynthesis mcImplSynthesis = new MCImplSynthesis(state,
586 if(isDistributeInfo) {
587 mcImplSynthesis.distribution(isDisAll, startnum);
589 double timeStartAnalysis = (double) System.nanoTime();
590 mcImplSynthesis.setScheduleThreshold(20);
591 mcImplSynthesis.setProbThreshold(0);
592 mcImplSynthesis.setGenerateThreshold(30);
593 Vector<Schedule> scheduling = mcImplSynthesis.synthesis();
595 double timeEndAnalysis = (double) System.nanoTime();
596 if(state.BAMBOOCOMPILETIME) {
597 double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
598 System.err.println("The analysis took" + dt + "sec.");
602 // generate multicore codes
603 if(state.MULTICORE) {
604 BuildCodeMultiCore bcm=new BuildCodeMultiCore(state,
609 mcImplSynthesis.getCoreNum(),
612 bcm.setOwnershipAnalysis(oa);
620 if(!state.MULTICORE) {
621 if (state.DSM||state.SINGLETM) {
622 CallGraph callgraph=new CallGraph(state);
623 if (state.PREFETCH) {
624 //speed up prefetch generation using locality analysis results
625 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
626 pa=new PrefetchAnalysis(state, callgraph, tu, la);
628 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
629 GenerateConversions gc=new GenerateConversions(la, state);
630 BuildCode bc=new BuildCode(state, bf.getMap(), tu, la, pa, mlpa,oooa);
633 BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa, pa, mlpa,oooa);
638 System.out.println("Lines="+state.lines);
642 public static void loadClass(State state, BuildIR bir, String sourcefile) {
644 ParseNode pn=readSourceFile(state, sourcefile);
645 bir.buildtree(pn, null);
646 } catch (Exception e) {
647 System.out.println("Error in sourcefile:"+sourcefile);
651 System.out.println("Error in sourcefile:"+sourcefile);
657 /** Reads in a source file and adds the parse tree to the state object. */
659 public static ParseNode readSourceFile(State state, String sourcefile) {
661 Reader fr= new BufferedReader(new FileReader(sourcefile));
662 Lex.Lexer l = new Lex.Lexer(fr);
663 java_cup.runtime.lr_parser g;
664 g = new Parse.Parser(l);
667 p=(ParseNode) g./*debug_*/parse().value;
668 } catch (Exception e) {
669 System.err.println("Error parsing file:"+sourcefile);
673 state.addParseNode(p);
674 if (l.numErrors()!=0) {
675 System.out.println("Error parsing "+sourcefile);
676 System.exit(l.numErrors());
678 state.lines+=l.line_num;
681 } catch (Exception e) {