public override Result VisitDevice([NotNull] testParser.DeviceContext context) { var ident = context.IDENT(); var deviceStr = ident.GetText().ToUpper(); Device device; if (!Device.TryParse(deviceStr, out device)) { return(Result.CreateError("解析できなかったデバイス:" + deviceStr)); } return(Result.CreateSuccess(device)); }
/// <summary> /// Exit a parse tree produced by <see cref="testParser.device"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitDevice([NotNull] testParser.DeviceContext context) { }
/// <summary> /// Visit a parse tree produced by <see cref="testParser.device"/>. /// <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 VisitDevice([NotNull] testParser.DeviceContext context) { return(VisitChildren(context)); }