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.401 2008/01/04 11:41:27 grubba Exp $ + || $Id: language.yacc,v 1.402 2008/01/05 19:06:30 grubba Exp $   */      %pure_parser      %token TOK_ARROW      /*    * Basic value pushing    */   %token TOK_CONSTANT TOK_FLOAT TOK_STRING
pike.git/src/language.yacc:149:      /* Get verbose parse error reporting. */   #define YYERROR_VERBOSE 1      /* #define LAMBDA_DEBUG 1 */      static struct pike_string *get_new_name();   int add_local_name(struct pike_string *, struct pike_type *, node *);   int low_add_local_name(struct compiler_frame *,    struct pike_string *, struct pike_type *, node *); + static mark_lvalues_as_used(node *n);   static node *lexical_islocal(struct pike_string *);   static void safe_inc_enum(void);   static int call_handle_import(struct pike_string *s);      static int inherit_depth;   static struct program_state *inherit_state = NULL;      /*    * Kludge for Bison not using prototypes.    */
pike.git/src/language.yacc:1919:    $3=mksvaluenode(Pike_sp-1);    type=$3->type;    pop_stack();    }    }    if(!type) type = mixed_type_string;    add_ref(type);    low_add_local_name(Pike_compiler->compiler_frame, /*->previous,*/    $1->u.sval.u.string,    type, $3); +  /* Note: Intentionally not marked as used. */    free_node($1);    }    | bad_identifier '=' safe_expr0 { if ($3) free_node($3); }    | error '=' safe_expr0 { if ($3) free_node($3); }    ;      local_constant_list: local_constant_name    | local_constant_list ',' local_constant_name    ;   
pike.git/src/language.yacc:3106:      expr00: expr0    | '@' expr0 { $$=mknode(F_PUSH_ARRAY,$2,0); };      expr0: expr01    | expr4 '=' expr0 { $$=mknode(F_ASSIGN,$3,$1); }    | expr4 '=' error { $$=$1; reset_type_stack(); yyerrok; }    | bad_expr_ident '=' expr0 { $$=$3; }    | open_bracket_with_line_info low_lvalue_list ']' '=' expr0    { +  if (!(lex.pragmas & ID_STRICT_TYPES)) { +  mark_lvalues_as_used($2); +  }    $$=mknode(F_ASSIGN,$5,mknode(F_ARRAY_LVALUE,$2,0));    COPY_LINE_NUMBER_INFO($$, $1);    free_node ($1);    }    | expr4 assign expr0 { $$=mknode($2,$1,$3); }    | expr4 assign error { $$=$1; reset_type_stack(); yyerrok; }    | bad_expr_ident assign expr0 { $$=$3; }    | open_bracket_with_line_info low_lvalue_list ']' assign expr0    {    $$=mknode($4,mknode(F_ARRAY_LVALUE,$2,0),$5);    COPY_LINE_NUMBER_INFO($$, $1);    free_node ($1);    }    | open_bracket_with_line_info low_lvalue_list ']' error -  { $$=$2; free_node ($1); reset_type_stack(); yyerrok; } +  { +  $$=$2; free_node ($1); reset_type_stack(); yyerrok; +  }   /* | error { $$=0; reset_type_stack(); } */    ;      expr01: expr1    | expr1 '?' expr01 ':' expr01 { $$=mknode('?',$1,mknode(':',$3,$5)); }    ;      assign: TOK_AND_EQ { $$=F_AND_EQ; }    | TOK_OR_EQ { $$=F_OR_EQ; }    | TOK_XOR_EQ { $$=F_XOR_EQ; }
pike.git/src/language.yacc:4029:   lvalue: expr4    | open_bracket_with_line_info low_lvalue_list ']'    {    $$=mknode(F_ARRAY_LVALUE, $2,0);    COPY_LINE_NUMBER_INFO($$, $1);    free_node($1);    }    | type6 TOK_IDENTIFIER    {    int id = add_local_name($2->u.sval.u.string,compiler_pop_type(),0); +  /* Note: Variable intentionally not marked as used. */    if (id >= 0)    $$=mklocalnode(id,-1);    else    $$ = 0;    free_node($2);    } -  +  /* FIXME: Add production for type6 ==> constant type svalue here? */    | bad_expr_ident    { $$=mknewintnode(0); }    ; - low_lvalue_list: lvalue lvalue_list { $$=mknode(F_LVALUE_LIST,$1,$2); } +  + low_lvalue_list: lvalue lvalue_list +  { +  $$=mknode(F_LVALUE_LIST,$1,$2); +  }    ;      lvalue_list: /* empty */ { $$ = 0; } -  | ',' lvalue lvalue_list { $$ = mknode(F_LVALUE_LIST,$2,$3); } +  | ',' lvalue lvalue_list +  { +  $$ = mknode(F_LVALUE_LIST,$2,$3); +  }    ;      string: TOK_STRING    | string TOK_STRING    {    struct pike_string *a,*b;    copy_shared_string(a,$1->u.sval.u.string);    copy_shared_string(b,$2->u.sval.u.string);    free_node($1);    free_node($2);
pike.git/src/language.yacc:4343:   int add_local_name(struct pike_string *str,    struct pike_type *type,    node *def)   {    return low_add_local_name(Pike_compiler->compiler_frame,    str,    type,    def);   }    + /* Mark local variables declared in a multi-assign expression as used. */ + static mark_lvalues_as_used(node *n) + { +  while (n && n->token == F_LVALUE_LIST) { +  if (CAR(n)->token == F_ARRAY_LVALUE) { +  mark_lvalues_as_used(CAAR(n)); +  } else if ((CAR(n)->token == F_LOCAL) && !(CAR(n)->u.integer.b)) { +  Pike_compiler->compiler_frame->variable[CAR(n)->u.integer.a] |= +  LOCAL_VAR_IS_USED; +  } +  n = CDR(n); +  } + } +    #if 0   /* Note that this function eats a reference to each of    * 'type' and 'initializer', but not to 'name'.    * Note also that 'initializer' may be NULL.    */   static node *add_static_variable(struct pike_string *name,    struct pike_type *type,    int depth,    node *initializer)   {