/// <summary> /// When visiting a product name with key and value node, in case the current vistor is searching for the key, returns the key. /// In case it's a value, tries to find children using different strategies. /// </summary> /// <param name="context">The context of the current node<see cref="UserAgentParser.ProductNameKeyValueContext"/>.</param> /// <returns>The found children as <see cref="IEnumerator{IParseTree}"/>.</returns> public override IEnumerator <IParseTree> VisitProductNameKeyValue([NotNull] UserAgentParser.ProductNameKeyValueContext context) { switch (this.name) { case UserAgentTreeFlattener.KEY: var list = new List <ParserRuleContext>() { context.key }; return(list.GetEnumerator()); case UserAgentTreeFlattener.VALUE: var children = context.multipleWords().Select(s => s as IParseTree).ToList(); if (children.Count != 0) { return(children.GetEnumerator()); } children = context.keyValueProductVersionName().Select(s => s as IParseTree).ToList(); if (children.Count != 0) { return(children.GetEnumerator()); } children = context.siteUrl().Select(s => s as IParseTree).ToList(); if (children.Count != 0) { return(children.GetEnumerator()); } children = context.emailAddress().Select(s => s as IParseTree).ToList(); if (children.Count != 0) { return(children.GetEnumerator()); } children = context.uuId().Select(s => s as IParseTree).ToList(); return(children.GetEnumerator()); default: return(this.GetChildrenByName(context)); } }
/// <summary> /// When a product name key value is found. /// </summary> /// <param name="context">The context node.</param> public override void EnterProductNameKeyValue([NotNull] UserAgentParser.ProductNameKeyValueContext context) { this.Inform(context, "name.(1)keyvalue", context.GetText(), false); this.InformSubstrings(context, NAME, true); }
/// <summary> /// Visit a parse tree produced by <see cref="UserAgentParser.productNameKeyValue"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitProductNameKeyValue([NotNull] UserAgentParser.ProductNameKeyValueContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by <see cref="UserAgentParser.productNameKeyValue"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitProductNameKeyValue([NotNull] UserAgentParser.ProductNameKeyValueContext context) { }