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.339 2004/08/16 16:22:11 mast Exp $ + || $Id: language.yacc,v 1.340 2004/08/25 14:16:20 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.339 2004/08/16 16:22:11 mast Exp $"); + RCSID("$Id: language.yacc,v 1.340 2004/08/25 14:16:20 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:566:    {    yyerror("Missing ';'.");    yyerror("Unexpected end of file.");    }    | modifiers TOK_CONSTANT error '}' { yyerror("Missing ';'."); }    ;      block_or_semi: block    {    $$ = check_node_hash(mknode(F_COMMA_EXPR,$1,mknode(F_RETURN,mkintnode(0),0))); -  if ($1) COPY_LINE_NUMBER_INFO ($$, $1); +  COPY_LINE_NUMBER_INFO($$, $1);    }    | ';' { $$ = NULL; }    | TOK_LEX_EOF { yyerror("Expected ';'."); $$ = NULL; }    | error { $$ = NULL; }    ;         type_or_error: simple_type    {   #ifdef PIKE_DEBUG
pike.git/src/language.yacc:1116:      optional_stars: optional_stars '*' { $$=$1 + 1; }    | /* empty */ { $$=0; }    ;      cast: open_paren_with_line_info type ')'    {    struct pike_type *s = compiler_pop_type();    $$ = mktypenode(s);    free_type(s); -  COPY_LINE_NUMBER_INFO ($$, $1); +  COPY_LINE_NUMBER_INFO($$, $1);    free_node ($1);    }    ;      soft_cast: open_bracket_with_line_info type ']'    {    struct pike_type *s = compiler_pop_type();    $$ = mktypenode(s);    free_type(s); -  COPY_LINE_NUMBER_INFO ($$, $1); +  COPY_LINE_NUMBER_INFO($$, $1);    free_node ($1);    }    ;      full_type: type4    | full_type '*'    {    if (Pike_compiler->compiler_pass == 2) {    yywarning("The *-syntax in types is obsolete. Use array instead.");    }
pike.git/src/language.yacc:1670:    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>4; -  if ($5) COPY_LINE_NUMBER_INFO ($5, $3); +  COPY_LINE_NUMBER_INFO($5, $3);    free_node ($3);    $$=$5;    }    ;      end_block: '}'    | TOK_LEX_EOF    {    yyerror("Missing '}'.");    yyerror("Unexpected end of file.");
pike.git/src/language.yacc:1828:    }    ':' statement    {    $$ = mknode(Pike_compiler->compiler_frame->opt_flags & OPT_CUSTOM_LABELS ?    F_CUSTOM_STMT_LABEL : F_NORMAL_STMT_LABEL,    $1, $4);       /* FIXME: This won't be correct if the node happens to be shared.    * That's an issue to be solved with shared nodes in general,    * though. */ -  COPY_LINE_NUMBER_INFO ($$, $1); +  COPY_LINE_NUMBER_INFO($$, $1);    }    ;      optional_label: TOK_IDENTIFIER    | /* empty */ {$$ = 0;}    ;      break: TOK_BREAK optional_label { $$=mknode(F_BREAK,$2,0); } ;   default: TOK_DEFAULT ':' { $$=mknode(F_DEFAULT,0,0); }    | TOK_DEFAULT
pike.git/src/language.yacc:2635:    $<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('?', $6,    mknode(':',    mkcastnode(void_type_string, $8),    mkcastnode(void_type_string, $9)));    $$ = mkcastnode(void_type_string, $$); -  COPY_LINE_NUMBER_INFO ($$, $3); +  COPY_LINE_NUMBER_INFO($$, $3);    free_node ($3);    pop_local_variables($<number>2);    Pike_compiler->compiler_frame->last_block_level=$<number>4;    }    ;      end_cond: ')'    | '}' { yyerror("Missing ')'."); }    | TOK_LEX_EOF    {
pike.git/src/language.yacc:2695:    {    if ($7) {    $$=mknode(F_FOREACH,    mknode(F_VAL_LVAL,$6,$7),    $9);    } else {    /* Error in lvalue */    free_node($6);    $$=$9;    } -  COPY_LINE_NUMBER_INFO ($$, $3); +  COPY_LINE_NUMBER_INFO($$, $3);    free_node ($3);    pop_local_variables($<number>2);    Pike_compiler->compiler_frame->last_block_level=$<number>4;    Pike_compiler->compiler_frame->opt_flags |= OPT_CUSTOM_LABELS;    }    ;      do: TOK_DO line_number_info statement    TOK_WHILE '(' safe_comma_expr end_cond expected_semicolon    {    $$=mknode(F_DO,$3,$6); -  COPY_LINE_NUMBER_INFO ($$, $2); +  COPY_LINE_NUMBER_INFO($$, $2);    free_node ($2);    Pike_compiler->compiler_frame->opt_flags |= OPT_CUSTOM_LABELS;    }    | TOK_DO line_number_info statement TOK_WHILE TOK_LEX_EOF    {    free_node ($2);    $$=0;    yyerror("Missing '(' in do-while loop.");    yyerror("Unexpected end of file.");    }
pike.git/src/language.yacc:2750:    {    /* 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    {    $$=mknode(F_COMMA_EXPR, mkcastnode(void_type_string, $6),    mknode(F_FOR,$8,mknode(':',$12,$10))); -  COPY_LINE_NUMBER_INFO ($$, $3); +  COPY_LINE_NUMBER_INFO($$, $3);    free_node ($3);    pop_local_variables($<number>2);    Pike_compiler->compiler_frame->last_block_level=$<number>4;    Pike_compiler->compiler_frame->opt_flags |= OPT_CUSTOM_LABELS;    }    ;         while: TOK_WHILE    {
pike.git/src/language.yacc:2772:    }    line_number_info    {    /* 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_FOR,$6,mknode(':',$8,NULL)); -  COPY_LINE_NUMBER_INFO ($$, $3); +  COPY_LINE_NUMBER_INFO($$, $3);    free_node ($3);    pop_local_variables($<number>2);    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    ;
pike.git/src/language.yacc:2797:    }    line_number_info    {    /* 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,$6,$8); -  COPY_LINE_NUMBER_INFO ($$, $3); +  COPY_LINE_NUMBER_INFO($$, $3);    free_node ($3);    pop_local_variables($<number>2);    Pike_compiler->compiler_frame->last_block_level=$<number>4;    }    ;      case: TOK_CASE safe_comma_expr expected_colon    {    $$=mknode(F_CASE,$2,0);    }
pike.git/src/language.yacc:2891:   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; }    | open_bracket_with_line_info low_lvalue_list ']' '=' expr0    {    $$=mknode(F_ASSIGN,$5,mknode(F_ARRAY_LVALUE,$2,0)); -  COPY_LINE_NUMBER_INFO ($$, $1); +  COPY_LINE_NUMBER_INFO($$, $1);    free_node ($1);    }    | expr4 assign expr0 { $$=mknode($2,$1,$3); }    | expr4 assign error { $$=$1; reset_type_stack(); yyerrok; }    | bad_expr_ident assign expr0 { $$=$3; }    | open_bracket_with_line_info low_lvalue_list ']' assign expr0    {    $$=mknode($4,mknode(F_ARRAY_LVALUE,$2,0),$5); -  COPY_LINE_NUMBER_INFO ($$, $1); +  COPY_LINE_NUMBER_INFO($$, $1);    free_node ($1);    }    | open_bracket_with_line_info low_lvalue_list ']' error    { $$=$2; free_node ($1); reset_type_stack(); yyerrok; }   /* | error { $$=0; reset_type_stack(); } */    ;      expr01: expr1    | expr1 '?' expr01 ':' expr01 { $$=mknode('?',$1,mknode(':',$3,$5)); }    ;
pike.git/src/language.yacc:3138:    | gauge    | typeof    | sscanf    | lambda    | class    | enum    | idents2    | expr4 open_paren_with_line_info expr_list ')'    {    $$=mkapplynode($1,$3); -  COPY_LINE_NUMBER_INFO ($$, $2); +  COPY_LINE_NUMBER_INFO($$, $2);    free_node ($2);    }    | expr4 open_paren_with_line_info error ')'    {    $$=mkapplynode($1, NULL);    free_node ($2);    yyerrok;    }    | expr4 open_paren_with_line_info error TOK_LEX_EOF    {
pike.git/src/language.yacc:3169:    }    | expr4 open_paren_with_line_info error '}'    {    yyerror("Missing ')'.");    $$=mkapplynode($1, NULL);    free_node ($2);    }    | expr4 open_bracket_with_line_info '*' ']'    {    $$=mknode(F_AUTO_MAP_MARKER, $1, 0); -  COPY_LINE_NUMBER_INFO ($$, $2); +  COPY_LINE_NUMBER_INFO($$, $2);    free_node ($2);    }    | expr4 open_bracket_with_line_info expr0 ']'    {    $$=mknode(F_INDEX,$1,$3); -  COPY_LINE_NUMBER_INFO ($$, $2); +  COPY_LINE_NUMBER_INFO($$, $2);    free_node ($2);    }    | expr4 open_bracket_with_line_info    comma_expr_or_zero expected_dot_dot comma_expr_or_maxint ']'    {    $$=mknode(F_RANGE,$1,mknode(F_ARG_LIST,$3,$5)); -  COPY_LINE_NUMBER_INFO ($$, $2); +  COPY_LINE_NUMBER_INFO($$, $2);    free_node ($2);    }    | expr4 open_bracket_with_line_info error ']'    {    $$=$1;    free_node ($2);    yyerrok;    }    | expr4 open_bracket_with_line_info error TOK_LEX_EOF    {
pike.git/src/language.yacc:3204:    yyerror("Unexpected end of file.");    free_node ($2);    }    | expr4 open_bracket_with_line_info error ';'    {$$=$1; yyerror("Missing ']'."); free_node ($2);}    | expr4 open_bracket_with_line_info error '}'    {$$=$1; yyerror("Missing ']'."); free_node ($2);}    | expr4 open_bracket_with_line_info error ')'    {$$=$1; yyerror("Missing ']'."); free_node ($2);}    | open_paren_with_line_info comma_expr2 ')' -  {$$=$2; COPY_LINE_NUMBER_INFO ($$, $1); free_node ($1);} +  {$$=$2; COPY_LINE_NUMBER_INFO($$, $1); free_node ($1);}    | open_paren_with_line_info '{' expr_list close_brace_or_missing ')'    {    $$=mkefuncallnode("aggregate",$3); -  COPY_LINE_NUMBER_INFO ($$, $1); +  COPY_LINE_NUMBER_INFO($$, $1);    free_node ($1);    }    | open_paren_with_line_info    open_bracket_with_line_info /* Only to avoid shift/reduce conflicts. */    m_expr_list close_bracket_or_missing ')'    {    $$=mkefuncallnode("aggregate_mapping",$3); -  COPY_LINE_NUMBER_INFO ($$, $1); +  COPY_LINE_NUMBER_INFO($$, $1);    free_node ($1);    free_node ($2);    }    | TOK_MULTISET_START line_number_info expr_list TOK_MULTISET_END    {    $$=mkefuncallnode("aggregate_multiset",$3); -  COPY_LINE_NUMBER_INFO ($$, $2); +  COPY_LINE_NUMBER_INFO($$, $2);    free_node ($2);    }    | TOK_MULTISET_START line_number_info expr_list ')'    {    yyerror("Missing '>'.");    $$=mkefuncallnode("aggregate_multiset",$3); -  COPY_LINE_NUMBER_INFO ($$, $2); +  COPY_LINE_NUMBER_INFO($$, $2);    free_node ($2);    }    | open_paren_with_line_info error ')' { $$=$1; yyerrok; }    | open_paren_with_line_info error TOK_LEX_EOF    {    $$=$1; yyerror("Missing ')'.");    yyerror("Unexpected end of file.");    }    | open_paren_with_line_info error ';' { $$=$1; yyerror("Missing ')'."); }    | open_paren_with_line_info error '}' { $$=$1; yyerror("Missing ')'."); }
pike.git/src/language.yacc:3256:    | TOK_MULTISET_START line_number_info error TOK_LEX_EOF    {    $$=$2; yyerror("Missing '>)'.");    yyerror("Unexpected end of file.");    }    | TOK_MULTISET_START line_number_info error ';' { $$=$2; yyerror("Missing '>)'."); }    | TOK_MULTISET_START line_number_info error '}' { $$=$2; yyerror("Missing '>)'."); }    | expr4 TOK_ARROW line_number_info magic_identifier    {    $$=mknode(F_ARROW,$1,$4); -  COPY_LINE_NUMBER_INFO ($$, $3); +  COPY_LINE_NUMBER_INFO($$, $3);    free_node ($3);    }    | expr4 TOK_ARROW line_number_info error {$$=$1; free_node ($3);}    ;      idents2: idents    | TOK_LOCAL_ID TOK_COLON_COLON TOK_IDENTIFIER    {    int i;   
pike.git/src/language.yacc:3741:    {    $$=0; yyerror("Missing ')'.");    yyerror("Unexpected end of file.");    }    | TOK_SSCANF '(' error '}' { $$=0; yyerror("Missing ')'."); }    | TOK_SSCANF '(' error ';' { $$=0; yyerror("Missing ')'."); }    ;      lvalue: expr4    | open_bracket_with_line_info low_lvalue_list ']' -  { $$=mknode(F_ARRAY_LVALUE, $2,0); COPY_LINE_NUMBER_INFO ($$, $1); free_node ($1); } +  { +  $$=mknode(F_ARRAY_LVALUE, $2,0); +  COPY_LINE_NUMBER_INFO($$, $1); +  free_node($1); +  }    | type6 TOK_IDENTIFIER    {    int id = add_local_name($2->u.sval.u.string,compiler_pop_type(),0);    if (id >= 0)    $$=mklocalnode(id,0);    else    $$ = 0;    free_node($2);    }    | bad_expr_ident