pike.git / src / language.yacc

version» Context lines:

pike.git/src/language.yacc:179:   %left F_LSH F_RSH   %left '+' '-'   %left '*' '%' '/'   %right F_NOT '~'   %nonassoc F_INC F_DEC      %{   /* This is the grammar definition of Pike. */      #include "global.h" - RCSID("$Id: language.yacc,v 1.156 1999/12/30 14:45:37 grubba Exp $"); + RCSID("$Id: language.yacc,v 1.157 1999/12/30 16:36:05 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:464:   /* NOTE: Pushes the resolved program on the stack. */   program_ref: low_program_ref    {    resolv_program($1);    free_node($1);    }    ;      inheritance: modifiers F_INHERIT low_program_ref optional_rename_inherit ';'    { +  if (($1 & ID_EXTERN) && (compiler_pass == 1)) { +  yywarning("Extern declared inherit."); +  }    if(!(new_program->flags & PROGRAM_PASS_1_DONE))    {    struct pike_string *s=sp[-1].u.string;    if($4) s=$4->u.sval.u.string;    compiler_do_inherit($3,$1,s);    }    if($4) free_node($4);    pop_n_elems(1);    free_node($3);    }
pike.git/src/language.yacc:537:   constant_name: F_IDENTIFIER '=' safe_expr0    {    int tmp;    /* This can be made more lenient in the future */       /* Ugly hack to make sure that $3 is optimized */    tmp=compiler_pass;    $3=mknode(F_COMMA_EXPR,$3,0);    compiler_pass=tmp;    +  if ((current_modifiers & ID_EXTERN) && (compiler_pass == 1)) { +  yywarning("Extern declared constant."); +  } +     if(!is_const($3))    {    if(compiler_pass==2)    yyerror("Constant definition is not constant.");    else -  add_constant($1->u.sval.u.string,0, current_modifiers); +  add_constant($1->u.sval.u.string, 0, current_modifiers & ~ID_EXTERN);    } else {    if(!num_parse_error)    {    tmp=eval_low($3);    if(tmp < 1)    {    yyerror("Error in constant definition.");    }else{    pop_n_elems(tmp-1); -  add_constant($1->u.sval.u.string,sp-1,current_modifiers); +  add_constant($1->u.sval.u.string, sp-1, +  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); }    ;
pike.git/src/language.yacc:685:    {    struct pike_string *s=compiler_pop_type();    $<n>$=mkstrnode(s);    free_string(s);    }       if(compiler_pass==1)    {    $<number>5=define_function(check_node_hash($4)->u.sval.u.string,    check_node_hash($<n>$)->u.sval.u.string, -  $1, +  $1 & (~ID_EXTERN),    IDENTIFIER_PIKE_FUNCTION,    0);    }    }    block_or_semi    {    int e;    if($10)    {    int f;    node *check_args = NULL;    int save_line = lex.current_line;   #ifdef PIKE_DEBUG    struct pike_string *save_file = lex.current_file;    lex.current_file = $8->current_file;   #endif /* PIKE_DEBUG */    lex.current_line = $8->line_number;    -  +  if (($1 & ID_EXTERN) && (compiler_pass == 1)) { +  yywarning("Extern declared function definition."); +  } +     for(e=0; e<$7; e++)    {    if(!compiler_frame->variable[e].name ||    !compiler_frame->variable[e].name->len)    {    my_yyerror("Missing name for argument %d.",e);    } else {    /* FIXME: Should probably use some other flag. */    if ((runtime_options & RUNTIME_CHECK_TYPES) &&    (compiler_pass == 2) &&
pike.git/src/language.yacc:1233:    free_string(type);    free_node($2);    }    | optional_stars bad_identifier {}    | optional_stars F_IDENTIFIER '='    {    struct pike_string *type;    push_finished_type(compiler_frame->current_type);    while($1--) push_type(T_ARRAY);    type=compiler_pop_type(); -  $<number>$=define_variable($2->u.sval.u.string, type, current_modifiers); +  if ((current_modifiers & ID_EXTERN) && (compiler_pass == 1)) { +  yywarning("Extern declared variable has initializer."); +  } +  $<number>$=define_variable($2->u.sval.u.string, type, +  current_modifiers & (~ID_EXTERN));    free_string(type);    }    expr0    {    init_node=mknode(F_COMMA_EXPR,init_node,    mkcastnode(void_type_string,    mknode(F_ASSIGN,$5,    mkidentifiernode($<number>4))));    free_node($2);    }
pike.git/src/language.yacc:1649:    sprintf(buffer,"__class_%ld_%ld",(long)new_program->id,    local_class_counter++);    s=make_shared_string(buffer);    $3=mkstrnode(s);    free_string(s);    $1|=ID_STATIC | ID_PRIVATE | ID_INLINE;    }    /* fprintf(stderr, "LANGUAGE.YACC: CLASS start\n"); */    if(compiler_pass==1)    { -  low_start_new_program(0, $3->u.sval.u.string, $1); +  if ($1 & ID_EXTERN) { +  yywarning("Extern declared class definition."); +  } +  low_start_new_program(0, $3->u.sval.u.string, $1 & ~ID_EXTERN);    if(lex.current_file)    {    store_linenumber(lex.current_line, lex.current_file); -  debug_malloc_name(new_program, lex.current_file->str, lex.current_line); +  debug_malloc_name(new_program, lex.current_file->str, +  lex.current_line);    }    }else{    int i;    struct program *p;    struct identifier *id;    int tmp=compiler_pass;    i=isidentifier($3->u.sval.u.string);    if(i<0)    {    low_start_new_program(new_program,0,0);    yyerror("Pass 2: program not defined!");    }else{    id=ID_FROM_INT(new_program, i);    if(IDENTIFIER_IS_CONSTANT(id->identifier_flags))    {    struct svalue *s;    s=&PROG_FROM_INT(new_program,i)->constants[id->func.offset].sval;    if(s->type==T_PROGRAM)    { -  low_start_new_program(s->u.program, $3->u.sval.u.string, $1); +  low_start_new_program(s->u.program, $3->u.sval.u.string, +  $1 & ~ID_EXTERN);    }else{    yyerror("Pass 2: constant redefined!");    low_start_new_program(new_program, 0,0);    }    }else{    yyerror("Pass 2: class constant no longer constant!");    low_start_new_program(new_program, 0,0);    }    }    compiler_pass=tmp;