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.326 2003/11/14 00:15:06 mast Exp $ + || $Id: language.yacc,v 1.327 2004/03/12 21:17:18 grubba Exp $   */      %pure_parser      %token TOK_ARROW      /*    * Basic value pushing    */   %token TOK_CONSTANT TOK_FLOAT TOK_STRING
pike.git/src/language.yacc:106:   %left TOK_LSH TOK_RSH   %left '+' '-'   %left '*' '%' '/'   %right TOK_NOT '~'   %nonassoc TOK_INC TOK_DEC      %{   /* This is the grammar definition of Pike. */      #include "global.h" - RCSID("$Id: language.yacc,v 1.326 2003/11/14 00:15:06 mast Exp $"); + RCSID("$Id: language.yacc,v 1.327 2004/03/12 21:17:18 grubba Exp $");   #ifdef HAVE_MEMORY_H   #include <memory.h>   #endif      #include "interpret.h"   #include "array.h"   #include "object.h"   #include "stralloc.h"   #include "las.h"   #include "interpret.h"
pike.git/src/language.yacc:450:    yywarning("Extern declared inherit.");    }    if($4 && !(Pike_compiler->new_program->flags & PROGRAM_PASS_1_DONE))    {    struct pike_string *s=Pike_sp[-1].u.string;    if($5) s=$5->u.sval.u.string;    compiler_do_inherit($4,$1,s);    }    if($5) free_node($5);    pop_stack(); -  free_node($4); +  if ($4) free_node($4);    }    | modifiers TOK_INHERIT force_resolve low_program_ref error ';'    {    force_resolve = $3;   #ifdef FORCE_RESOLVE_DEBUG    fprintf(stderr, "force_resolve restored to %d\n", force_resolve);   #endif    free_node($4);    pop_stack();    yyerrok;
pike.git/src/language.yacc:546:    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();    }else{    pop_n_elems(DO_NOT_WARN((INT32)(tmp - 1))); -  +  } +  } else { +  push_undefined(); +  }    add_constant($1->u.sval.u.string, Pike_sp-1,    Pike_compiler->current_modifiers & ~ID_EXTERN);    pop_stack();    } -  } -  } +     if($3) free_node($3);    free_node($1);    }    | bad_identifier '=' safe_expr0 { if ($3) free_node($3); }    | error '=' safe_expr0 { if ($3) free_node($3); }    ;      constant_list: constant_name    | constant_list ',' constant_name    ;
pike.git/src/language.yacc:2852:    yyerror("Unexpected end of file.");    }    ;      return: TOK_RETURN expected_semicolon    {    if(!TEST_COMPAT(0,6) &&    !match_types(Pike_compiler->compiler_frame->current_return_type,    void_type_string))    { -  yyerror("Must return a value for a non-void function."); +  yytype_error("Must return a value for a non-void function.", +  Pike_compiler->compiler_frame->current_return_type, +  void_type_string, 0);    }    $$=mknode(F_RETURN,mkintnode(0),0);    }    | TOK_RETURN safe_comma_expr expected_semicolon    {    $$=mknode(F_RETURN,$2,0);    }    ;      unused: { $$=0; }
pike.git/src/language.yacc:3324:    }    }    if (i < 0) {    add_to_identifier_references(funp);    i = Pike_compiler->new_program->num_identifier_references - 1;    }    }    $$ = mkidentifiernode(i);    }    } else { -  if (!Pike_compiler->num_parse_error) { +     if (Pike_compiler->compiler_pass == 2) { -  my_yyerror("'%s' not defined in local scope.", Pike_compiler->last_identifier->str); +  my_yyerror("'%s' not defined in local scope.", +  Pike_compiler->last_identifier->str);    $$ = 0;    } else {    $$ = mknode(F_UNDEFINED, 0, 0);    } -  } else { -  $$ = mkintnode(0); +     } -  } +        free_node($3);    }    | TOK_LOCAL_ID TOK_COLON_COLON bad_identifier    {    $$=0;    }    ;      idents: low_idents
pike.git/src/language.yacc:3468:    {    if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier);    copy_shared_string(Pike_compiler->last_identifier, $1->u.sval.u.string);       if(($$=lexical_islocal(Pike_compiler->last_identifier)))    {    /* done, nothing to do here */    }else if(!($$=find_module_identifier(Pike_compiler->last_identifier,1)) &&    !($$ = program_magic_identifier (Pike_compiler, 0, 0,    Pike_compiler->last_identifier, 0))) { -  if(!Pike_compiler->num_parse_error) -  { -  if(Pike_compiler->compiler_pass==2) -  { -  my_yyerror("Undefined identifier \"%s\".", Pike_compiler->last_identifier->str); +  if(force_resolve || +  ((!Pike_compiler->num_parse_error) && +  (Pike_compiler->compiler_pass==2))) { +  my_yyerror("Undefined identifier \"%s\".", +  Pike_compiler->last_identifier->str);    $$=0;    }else{    $$=mknode(F_UNDEFINED,0,0);    } -  }else{ -  $$=mkintnode(0); +     } -  } +     free_node($1);    }    | TOK_PREDEF TOK_COLON_COLON TOK_IDENTIFIER    {    node *tmp2;    extern dynamic_buffer used_modules;       if(Pike_compiler->last_identifier) free_string(Pike_compiler->last_identifier);    copy_shared_string(Pike_compiler->last_identifier, $3->u.sval.u.string);   
pike.git/src/language.yacc:3531:    if (inherit_depth > 0) {    $$ = mkexternalnode(inherit_state->new_program, id);    } else {    $$ = mkidentifiernode(id);    }    } else if (($$ = program_magic_identifier (inherit_state, inherit_depth, $1,    Pike_compiler->last_identifier, 1))) {    /* All done. */    }    else { -  if (Pike_compiler->compiler_pass == 2) { +  if (force_resolve || (Pike_compiler->compiler_pass == 2)) {    if (inherit_state->new_program->inherits[$1].name) {    my_yyerror("Undefined identifier \"%s::%s\".",    inherit_state->new_program->inherits[$1].name->str,    Pike_compiler->last_identifier->str);    } else { -  my_yyerror("Undefined identifier \"%s\".", Pike_compiler->last_identifier->str); +  my_yyerror("Undefined identifier \"%s\".", +  Pike_compiler->last_identifier->str);    }    $$=0;    }    else    $$=mknode(F_UNDEFINED,0,0);    }    } else {    $$=0;    }   
pike.git/src/language.yacc:3901:      /* empty: ; */ /* line_number_info is now used in these cases. */      %%      void yyerror(char *str)   {    extern int num_parse_error;    extern int cumulative_parse_error;    +  STACK_LEVEL_START(0); +    #ifdef PIKE_DEBUG    if(Pike_interpreter.recoveries && Pike_sp-Pike_interpreter.evaluator_stack < Pike_interpreter.recoveries->stack_pointer)    Pike_fatal("Stack error (underflow)\n");   #endif       if (Pike_compiler->num_parse_error > 10) return;    Pike_compiler->num_parse_error++;    cumulative_parse_error++;       if ((error_handler && error_handler->prog) || get_master())
pike.git/src/language.yacc:3937:    lex.current_file->str,    (long)lex.current_line,    str);    } else {    (void)fprintf(stderr, "NULL:%ld: %s\n",    (long)lex.current_line,    str);    }    fflush(stderr);    } +  +  STACK_LEVEL_DONE(0);   }      static int low_islocal(struct compiler_frame *f,    struct pike_string *str)   {    int e;    for(e=f->current_number_of_locals-1;e>=0;e--)    if(f->variable[e].name==str)    return e;    return -1;