public override void Visit(Process p)
        {
            Set set = new Set();
            set.AddRange((Set)p.Parent.Tag);

            foreach (Variable var in p.ReadVariables) {
                if (!set.Contains(var)) {
                    _warnings.Add(new Warning(var.LexicalInfo, "Use of unassigned variable " + var.Name));
                }
            }
            set.AddRange(p.AssignedVariables);

            p.Tag = set;
        }
        public override void Visit(Process p)
        {
            Set set = new Set();
            foreach (Process child in p.FlowsTo) {
                set.AddRange((Set)child.Tag);
            }

            set.AddRange(p.ReadVariables);

            foreach (Variable var in p.AssignedVariables) {
                if (!set.Contains(var) && var.Name != Variable.NotUsedName) {
                    _warnings.Add(new Warning(var.LexicalInfo, "This assignment to variable " + var.Name + " has no effect, it is never read"));
                    var.IsUsed = false;
                }
                set.Remove(var);
            }
            p.Tag = set;
        }
 void ParallelComposition(out Process proc, string locality)
 {
     Process ap; ParallelComposition pc = new ParallelComposition();
     ActionPrefix(out ap, locality);
     pc.Add(ap);
     while (la.kind == 12) {
     Get();
     ActionPrefix(out ap, locality);
     pc.Add(ap);
     }
     if (pc.Processes.Count == 1) proc = pc.Processes[0]; else {proc = pc; CopyPos(pc.Processes[0],proc,t);}
 }
 void NonDeterministicChoice(out Process proc, string locality)
 {
     NonDeterministicChoice ndc = new NonDeterministicChoice(); Process pc = null;
     ParallelComposition(out pc, locality);
     ndc.Add(pc);
     while (la.kind == 11) {
     Get();
     ParallelComposition(out pc, locality);
     ndc.Add(pc);
     }
     if (ndc.Processes.Count == 1) {proc = ndc.Processes[0]; } else {proc = ndc; CopyPos(proc,ndc.Processes[0], t);}
 }
 void ActionPrefix(out Process proc, string locality)
 {
     Process nextproc = new NilProcess(); proc = null; Action action = null;
     if (la.kind == 17 || la.kind == 19 || la.kind == 20) {
     Action(out action, locality);
     if (la.kind == 13) {
         Get();
         ActionPrefix(out nextproc, locality);
     }
     proc = new ActionPrefix(action, nextproc); CopyPos(proc, action, t);
     } else if (la.kind == 14) {
     Get();
     Process(out proc, locality);
     Expect(15);
     } else if (la.kind == 16) {
     Get();
     proc = new NilProcess(); SetPos(proc, t);
     } else SynErr(27);
 }
 public virtual void Visit(Process node)
 {
 }
 void Process(out Process proc)
 {
     Token start = la;
     NonDeterministicChoice(out proc);
     SetPos(proc, start, t);
 }
 public virtual string Format(Process p, int highlightActionID)
 {
     if (highlightActionID != -1)
     {
         _highlightID = highlightActionID;
     }
     if (p is ActionPrefix) {
         return Format((ActionPrefix)p);
     } else if (p is NilProcess) {
         return Format((NilProcess)p);
     } else if (p is ProcessConstant) {
         return Format((ProcessConstant)p);
     } else if (p is NonDeterministicChoice) {
         return Format((NonDeterministicChoice)p);
     } else if (p is ParallelComposition) {
         return Format((ParallelComposition)p);
     }
     return "ERROR: UNKNOWN PROCESS";
 }
 void BranchProcess(out Process proc)
 {
     Expression exp = null; Process ifProc = null; Process elseProc = null;
     Expect(18);
     Expression(out exp);
     Expect(19);
     Process(out ifProc);
     Expect(20);
     Process(out elseProc);
     proc = new BranchProcess(exp, ifProc, elseProc);
 }
 void ActionPrefix(out Process proc)
 {
     ActionPrefix ap = null; ActionPrefix prev = null; ActionPrefix first = null; Process nextProc = null; ProcessConstant pc; proc = null; Action act = null;
     while (la.kind == 3 || la.kind == 5 || la.kind == 6) {
     Token startAction = la;
     Action(out act);
     ap = new ActionPrefix(act, null); SetStartPos(ap,startAction); if (first == null) first = ap; if (prev != null) { prev.Process = ap;} prev = ap;
     SetPos(act, startAction, t);
     Expect(16);
     }
     if (la.kind == 10) {
     Get();
     Process(out nextProc);
     Expect(12);
     nextProc.ParenCount++;
     } else if (la.kind == 17) {
     Get();
     nextProc = new NilProcess(); SetPos(nextProc, t);
     } else if (la.kind == 1) {
     ProcessConstantInvoke(out pc);
     nextProc = pc;
     } else if (la.kind == 18) {
     BranchProcess(out nextProc);
     } else SynErr(42);
     if (first == null) proc = nextProc; else {ap.Process = nextProc; proc = first;};
     if (la.kind == 21) {
     PreProcessActions ppa = null;
     Relabelling(out ppa);
     nextProc.PreProcessActions = ppa;
     }
     if (la.kind == 24) {
     ActionRestrictions ar = null;
     Restriction(out ar);
     nextProc.ActionRestrictions = ar;
     }
 }
 public BranchProcess(Expression exp, Process ifBranch, Process elseBranch)
 {
     _children.Add(exp);
     _children.Add(ifBranch);
     _children.Add(elseBranch);
 }
 public ActionPrefix(Action action, Process proc)
 {
     _children.Add(action);
     _children.Add(proc);
 }
 public ReplicatedProcess(Process p)
 {
     _children.Add(p);
 }
 void Process(out Process p, string locality)
 {
     p = null; bool replicated = false; int startAction = _actionNr; Token replTok = null;
     if (la.kind == 10) {
     Get();
     replicated = true; replTok = t;
     }
     NonDeterministicChoice(out p, locality);
     if (replicated) {
        if (!(p is ActionPrefix) || (p is ActionPrefix && !(((ActionPrefix)p).Action is InAction))) {
            errors.SemErr(replTok.line, replTok.col, "Replicated processes are required to start with an in action!");
         }
        p = new ReplicatedProcess(p);
       }
 }
 void NonDeterministicChoice(out Process proc)
 {
     Process pc; NonDeterministicChoice ndc = new NonDeterministicChoice();
     ParallelComposition(out pc);
     ndc.Add(pc);
     while (la.kind == 14) {
     Get();
     ParallelComposition(out pc);
     ndc.Add(pc);
     }
     if (ndc.Processes.Count == 1) {proc = ndc.Processes[0]; }else {proc = ndc; CopyPos(proc,ndc.Processes[0], t);}
 }
 public void Add(Process p)
 {
     _children.Add(p);
 }
 public virtual string Format(Process p)
 {
     return Format(p, -1);
 }