X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fparser_proc_grammar.y;h=38194e9764131f0cc9b12728e0bff65b8caf5b50;hb=1d04e9e995fdc2fdfcd469c05d1bffdbda86f3f5;hp=bb8a9ce89d72faed460782ebd1c97f10707d0af5;hpb=c9384515a81cb64d345b299908b2852f51bb8e6e;p=m6w6%2Fext-psi diff --git a/src/parser_proc_grammar.y b/src/parser_proc_grammar.y index bb8a9ce..38194e9 100644 --- a/src/parser_proc_grammar.y +++ b/src/parser_proc_grammar.y @@ -456,12 +456,8 @@ block: } } | lib { - if (P->file.ln) { - P->error(PSI_DATA(P), $lib, PSI_WARNING, - "Extra 'lib \"%s\"' statement has no effect", $lib->text); - } else { - P->file.ln = strndup($lib->text, $lib->size); - } + char *libname = strdup($lib->text); + P->file.libnames = psi_plist_add(P->file.libnames, &libname); } | constant { psi_parser_proc_add_const(P, $constant); @@ -1115,9 +1111,10 @@ decl_extvar_stmt[list]: if (psi_decl_extvar_is_blacklisted(var->name)) { psi_decl_var_free(&var); } else { - list = psi_plist_add(list, psi_decl_extvar_init( - psi_decl_arg_init(psi_decl_type_copy($decl_arg->type), var))); - } + struct psi_decl_extvar *evar = psi_decl_extvar_init( + psi_decl_arg_init(psi_decl_type_copy($decl_arg->type), var)); + list = psi_plist_add(list, &evar); + } } free($vars); } @@ -1152,20 +1149,20 @@ decl_vars[vars]: ; ignored_decl: - STATIC decl_body ignored_decl_body { - $ignored_decl = $decl_body; -} -| STATIC CPP_INLINE decl_body ignored_decl_body { - $ignored_decl = $decl_body; -} -| CPP_INLINE decl_body ignored_decl_body { - $ignored_decl = $decl_body; -} -| NAME CPP_INLINE decl_body ignored_decl_body { + ignored_decl_qualifiers decl_body ignored_decl_body { $ignored_decl = $decl_body; } ; +ignored_decl_qualifiers: + STATIC +| STATIC CPP_INLINE +| CPP_EXTENSION CPP_INLINE +| CPP_EXTENSION STATIC CPP_INLINE +| CPP_INLINE +| NAME CPP_INLINE +; + ignored_decl_body: LBRACE ignored_decl_body_stmts RBRACE ; @@ -1250,7 +1247,31 @@ decl_functor_body[decl]: func->token = psi_token_copy($NAME); $decl = psi_decl_init(func, $args); +} +| qualified_decl_type[rval_type] indirection[i] LPAREN indirection[unused1] LPAREN indirection[unused2] name_token[NAME] RPAREN LPAREN decl_args[args] RPAREN RPAREN LPAREN decl_args[rval_args] RPAREN array_size[as] { + (void) $unused1; + (void) $unused2; + $NAME->type = PSI_T_NAME; + struct psi_token *type_token = psi_token_append("@", psi_token_copy($NAME), 1, "rval"); + struct psi_decl_arg *rval_func = psi_decl_arg_init($rval_type, psi_decl_var_init(type_token->text, $i, 0)); + struct psi_decl *rval_decl = psi_decl_init(rval_func, $rval_args); + + rval_func->var->token = psi_token_copy(type_token); + rval_func->token = psi_token_copy(type_token); + if ($as) { + rval_func->var->pointer_level += 1; + rval_func->var->array_size = $as; + } + + struct psi_decl_type *type = psi_decl_type_init(PSI_T_FUNCTION, type_token->text); + struct psi_decl_arg *func = psi_decl_arg_init(type, psi_decl_var_init($NAME->text, 1, 0)); + + type->real.func = rval_decl; + func->var->token = psi_token_copy($NAME); + func->token = psi_token_copy($NAME); + + $decl = psi_decl_init(func, $args); } ;