public override int ValidateElement(Identifier name, ValidationState context) { TerminalNode terminal = null; NamedNodeList lookup = (NamedNodeList)symbols[name.UniqueKey]; bool isTerminal = true; if (lookup == null) { isTerminal = false; lookup = new NamedNodeList(); lookup.Add(new NamedNode(name, null, null)); // fake it } foreach (NamedNode node in lookup) { if (contentRoot != null) { if (context.CurrentNode == null) { if (contentRoot.CanAccept(node)) { terminal = contentRoot.Accept(node, null, isTerminal, namedTerminals, context.RangeNodeCounters); break; } } else if (context.CurrentNode.CanAccept(node)) { terminal = context.CurrentNode.Parent.Accept(node, context.CurrentNode, isTerminal, namedTerminals, context.RangeNodeCounters); break; } } } if (terminal == null) { context.NeedValidateChildren = false; ValidateElementError(name, context); } context.CurrentNode = terminal; if (terminal != null) { context.ProcessContents = terminal.ProcessContents; } // result just indicates success or failure. return (terminal == null) ? -1 : 1; }
private NamedNode NewNamedTerminal(Identifier name, Member mem, TypeNode type) { NamedNode terminal = new NamedNode(name, mem, type); terminal.Pos = namedTerminalsArray.Count; namedTerminalsArray.Add(terminal); if (name != Identifier.Empty) { NamedNodeList list = (NamedNodeList)symbols[name.UniqueKey]; if (list == null) { list = new NamedNodeList(); symbols[name.UniqueKey] = list; } terminal.Symbol = symbolCount; symbolCount += list.Add(terminal); } return terminal; }