public static IType Parse(this CSharpParser.TypeContext context) { IType currenType = context.base_type().Parse(); IParseTree[] children = context.children.ToArray(); for (int i = 1; i < children.Length; i++) { IParseTree child = children[i]; if (child is TerminalNodeImpl) { TerminalNodeImpl node = (TerminalNodeImpl)child; if (node.IsType(CSharpLexer.INTERR)) { currenType = new NullableType(currenType); } else if (node.IsType(CSharpLexer.STAR)) { currenType = new PointerType(currenType); } else { throw new NotSupportedException(""); } } else if (child is CSharpParser.Rank_specifierContext) { CSharpParser.Rank_specifierContext rank = (CSharpParser.Rank_specifierContext)child; currenType = new ArrayType(currenType, rank.Parse()); } else { throw new NotSupportedException("Unknown type " + child.GetText()); } } return(currenType); }
public static int Parse(this CSharpParser.Rank_specifierContext context) { return(context.GetTokens(CSharpLexer.COMMA).Length + 1); }