Пример #1
0
        internal static CTFTypeSpecifier ParseTypeSpecifier(CTFScope scope, TokParser tp)
        {
            Token.EnumId id = tp.Token.Id;
            switch (id)
            {
            case Token.EnumId.VOID:
            case Token.EnumId.CHAR:
            case Token.EnumId.SHORT:
            case Token.EnumId.INT:
            case Token.EnumId.FLOAT:
            case Token.EnumId.DOUBLE:
            case Token.EnumId.SIGNED:
            case Token.EnumId.BOOL:
            case Token.EnumId.COMPLEX:
            case Token.EnumId.IMAGINARY:
                throw new CTFException();     // unsupported

            case Token.EnumId.LONG:
            case Token.EnumId.UNSIGNED:
                tp.Next();
                return(Get(id));

            case Token.EnumId.STRUCT:
                return(CTFStructSpecifier.Parse(scope, tp));

            case Token.EnumId.VARIANT:
                return(CTFVaraintSpecifier.Parse(scope, tp));

            case Token.EnumId.ENUM:
                return(CTFEnumSpecifier.Parse(scope, tp));

            // ctf-type-specifier
            case Token.EnumId.FLOATING_POINT:
            case Token.EnumId.INTEGER:
                tp.Next();
                tp.MustBe(Token.EnumId.LCURL);
                List <CTFAssignmentExpression> cael = CTFAssignmentExpression.ParseList(scope, tp);
                tp.MustBe(Token.EnumId.RCURL);
                return(new CTFATypeSpecifier(id, cael));

            case Token.EnumId.STRING:
                tp.Next();
                return(Get(Token.EnumId.STRING));

            case Token.EnumId.IDEN:     // must be a type in a scope
                CTFTypeSpecifier ct = CTFNTypeSpecifier.Get(scope, tp.Token.Buffer);
                if (ct == null)
                {
                    return(null);
                }

                tp.Next();
                return(ct);
            }

            return(null);
        }
Пример #2
0
        private List <CTFAssignmentExpression> ParseAEList(TokParser tp)
        {
            tp.Next();
            tp.MustBe(Token.EnumId.LCURL);
            List <CTFAssignmentExpression> lcae = CTFAssignmentExpression.ParseList(scope, tp);

            if (lcae == null)
            {
                throw new CTFException();
            }

            tp.MustBe(Token.EnumId.RCURL);
            return(lcae);
        }