pike.git / src / language.yacc

version» Context lines:

pike.git/src/language.yacc:145:   %left '^'   %left '&'   %left F_EQ F_NE   %left '>' F_GE '<' F_LE /* nonassoc? */   %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.38 1997/04/23 01:59:41 hubbe Exp $"); + RCSID("$Id: language.yacc,v 1.39 1997/04/23 04:11:26 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"   #include "lex.h"   #include "program.h"   #include "pike_types.h"   #include "constants.h"   #include "pike_macros.h"   #include "error.h"   #include "docode.h"      #define YYMAXDEPTH 600    -  + #ifndef DEBUG + #define DEBUG 1 + #endif + #define YYERROR_VERBOSE +    #ifdef DEBUG   #define YYDEBUG 1   #endif      void free_all_local_names();   void add_local_name(struct pike_string *,struct pike_string *);      /*    * The names and types of arguments and auto variables.    */
pike.git/src/language.yacc:199:    if(comp_stackp>sp)    {    yyerror("Compiler stack fixed.");    comp_stackp=sp;    }else if(comp_stackp<sp){    fatal("Compiler stack frame underflow.");    }   }      %} +    %union   {    int number;    FLOAT_TYPE fnum;    unsigned int address; /* Address of an instruction */    struct pike_string *string;    char *str;    unsigned short type;    struct node_s *n;    struct efun *efun;   }    -  + %{ + int yylex(YYSTYPE *yylval); + %} +    %type <fnum> F_FLOAT      %type <string> F_IDENTIFIER   %type <string> F_STRING   %type <string> cast   %type <string> simple_type   %type <string> low_string   %type <string> optional_identifier   %type <string> optional_rename_inherit   %type <string> string_constant
pike.git/src/language.yacc:544:    }    free_all_local_names();    free_string($4);    free_string($<string>8);    }    | modifiers type_or_error name_list ';' {}    | inheritance {}    | import {}    | constant {}    | class { free_node($1); } -  | error ';' +  | error ';' { yyerrok; }    {    reset_type_stack();    if(num_parse_error>5) YYACCEPT;    }    ;         optional_dot_dot_dot: F_DOT_DOT_DOT { $$=1; }    | /* empty */ { $$=0; }    ;
pike.git/src/language.yacc:580:    if(!$3) $3=make_shared_string("");    if(islocal($3) >= 0)    my_yyerror("Variable '%s' appears twice in argument list.",    $3->str);       add_local_name($3, pop_type());    }    ;      func_args: '(' arguments ')' { $$=$2; } -  | error ')' { $$=0; } +  | '(' error ')' { $$=0; yyerrok; }    ;      arguments: /* empty */ optional_comma { $$=0; }    | arguments2 optional_comma { $$=$1; }    ;      arguments2: new_arg_name { $$ = 1; }    | arguments2 ',' new_arg_name { $$ = $1 + 1; }    ;   
pike.git/src/language.yacc:816:    | do    | for    | switch    | case    | default    | return ';'    | block {}    | foreach    | break ';'    | continue ';' -  | error ';' { reset_type_stack(); $$=0; } +  | error ';' { reset_type_stack(); $$=0; yyerrok; }    | ';' { $$=0; }    ;         break: F_BREAK { $$=mknode(F_BREAK,0,0); } ;   default: F_DEFAULT ':' { $$=mknode(F_DEFAULT,0,0); } ;   continue: F_CONTINUE { $$=mknode(F_CONTINUE,0,0); } ;      lambda: F_LAMBDA    {
pike.git/src/language.yacc:881:    0);    free_string(name);    free_string(type);    comp_stackp=$<number>2;    pop_locals();    $$=mkidentifiernode(f);    }    ;      failsafe_program: '{' program '}' -  | error +  | error { yyerrok; }    ;      class: modifiers F_CLASS optional_identifier    {    start_new_program(); -  +  /* write(2, "start\n", 6); */    }    failsafe_program    {    struct svalue s; -  +  /* write(2, "end\n", 4); */    s.u.program=end_program();    if(!s.u.program)    {    yyerror("Class definition failed.");    s.type=T_INT;    s.subtype=0;    } else {    s.type=T_PROGRAM;    s.subtype=0;    }
pike.git/src/language.yacc:1022:    $$ = mknode(F_ARG_LIST,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 assign expr0 { $$=mknode($2,$1,$3); } -  | error assign expr01 { $$=0; reset_type_stack(); } +  | error assign expr01 { $$=0; reset_type_stack(); yyerrok; }    ;      expr01: expr1 { $$ = $1; }    | expr1 '?' expr01 ':' expr01 { $$=mknode('?',$1,mknode(':',$3,$5)); }    ;      assign: F_AND_EQ { $$=F_AND_EQ; }    | F_OR_EQ { $$=F_OR_EQ; }    | F_XOR_EQ { $$=F_XOR_EQ; }    | F_LSH_EQ { $$=F_LSH_EQ; }