}
P->enums = psi_plist_add(P->enums, &e);
}
-static inline void psi_parser_proc_add_from_typedef(struct psi_parser *P, struct psi_decl_arg *def)
-{
- if (def->type->real.def) {
- switch (def->type->type) {
- case PSI_T_STRUCT:
- psi_parser_proc_add_struct(P, def->type->real.strct);
- break;
- case PSI_T_UNION:
- psi_parser_proc_add_union(P, def->type->real.unn);
- break;
- case PSI_T_ENUM:
- psi_parser_proc_add_enum(P, def->type->real.enm);
- break;
- default:
- break;
- }
- }
-}
static inline void psi_parser_proc_add_typedef(struct psi_parser *P, struct psi_decl_arg *def)
{
assert(def);
P->types = psi_plist_init((psi_plist_dtor) psi_decl_arg_free);
}
P->types = psi_plist_add(P->types, &def);
- psi_parser_proc_add_from_typedef(P, def);
}
static inline void psi_parser_proc_add_const(struct psi_parser *P, struct psi_const *cnst) {
assert(cnst);
%empty {
$sig = psi_plist_init(NULL);
}
+| ELLIPSIS {
+ $sig = psi_plist_init(NULL); /* FIXME */
+}
| cpp_macro_sig_args
+| cpp_macro_sig_args[args] COMMA ELLIPSIS {
+ $sig = $args;
+}
;
cpp_macro_sig_args[args]:
if (psi_num_exp_validate(PSI_DATA(P), $num, NULL, NULL, NULL, NULL, NULL)) {
impl_val res = {0};
token_t type = psi_num_exp_exec($num, &res, NULL, &P->preproc->defs);
-
+
if (type == PSI_T_FLOAT || type == PSI_T_DOUBLE) {
$val = psi_impl_def_val_init(type, NULL);
} else {
$val = psi_impl_def_val_init(PSI_T_INT, NULL);
}
-
+
switch (type) {
case PSI_T_UINT8: $val->ival.zend.lval = res.u8; break;
case PSI_T_UINT16: $val->ival.zend.lval = res.u16; break;
case PSI_T_DOUBLE: $val->ival.dval = res.dval; break;
default:
assert(0);
-
+
}
} else {
$val = NULL;
TYPEDEF typedef[def_] EOS {
$def = $def_;
}
+| TYPEDEF VOID name_token EOS {
+ $def = psi_decl_arg_init(
+ psi_decl_type_init(PSI_T_VOID, $VOID->text),
+ psi_decl_var_init($name_token->text, 0, 0)
+ );
+ $def->token = psi_token_copy($VOID);
+ $def->type->token = psi_token_copy($VOID);
+ $def->var->token = psi_token_copy($name_token);
+}
| CPP_EXTENSION TYPEDEF typedef[def_] EOS {
$def = $def_;
}
$def->var->token = psi_token_copy($name_token);
$def->type->token = psi_token_copy($enum->token);
$def->type->real.enm = $enum;
+ psi_parser_proc_add_enum(P, $enum);
}
| struct_name[struct] align_and_size[as] struct_args_block[args] decl_var[var] {
$def = psi_decl_arg_init(psi_decl_type_init(PSI_T_STRUCT, $struct->text), $var);
$def->type->real.strct->token = psi_token_copy($struct);
$def->type->real.strct->align = $as.pos;
$def->type->real.strct->size = $as.len;
+ psi_parser_proc_add_struct(P, $def->type->real.strct);
}
| union_name[union] align_and_size[as] struct_args_block[args] decl_var[var] {
$def = psi_decl_arg_init(psi_decl_type_init(PSI_T_UNION, $union->text), $var);
$def->type->real.unn->token = psi_token_copy($union);
$def->type->real.unn->align = $as.pos;
$def->type->real.unn->size = $as.len;
+ psi_parser_proc_add_union(P, $def->type->real.unn);
}
| const_decl_type[type] decl_stdint_type[stdint] {
$stdint->type = PSI_T_NAME;
%empty {
$as = 0;
}
+| LBRACKET RBRACKET {
+ $as = 0;
+}
| LBRACKET NUMBER RBRACKET {
$as = atol($NUMBER->text);
}
;
asterisks[a]:
- ASTERISK {
+ asterisk {
$a = 1;
}
-| asterisks[a_] ASTERISK {
+| asterisks[a_] asterisk {
$a = $a_ + 1;
}
;
+asterisk:
+ ASTERISK
+| ASTERISK CONST
+;
+
/*
*
* impl
| let_calloc[calloc] {
$exp = psi_let_exp_init(PSI_LET_CALLOC, $calloc);
}
+| STATIC let_calloc[calloc] {
+ $exp = psi_let_exp_init(PSI_LET_CALLOC, $calloc);
+ $calloc->static_memory = 1;
+}
| let_callback[callback] {
$exp = psi_let_exp_init(PSI_LET_CALLBACK, $callback);
}