pike.git / src / language.yacc

version» Context lines:

pike.git/src/language.yacc:1:   /* -*- c -*-   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: language.yacc,v 1.381 2007/09/18 13:55:58 grubba Exp $ + || $Id: language.yacc,v 1.382 2007/09/29 15:09:03 grubba Exp $   */      %pure_parser      %token TOK_ARROW      /*    * Basic value pushing    */   %token TOK_CONSTANT TOK_FLOAT TOK_STRING
pike.git/src/language.yacc:587:    Pike_compiler->compiler_pass=tmp;    }       if ((Pike_compiler->current_modifiers & ID_EXTERN) &&    (Pike_compiler->compiler_pass == 1)) {    yywarning("Extern declared constant.");    }       if(!is_const($3))    { -  if(Pike_compiler->compiler_pass==2) +  if(Pike_compiler->compiler_pass==2) { +  int depth = 0; +  struct program_state *state = Pike_compiler; +  node *n = $3; +  while (((n->token == F_COMMA_EXPR) || (n->token == F_ARG_LIST)) && +  ((!CAR(n)) ^ (!CDR(n)))) { +  if (CAR(n)) n = CAR(n); +  else n = CDR(n); +  } +  if (n->token == F_EXTERNAL) { +  while (state && (state->new_program->id != n->u.integer.a)) { +  depth++; +  state = state->previous; +  } +  } +  if (depth && state) { +  /* Alias for a symbol in a surrounding scope. */ +  int id = really_low_reference_inherited_identifier(state, 0, +  n->u.integer.b); +  define_alias($1->u.sval.u.string, n->type, +  Pike_compiler->current_modifiers & ~ID_EXTERN, +  depth, id); +  } else {    yyerror("Constant definition is not constant."); -  else +  } +  } else    add_constant($1->u.sval.u.string, 0,    Pike_compiler->current_modifiers & ~ID_EXTERN);    } else {    if(!Pike_compiler->num_parse_error)    {    ptrdiff_t tmp=eval_low($3,1);    if(tmp < 1)    {    yyerror("Error in constant definition.");    push_undefined();