/* ibicc - The Ibi C Compiler Copyright (C) 2004 Antti-Juhani Kaijanaho Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef CPARSER_H #define CPARSER_H #include "ibicpp.h" /* The parser_t structures and all returned nodes are allocated from * the ibicc_source_t arena, so destroying the ibicc_source_t will * also destroy the pareser_t and all nodes. */ typedef struct parser_state *parser_t; parser_t parse_init(ibicpp_source_t); struct expr_node *parse_expr(parser_t); void parse_decl(parser_t); #define IBICC_TOK_LVALUECONV (IBICPP_FIRST_UNUSED+0) /* lvalue -> rvalue conv oper */ struct expr_node { unsigned null_pointer_constant : 1; unsigned constant_expr : 1; unsigned lvalue : 1; unsigned sequence_point : 1; /* between e1 and e2 */ struct type_node *ty; short oper; struct expr_node *e1; struct expr_node *e2; }; struct member_node { char const *name; struct type_node *ty; size_t bits; /* number of bits in bit field; if 0, not a bit field */ }; /* _Bool is T_INTEGRAL, width == 1 */ struct type_node { enum { T_VOID, T_INTEGRAL, T_FLOAT, T_ARRAY, T_POINTER, T_STRUCT, T_UNION, T_FUNCTION } tag; unsigned unsignd : 1; unsigned constq : 1; unsigned volatileq : 1; unsigned restrictq : 1; size_t width; /* for numeric types: number of value bits; * for structs and unions: number of members * for arrays: declared length, zero if incomplete */ size_t sizof; /* number of bytes in an object of this type, * including mandatory padding */ char const *aggr_tag; /* struct TAG or union TAG */ struct member_node *membs; }; #endif /* CPARSER_H */