pike.git / src / language.yacc

version» Context lines:

pike.git/src/language.yacc:92:   %token TOK_TYPEDEF   %token TOK_TYPEOF   %token TOK_VARIANT   %token TOK_VERSION   %token TOK_VOID_ID   %token TOK_WHILE   %token TOK_XOR_EQ   %token TOK_OPTIONAL   %token TOK_SAFE_INDEX   %token TOK_SAFE_START_INDEX + %token TOK_AUTO_ID         %right '='   %right '?'      %left TOK_LOR   %left TOK_LAND   %left '|'   %left '^'   %left '&'
pike.git/src/language.yacc:240:   %type <number> TOK_OBJECT_ID   %type <number> TOK_PREDEF   %type <number> TOK_PRIVATE   %type <number> TOK_PROGRAM_ID   %type <number> TOK_PROTECTED   %type <number> TOK_PUBLIC   %type <number> TOK_RETURN   %type <number> TOK_SSCANF   %type <number> TOK_STATIC   %type <number> TOK_STRING_ID + %type <number> TOK_AUTO_ID   %type <number> TOK_SWITCH   %type <number> TOK_VOID_ID   %type <number> TOK_WHILE   %type <number> arguments   %type <number> arguments2   %type <number> func_args   %type <number> create_arguments   %type <number> create_arguments2   %type <number> create_arg   %type <number> assign
pike.git/src/language.yacc:989:    }    c->lex.current_line = l;    c->lex.current_file = f;    }       f=dooptcode($6->u.sval.u.string, $13, $<n>12->u.sval.u.type, $1);       i = ID_FROM_INT(Pike_compiler->new_program, f);    i->opt_flags = Pike_compiler->compiler_frame->opt_flags;    +  if (Pike_compiler->compiler_pass == 2) +  { +  struct pike_type *t = Pike_compiler->compiler_frame->current_return_type; +  if( t->type == PIKE_T_AUTO ) +  { +  if( !t->car ) +  yyerror("'auto' without return statement is not allowed\n"); +  else +  { +  int e; +  struct pike_string *a = describe_type( t->car )->str; +  fprintf( stderr, "AUTO: -->%s\n", a); +  free_string( a ); +  /* push_finished_type( t->car );/\* return type.. *\/ */ +  +  /* for(; e>=0; e--) */ +  /* { */ +  /* push_finished_type(Pike_compiler->compiler_frame->variable[e].type); */ +  /* push_type(T_FUNCTION); */ +  /* } */ +  +  /* if ($2) { */ +  /* node *n = $2; */ +  /* while (n) { */ +  /* push_type_attribute(CDR(n)->u.sval.u.string); */ +  /* n = CAR(n); */ +  /* } */ +  /* } */ +  /* free_type( i->type ); */ +  /* i->type = compiler_pop_type(); */ +  } +  } +  } +    #ifdef PIKE_DEBUG    if(Pike_interpreter.recoveries &&    ((Pike_sp - Pike_interpreter.evaluator_stack) <    Pike_interpreter.recoveries->stack_pointer))    Pike_fatal("Stack error (underflow)\n");       if((Pike_compiler->compiler_pass == 1) &&    (f != Pike_compiler->compiler_frame->current_function_number)) {    fprintf(stderr, "define_function()/do_opt_code() failed for symbol %s\n",    $6->u.sval.u.string->str);
pike.git/src/language.yacc:1012:    }   #endif       c->lex.current_line = save_line;    c->lex.current_file = save_file;    } else {    /* Prototype; don't warn about unused arguments. */    for (e = Pike_compiler->compiler_frame->current_number_of_locals; e--;) {    Pike_compiler->compiler_frame->variable[e].flags |= LOCAL_VAR_IS_USED;    } +  if( Pike_compiler->compiler_frame->current_return_type->type == PIKE_T_AUTO ) +  yyerror("'auto' return type not allowed for prototypes\n");    }   #ifdef PIKE_DEBUG    if (Pike_compiler->compiler_frame != $7) {    Pike_fatal("Lost track of compiler_frame!\n"    " Got: %p (Expected: %p) Previous: %p\n",    Pike_compiler->compiler_frame, $7,    Pike_compiler->compiler_frame->previous);    }   #endif    pop_compiler_frame();
pike.git/src/language.yacc:1214:    | TOK_MULTISET_ID { $$ = "multiset"; }    | TOK_OBJECT_ID { $$ = "object"; }    | TOK_FUNCTION_ID { $$ = "function"; }    | TOK_FUNCTION_NAME { $$ = "__func__"; }    | TOK_PROGRAM_ID { $$ = "program"; }    | TOK_STRING_ID { $$ = "string"; }    | TOK_FLOAT_ID { $$ = "float"; }    | TOK_INT_ID { $$ = "int"; }    | TOK_ENUM { $$ = "enum"; }    | TOK_TYPEDEF { $$ = "typedef"; } +  /* | TOK_AUTO_ID { $$ = "auto"; } */    ;      magic_identifiers3:    TOK_IF { $$ = "if"; }    | TOK_DO { $$ = "do"; }    | TOK_FOR { $$ = "for"; }    | TOK_WHILE { $$ = "while"; }    | TOK_ELSE { $$ = "else"; }    | TOK_FOREACH { $$ = "foreach"; }    | TOK_CATCH { $$ = "catch"; }
pike.git/src/language.yacc:1396:   type2: type2 '|' type8 { push_type(T_OR); }    | basic_type    ;      type8: basic_type | identifier_type ;      basic_type:    TOK_FLOAT_ID { push_type(T_FLOAT); }    | TOK_VOID_ID { push_type(T_VOID); }    | TOK_MIXED_ID { push_type(T_MIXED); } +  | TOK_AUTO_ID { push_type(PIKE_T_AUTO); }    | TOK_STRING_ID opt_string_width {}    | TOK_INT_ID opt_int_range {}    | TOK_MAPPING_ID opt_mapping_type {}    | TOK_FUNCTION_ID opt_function_type {}    | TOK_OBJECT_ID opt_object_type {}    | TOK_PROGRAM_ID opt_object_type { push_type(T_PROGRAM); }    | TOK_ARRAY_ID opt_array_type { push_type(T_ARRAY); }    | TOK_MULTISET_ID opt_array_type { push_type(T_MULTISET); }    | TOK_ATTRIBUTE_ID '(' string_constant ',' type7 ')'    {
pike.git/src/language.yacc:1771:    if ((Pike_compiler->current_modifiers & ID_EXTERN) &&    (Pike_compiler->compiler_pass == 1)) {    yywarning("Extern declared variable has initializer.");    }    $<number>$=define_variable($2->u.sval.u.string, type,    Pike_compiler->current_modifiers & (~ID_EXTERN));    free_type(type);    }    expr0    { +  if( Pike_compiler->compiler_pass == 2 && is_auto_variable_type( $<number>4 ) ) +  { +  fix_type_field( $5 ); +  fix_auto_variable_type( $<number>4, $5->type ); +  }    Pike_compiler->init_node=mknode(F_COMMA_EXPR,Pike_compiler->init_node,    mkcastnode(void_type_string,    mknode(F_ASSIGN,$5,    mkidentifiernode($<number>4))));    free_node($2);    }    | optional_stars TOK_IDENTIFIER '=' error    {    free_node($2);    }
pike.git/src/language.yacc:1813:    /* FIXME: Consider using mklocalnode(id, -1). */    $$=mknode(F_ASSIGN,mkintnode(0),mklocalnode(id,0));    } else    $$ = 0;    free_node($2);    }    | optional_stars bad_identifier { $$=0; }    | optional_stars TOK_IDENTIFIER '=' expr0    {    int id; +  struct pike_type *type;    push_finished_type($<n>0->u.sval.u.type);    if ($1 && (Pike_compiler->compiler_pass == 2) && !TEST_COMPAT (0, 6)) {    yywarning("The *-syntax in types is obsolete. Use array instead.");    }    while($1--) push_type(T_ARRAY); -  id = add_local_name($2->u.sval.u.string, compiler_pop_type(),0); +  type = compiler_pop_type(); +  if( type->type == PIKE_T_AUTO && Pike_compiler->compiler_pass == 2) +  { +  free_type( type ); +  fix_type_field( $4 ); +  copy_pike_type( type, $4->type ); +  } +  id = add_local_name($2->u.sval.u.string, type,0);    if (id >= 0) {    if (!(THIS_COMPILATION->lex.pragmas & ID_STRICT_TYPES)) {    /* Only warn about unused initialized variables in strict types mode. */    Pike_compiler->compiler_frame->variable[id].flags |= LOCAL_VAR_IS_USED;    }    $$=mknode(F_ASSIGN,$4,mklocalnode(id,0));    } else    $$ = 0;    free_node($2);    }