pike.git / src / language.yacc

version» Context lines:

pike.git/src/language.yacc:103:   %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.226 2001/02/20 22:03:48 grubba Exp $"); + RCSID("$Id: language.yacc,v 1.227 2001/02/23 14:31:07 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:602:    int e;    /* construct the function type */    push_finished_type(Pike_compiler->compiler_frame->current_type);    if ($3 && (Pike_compiler->compiler_pass == 2)) {    yywarning("The *-syntax in types is obsolete. Use array instead.");    }    while(--$3>=0) push_type(T_ARRAY);       if(Pike_compiler->compiler_frame->current_return_type)    free_type(Pike_compiler->compiler_frame->current_return_type); -  Pike_compiler->compiler_frame->current_return_type=compiler_pop_type(); +  Pike_compiler->compiler_frame->current_return_type = compiler_pop_type();       push_finished_type(Pike_compiler->compiler_frame->current_return_type);       e=$7-1;    if(Pike_compiler->varargs)    {    push_finished_type(Pike_compiler->compiler_frame->variable[e].type);    e--;    Pike_compiler->varargs=0;    pop_type_stack();
pike.git/src/language.yacc:755:    /* If there is a bad argument, call the fallback, and return. */    if (! pike_types_le(void_type_string, arg_type)) {    /* Argument my not be void.    * ie it's required.    */    num_required_args++;    }    } else {    /* FIXME: Should probably use some other flag. */    if ((runtime_options & RUNTIME_CHECK_TYPES) && -  (Pike_compiler->compiler_frame->variable[e].type != mixed_type_string)) { +  (Pike_compiler->compiler_frame->variable[e].type != +  mixed_type_string)) {    node *local_node;       /* fprintf(stderr, "Creating soft cast node for local #%d\n", e);*/       local_node = mklocalnode(e, 0);       /* The following is needed to go around the optimization in    * mksoftcastnode().    */    free_type(local_node->type);
pike.git/src/language.yacc:1531:    }    ;      failsafe_block: block    | error { $$=0; }    | TOK_LEX_EOF { yyerror("Unexpected end of file."); $$=0; }    ;         local_name_list: new_local_name -  | local_name_list ',' { $<n>$=$<n>0; } new_local_name { $$=mknode(F_COMMA_EXPR,mkcastnode(void_type_string,$1),$4); } +  | local_name_list ',' { $<n>$=$<n>0; } new_local_name +  { $$ = mknode(F_COMMA_EXPR, mkcastnode(void_type_string, $1), $4); }    ;      local_name_list2: new_local_name2 -  | local_name_list2 ',' { $<n>$=$<n>0; } new_local_name { $$=mknode(F_COMMA_EXPR,mkcastnode(void_type_string,$1),$4); } +  | local_name_list2 ',' { $<n>$=$<n>0; } new_local_name +  { $$ = mknode(F_COMMA_EXPR, mkcastnode(void_type_string, $1), $4); }    ;         local_constant_name: TOK_IDENTIFIER '=' safe_expr0    {    struct pike_type *type;       /* Ugly hack to make sure that $3 is optimized */    {    int tmp=Pike_compiler->compiler_pass;
pike.git/src/language.yacc:1568:    {    yyerror("Error in constant definition.");    }else{    pop_n_elems(DO_NOT_WARN((INT32)(tmp - 1)));    if($3) free_node($3);    $3=mksvaluenode(Pike_sp-1);    type=$3->type;    pop_stack();    }    } -  if(!type) type=mixed_type_string; +  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);    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:1597:    yyerror("Missing ';'.");    yyerror("Unexpected end of file.");    }    | TOK_CONSTANT error '}' { yyerror("Missing ';'."); }    ;         statements: { $$=0; }    | statements statement    { -  $$=mknode(F_COMMA_EXPR,$1,mkcastnode(void_type_string,$2)); +  $$ = mknode(F_COMMA_EXPR, $1, mkcastnode(void_type_string, $2));    }    ;         normal_label_statement: unused2 ';'    | import { $$=0; }    | cond    | return expected_semicolon    | local_constant { $$=0; }    | block
pike.git/src/language.yacc:2270:    }    {    /* Trick to store more than one number on compiler stack - Hubbe */    $<number>$=Pike_compiler->compiler_frame->last_block_level;    Pike_compiler->compiler_frame->last_block_level=$<number>2;    }    '(' safe_comma_expr end_cond statement optional_else_part    {    $$=mknode('?',$5,mknode(':',$7,$8));    $$->line_number=$1; -  $$=mkcastnode(void_type_string,$$); +  $$=mkcastnode(void_type_string, $$);    $$->line_number=$1;    pop_local_variables($<number>2);    Pike_compiler->compiler_frame->last_block_level=$<number>3;    }    ;      end_cond: ')'    | '}' { yyerror("Missing ')'."); }    | TOK_LEX_EOF    {
pike.git/src/language.yacc:2366:    {    /* Trick to store more than one number on compiler stack - Hubbe */    $<number>$=Pike_compiler->compiler_frame->last_block_level;    Pike_compiler->compiler_frame->last_block_level=$<number>2;    }    '(' unused expected_semicolon for_expr expected_semicolon unused end_cond    statement    {    int i=lex.current_line;    lex.current_line=$1; -  $$=mknode(F_COMMA_EXPR, mkcastnode(void_type_string,$5), +  $$=mknode(F_COMMA_EXPR, mkcastnode(void_type_string, $5),    mknode(F_FOR,$7,mknode(':',$11,$9)));    lex.current_line=i;    pop_local_variables($<number>2);    Pike_compiler->compiler_frame->last_block_level=$<number>3;    Pike_compiler->compiler_frame->opt_flags |= OPT_CUSTOM_LABELS;    }    ;         while: TOK_WHILE
pike.git/src/language.yacc:2462:    }    $$=mknode(F_RETURN,mkintnode(0),0);    }    | TOK_RETURN safe_comma_expr    {    $$=mknode(F_RETURN,$2,0);    }    ;      unused: { $$=0; } -  | safe_comma_expr { $$=mkcastnode(void_type_string,$1); } +  | safe_comma_expr { $$=mkcastnode(void_type_string, $1); }    ;    - unused2: comma_expr { $$=mkcastnode(void_type_string,$1); } ; + unused2: comma_expr { $$=mkcastnode(void_type_string, $1); } ;      optional_comma_expr: { $$=0; }    | safe_comma_expr    ;      safe_comma_expr: comma_expr    | error { $$=0; }    ;      comma_expr: comma_expr2    | simple_type2 local_name_list { $$=$2; free_node($1); }    | simple_identifier_type local_name_list2 { $$=$2; free_node($1); }    | simple_identifier_type local_function { $$=$2; free_node($1); }    | simple_type2 local_function2 { $$=$2; free_node($1); }    ;         comma_expr2: expr0    | comma_expr2 ',' expr0    { -  $$ = mknode(F_COMMA_EXPR,mkcastnode(void_type_string,$1),$3); +  $$ = mknode(F_COMMA_EXPR, mkcastnode(void_type_string, $1), $3);    }    ;      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; }