public NvdlSection Pop() { NvdlSection ret = this [List.Count - 1]; List.RemoveAt(List.Count - 1); return(ret); }
private void PopulateInterp( NvdlDispatcher d, NvdlInterpretation i, NvdlSection parentState) { SimpleMode m = FindContextMode(i.Action, parentState); SimpleRule rule = FindElementRule(m, dispatcher.Reader); NvdlDebug.Writer.WriteLine("***** populate interp from action {0} whose mode is {1}. Rule is {2} whose actions are {3}", i.Action.Location, m.Location, rule.Location, rule.Actions.Length); foreach (SimpleAction a in rule.Actions) { NvdlInterpretation cur = i; for (; cur != null; cur = cur.Parent) { if (cur.CreatedMode == m && cur.Action == a) { NvdlDebug.Writer.WriteLine("------- corresponding PlanElem already exists."); break; } } if (cur == null) { cur = CreateInterp(d, m, a, i); } ilist.Add(cur); } }
private bool MatchPath(SimplePath path, NvdlSection parentState) { var stack = parentState.elementNameStack.ToArray(); if (stack.Length == 0) { return(false); } int elemStep = stack.Length - 1; for (int i = path.Steps.Length - 1; i >= 0 && elemStep >= 0;) { SimplePathStep ps = path.Steps [i]; if (ps.Name != stack [elemStep] as string) { // reject a/b while allow a//b if (!ps.Descendants) { return(false); } --elemStep; } else { i--; elemStep--; } } return(true); }
public NvdlSection(NvdlDispatcher dispatcher, NvdlSection parentState) { this.dispatcher = dispatcher; this.ns = dispatcher.Reader.NamespaceURI; if (parentState == null) { foreach (SimpleAction a in FindElementRule( dispatcher.Rules.StartMode, dispatcher.Reader).Actions) { ilist.Add(GetInterp(a, dispatcher)); } } else { foreach (NvdlInterpretation pi in parentState.ilist) { PopulateInterp(dispatcher, pi, parentState); } } NvdlDebug.Writer.WriteLine("New section: ns {0} / interp.count {1} / loc: {2}", ns, ilist.Count, ((IXmlLineInfo)dispatcher.Reader).LineNumber); }
NvdlSection GetSection(NvdlSection section) { if (section == null) { return(new NvdlSection(this, null)); } else if (section.Namespace != Reader.NamespaceURI) { return(new NvdlSection(this, section)); } else if (qnameStack.Count > 0 && rules.Triggers.Length > 0) { for (int t = 0; t < rules.Triggers.Length; t++) { SimpleTrigger st = rules.Triggers [t]; XmlQualifiedName parent = (XmlQualifiedName)qnameStack.Peek(); if (st.Cover(Reader.LocalName, Reader.NamespaceURI) && !st.Cover(parent.Name, parent.Namespace)) { NvdlDebug.Writer.WriteLine("======== triggered by {0}", st.Location); return(new NvdlSection(this, section)); } } } return(section); }
public void StartElement () { NvdlDebug.Writer.WriteLine (" <dispatcher.StartElement {0}. stack depth: {1}. current section ns {2}", Reader.Name, sectionStack.Count, section == null ? "(none)" : section.Namespace); NvdlSection prev = section; section = GetSection (section); section.StartElement (); if (Reader.IsEmptyElement) { section.EndSection (); section = prev; } else { sectionStack.Push (section); qnameStack.Push (new XmlQualifiedName (Reader.LocalName, Reader.NamespaceURI)); } }
private SimpleMode FindContextMode(SimpleAction a, NvdlSection parentState) { if (a.Contexts != null) { foreach (SimpleContext ctx in a.Contexts) { foreach (SimplePath path in ctx.Path) { if (MatchPath(path, parentState)) { return(ctx.UseMode); } } } } return(a.DefaultMode); }
private SimpleMode FindContextMode(SimpleAction a, NvdlSection parentState) { if (a.Contexts != null) { foreach (SimpleContext ctx in a.Contexts) { foreach (SimplePath path in ctx.Path) { if (MatchPath(path, parentState)) { NvdlDebug.Writer.WriteLine("------ matched context at {0}.", ctx.Location); return(ctx.UseMode); } } } } return(a.DefaultMode); }
public void StartElement() { NvdlDebug.Writer.WriteLine(" <dispatcher.StartElement {0}. stack depth: {1}. current section ns {2}", Reader.Name, sectionStack.Count, section == null ? "(none)" : section.Namespace); NvdlSection prev = section; section = GetSection(section); section.StartElement(); if (Reader.IsEmptyElement) { section.EndSection(); section = prev; } else { sectionStack.Push(section); qnameStack.Push(new XmlQualifiedName(Reader.LocalName, Reader.NamespaceURI)); } }
private bool MatchPath(SimplePath path, NvdlSection parentState) { ArrayList stack = parentState.elementNameStack; if (stack.Count == 0) { return(false); } int elemStep = stack.Count - 1; for (int i = path.Steps.Length - 1; i >= 0 && elemStep >= 0;) { SimplePathStep ps = path.Steps [i]; if (ps.Name != stack [elemStep] as string) { // reject a/b while allow a//b if (!ps.Descendants) { return(false); } --elemStep; } else { i--; elemStep--; } } NvdlDebug.Writer.Write("------ matched path: "); for (int i = 0; i < stack.Count; i++) { NvdlDebug.Writer.Write('[' + (string)stack [i] + ']'); } NvdlDebug.Writer.Write(" -> "); for (int i = 0; i < path.Steps.Length; i++) { NvdlDebug.Writer.Write('[' + path.Steps [i].Name + ']'); } NvdlDebug.Writer.WriteLine(); return(true); }
NvdlSection GetSection (NvdlSection section) { if (section == null) return new NvdlSection (this, null); else if (section.Namespace != Reader.NamespaceURI) return new NvdlSection (this, section); else if (qnameStack.Count > 0 && rules.Triggers.Length > 0) { for (int t = 0; t < rules.Triggers.Length; t++) { SimpleTrigger st = rules.Triggers [t]; XmlQualifiedName parent = (XmlQualifiedName) qnameStack.Peek (); if (st.Cover (Reader.LocalName, Reader.NamespaceURI) && !st.Cover (parent.Name, parent.Namespace)) { NvdlDebug.Writer.WriteLine ("======== triggered by {0}", st.Location); return new NvdlSection (this, section); } } } return section; }
public void EndElement() { NvdlDebug.Writer.WriteLine(" <dispatcher.EndElement {0}. depth: {1}", Reader.Name, sectionStack.Count); if (section != null) { section = sectionStack.Pop(); section.EndElement(); section.EndSection(); if (sectionStack.Count > 0) { section = sectionStack.Peek(); } else { section = null; } } qnameStack.Pop(); }
public NvdlSection(NvdlDispatcher dispatcher, NvdlSection parentState) { this.dispatcher = dispatcher; this.ns = dispatcher.Reader.NamespaceURI; if (parentState == null) { foreach (SimpleAction a in FindElementRule( dispatcher.Rules.StartMode, dispatcher.Reader).Actions) { ilist.Add(GetInterp(a, dispatcher)); } } else { foreach (NvdlInterpretation pi in parentState.ilist) { PopulateInterp(dispatcher, pi, parentState); } } }
private void PopulateInterp( NvdlDispatcher d, NvdlInterpretation i, NvdlSection parentState) { SimpleMode m = FindContextMode(i.Action, parentState); SimpleRule rule = FindElementRule(m, dispatcher.Reader); foreach (SimpleAction a in rule.Actions) { NvdlInterpretation cur = i; for (; cur != null; cur = cur.Parent) { if (cur.CreatedMode == m && cur.Action == a) { break; } } if (cur == null) { cur = CreateInterp(d, m, a, i); } ilist.Add(cur); } }
public NvdlSection (NvdlDispatcher dispatcher, NvdlSection parentState) { this.dispatcher = dispatcher; this.ns = dispatcher.Reader.NamespaceURI; if (parentState == null) { foreach (SimpleAction a in FindElementRule ( dispatcher.Rules.StartMode, dispatcher.Reader).Actions) ilist.Add (GetInterp (a, dispatcher)); } else { foreach (NvdlInterpretation pi in parentState.ilist) { PopulateInterp (dispatcher, pi, parentState); } } NvdlDebug.Writer.WriteLine ("New section: ns {0} / interp.count {1} / loc: {2}", ns, ilist.Count, ((IXmlLineInfo) dispatcher.Reader).LineNumber); }
private void PopulateInterp ( NvdlDispatcher d, NvdlInterpretation i, NvdlSection parentState) { SimpleMode m = FindContextMode (i.Action, parentState); SimpleRule rule = FindElementRule (m, dispatcher.Reader); NvdlDebug.Writer.WriteLine ("***** populate interp from action {0} whose mode is {1}. Rule is {2} whose actions are {3}", i.Action.Location, m.Location, rule.Location, rule.Actions.Length); foreach (SimpleAction a in rule.Actions) { NvdlInterpretation cur = i; for (;cur != null; cur = cur.Parent) if (cur.CreatedMode == m && cur.Action == a) { NvdlDebug.Writer.WriteLine ("------- corresponding PlanElem already exists."); break; } if (cur == null) cur = CreateInterp (d, m, a, i); ilist.Add (cur); } }
public void Push(NvdlSection state) { List.Add(state); }
private SimpleMode FindContextMode (SimpleAction a, NvdlSection parentState) { if (a.Contexts != null) foreach (SimpleContext ctx in a.Contexts) foreach (SimplePath path in ctx.Path) if (MatchPath (path, parentState)) { NvdlDebug.Writer.WriteLine ("------ matched context at {0}.", ctx.Location); return ctx.UseMode; } return a.DefaultMode; }
private bool MatchPath (SimplePath path, NvdlSection parentState) { ArrayList stack = parentState.elementNameStack; if (stack.Count == 0) return false; int elemStep = stack.Count - 1; for (int i = path.Steps.Length - 1; i >= 0 && elemStep >= 0;) { SimplePathStep ps = path.Steps [i]; if (ps.Name != stack [elemStep] as string) { // reject a/b while allow a//b if (!ps.Descendants) return false; --elemStep; } else { i--; elemStep--; } } NvdlDebug.Writer.Write ("------ matched path: "); for (int i = 0; i < stack.Count; i++) NvdlDebug.Writer.Write ('[' + (string) stack [i] + ']'); NvdlDebug.Writer.Write (" -> "); for (int i = 0; i < path.Steps.Length; i++) NvdlDebug.Writer.Write ('[' + path.Steps [i].Name + ']'); NvdlDebug.Writer.WriteLine (); return true; }
public void Push (NvdlSection state) { List.Add (state); }
public void EndElement () { NvdlDebug.Writer.WriteLine (" <dispatcher.EndElement {0}. depth: {1}", Reader.Name, sectionStack.Count); if (section != null) { section = sectionStack.Pop (); section.EndElement (); section.EndSection (); if (sectionStack.Count > 0) section = sectionStack.Peek (); else section = null; } qnameStack.Pop (); }