Exemplo n.º 1
0
        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");
            }
        }
Exemplo n.º 2
0
        void NewtypeDecl(DeclModifierData dmod, ModuleDefinition module, out TopLevelDecl td)
        {
            IToken id, bvId;
            Attributes attrs = null;
            td = null;
            Type baseType = null;
            Expression wh;
            CheckDeclModifiers(dmod, "Newtypes", AllowedDeclModifiers.None);

            Expect(84);
            while (la.kind == 50) {
            Attribute(ref attrs);
            }
            NoUSIdent(out id);
            Expect(74);
            if (IsIdentColonOrBar()) {
            NoUSIdent(out bvId);
            if (la.kind == 22) {
                Get();
                Type(out baseType);
            }
            if (baseType == null) { baseType = new InferredTypeProxy(); }
            Expect(24);
            Expression(out wh, false, true);
            td = new NewtypeDecl(theVerifyThisFile ? id : new IncludeToken(id), id.val, module, new BoundVar(bvId, bvId.val, baseType), wh, attrs);
            } else if (StartOf(6)) {
            Type(out baseType);
            td = new NewtypeDecl(theVerifyThisFile ? id : new IncludeToken(id), id.val, module, baseType, attrs);
            } else SynErr(159);
        }