Beispiel #1
0
        void ParseStructMemberDeclaration(Modifiers m)
        {
            TypeKind type; int op;
            if (la.kind == 17) {
            m.Check(constantsMod);
            Get();
            ParseType(out type, false);
            Expect(1);
            Expect(86);
            ParseExpression();
            while (la.kind == 88) {
                Get();
                Expect(1);
                Expect(86);
                ParseExpression();
            }
            Expect(116);
            } else if (la.kind == 26) {
            m.Check(propEvntMethsMod);
            Get();
            ParseType(out type, false);
            if (IsFieldDecl()) {
                ParseVariableDeclarators(m);
                Expect(116);
            } else if (la.kind == 1) {
                ParseTypeName();
                Expect(97);
                ParseEventAccessorDeclarations();
                Expect(113);
            } else SynErr(157);
            } else if (kindInContext(la.kind) == _ident && Peek(1).kind == _lpar) {
            m.Check(constructorsMod|staticConstrMod);
            Expect(1);
            Expect(99);
            if (StartOf(7)) {
                m.Check(constructorsMod);
                ParseFormalParameterList();
            }
            Expect(115);
            if (la.kind == 87) {
                m.Check(constructorsMod);
                Get();
                if (la.kind == 8) {
                    Get();
                } else if (la.kind == 68) {
                    Get();
                } else SynErr(158);
                Expect(99);
                if (StartOf(15)) {
                    ParseArgument();
                    while (la.kind == 88) {
                        Get();
                        ParseArgument();
                    }
                }
                Expect(115);
            } else if (la.kind == 97 || la.kind == 116) {
            } else SynErr(159);
            if (la.kind == 97) {
                ParseBlock();
            } else if (la.kind == 116) {
                Get();
            } else SynErr(160);
            } else if (la.kind == 31) {
            Get();
            ParseType(out type, true);
            Expect(1);
            Expect(98);
            ParseExpression();
            Expect(114);
            Expect(116);
            } else if (IsTypeDeclaration()) {
            ParseTypeDeclaration(m);
            } else if (StartOf(16)) {
            if ("partial".Equals(la.val)) {
                Expect(1);
            }
            ParseType(out type, true);
            if (la.kind == 49) {
                m.Check(operatorsMod);
                m.CheckMust(operatorsMustMod);
                if (type == TypeKind.@void) { Error("operator not allowed on void"); }

                Get();
                ParseOverloadableOp(out op);
                Expect(99);
                ParseType(out type, false);
                Expect(1);
                if (la.kind == 88) {
                    Get();
                    ParseType(out type, false);
                    if ((op & binaryOp) == 0) Error("too many operands for unary operator");
                    Expect(1);
                } else if (la.kind == 115) {
                    if ((op & unaryOp) == 0) Error("too few operands for binary operator");
                } else SynErr(161);
                Expect(115);
                if (la.kind == 97) {
                    ParseBlock();
                } else if (la.kind == 116) {
                    Get();
                } else SynErr(162);
            } else if (IsFieldDecl()) {
                m.Check(fieldsMod);
                if (type == TypeKind.@void) { Error("field type must not be void"); }

                ParseVariableDeclarators(m);
                Expect(116);
            } else if (la.kind == 1) {
                ParseMemberName();
                if (la.kind == 97) {
                    m.Check(propEvntMethsMod);
                    if (type == TypeKind.@void) { Error("property type must not be void"); }

                    Get();
                    ParseAccessorDeclarations(m);
                    Expect(113);
                } else if (la.kind == 91) {
                    m.Check(indexersMod);
                    if (type == TypeKind.@void) { Error("indexer type must not be void"); }

                    Get();
                    Expect(68);
                    Expect(98);
                    ParseFormalParameterList();
                    Expect(114);
                    Expect(97);
                    ParseAccessorDeclarations(m);
                    Expect(113);
                } else if (la.kind == 99 || la.kind == 101) {
                    m.Check(propEvntMethsMod);
                    if (la.kind == 101) {
                        ParseTypeParameterList();
                    }
                    Expect(99);
                    if (StartOf(7)) {
                        ParseFormalParameterList();
                    }
                    Expect(115);
                    while (la.kind == 1) {
                        ParseTypeParameterConstraintsClause();
                    }
                    if (la.kind == 97) {
                        ParseBlock();
                    } else if (la.kind == 116) {
                        Get();
                    } else SynErr(163);
                } else SynErr(164);
            } else if (la.kind == 68) {
                m.Check(indexersMod);
                if (type == TypeKind.@void) { Error("indexer type must not be void"); }

                Get();
                Expect(98);
                ParseFormalParameterList();
                Expect(114);
                Expect(97);
                ParseAccessorDeclarations(m);
                Expect(113);
            } else SynErr(165);
            } else if (la.kind == 27 || la.kind == 37) {
            m.Check(operatorsMod);
            m.CheckMust(operatorsMustMod);

            if (la.kind == 37) {
                Get();
            } else {
                Get();
            }
            Expect(49);
            ParseType(out type, false);
            if (type == TypeKind.@void) { Error("cast type must not be void"); }
            Expect(99);
            ParseType(out type, false);
            Expect(1);
            Expect(115);
            if (la.kind == 97) {
                ParseBlock();
            } else if (la.kind == 116) {
                Get();
            } else SynErr(166);
            } else SynErr(167);
        }