X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fparser_proc.y;h=0d0aa61ceb99a33824033d2b030a3400595b2348;hp=409987729a8a1dca3f20f46a8ce3df03aebe14d6;hb=5359ad5c181e5772f350fe1cba060cbed3a05b91;hpb=04a60b34fc18ea3a2638893eaf24514177692eeb diff --git a/src/parser_proc.y b/src/parser_proc.y index 4099877..0d0aa61 100644 --- a/src/parser_proc.y +++ b/src/parser_proc.y @@ -1,4 +1,10 @@ %include { +#ifdef HAVE_CONFIG_H +# include "config.h" +#else +# include "php_config.h" +#endif + #include #include #include @@ -8,12 +14,12 @@ #include "parser.h" } %include { void psi_error(int, const char *, int, const char *, ...); } -%name PSI_ParserProc +%name psi_parser_proc_ %token_prefix PSI_T_ -%token_type {PSI_Token *} +%token_type {struct psi_token *} %token_destructor {free($$);} %default_destructor {(void)P;} -%extra_argument {PSI_Parser *P} +%extra_argument {struct psi_parser *P} %syntax_error { ++P->errors; if (TOKEN && TOKEN->type != PSI_T_EOF) { psi_error(PSI_WARNING, TOKEN->file, TOKEN->line, "PSI syntax error: Unexpected token '%s'", TOKEN->text); } else { psi_error(PSI_WARNING, P->psi.file.fn, P->line, "PSI syntax error: Unexpected end of input"); } } %nonassoc NAME. %left PLUS MINUS. @@ -197,8 +203,8 @@ enum_name(n) ::= ENUM(E) optional_name(N). { free(E); } else { char digest[17]; - PSI_TokenHash(E, digest); - n = PSI_TokenTranslit(PSI_TokenAppend(E, 1, digest), " ", "@"); + psi_token_hash(E, digest); + n = psi_token_translit(psi_token_append(E, 1, digest), " ", "@"); } } decl_enum(e) ::= enum_name(N) LBRACE decl_enum_items(list) RBRACE. { @@ -225,8 +231,8 @@ union_name(n) ::= UNION(U) optional_name(N). { free(U); } else { char digest[17]; - PSI_TokenHash(U, digest); - n = PSI_TokenTranslit(PSI_TokenAppend(U, 1, digest), " ", "@"); + psi_token_hash(U, digest); + n = psi_token_translit(psi_token_append(U, 1, digest), " ", "@"); } } struct_name(n) ::= STRUCT(S) optional_name(N). { @@ -235,8 +241,8 @@ struct_name(n) ::= STRUCT(S) optional_name(N). { free(S); } else { char digest[17]; - PSI_TokenHash(S, digest); - n = PSI_TokenTranslit(PSI_TokenAppend(S, 1, digest), " ", "@"); + psi_token_hash(S, digest); + n = psi_token_translit(psi_token_append(S, 1, digest), " ", "@"); } } decl_struct_args_block(args_) ::= LBRACE struct_args(args) RBRACE. { @@ -284,7 +290,7 @@ decl_typedef(def) ::= TYPEDEF(T) decl_typedef_body(def_) EOS. { } decl_typedef_body_ex(def) ::= struct_name(N) align_and_size(as) decl_struct_args_block(args) decl_var(var). { def = init_decl_arg(init_decl_type(PSI_T_STRUCT, N->text), var); - def->type->token = PSI_TokenCopy(N); + def->type->token = psi_token_copy(N); def->type->real.strct = init_decl_struct(N->text, args); def->type->real.strct->token = N; def->type->real.strct->align = as.pos; @@ -292,7 +298,7 @@ decl_typedef_body_ex(def) ::= struct_name(N) align_and_size(as) decl_struct_args } decl_typedef_body_ex(def) ::= union_name(N) align_and_size(as) decl_struct_args_block(args) decl_var(var). { def = init_decl_arg(init_decl_type(PSI_T_UNION, N->text), var); - def->type->token = PSI_TokenCopy(N); + def->type->token = psi_token_copy(N); def->type->real.unn = init_decl_union(N->text, args); def->type->real.unn->token = N; def->type->real.unn->align = as.pos; @@ -301,7 +307,7 @@ decl_typedef_body_ex(def) ::= union_name(N) align_and_size(as) decl_struct_args_ decl_typedef_body_ex(def) ::= decl_enum(e) NAME(ALIAS). { def = init_decl_arg(init_decl_type(PSI_T_ENUM, e->name), init_decl_var(ALIAS->text, 0, 0)); def->var->token = ALIAS; - def->type->token = PSI_TokenCopy(e->token); + def->type->token = psi_token_copy(e->token); def->type->real.enm = e; } decl_typedef_body(def) ::= decl_typedef_body_ex(def_). { @@ -312,7 +318,7 @@ decl_typedef_body_fn_args(args) ::= LPAREN decl_args(args_) RPAREN. { } decl_typedef_body(def) ::= decl_func(func_) decl_typedef_body_fn_args(args). { def = init_decl_arg(init_decl_type(PSI_T_FUNCTION, func_->var->name), copy_decl_var(func_->var)); - def->type->token = PSI_TokenCopy(func_->token); + def->type->token = psi_token_copy(func_->token); def->type->real.func = init_decl(init_decl_abi("default"), func_, args); } decl_typedef_body(def) ::= decl_arg(arg). { @@ -346,7 +352,7 @@ decl_typedef_body(def) ::= VOID(T) indirection(decl_i) LPAREN indirection(type_i copy_decl_var(func_->var) ); def->var->pointer_level = type_i; - def->type->token = PSI_TokenCopy(func_->token); + def->type->token = psi_token_copy(func_->token); def->type->real.func = init_decl(init_decl_abi("default"), func_, args); } decl_typedef_body(def) ::= CONST VOID(T) pointers(decl_i) LPAREN indirection(type_i) NAME(N) RPAREN decl_typedef_body_fn_args(args). { @@ -362,7 +368,7 @@ decl_typedef_body(def) ::= CONST VOID(T) pointers(decl_i) LPAREN indirection(typ copy_decl_var(func_->var) ); def->var->pointer_level = type_i; - def->type->token = PSI_TokenCopy(func_->token); + def->type->token = psi_token_copy(func_->token); def->type->real.func = init_decl(init_decl_abi("default"), func_, args); } decl_abi(abi) ::= NAME(T). { @@ -399,7 +405,7 @@ decl_typedef_body(def) ::= const_decl_type(type_) indirection(decl_i) LPAREN ind copy_decl_var(func_->var) ); def->var->pointer_level = type_i; - def->type->token = PSI_TokenCopy(func_->token); + def->type->token = psi_token_copy(func_->token); def->type->real.func = init_decl(init_decl_abi("default"), func_, args); } decl_arg(arg_) ::= VOID(T) pointers(p) NAME(N). { @@ -475,7 +481,7 @@ decl_scalar_type(type_) ::= CHAR(C). { } decl_scalar_type(type_) ::= SHORT(S) decl_scalar_type_short(s). { if (s) { - type_ = PSI_TokenCat(2, S, s); + type_ = psi_token_cat(2, S, s); free(S); free(s); } else { @@ -493,7 +499,7 @@ decl_scalar_type(type_) ::= INT(I). { } decl_scalar_type(type_) ::= LONG(L) decl_scalar_type_long(l). { if (l) { - type_ = PSI_TokenCat(2, L, l); + type_ = psi_token_cat(2, L, l); free(L); free(l); } else { @@ -508,7 +514,7 @@ decl_scalar_type_long(l) ::= DOUBLE(D). { } decl_scalar_type_long(l) ::= LONG(L) decl_scalar_type_long_long(ll). { if (ll) { - l = PSI_TokenCat(2, L, ll); + l = psi_token_cat(2, L, ll); free(L); free(ll); } else { @@ -522,14 +528,14 @@ decl_scalar_type_long_long(ll) ::= INT(I). { ll = I; } decl_type(type_) ::= UNSIGNED(U) decl_scalar_type(N). { - PSI_Token *T = PSI_TokenCat(2, U, N); + struct psi_token *T = psi_token_cat(2, U, N); type_ = init_decl_type(T->type, T->text); type_->token = T; free(U); free(N); } decl_type(type_) ::= SIGNED(S) decl_scalar_type(N). { - PSI_Token *T = PSI_TokenCat(2, S, N); + struct psi_token *T = psi_token_cat(2, S, N); type_ = init_decl_type(T->type, T->text); type_->token = T; free(S); @@ -637,7 +643,7 @@ num_exp(exp) ::= num_exp_token(tok). { } num_exp(exp) ::= decl_var(var). { exp = init_num_exp(PSI_T_NAME, var); - exp->token = PSI_TokenCopy(var->token); + exp->token = psi_token_copy(var->token); } num_exp(exp) ::= num_exp(exp_) num_exp_op_token(operator_) num_exp(operand_). { exp_->operator = operator_->type;