public override object VisitArrayType([NotNull] ClepsParser.ArrayTypeContext context) { ClepsType basicType = Visit(context.BaseType) as ClepsType; Debug.Assert(basicType != null); long[] dimensions = context._ArrayDimensions.Select(n => { long val; if (long.TryParse(n.GetText(), out val)) { return(val); } else { string errorMessage = String.Format("Expected a numeric value for array dimensions. However found {0} instead.", n.GetText()); Status.AddError(new CompilerError(FileName, n.Start.Line, n.Start.Column, errorMessage)); //in case of an error, try to gracefully continue by assuming the array dimensions is 1 return(1); } }).ToArray(); var ret = new ArrayClepsType(basicType, dimensions); return(ret); }
/// <summary> /// Exit a parse tree produced by <see cref="ClepsParser.ArrayType"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitArrayType([NotNull] ClepsParser.ArrayTypeContext context) { }
/// <summary> /// Visit a parse tree produced by <see cref="ClepsParser.ArrayType"/>. /// <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 VisitArrayType([NotNull] ClepsParser.ArrayTypeContext context) { return(VisitChildren(context)); }