private TypeSynonymNode ToTypeSynonymNode(OpaqueTypeDecl ot) { Console.WriteLine("Type synonym: " + ot.Name); var dc = new DocComment(ot.DocComment); return(new TypeSynonymNode { Name = ot.Name, TypeParams = ot.TypeArgs.Select(tp => ToTypeParamNode(tp, dc)).ToList(), Rhs = null, UserDoc = dc.MainBody, Token = ToTokenNode(ot.tok), }); }
void OtherTypeDecl(ModuleDefinition module, out TopLevelDecl td) { IToken id; Attributes attrs = null; var eqSupport = TypeParameter.EqualitySupportValue.Unspecified; var typeArgs = new List<TypeParameter>(); td = null; Type ty; Expect(80); while (la.kind == 46) { Attribute(ref attrs); } NoUSIdent(out id); if (la.kind == 50) { Get(); Expect(54); Expect(51); eqSupport = TypeParameter.EqualitySupportValue.Required; if (la.kind == 52) { GenericParameters(typeArgs); } } else if (StartOf(4)) { if (la.kind == 52) { GenericParameters(typeArgs); } if (la.kind == 67) { Get(); Type(out ty); td = new TypeSynonymDecl(id, id.val, typeArgs, module, ty, attrs); } } else SynErr(146); if (td == null) { td = new OpaqueTypeDecl(id, id.val, module, eqSupport, typeArgs, attrs); } if (la.kind == 28) { while (!(la.kind == 0 || la.kind == 28)) {SynErr(147); Get();} Get(); errors.Warning(t, "the semi-colon that used to terminate an opaque-type declaration has been deprecated; in the new syntax, just leave off the semi-colon"); } }
void OtherTypeDecl(DeclModifierData dmod, ModuleDefinition module, out TopLevelDecl td) { IToken id, bvId; Attributes attrs = null; var eqSupport = TypeParameter.EqualitySupportValue.Unspecified; var typeArgs = new List<TypeParameter>(); td = null; Type ty = null; Expression constraint; var kind = "Opaque type"; Expect(85); while (la.kind == 50) { Attribute(ref attrs); } NoUSIdent(out id); if (la.kind == 54) { Get(); Expect(58); Expect(55); eqSupport = TypeParameter.EqualitySupportValue.Required; if (la.kind == 56) { GenericParameters(typeArgs); } } else if (StartOf(7)) { if (la.kind == 56) { GenericParameters(typeArgs); } if (la.kind == 74) { Get(); if (IsIdentColonOrBar()) { NoUSIdent(out bvId); if (la.kind == 22) { Get(); Type(out ty); } if (ty == null) { ty = new InferredTypeProxy(); } Expect(24); Expression(out constraint, false, true); td = new SubsetTypeDecl(id, id.val, typeArgs, module, new BoundVar(bvId, bvId.val, ty), constraint, attrs); kind = "Subset type"; } else if (StartOf(6)) { Type(out ty); td = new TypeSynonymDecl(id, id.val, typeArgs, module, ty, attrs); kind = "Type synonym"; } else SynErr(160); } } else SynErr(161); if (td == null) { td = new OpaqueTypeDecl(id, id.val, module, eqSupport, typeArgs, attrs); } CheckDeclModifiers(dmod, kind, AllowedDeclModifiers.None); if (la.kind == 30) { while (!(la.kind == 0 || la.kind == 30)) {SynErr(162); Get();} Get(); errors.Deprecated(t, "the semi-colon that used to terminate an opaque-type declaration has been deprecated; in the new syntax, just leave off the semi-colon"); } }