public override BaseExpression VisitSelector([NotNull] ExpressionParser.SelectorContext context) { if (context.DOT() is not null) { var baseExpression = Visit(context.selector()); var fieldName = context.identifier().GetText(); return(new FieldSelectorExpression(baseExpression, fieldName)); } else if (context.LBRACKET() is not null) { throw new NotImplementedException(); } else if (context.functionInvoke() is not null) { return(Visit(context.functionInvoke())); } else { var thingName = context.identifier().GetText(); if (thingName.StartsWith("Year")) { throw new NotImplementedException("Year-qualified references not yet implemented."); } else if (thingName == "Form8949Code") { return(new Form8949CodeReferenceExpression()); } else if (thingName.StartsWith("Form")) { return(new FormReferenceExpression(thingName.Substring(4))); } else { var fieldName = context.identifier().GetText(); return(new FieldSelectorExpression(new FormReferenceExpression(_environment.CurrentFormName), fieldName)); } } }
/// <summary> /// Visit a parse tree produced by <see cref="ExpressionParser.selector"/>. /// <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 VisitSelector([NotNull] ExpressionParser.SelectorContext context) { return(VisitChildren(context)); }