Loyc.Syntax.CodeSymbols.CountArrayDimensions C# (CSharp) Method

CountArrayDimensions() public static method

Returns the rank of an array symbol when IsArrayKeyword is true, or 0 if the symbol does not represent an array type.
public static CountArrayDimensions ( Symbol s ) : int
s Symbol
return int
		public static int CountArrayDimensions(Symbol s)
		{
			if (s.Name.Length >= 3 && s.Name.StartsWith("#[") && s.Name[s.Name.Length-1] == ']') {
				for (int i = 2; i < s.Name.Length-1; i++)
					if (s.Name[i] != ',')
						return 0;
				return s.Name.Length-2;
			}
			return 0;
		}
		/// <summary>Gets the Symbol for an array with the specified number of 

Usage Example

Exemplo n.º 1
0
        int CountDimensionsIfArrayType(LNode type)
        {
            LNode dimsNode;

            if (type.Calls(S.Of, 2) && (dimsNode = type.Args[0]).IsId)
            {
                return(S.CountArrayDimensions(dimsNode.Name));
            }
            return(0);
        }
All Usage Examples Of Loyc.Syntax.CodeSymbols::CountArrayDimensions