private int ParseMultipleRule(Node ruleNode, int currentRule, Dictionary <string, List <Node> > vars) { List <Node> children = ruleNode.GetChildren(); List <List <Entry> > inputEntries = new List <List <Entry> > (); List <List <Entry> > outputEntries = new List <List <Entry> > (); String policy; foreach (Node node in children[0].GetChildren()) { if ((node.GetNodeType() != Node.Type.TENTRY) && (node.GetNodeType() != Node.Type.TEVENT)) { throw new CloudMakefile.ParseException("The children of TENTRIES node should be of TENTRY type."); } outputEntries.Add(NFA.ParseTreeNode(node)); } foreach (Node node in children[1].GetChildren()) { if ((node.GetNodeType() != Node.Type.TENTRY) && (node.GetNodeType() != Node.Type.TEVENT)) { throw new CloudMakefile.ParseException("The children of TENTRIES node should be of TENTRY type."); } inputEntries.Add(NFA.ParseTreeNode(node)); } policy = ParseString(children [2]); return(ParseMultipleRule(inputEntries, outputEntries, policy, currentRule, vars, new Dictionary <string, NFA> ())); }
private int ParseMultipleRule(List <List <Entry> > inputEntries, List <List <Entry> > outputEntries, string policy, int currentRule, Dictionary <string, List <Node> > mVars, Dictionary <string, NFA> vars) { if (mVars.Count == 0) { ParseSingleRule(inputEntries, outputEntries, policy, currentRule, vars); return(currentRule + 1); } string varName = mVars.First().Key; List <Node> nodeList = mVars [varName]; int nextRule = currentRule; foreach (Node node in nodeList) { Dictionary <string, List <Node> > tempMVars = new Dictionary <string, List <Node> > (mVars); Dictionary <string, NFA> tempVars = new Dictionary <string, NFA> (vars); List <Entry> entryList = NFA.ParseTreeNode(node); if ((entryList.Count != 1) || (entryList [0].IsVar() != false)) { throw new CloudMakefile.ParseException("Variables should return only one NFA when parsed."); } tempMVars.Remove(varName); tempVars [varName] = entryList [0].GetNFA(); nextRule = ParseMultipleRule(inputEntries, outputEntries, policy, nextRule, tempMVars, tempVars); } return(nextRule); }