pike.git / src / language.yacc

version» Context lines:

pike.git/src/language.yacc:105:   %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.234 2002/01/02 12:48:34 grubba Exp $"); + RCSID("$Id: language.yacc,v 1.235 2002/10/19 10:14:14 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:1579:    $$=mknode(F_ASSIGN,$3, mklocalnode(islocal($1->u.sval.u.string),0));    free_node($1);    }    | bad_identifier '=' safe_expr0 { $$=$3; }    ;      block:'{'    {    $<number>1=Pike_compiler->num_used_modules;    $<number>$=Pike_compiler->compiler_frame->current_number_of_locals; -  } +  } empty    {    /* Trick to store more than one number on compiler stack - Hubbe */    $<number>$=Pike_compiler->compiler_frame->last_block_level;       if($<number>$ == -1) /* if 'first block' */    Pike_compiler->compiler_frame->last_block_level=0; /* all variables */    else    Pike_compiler->compiler_frame->last_block_level=$<number>2;    }    statements end_block    {    unuse_modules(Pike_compiler->num_used_modules - $<number>1);    pop_local_variables($<number>2); -  Pike_compiler->compiler_frame->last_block_level=$<number>3; -  $$=$4; +  Pike_compiler->compiler_frame->last_block_level=$<number>4; +  $$=$5;    }    ;      end_block: '}'    | TOK_LEX_EOF    {    yyerror("Missing '}'.");    yyerror("Unexpected end of file.");    }    ;
pike.git/src/language.yacc:2461:    pop_stack();    free_node($4);    }    free_type(t);    }    ;      cond: TOK_IF    {    $<number>$=Pike_compiler->compiler_frame->current_number_of_locals; -  } +  } empty    {    /* 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)); +  $$=mknode('?',$6,mknode(':',$8,$9));    $$->line_number=$1;    $$=mkcastnode(void_type_string,$$);    $$->line_number=$1;    pop_local_variables($<number>2); -  Pike_compiler->compiler_frame->last_block_level=$<number>3; +  Pike_compiler->compiler_frame->last_block_level=$<number>4;    }    ;      end_cond: ')'    | '}' { yyerror("Missing ')'."); }    | TOK_LEX_EOF    {    yyerror("Missing ')'.");    yyerror("Unexpected end of file.");    }
pike.git/src/language.yacc:2503:    ;      safe_expr0: expr0    | TOK_LEX_EOF { yyerror("Unexpected end of file."); $$=0; }    | error { $$=0; }    ;      foreach: TOK_FOREACH    {    $<number>$=Pike_compiler->compiler_frame->current_number_of_locals; -  } +  } empty    {    /* 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;    }    '(' expr0 ',' safe_lvalue end_cond statement    { -  if ($7) { -  $$=mknode(F_FOREACH, mknode(F_VAL_LVAL,$5,$7),$9); +  if ($8) { +  $$=mknode(F_FOREACH, mknode(F_VAL_LVAL,$6,$8),$10);    $$->line_number=$1;    } else {    /* Error in lvalue */ -  free_node($5); -  $$=$9; +  free_node($6); +  $$=$10;    }    pop_local_variables($<number>2); -  Pike_compiler->compiler_frame->last_block_level=$<number>3; +  Pike_compiler->compiler_frame->last_block_level=$<number>4;    Pike_compiler->compiler_frame->opt_flags |= OPT_CUSTOM_LABELS;    }    ;      do: TOK_DO statement TOK_WHILE '(' safe_comma_expr end_cond expected_semicolon    {    $$=mknode(F_DO,$2,$5);    $$->line_number=$1;    Pike_compiler->compiler_frame->opt_flags |= OPT_CUSTOM_LABELS;    }
pike.git/src/language.yacc:2556:    | TOK_LEX_EOF    {    yyerror("Missing ';'.");    yyerror("Unexpected end of file.");    }    ;      for: TOK_FOR    {    $<number>$=Pike_compiler->compiler_frame->current_number_of_locals; -  } +  } empty    {    /* 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_FOR,$7,mknode(':',$11,$9))); +  $$=mknode(F_COMMA_EXPR, mkcastnode(void_type_string,$6), +  mknode(F_FOR,$8,mknode(':',$12,$10)));    lex.current_line=i;    pop_local_variables($<number>2); -  Pike_compiler->compiler_frame->last_block_level=$<number>3; +  Pike_compiler->compiler_frame->last_block_level=$<number>4;    Pike_compiler->compiler_frame->opt_flags |= OPT_CUSTOM_LABELS;    }    ;         while: TOK_WHILE    {    $<number>$=Pike_compiler->compiler_frame->current_number_of_locals; -  } +  } empty    {    /* 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    {    int i=lex.current_line;    lex.current_line=$1; -  $$=mknode(F_FOR,$5,mknode(':',$7,NULL)); +  $$=mknode(F_FOR,$6,mknode(':',$8,NULL));    lex.current_line=i;    pop_local_variables($<number>2); -  Pike_compiler->compiler_frame->last_block_level=$<number>3; +  Pike_compiler->compiler_frame->last_block_level=$<number>4;    Pike_compiler->compiler_frame->opt_flags |= OPT_CUSTOM_LABELS;    }    ;      for_expr: /* EMPTY */ { $$=mkintnode(1); }    | safe_comma_expr    ;      switch: TOK_SWITCH    {    $<number>$=Pike_compiler->compiler_frame->current_number_of_locals; -  } +  } empty    {    /* 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    { -  $$=mknode(F_SWITCH,$5,$7); +  $$=mknode(F_SWITCH,$6,$8);    $$->line_number=$1;    pop_local_variables($<number>2); -  Pike_compiler->compiler_frame->last_block_level=$<number>3; +  Pike_compiler->compiler_frame->last_block_level=$<number>4;    }    ;      case: TOK_CASE safe_comma_expr expected_colon    {    $$=mknode(F_CASE,$2,0);    }    | TOK_CASE safe_comma_expr expected_dot_dot optional_comma_expr expected_colon    {    $$=mknode(F_CASE,$4?$2:0,$4?$4:$2);
pike.git/src/language.yacc:2846:   optional_block: /* EMPTY */ { $$=0; }    | '{' push_compiler_frame0    {    debug_malloc_touch(Pike_compiler->compiler_frame->current_return_type);    if(Pike_compiler->compiler_frame->current_return_type)    free_string(Pike_compiler->compiler_frame->current_return_type);    copy_shared_string(Pike_compiler->compiler_frame->current_return_type,any_type_string);       /* block code */    $<number>1=Pike_compiler->num_used_modules; -  $<number>3=Pike_compiler->compiler_frame->current_number_of_locals; +  $<number>$=Pike_compiler->compiler_frame->current_number_of_locals;    }    statements end_block    {    struct pike_string *type;    char buf[40];    int f,e;    struct pike_string *name;       /* block code */    unuse_modules(Pike_compiler->num_used_modules - $<number>1);
pike.git/src/language.yacc:3544:    | TOK_DEFAULT    { yyerror("default is a reserved word."); }    | TOK_FOR    { yyerror("for is a reserved word."); }    | TOK_FOREACH    { yyerror("foreach is a reserved word."); }    | TOK_IF    { yyerror("if is a reserved word."); }    ;    + /* Kludge for bison 1.50. */ + empty: /* empty */ ;    -  +    %%      void yyerror(char *str)   {    extern int num_parse_error;    extern int cumulative_parse_error;      #ifdef PIKE_DEBUG    if(Pike_interpreter.recoveries && Pike_sp-Pike_interpreter.evaluator_stack < Pike_interpreter.recoveries->stack_pointer)    fatal("Stack error (underflow)\n");