Example #1
0
        Aggregate *new_aggregate(SrcPos pos, AggregateKind kind, AggregateItem *items, int num_items)
        {
            Aggregate *aggregate = (Aggregate *)ast_alloc(sizeof(Aggregate));

            aggregate->pos       = pos;
            aggregate->kind      = kind;
            aggregate->items     = items;
            aggregate->num_items = num_items;
            return(aggregate);
        }
Example #2
0
        Aggregate new_aggregate(SrcPos pos, AggregateKind kind, AggregateItem[] items, int num_items)
        {
            Aggregate aggregate;

            aggregate.pos       = pos;
            aggregate.kind      = kind;
            aggregate.items     = items;
            aggregate.num_items = num_items;
            return(aggregate);
        }
Example #3
0
        Aggregate *parse_aggregate(AggregateKind kind)
        {
            SrcPos pos = token.pos;

            expect_token(TOKEN_LBRACE);
            var items = Buffer <AggregateItem> .Create(16);

            while (!is_token_eof() && !is_token(TOKEN_RBRACE))
            {
                var item = parse_decl_aggregate_item();
                items.Add(item);
            }
            expect_token(TOKEN_RBRACE);
            return(new_aggregate(pos, kind, items, items.count));
        }
Example #4
0
        Decl *parse_decl_aggregate(SrcPos pos, DeclKind kind)
        {
            assert(kind == DECL_STRUCT || kind == DECL_UNION);
            var           name           = parse_name();
            AggregateKind aggregate_kind = kind == DECL_STRUCT ? AGGREGATE_STRUCT : AGGREGATE_UNION;

            if (match_token(TOKEN_SEMICOLON))
            {
                Decl *decl = new_decl_aggregate(pos, kind, name, new_aggregate(pos, aggregate_kind, null, 0));
                decl->is_incomplete = true;
                return(decl);
            }
            else
            {
                return(new_decl_aggregate(pos, kind, name, parse_aggregate(aggregate_kind)));
            }
        }