pike.git / src / language.yacc

version» Context lines:

pike.git/src/language.yacc:310:   %type <n> string   %type <n> TOK_STRING   %type <n> TOK_NUMBER   %type <n> TOK_BITS   %type <n> optional_rename_inherit   %type <n> optional_identifier   %type <n> implicit_identifier   %type <n> TOK_IDENTIFIER   %type <n> TOK_RESERVED   %type <n> TOK_VERSION + %type <n> annotation   %type <n> attribute   %type <n> assoc_pair   %type <n> line_number_info   %type <n> block   %type <n> optional_block   %type <n> failsafe_block   %type <n> open_paren_with_line_info   %type <n> close_paren_or_missing   %type <n> open_bracket_with_line_info   %type <n> block_or_semi
pike.git/src/language.yacc:336:   %type <n> enum   %type <n> enum_value   %type <n> safe_comma_expr   %type <n> comma_expr   %type <n> comma_expr2   %type <n> range_bound   %type <n> cond   %type <n> continue   %type <n> default   %type <n> do + %type <n> constant_expr   %type <n> safe_expr0   %type <n> splice_expr   %type <n> expr01   %type <n> expr1   %type <n> expr2   %type <n> expr3 expr0   %type <n> apply   %type <n> expr4   %type <n> expr5   %type <n> expr_list
pike.git/src/language.yacc:1057:    {    if ($10) free_node($10);    }    | modifiers optional_attributes simple_type optional_constant name_list ';'    | inheritance {}    | implement {}    | import {}    | constant {}    | modifiers named_class { free_node($2); }    | modifiers enum { free_node($2); } +  | annotation ';' { free_node($1); }    | typedef {}    | static_assertion expected_semicolon {}    | error TOK_LEX_EOF    {    reset_type_stack();    yyerror("Missing ';'.");    yyerror("Unexpected end of file");    }    | error ';'    {
pike.git/src/language.yacc:1256:      magic_identifier: TOK_IDENTIFIER | TOK_RESERVED    | magic_identifiers    {    struct pike_string *tmp=make_shared_string($1);    $$=mkstrnode(tmp);    free_string(tmp);    }    ;    + annotation: '@' constant_expr +  { +  $$ = $2; +  } +  ; +    modifiers: modifier_list    {    $$=Pike_compiler->current_modifiers=$1 |    (THIS_COMPILATION->lex.pragmas & ID_MODIFIER_MASK);    } -  +  | annotation ':' modifiers +  { +  if ($1) free_node($1); +  $$ = $3; +  }    ;      modifier_list: /* empty */ { $$ = 0; }    | modifier_list modifier { $$ = $1 | $2; }    ;      attribute: TOK_ATTRIBUTE_ID '(' string_constant optional_comma ')'    {    $$ = $3;    }
pike.git/src/language.yacc:1915:    | TOK_LEX_EOF { yyerror("Unexpected end of file."); $$=0; }    ;      /* Type at compiler_frame->current_type. */   local_name_list: new_local_name    | local_name_list ',' new_local_name    { $$ = mknode(F_COMMA_EXPR, mkcastnode(void_type_string, $1), $3); }    ;       + constant_expr: safe_expr0 +  { +  /* Ugly hack to make sure that $1 is optimized */ +  { +  int tmp = Pike_compiler->compiler_pass; +  $$ = mknode(F_COMMA_EXPR, $1, 0); +  optimize_node($$); +  Pike_compiler->compiler_pass = tmp; +  } +  +  if(!is_const($$)) { +  if(Pike_compiler->compiler_pass == COMPILER_PASS_LAST) +  yyerror("Expected constant expression."); +  push_int(0); +  } else { +  ptrdiff_t tmp = eval_low($$, 1); +  if(tmp < 1) +  { +  if(Pike_compiler->compiler_pass == COMPILER_PASS_LAST) +  yyerror("Error evaluating constant expression."); +  push_int(0); +  } else { +  pop_n_elems((INT32)(tmp - 1)); +  } +  } +  free_node($$); +  $$ = mksvaluenode(Pike_sp - 1); +  pop_stack(); +  } +  ; +    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;