Blame view

circus/src/jcircus/newutil/PrinterUtil.java 23.8 KB
8d0dc533f   Madiel de Souza Conserva Filho   first
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
  package jcircus.newutil;
  
  import java.util.List;
  import java.util.Vector;
  
  import javax.swing.Action;
  import javax.swing.JOptionPane;
  
  import jcircus.complementaryenvs.ChanDotFieldEnv;
  import jcircus.parallelism.CopyProcessAnn;
  import jcircus.parallelism.HiddenFromGUIInfo;
  import net.sourceforge.czt.circus.ast.Action1;
  import net.sourceforge.czt.circus.ast.Action2;
  import net.sourceforge.czt.circus.ast.ActionList;
  import net.sourceforge.czt.circus.ast.ActionPara;
  import net.sourceforge.czt.circus.ast.AssignmentCommand;
  import net.sourceforge.czt.circus.ast.AssignmentPairs;
  import net.sourceforge.czt.circus.ast.BasicAction;
  import net.sourceforge.czt.circus.ast.BasicProcess;
  import net.sourceforge.czt.circus.ast.CallAction;
  import net.sourceforge.czt.circus.ast.CallProcess;
  import net.sourceforge.czt.circus.ast.ChannelDecl;
  import net.sourceforge.czt.circus.ast.ChannelPara;
  import net.sourceforge.czt.circus.ast.ChannelSet;
  import net.sourceforge.czt.circus.ast.ChaosAction;
  import net.sourceforge.czt.circus.ast.CircusAction;
  import net.sourceforge.czt.circus.ast.CircusActionList;
  import net.sourceforge.czt.circus.ast.CircusChannelSet;
  import net.sourceforge.czt.circus.ast.CircusCommand;
  import net.sourceforge.czt.circus.ast.CircusFieldList;
  import net.sourceforge.czt.circus.ast.CircusProcess;
  import net.sourceforge.czt.circus.ast.Communication;
  import net.sourceforge.czt.circus.ast.DotField;
  import net.sourceforge.czt.circus.ast.ExtChoiceAction;
  import net.sourceforge.czt.circus.ast.ExtChoiceProcess;
  import net.sourceforge.czt.circus.ast.Field;
  import net.sourceforge.czt.circus.ast.GuardedAction;
  import net.sourceforge.czt.circus.ast.HideAction;
  import net.sourceforge.czt.circus.ast.HideProcess;
  import net.sourceforge.czt.circus.ast.IfGuardedCommand;
  import net.sourceforge.czt.circus.ast.InputField;
  import net.sourceforge.czt.circus.ast.IntChoiceAction;
  import net.sourceforge.czt.circus.ast.IntChoiceProcess;
  import net.sourceforge.czt.circus.ast.InterleaveAction;
  import net.sourceforge.czt.circus.ast.MuAction;
  import net.sourceforge.czt.circus.ast.ParAction;
  import net.sourceforge.czt.circus.ast.ParProcess;
  import net.sourceforge.czt.circus.ast.ParallelAction;
  import net.sourceforge.czt.circus.ast.ParallelProcess;
  import net.sourceforge.czt.circus.ast.ParamAction;
  import net.sourceforge.czt.circus.ast.ParamProcess;
  import net.sourceforge.czt.circus.ast.PrefixingAction;
  import net.sourceforge.czt.circus.ast.ProcessPara;
  import net.sourceforge.czt.circus.ast.RenameAction;
  import net.sourceforge.czt.circus.ast.RenameProcess;
  import net.sourceforge.czt.circus.ast.SeqAction;
  import net.sourceforge.czt.circus.ast.SeqProcess;
  import net.sourceforge.czt.circus.ast.SkipAction;
  import net.sourceforge.czt.circus.ast.SpecStmtCommand;
  import net.sourceforge.czt.circus.ast.StopAction;
  import net.sourceforge.czt.circus.ast.VarDeclCommand;
  import net.sourceforge.czt.z.ast.AndPred;
  import net.sourceforge.czt.z.ast.ApplExpr;
  import net.sourceforge.czt.z.ast.AxPara;
  import net.sourceforge.czt.z.ast.ConstDecl;
  import net.sourceforge.czt.z.ast.Decl;
  import net.sourceforge.czt.z.ast.Expr;
  import net.sourceforge.czt.z.ast.ImpliesExpr;
  import net.sourceforge.czt.z.ast.MemPred;
  import net.sourceforge.czt.z.ast.NameList;
  import net.sourceforge.czt.z.ast.NarrSect;
  import net.sourceforge.czt.z.ast.NumExpr;
  import net.sourceforge.czt.z.ast.OrPred;
  import net.sourceforge.czt.z.ast.Pred;
  import net.sourceforge.czt.z.ast.RefExpr;
  import net.sourceforge.czt.z.ast.SchExpr;
  import net.sourceforge.czt.z.ast.SchText;
  import net.sourceforge.czt.z.ast.SetExpr;
  import net.sourceforge.czt.z.ast.Spec;
  import net.sourceforge.czt.z.ast.TupleExpr;
  import net.sourceforge.czt.z.ast.VarDecl;
  import net.sourceforge.czt.z.ast.ZDeclList;
  import net.sourceforge.czt.z.ast.ZExprList;
  import net.sourceforge.czt.z.ast.ZNameList;
  import net.sourceforge.czt.z.ast.ZParaList;
  import net.sourceforge.czt.z.ast.ZSchText;
  import net.sourceforge.czt.z.ast.ZSect;
  
  public class PrinterUtil {
  	
  	public static String specAsString (Spec spec) {
      	ZSect zSect;
      	if (spec.getSect().get(0) instanceof NarrSect)
      		zSect = (ZSect) spec.getSect().get(1);
      	else
      		zSect = (ZSect) spec.getSect().get(0);
          ZParaList paras = (ZParaList) zSect.getParaList();
          String str = "";
  		for (int i = 0; i < paras.size(); i++) {
  			if (paras.get(i) instanceof ChannelPara) {
  				str = str + channelParaAsString ((ChannelPara)paras.get(i)) + "
  ";
  			}
  			else if (paras.get(i) instanceof ProcessPara) {
              	ProcessPara para = (ProcessPara) paras.get(i); //Aqui vai invocar os visitadores dos paragrafos que nao forem narrativos (com texto), ou de tags de Latex
              	String paraName = para.getZName().toString();
              	str = "
  " + str + processParaString (para, spec) + "
  ";
  			}
  		}
  		str = str + "
  ";
  		return str;
  	}
  	private static String channelParaAsString (ChannelPara channelPara) {
  		ZDeclList decls = channelPara.getZDeclList();
  		String declsstring = printZDeclList (decls);
  		return "Channel " + declsstring;
  	}
  	public static String printCalls (CircusAction action, CircusProcess process, Spec spec) {
  		Vector <String> callsvec = CallUtil.recursiveCalls (/*action, */process, spec);
  		String str = "Action: " + printAction (action, spec) + "
  Calls: ";
  		for (int i = 0; i < callsvec.size(); i++) {
  			str = str + callsvec.elementAt(i) + ", ";
  		}
  		return str;
  	}
  	public static void printCallsPane (CircusAction action, CircusProcess process, Spec spec) {
  		JOptionPane.showMessageDialog (null, printCalls (action, process, spec));
  	}
  	public static String printAxPara (AxPara axpara) {
  		String namelist = "NameList :: " + printZNameList (axpara.getZNameList());
  		String zschtext = "ZSchText :: " + printZSchText (axpara.getZSchText());
  		return "AxPara :: [" + namelist + " , " + zschtext + "]";
  	}
  	public static String printZSchText (ZSchText schtext) {
  		String decllist = "DeclList :: " + printZDeclList (schtext.getZDeclList());
  		String pred = "Predicate :: " + printPred (schtext.getPred());
  		return decllist + " , " + pred;
  	}
  	public static String printZNameList (ZNameList namelist) {
  		int size = namelist.size();
  		String str = "[";
  		for (int i = 0; i < size; i++) {
  			str = str + namelist.get (i);
  			if (i < size - 1)
  				str = str + ", ";
  		}
  		return str + "]";
  	}
  	public static String printBasicProcess (BasicProcess process, Spec spec) { //OBS: Este metodo pode ser aprimorado tbm para imprimir acoes de esquema e estados 
  		String str = "";
  		str = str + "begin
  ";
  		ZParaList paraList = process.getZParaList();
  		for (int i = 0; i < paraList.size(); i++) {
  			if (paraList.get(i) instanceof ActionPara) {
  				ActionPara para = (ActionPara) paraList.get(i);
  				str = str + "          " + para.getName().toString() + " ^= " + printAction (para.getCircusAction(), spec) + "
  ";
  			}
  			else if (paraList.get(i) instanceof AxPara) {
  				AxPara para = (AxPara) paraList.get(i);
  				str = str + "          " + para.getName().toString() + printAxPara (para);
  			}
  		}
  		str = str + "end
  ";
  		return str;
  	}
  	public static String printParamProcess (ParamProcess process) { //TODO
  		return "";
  	}
  	public static String processParaString (ProcessPara processPara, Spec spec) {
  		String str = "";
  		str = str + "process " + processPara.getName().toString() + " ^= " + printProcess (processPara.getCircusProcess(), spec);
  		return str;
  	}
  	public static void printProcessPara (ProcessPara processPara, Spec spec) {
  		System.out.println ("WWWW00WW :: " + processParaString (processPara, spec));
  	}
  	public static void printProcessPara (String paraname, CircusProcess process, Spec spec) {
  		System.out.println (paraname + " ^= " + PrinterUtil.printProcess(process, spec));
  	}
  	public static String printActionPara (ActionPara actionPara, Spec spec) {
  		return actionPara.getName().toString() + " ^= " + printAction (actionPara.getCircusAction(), spec) + "
  ";
  	}
  	public static String printChannelSet (CircusProcess process, Spec spec) {
  		Vector <String> strChanSet = ChanSetUtil.channelSet(process, spec);
  		String str = "";
  		for (int i = 0; i < strChanSet.size(); i++) {
  			str = str + strChanSet.elementAt(i);
  			if (i < strChanSet.size() - 1) {
  				str = str + ", ";
  			}
  		}
  		return str;
  	}
  	public static String printChannelSet (CircusAction action, Spec spec) {
  		Vector <String> strChanSet = ChanSetUtil.channelSet(action, spec);
  		String str = "";
  		for (int i = 0; i < strChanSet.size(); i++) {
  			str = str + strChanSet.elementAt(i);
  			if (i < strChanSet.size() - 1) {
  				str = str + ", ";
  			}
  		}
  		return str;
  	}
  	public static String printCommunication (Communication comm) {
  		String str = "";
  		String channel = comm.getChannelExpr().getZName().toString();
  		CircusFieldList cfl = comm.getCircusFieldList();
  		int size = cfl.size();
  		str = channel;
  		for (int i = 0; i < size; i++) {
  			Field field = cfl.get(i);
  			if (field instanceof InputField) {
  				str = str + "?" + ((InputField)field).getVariableZName().toString();
  			}
  			else if (field instanceof DotField && ChanDotFieldEnv.hasOutputFieldAnn (field)) {
  				str = str + "!" + printExpression (((DotField)field).getExpr());
  			}
  			else {
  				str = str + "." + printExpression (((DotField)field).getExpr());
  			}
  		}
  		return str;
  	}
  	public static String printPred (Pred pred) { //QUANDO INVOCADO, LEVA O MÉTODO printExpression a um loop infinito
  		if (pred instanceof MemPred) {
  			MemPred mp = (MemPred)pred;
  			Expr exprleft = mp.getLeftExpr();
  			Expr exprright = mp.getRightExpr();
  			if (mp.getMixfix()) {
  				return "(" + printExpression (((MemPred)pred).getLeftExpr()) + " = " + printExpression (((MemPred)pred).getRightExpr());
  			}
  			else {
  				return "(" + printExpression (((MemPred)pred).getLeftExpr()) + " OP " + printExpression (((MemPred)pred).getRightExpr());
  			}
  		}
  		else if (pred instanceof AndPred) {
  			AndPred ap = (AndPred)pred;
  			return printPred (ap.getLeftPred()) + " AND " + printPred (ap.getRightPred());
  		}
  		else if (pred instanceof OrPred) {
  			OrPred ap = (OrPred)pred;
  			return printPred (ap.getLeftPred()) + " OR " + printPred (ap.getRightPred());
  		}
  		else {
  			return "PREDICADO";
  		}
  	}
  	public static String printVarDecl (VarDecl decl) {
  		String str = "";
  		ZNameList nameList = decl.getZNameList();
  		int size = nameList.size();
  		str = str + printZNameList (nameList);
  		/*for (int i = 0; i < size; i++) {
  			str = str + nameList.get(i).toString();
  			if (i < size - 1)
  				str = str + ", ";
  		}*/
  		String expression = PrinterUtil.printExpression(decl.getExpr());
  		str = str + ": " + expression;
  		return str;
  	}
  	public static String printZDeclList (ZDeclList declList) {
  		String str = "";
  		int size = declList.size();
  		for (int i = 0; i < size; i++) {
  			Decl decl = declList.get(i);
  			if (decl instanceof VarDecl) {
  				str = str + "[" + printVarDecl ((VarDecl)decl) + "]";
  				if (i < size - 1)
  					str = str + ", ";
  			}
  			else if (decl instanceof ConstDecl) {
  				str = str + "[" + printConstDecl ((ConstDecl)decl) + "]";
  				if (i < size - 1)
  					str = str + ", ";
  			}
  			else if (decl instanceof ChannelDecl) {
  				str = str + "[" + printChannelDecl ((ChannelDecl)decl) + "]";
  				if (i < size - 1)
  					str = str + ", ";
  			}
  		}
  		return str;
  	}
  	public static String printChannelDecl (ChannelDecl decl) {
  		String channelliststring = printZNameList (decl.getZChannelNameList());
  		Expr expr = decl.getExpr();
  		String exprstring = printExpression (decl.getExpr());
  		return channelliststring + " : " + exprstring;
  	}
  	public static String printConstDecl (ConstDecl decl) {
  		return decl.getZName().toString() + " : " + printExpression (decl.getExpr());
  	}
  	public static String printAction (CircusAction action, Spec spec) {
  		//String str = "";
  		if (action instanceof ParamAction) {
  			return printZDeclList (((ParamAction)action).getZDeclList()) + " @ " + printAction (((ParamAction)action).getCircusAction(), spec);
  		}
  		else if (action instanceof ExtChoiceAction) {
  			return "(" + printAction (((ExtChoiceAction)action).getLeftAction(), spec) + " [] " + printAction (((ExtChoiceAction)action).getRightAction(), spec) + ")";
  		}
  		else if (action instanceof IntChoiceAction) {
  			return "(" + printAction (((IntChoiceAction)action).getLeftAction(), spec) + " |~| " + printAction (((IntChoiceAction)action).getRightAction(), spec) + ")";
  		}
  		else if (action instanceof SeqAction) {
  			return "(" + printAction (((SeqAction)action).getLeftAction(), spec) + " ; " + printAction (((SeqAction)action).getRightAction(), spec) + ")";
  		}
  		else if (action instanceof ParallelAction) {
  			return "(" + 
  					printAction (((ParallelAction)action).getLeftAction(), spec) + 
  					" |{" + printChannelSet (action, spec) +  "}| " +
  					printAction (((ParallelAction)action).getRightAction(), spec) + ")";
  		}
  		else if (action instanceof InterleaveAction) {
  			return "(" + printAction (((InterleaveAction)action).getLeftAction(), spec) + " |{" + printChannelSet (action, spec) +  "}| " + printAction (((InterleaveAction)action).getRightAction(), spec) + ")";
  		}
  		else if (action instanceof PrefixingAction) {
  			String commName = ((PrefixingAction)action).getCommunication().getChannelExpr().getName().toString();
  			//return commName + " -> " + printAction (((PrefixingAction)action).getCircusAction());
  			return printCommunication (((PrefixingAction)action).getCommunication()) + " -> " + printAction (((PrefixingAction)action).getCircusAction(), spec);
  		}
  		else if (action instanceof GuardedAction) {
  			return "(" + /*"(PREDICADO)"*/ printPred (((GuardedAction)action).getPred()) + " & " + printAction (((GuardedAction)action).getCircusAction(), spec) + ")";
  		}
  		else if (action instanceof MuAction) {
  			return "u" + ((MuAction)action).getName().toString() + " @ " + printAction (((MuAction)action).getCircusAction(), spec);
  		}
  		else if (action instanceof HideAction) {
  			return "(" + printAction (((HideAction)action).getCircusAction(), spec) + ")";
  		}
  		else if (action instanceof SkipAction) {
  			return "SKIP";
  		}
  		else if (action instanceof StopAction) {
  			return "STOP";
  		}
  		else if (action instanceof ChaosAction) {
  			return "CHAOS";
  		}
  		else if (action instanceof CallAction) {
  			ZExprList callexprs = ((CallAction)action).getZExprList();
  			int size = callexprs.size();
  			String ret = ((CallAction)action).getZName().toString();
  			for (int i = 0; i < size; i++) {
  				if (i == 0) {
  					ret = ret + " ( ";
  				}
  				ret = ret + printExpression (callexprs.get(i));
  				if (i == size - 1) {
  					ret = ret + " )";
  				}
  			}
  			return ret;
  			//return ((CallAction)action).getZName().toString() + " ( " + printExpression ();
  		}
  		else if (action instanceof RenameAction) {
  			return printAction (((RenameAction)action).getCircusAction(), spec) + printAssignmentPairs (((RenameAction)action).getAssignmentPairs());
  		}
  		else if (action instanceof CircusCommand) {
  			if (action instanceof VarDeclCommand) {
  				VarDeclCommand vdc = (VarDeclCommand)action;
  				String printDeclList = "";
  				if (vdc != null) {
  					if (vdc.getDeclList() != null)
  						printDeclList = printZDeclList (vdc.getZDeclList());
  				}
  				String printAction = printAction (vdc.getCircusAction(), spec);
  				return "[" + printDeclList + "]" + printAction;
  			}
  			else if (action instanceof AssignmentCommand) {
  				String str = "";
  				AssignmentCommand as = (AssignmentCommand)action;
  				ZNameList names = as.getAssignmentPairs().getZLHS();
  				ZExprList exprs = as.getAssignmentPairs().getZRHS();
  				for (int i = 0; i < names.size(); i++) {
  					str = str + names.get(i).toString();
  					if (i < names.size() - 1) {
  						str = str + ", ";
  					}
  				}
  				str = str + " = ";
  				for (int i = 0; i < exprs.size(); i++) {
  					str = str + printExpression (exprs.get(i));
  					if (i < exprs.size() - 1) {
  						str = str + ", ";
  					}
  				}
  				return str;
  			}
  			else if (action instanceof IfGuardedCommand) {
  				IfGuardedCommand igc = (IfGuardedCommand)action;
  				CircusActionList actions = (CircusActionList) igc.getActionList();
  				String str = "if (PREDICADO) then ";
  				for (int i = 0; i < actions.size(); i++) {
  					str = str + printAction (actions.get(i), spec);
  					if (i < actions.size() - 2) {
  						str = str + " else if ";
  					}
  					else if (i < actions.size() - 1) {
  						str = str + " else ";
  					}
  					else {
  						str = str + " endif";
  					}
  				}
  				return str;
  			}
  			else {//if (action instanceof SpecStmtCommand) {
  				return "";
  			}
  		}
  		else {
  			return "";
  		}
  	}
  	private static String printSchExpr (SchExpr schexpr) {
  		String str = "SchExpr { " + printZSchText (schexpr.getZSchText()) + " }";
  		return str;
  	}
  	public static String printExpression (Expr expr) {
  		System.out.println ("-------------||||||||----------");
  		if (expr instanceof RefExpr) {
  			return ((RefExpr)expr).getZName().toString();
  		}
  		else if (expr instanceof NumExpr) {
  			return ((NumExpr)expr).getValue().toString();
  		}
  		else if (expr instanceof TupleExpr) {
  			String str = "";
  			TupleExpr expr2 = (TupleExpr)expr;
  			ZExprList exprs = expr2.getZExprList();
  			for (int i = 0; i < exprs.size(); i++) {
  				str = str + printExpression (exprs.get(i));
  				if (i < exprs.size() - 1)
  					str = str + "; ";
  			}
  			return str;
  		}
  		else if (expr instanceof ApplExpr) {
  			String str = "";
  			String left = printExpression (((ApplExpr) expr).getLeftExpr());
  			String right = printExpression (((ApplExpr) expr).getRightExpr());
  			str = str + "(" + left + " [" + right + "]" + ")";
  			return str;
  		}
  		else if (expr instanceof SetExpr) {
  			String str = "SetExpr {";
  			SetExpr setexpr = (SetExpr)expr;
  			ZExprList exprs = setexpr.getZExprList();
  			int size = exprs.size();
  			for (int i = 0; i < size; i++) {
  				str = str + exprs.get(i);
  				if (i < size - 1) {
  					str = str + ", ";
  				}
  			}
  			return str + "}";
  		}
  		else if (expr instanceof SchExpr) {
  			return printSchExpr ((SchExpr)expr);
  		}
  		else {
  			return "EXPR";
  		}
  	}
  	public static String printProcess (CircusProcess process, Spec spec) {
  		String str = "";
  		if (process instanceof ExtChoiceProcess) {
  			return "(" + printProcess (((ExtChoiceProcess)process).getLeftProcess(), spec) + " [] " + printProcess (((ExtChoiceProcess)process).getRightProcess(), spec) + ")";
  		}
  		else if (process instanceof IntChoiceProcess) {
  			return "(" + printProcess (((IntChoiceProcess)process).getLeftProcess(), spec) + " |~| " + printProcess (((IntChoiceProcess)process).getRightProcess(), spec) + ")";
  		}
  		else if (process instanceof SeqProcess) {
  			return "(" + printProcess (((SeqProcess)process).getLeftProcess(), spec) + " ; " + printProcess (((SeqProcess)process).getRightProcess(), spec) + ")";
  		}
  		else if (process instanceof ParProcess) {
  			if (process instanceof ParallelProcess) {
  				return 
  						"(" + printProcess (((ParProcess)process).getLeftProcess(), spec) + 
  						" |{" + printChannelSet (process, spec) + "}| " 
  						+ printProcess (((ParProcess)process).getRightProcess(), spec) + ")";
  			}
  			else /*if (process instanceof InterleaveProcess)*/ {
  				return "(" + printProcess (((ParProcess)process).getLeftProcess(), spec) + " ||| " + printProcess (((ParProcess)process).getRightProcess(), spec) + ")";
  			}
  		}
  		else if (process instanceof HideProcess) {
  			return "(" + printProcess (((HideProcess)process).getCircusProcess(), spec) + ")";
  		}
  		else if (process instanceof CallProcess) {
  			return ((CallProcess)process).getCallExpr().getZName().toString();
  		}
  		else if (process instanceof RenameProcess) {
  			return printProcess (((RenameProcess)process).getCircusProcess(), spec) + printAssignmentPairs (((RenameProcess)process).getAssignmentPairs());
  		}
  		else if (process instanceof BasicProcess) {
  			return printBasicProcess ((BasicProcess)process, spec);
  		}
  		else if (process instanceof ParamProcess) {
  			ZDeclList decls = ((ParamProcess)process).getZDeclList();
  			return " (params) " + printBasicProcess (((ParamProcess)process).getCircusBasicProcess(), spec);//action.getClass().toString();
  		}
  		else {
  			return " Process to have its implementation exhibited ";
  		}
  	}
  	public static String printAssignmentPairs (AssignmentPairs ap) {
  		ZNameList lhs = (ZNameList) ap.getLHS();
  		ZNameList rhs = (ZNameList) ap.getRHS();
  		String str = "";
  		for (int i = 0; i < lhs.size(); i++) {
  			str = str + lhs.get(i).toString() + " <- " + rhs.get(i).toString();
  			if (i < lhs.size() - 1) {
  				str = str + ", ";
  			}
  		}
  		return str;
  	}
  	public static String printAnns4Action (CircusAction action, Spec spec) { //TODO ERRADO
  		String str = "";
  		if (action instanceof MuAction) {
  			MuAction act = (MuAction) action;
  			String name = act.getName().toString();
  			return "(mu" + name + " * " + printAnns4Action (act.getCircusAction(), spec) + ")";
  		}
  		/*else if (action instanceof CircusCommand) {
  			
  		}*/
  		else if (action instanceof ExtChoiceAction) {
  			return "(" + printAnns4Action (((ExtChoiceAction)action).getLeftAction(), spec) + " [] " + printAnns4Action (((ExtChoiceAction)action).getRightAction(), spec) + ")";
  		}
  		else if (action instanceof IntChoiceAction) {
  			return "(" + printAnns4Action (((IntChoiceAction)action).getLeftAction(), spec) + " |~| " + printAnns4Action (((IntChoiceAction)action).getRightAction(), spec) + ")";
  		}
  		else if (action instanceof SeqAction) {
  			return "(" + printAnns4Action (((SeqAction)action).getLeftAction(), spec) + " ; " + printAnns4Action (((SeqAction)action).getRightAction(), spec) + ")";
  		}
  		else if (action instanceof ParAction) {
  			return "(" + printAnns4Action (((ParAction)action).getLeftAction(), spec) + " || " + printAnns4Action (((ParAction)action).getRightAction(), spec) + ")";
  		}
  		else if (action instanceof PrefixingAction || action instanceof CallAction) {
  			return " " + action.getAnn(Integer.class) + " ";
  		}
  		else if (action instanceof GuardedAction) {
  			return "(" + printAction (((GuardedAction)action).getCircusAction(), spec) + ")";
  		}
  		else if (action instanceof HideAction) {
  			return "(" + printAction (((HideAction)action).getCircusAction(), spec) + ")";
  		}
  		else if (action instanceof SkipAction) {
  			return "SKIP";
  		}
  		else if (action instanceof ChaosAction) {
  			return "CHAOS";
  		}
  		else if (action instanceof CallAction) {
  			return ((CallAction)action).getName().toString();
  		}
  		else {
  			return "ACTION";
  		}
  	}
  	public static int countCallActions (CircusAction action, int counter) {
  		if (action instanceof CallAction) {
  			counter++;
  			return counter;
  		}
  		else if (action instanceof Action2) {
  			return countCallActions (((Action2)action).getLeftAction(), counter) + countCallActions (((Action2)action).getRightAction(), counter);
  		}
  		else if (action instanceof Action1) {
  			return countCallActions (((Action1)action).getCircusAction(), counter);
  		}
  		else if (action instanceof CircusCommand) {
  			if (action instanceof AssignmentCommand) {
  				return 0;
  			}
  			else if (action instanceof VarDeclCommand) {
  				return countCallActions (((VarDeclCommand)action).getCircusAction(), counter);
  			}
  			else if (action instanceof IfGuardedCommand) {
  				CircusActionList cal = ((IfGuardedCommand)action).getGuardedActionList();
  				int size = cal.size();
  				int ifguardedcounter = 0;
  				for (int i = 0; i < size; i++) {
  					CircusAction act = cal.get(i);
  					ifguardedcounter += countCallActions (act, counter);
  				}
  				return ifguardedcounter;
  			}
  			else {
  				ExceptionUtil.throwImplementationException("PrinterUtil.countCallActions", action.getClass());
  				return 0;
  			}
  		}
  		else if (action instanceof BasicAction) {
  			return 0;
  		}
  		else {
  			ExceptionUtil.throwImplementationException("PrinterUtil.countCallActions", action.getClass());
  			return 0;
  		}
  	}
  }