public static IType NextType(this TokenStream toks, bool includeVoid) { string identifier = toks.GetIdentifierNext(); if (identifier == "void" && !includeVoid) { InfoProvider.AddError("Unexpected `void` type", ExceptionType.IllegalType, toks.SourcePosition); } int dimens = 0; while (!toks.Eof) { if (toks.IsNext("[")) { dimens++; } else { toks.PushBack(); break; } toks.CheckNext("]", ExceptionType.Brace); } if (identifier == "void" && dimens > 0) { InfoProvider.AddError("Unexpected `void` typed array", ExceptionType.IllegalType, toks.SourcePosition); } IType result; if (Compiler.IsPlainType(identifier)) { result = new PlainType(identifier); } else { result = new ClassType(identifier); } if (dimens != 0) { return(new ArrayType(result, dimens)); } return(result); }
public static bool IsPlainType(string type, bool includeVoid = false) { var dt = PlainType.FromString(type); return(!(dt == DataTypes.Null || (dt == DataTypes.Void && includeVoid))); }