From 1ad7a1e3d8da7b00a9e589c201fe79e5b9541692 Mon Sep 17 00:00:00 2001 From: Mitchell Blank Jr Date: Sun, 20 May 2012 00:19:38 -0700 Subject: C++ compilability: don't use "node" as both a type and a member I originally solved this by renaming the "node" type to "node_t", but Matz didn't like that. He suggested renaming the member variable "nd" instead: https://github.com/mruby/mruby/pull/144#issuecomment-5743153 --- src/parse.y | 94 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/parse.y b/src/parse.y index 4b1f02106..9a7748d30 100644 --- a/src/parse.y +++ b/src/parse.y @@ -813,7 +813,7 @@ var_reference(parser_state *p, node *lhs) %lex-param {parser_state *p} %union { - node *node; + node *nd; mrb_sym id; int num; unsigned int stack; @@ -871,28 +871,28 @@ var_reference(parser_state *p, node *lhs) keyword__ENCODING__ %token tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL -%token tINTEGER tFLOAT tCHAR tREGEXP -%token tSTRING tSTRING_PART -%token tNTH_REF tBACK_REF +%token tINTEGER tFLOAT tCHAR tREGEXP +%token tSTRING tSTRING_PART +%token tNTH_REF tBACK_REF %token tREGEXP_END -%type singleton string string_interp regexp -%type literal numeric cpath -%type top_compstmt top_stmts top_stmt -%type bodystmt compstmt stmts stmt expr arg primary command command_call method_call -%type expr_value arg_value primary_value -%type if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure -%type args call_args opt_call_args -%type paren_args opt_paren_args variable -%type command_args aref_args opt_block_arg block_arg var_ref var_lhs -%type command_asgn mrhs superclass block_call block_command -%type f_block_optarg f_block_opt -%type f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs -%type assoc_list assocs assoc undef_list backref for_var -%type block_param opt_block_param block_param_def f_opt -%type bv_decls opt_bv_decl bvar f_larglist lambda_body -%type brace_block cmd_brace_block do_block lhs none fitem f_bad_arg -%type mlhs mlhs_list mlhs_post mlhs_basic mlhs_item mlhs_node mlhs_inner +%type singleton string string_interp regexp +%type literal numeric cpath +%type top_compstmt top_stmts top_stmt +%type bodystmt compstmt stmts stmt expr arg primary command command_call method_call +%type expr_value arg_value primary_value +%type if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure +%type args call_args opt_call_args +%type paren_args opt_paren_args variable +%type command_args aref_args opt_block_arg block_arg var_ref var_lhs +%type command_asgn mrhs superclass block_call block_command +%type f_block_optarg f_block_opt +%type f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs +%type assoc_list assocs assoc undef_list backref for_var +%type block_param opt_block_param block_param_def f_opt +%type bv_decls opt_bv_decl bvar f_larglist lambda_body +%type brace_block cmd_brace_block do_block lhs none fitem f_bad_arg +%type mlhs mlhs_list mlhs_post mlhs_basic mlhs_item mlhs_node mlhs_inner %type fsym sym symbol operation operation2 operation3 %type cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg @@ -1007,12 +1007,12 @@ top_stmt : stmt if (p->in_def || p->in_single) { yyerror(p, "BEGIN in method"); } - $$ = local_switch(p); + $$ = local_switch(p); } '{' top_compstmt '}' { p->begin_tree = push(p->begin_tree, $4); - local_resume(p, $2); + local_resume(p, $2); $$ = 0; } ; @@ -1980,13 +1980,13 @@ primary : literal { if (p->in_def || p->in_single) yyerror(p, "class definition in method body"); - $$ = local_switch(p); + $$ = local_switch(p); } bodystmt keyword_end { $$ = new_class(p, $2, $3, $5); - local_resume(p, $4); + local_resume(p, $4); } | keyword_class tLSHFT expr { @@ -1995,54 +1995,54 @@ primary : literal } term { - $$ = cons(local_switch(p), (node*)(intptr_t)p->in_single); + $$ = cons(local_switch(p), (node*)(intptr_t)p->in_single); p->in_single = 0; } bodystmt keyword_end { $$ = new_sclass(p, $3, $7); - local_resume(p, $6->car); + local_resume(p, $6->car); p->in_def = $4; - p->in_single = (int)(intptr_t)$6->cdr; + p->in_single = (int)(intptr_t)$6->cdr; } | keyword_module cpath { if (p->in_def || p->in_single) yyerror(p, "module definition in method body"); - $$ = local_switch(p); + $$ = local_switch(p); } bodystmt keyword_end { $$ = new_module(p, $2, $4); - local_resume(p, $3); + local_resume(p, $3); } | keyword_def fname { p->in_def++; - $$ = local_switch(p); + $$ = local_switch(p); } f_arglist bodystmt keyword_end { $$ = new_def(p, $2, $4, $5); - local_resume(p, $3); + local_resume(p, $3); p->in_def--; } | keyword_def singleton dot_or_colon {p->lstate = EXPR_FNAME;} fname { p->in_single++; p->lstate = EXPR_ENDFN; /* force for args */ - $$ = local_switch(p); + $$ = local_switch(p); } f_arglist bodystmt keyword_end { $$ = new_sdef(p, $2, $5, $7, $8); - local_resume(p, $6); + local_resume(p, $6); p->in_single--; } | keyword_break @@ -3355,7 +3355,7 @@ parse_string(parser_state *p, int term) p->lstate = EXPR_BEG; p->sterm = term; p->cmd_start = TRUE; - yylval.node = new_str(p, tok(p), toklen(p)); + yylval.nd = new_str(p, tok(p), toklen(p)); return tSTRING_PART; } tokadd(p, '#'); @@ -3368,7 +3368,7 @@ parse_string(parser_state *p, int term) tokfix(p); p->lstate = EXPR_END; p->sterm = 0; - yylval.node = new_str(p, tok(p), toklen(p)); + yylval.nd = new_str(p, tok(p), toklen(p)); return tSTRING; } @@ -3409,7 +3409,7 @@ parse_qstring(parser_state *p, int term) } tokfix(p); - yylval.node = new_str(p, tok(p), toklen(p)); + yylval.nd = new_str(p, tok(p), toklen(p)); p->lstate = EXPR_END; return tSTRING; } @@ -3717,7 +3717,7 @@ parser_yylex(parser_state *p) tokadd(p, c); } tokfix(p); - yylval.node = new_str(p, tok(p), toklen(p)); + yylval.nd = new_str(p, tok(p), toklen(p)); p->lstate = EXPR_END; return tCHAR; @@ -3894,7 +3894,7 @@ parser_yylex(parser_state *p) no_digits(); } else if (nondigit) goto trailing_uc; - yylval.node = new_int(p, tok(p), 16); + yylval.nd = new_int(p, tok(p), 16); return tINTEGER; } if (c == 'b' || c == 'B') { @@ -3918,7 +3918,7 @@ parser_yylex(parser_state *p) no_digits(); } else if (nondigit) goto trailing_uc; - yylval.node = new_int(p, tok(p), 2); + yylval.nd = new_int(p, tok(p), 2); return tINTEGER; } if (c == 'd' || c == 'D') { @@ -3942,7 +3942,7 @@ parser_yylex(parser_state *p) no_digits(); } else if (nondigit) goto trailing_uc; - yylval.node = new_int(p, tok(p), 10); + yylval.nd = new_int(p, tok(p), 10); return tINTEGER; } if (c == '_') { @@ -3975,7 +3975,7 @@ parser_yylex(parser_state *p) pushback(p, c); tokfix(p); if (nondigit) goto trailing_uc; - yylval.node = new_int(p, tok(p), 8); + yylval.nd = new_int(p, tok(p), 8); return tINTEGER; } if (nondigit) { @@ -3992,7 +3992,7 @@ parser_yylex(parser_state *p) } else { pushback(p, c); - yylval.node = new_int(p, "0", 10); + yylval.nd = new_int(p, "0", 10); return tINTEGER; } } @@ -4069,10 +4069,10 @@ parser_yylex(parser_state *p) yywarning_s(p, "float %s out of range", tok(p)); errno = 0; } - yylval.node = new_float(p, tok(p)); + yylval.nd = new_float(p, tok(p)); return tFLOAT; } - yylval.node = new_int(p, tok(p), 10); + yylval.nd = new_int(p, tok(p), 10); return tINTEGER; } @@ -4404,7 +4404,7 @@ parser_yylex(parser_state *p) tokadd(p, c); goto gvar; } - yylval.node = new_back_ref(p, c); + yylval.nd = new_back_ref(p, c); return tBACK_REF; case '1': case '2': case '3': @@ -4417,7 +4417,7 @@ parser_yylex(parser_state *p) pushback(p, c); if (last_state == EXPR_FNAME) goto gvar; tokfix(p); - yylval.node = new_nth_ref(p, atoi(tok(p))); + yylval.nd = new_nth_ref(p, atoi(tok(p))); return tNTH_REF; default: -- cgit v1.2.3