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);
        }
Beispiel #2
0
        public CTFVariantType(CTFScope scope, CTFVaraintSpecifier vs)
        {
            tag   = vs.Cue.GetName();
            elems = new CTFVElem[vs.List.Count];
            int i = 0;

            foreach (CTFStructOrVariantDeclaration cd in vs.List)
            {
                CTFType ct   = GetType(scope, cd.List);
                string  name = cd.Cd.Name;
                elems[i++] = new CTFVElem(name, ct);
            }
        }