Skip to content

Commit

Permalink
hipster expression ... which does nothing but wig out if not passed a…
Browse files Browse the repository at this point in the history
… string ...
  • Loading branch information
krakjoe committed Mar 3, 2016
1 parent de3e033 commit 4efb1a4
Show file tree
Hide file tree
Showing 9 changed files with 2,777 additions and 2,664 deletions.
1 change: 1 addition & 0 deletions Zend/zend_ast.h
Expand Up @@ -96,6 +96,7 @@ enum _zend_ast_kind {
ZEND_AST_GOTO,
ZEND_AST_BREAK,
ZEND_AST_CONTINUE,
ZEND_AST_HIPSTER,

/* 2 child nodes */
ZEND_AST_DIM = 2 << ZEND_AST_NUM_CHILDREN_SHIFT,
Expand Down
13 changes: 13 additions & 0 deletions Zend/zend_compile.c
Expand Up @@ -4293,6 +4293,16 @@ void zend_compile_foreach(zend_ast *ast) /* {{{ */
}
/* }}} */

void zend_compile_hipster(znode *result, zend_ast *ast) /* {{{ */
{
zend_ast *expr_ast = ast->child[0];
znode expr_node;

zend_compile_expr(&expr_node, expr_ast);

zend_emit_op(result, ZEND_HIPSTER, &expr_node, NULL);
} /* }}} */

void zend_compile_if(zend_ast *ast) /* {{{ */
{
zend_ast_list *list = zend_ast_get_list(ast);
Expand Down Expand Up @@ -7547,6 +7557,9 @@ void zend_compile_expr(znode *result, zend_ast *ast) /* {{{ */
case ZEND_AST_YIELD:
zend_compile_yield(result, ast);
return;
case ZEND_AST_HIPSTER:
zend_compile_hipster(result, ast);
return;
case ZEND_AST_YIELD_FROM:
zend_compile_yield_from(result, ast);
return;
Expand Down
4 changes: 3 additions & 1 deletion Zend/zend_language_parser.y
Expand Up @@ -71,6 +71,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
%left '&'
%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL T_SPACESHIP
%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL
%nonassoc T_HIPSTER
%left T_SL T_SR
%left '+' '-' '.'
%left '*' '/' '%'
Expand Down Expand Up @@ -186,6 +187,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
%token T_ISSET "isset (T_ISSET)"
%token T_EMPTY "empty (T_EMPTY)"
%token T_HALT_COMPILER "__halt_compiler (T_HALT_COMPILER)"
%token T_HIPSTER "hipster (T_HIPSTER)"
%token T_CLASS "class (T_CLASS)"
%token T_TRAIT "trait (T_TRAIT)"
%token T_INTERFACE "interface (T_INTERFACE)"
Expand Down Expand Up @@ -412,7 +414,6 @@ inner_statement:
"__HALT_COMPILER() can only be used from the outermost scope"); }
;


statement:
'{' inner_statement_list '}' { $$ = $2; }
| if_stmt { $$ = $1; }
Expand Down Expand Up @@ -943,6 +944,7 @@ expr_without_variable:
| expr T_COALESCE expr
{ $$ = zend_ast_create(ZEND_AST_COALESCE, $1, $3); }
| internal_functions_in_yacc { $$ = $1; }
| T_HIPSTER '(' expr ')' { $$ = zend_ast_create(ZEND_AST_HIPSTER, $3); }
| T_INT_CAST expr { $$ = zend_ast_create_cast(IS_LONG, $2); }
| T_DOUBLE_CAST expr { $$ = zend_ast_create_cast(IS_DOUBLE, $2); }
| T_STRING_CAST expr { $$ = zend_ast_create_cast(IS_STRING, $2); }
Expand Down

0 comments on commit 4efb1a4

Please sign in to comment.