return res;
}
+/**
+ * Returns the size of an entity node.
+ *
+ * @param kind the entity kind
+ */
static size_t get_entity_struct_size(entity_kind_t kind)
{
static const size_t sizes[] = {
return sizes[kind];
}
+/**
+ * Allocate an entity of given kind and initialize all
+ * fields with zero.
+ */
static entity_t *allocate_entity_zero(entity_kind_t kind)
{
size_t size = get_entity_struct_size(kind);
/**
* Allocate a statement node of given kind and initialize all
- * fields with zero.
+ * fields with zero. Sets its source position to the position
+ * of the current token.
*/
static statement_t *allocate_statement_zero(statement_kind_t kind)
{
}
/**
- * Creates a new invalid expression.
+ * Creates a new invalid expression at the source position
+ * of the current token.
*/
static expression_t *create_invalid_expression(void)
{
}
/**
- * Adds a token to the token anchor set (a multi-set).
+ * Adds a token type to the token type anchor set (a multi-set).
*/
static void add_anchor_token(int token_type)
{
++token_anchor_set[token_type];
}
+/**
+ * Set the number of tokens types of the given type
+ * to zero and return the old count.
+ */
static int save_and_reset_anchor_state(int token_type)
{
assert(0 <= token_type && token_type < T_LAST_TOKEN);
return count;
}
+/**
+ * Restore the number of token types to the given count.
+ */
static void restore_anchor_state(int token_type, int count)
{
assert(0 <= token_type && token_type < T_LAST_TOKEN);
}
/**
- * Remove a token from the token anchor set (a multi-set).
+ * Remove a token type from the token type anchor set (a multi-set).
*/
static void rem_anchor_token(int token_type)
{
--token_anchor_set[token_type];
}
+/**
+ * Return true if the token type of the current token is
+ * in the anchor set.
+ */
static bool at_anchor(void)
{
if (token.type < 0)
}
/**
- * Eat tokens until a matching token is found.
+ * Eat tokens until a matching token type is found.
*/
static void eat_until_matching_token(int type)
{
}
}
+/**
+ * Eat a whoel block from input tokens.
+ */
static void eat_block(void)
{
eat_until_matching_token('{');
}
/**
- * Expect the the current token is the expected token.
+ * Expect the current token is the expected token.
* If not, generate an error, eat the current statement,
* and goto the end_error label.
*/
next_token(); \
} while (0)
+/**
+ * Push a given scope on the scope stack and make it the
+ * current scope
+ */
static scope_t *scope_push(scope_t *new_scope)
{
if (current_scope != NULL) {
return old_scope;
}
+/**
+ * Pop the current scope from the scope stack.
+ */
static void scope_pop(scope_t *old_scope)
{
current_scope = old_scope;
return (int) akind;
}
+/**
+ * Return the type rank for an atomic type.
+ */
static int get_rank(const type_t *type)
{
assert(!is_typeref(type));
return get_akind_rank(type->atomic.akind);
}
+/**
+ * Do integer promotion for a given type.
+ *
+ * @param type the type to promote
+ * @return the promoted type
+ */
static type_t *promote_integer(type_t *type)
{
if (type->kind == TYPE_BITFIELD)
}
/**
- * Check if a given expression represents the 0 pointer constant.
+ * Check if a given expression represents the NULL constant.
+ *
+ * @param expression the expression to check
*/
static bool is_null_pointer_constant(const expression_t *expression)
{
}
/**
- * Allocate a new gnu temporal attribute.
+ * Allocate a new gnu temporal attribute of given kind.
*/
static gnu_attribute_t *allocate_gnu_attribute(gnu_attribute_kind_t kind)
{
}
/**
- * parse one constant expression argument.
+ * Parse one constant expression argument of the given attribute.
*/
static void parse_gnu_attribute_const_arg(gnu_attribute_t *attribute)
{
}
/**
- * parse a list of constant expressions arguments.
+ * Parse a list of constant expressions arguments of the given attribute.
*/
static void parse_gnu_attribute_const_arg_list(gnu_attribute_t *attribute)
{
}
/**
- * parse one string literal argument.
+ * Parse one string literal argument of the given attribute.
*/
static void parse_gnu_attribute_string_arg(gnu_attribute_t *attribute,
string_t *string)
}
/**
- * parse one tls model.
+ * Parse one tls model of the given attribute.
*/
static void parse_gnu_attribute_tls_model_arg(gnu_attribute_t *attribute)
{
}
/**
- * parse one tls model.
+ * Parse one tls model of the given attribute.
*/
static void parse_gnu_attribute_visibility_arg(gnu_attribute_t *attribute)
{
}
/**
- * parse one (code) model.
+ * Parse one (code) model of the given attribute.
*/
static void parse_gnu_attribute_model_arg(gnu_attribute_t *attribute)
{
attribute->invalid = true;
}
+/**
+ * Parse one mode of the given attribute.
+ */
static void parse_gnu_attribute_mode_arg(gnu_attribute_t *attribute)
{
/* TODO: find out what is allowed here... */
}
/**
- * parse one interrupt argument.
+ * Parse one interrupt argument of the given attribute.
*/
static void parse_gnu_attribute_interrupt_arg(gnu_attribute_t *attribute)
{
}
/**
- * parse ( identifier, const expression, const expression )
+ * Parse ( identifier, const expression, const expression )
*/
static void parse_gnu_attribute_format_args(gnu_attribute_t *attribute)
{
attribute->u.value = true;
}
+/**
+ * Check that a given GNU attribute has no arguments.
+ */
static void check_no_argument(gnu_attribute_t *attribute, const char *name)
{
if (!attribute->have_arguments)