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.232 2001/03/05 21:32:52 grubba Exp $"); + RCSID("$Id: language.yacc,v 1.233 2001/03/17 06:25:58 hubbe 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:309:   %type <n> m_expr_list2   %type <n> new_local_name   %type <n> new_local_name2   %type <n> normal_label_statement   %type <n> optional_else_part   %type <n> optional_label   %type <n> return   %type <n> sscanf   %type <n> statement   %type <n> statements + %type <n> statement_with_semicolon   %type <n> switch   %type <n> typeof   %type <n> unused   %type <n> unused2   %type <n> while   %type <n> optional_comma_expr   %type <n> low_program_ref   %type <n> local_function   %type <n> local_function2   %type <n> magic_identifier
pike.git/src/language.yacc:1603:         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;    $3=mknode(F_COMMA_EXPR,$3,0); +  optimize_node($3);    Pike_compiler->compiler_pass=tmp;    type=$3->u.node.a->type;    }       if(!is_const($3))    {    if(Pike_compiler->compiler_pass==2)    yyerror("Constant definition is not constant.");    }else{    ptrdiff_t tmp=eval_low($3);
pike.git/src/language.yacc:1657:    ;         statements: { $$=0; }    | statements statement    {    $$ = mknode(F_COMMA_EXPR, $1, mkcastnode(void_type_string, $2));    }    ;    + statement_with_semicolon: unused2 optional_block +  { +  if($2) +  { +  $$=recursive_add_call_arg($1,$2); +  }else{ +  $$=$1; +  } +  } + ;    - normal_label_statement: unused2 ';' + normal_label_statement: statement_with_semicolon    | import { $$=0; }    | cond -  | return expected_semicolon +  | return    | local_constant { $$=0; }    | block    | break expected_semicolon    | continue expected_semicolon    | error ';' { reset_type_stack(); $$=0; yyerrok; }    | error TOK_LEX_EOF    {    reset_type_stack();    yyerror("Missing ';'.");    yyerror("Unexpected end of file.");
pike.git/src/language.yacc:2533:    {    yyerror("Missing ':'.");    }    | TOK_LEX_EOF    {    yyerror("Missing ':'.");    yyerror("Unexpected end of file.");    }    ;    - return: TOK_RETURN + return: TOK_RETURN expected_semicolon    {    if(!TEST_COMPAT(0,6) &&    !match_types(Pike_compiler->compiler_frame->current_return_type,    void_type_string))    {    yyerror("Must return a value for a non-void function.");    }    $$=mknode(F_RETURN,mkintnode(0),0);    } -  | TOK_RETURN safe_comma_expr +  | TOK_RETURN safe_comma_expr expected_semicolon    {    $$=mknode(F_RETURN,$2,0);    }    ;      unused: { $$=0; }    | safe_comma_expr { $$=mkcastnode(void_type_string, $1); }    ;      unused2: comma_expr { $$=mkcastnode(void_type_string, $1); } ;
pike.git/src/language.yacc:2723:    * require using ugly implicit variables or extending    * the syntax, and if you extend the syntax you might    * as well use lambda() instead.    * -Hubbe    *    * We might want to allow having more than block after    * a function ( ie. func(args) {} {} {} {} )    * -Hubbe    */    - optional_block: /* EMPTY */ { $$=0; } + 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_type(Pike_compiler->compiler_frame->current_return_type);    copy_type(Pike_compiler->compiler_frame->current_return_type,    any_type_string);       /* block code */    $<number>1=Pike_compiler->num_used_modules;
pike.git/src/language.yacc:2806:   expr4: string    | TOK_NUMBER    | TOK_FLOAT { $$=mkfloatnode((FLOAT_TYPE)$1); }    | catch    | gauge    | typeof    | sscanf    | lambda    | class    | idents2 -  | expr4 '(' expr_list ')' optional_block +  | expr4 '(' expr_list ')'    { -  if($5) $3=mknode(F_ARG_LIST, $3, $5); +     $$=mkapplynode($1,$3);    }    | expr4 '(' error ')' { $$=mkapplynode($1, NULL); yyerrok; }    | expr4 '(' error TOK_LEX_EOF    {    yyerror("Missing ')'."); $$=mkapplynode($1, NULL);    yyerror("Unexpected end of file.");    }    | expr4 '(' error ';' { yyerror("Missing ')'."); $$=mkapplynode($1, NULL); }    | expr4 '(' error '}' { yyerror("Missing ')'."); $$=mkapplynode($1, NULL); }
pike.git/src/language.yacc:3191:   typeof: TOK_TYPEOF '(' expr0 ')'    {    struct pike_type *t;    node *tmp;       /* FIXME: Why build the node at all? */    /* Because the optimizer cannot optimize the root node of the    * tree properly -Hubbe    */    tmp=mknode(F_COMMA_EXPR, $3, 0); +  optimize_node(tmp);       t=(tmp && CAR(tmp) && CAR(tmp)->type ? CAR(tmp)->type : mixed_type_string);    if(TEST_COMPAT(7,0))    {    struct pike_string *s=describe_type(t);    $$ = mkstrnode(s);    free_string(s);    }else{    $$ = mktypenode(t);    }