@@ -85,8 +85,6 @@ program ::= xx_language(Q) . {
8585}
8686
8787%destructor xx_language {
88- //zval_ptr_dtor($$);
89- //efree($$);
9088 if (&$$) {
9189 zval_ptr_dtor(&$$);
9290 }
@@ -274,6 +272,8 @@ xx_class_def(R) ::= FINAL CLASS IDENTIFIER(I) EXTENDS IDENTIFIER(E) IMPLEMENTS x
274272 xx_ret_class(&R, I, &B, 0, 1, E, &L, status->scanner_state);
275273}
276274
275+ /* TODO: Add internall class */
276+
277277xx_class_body(R) ::= BRACKET_OPEN BRACKET_CLOSE . {
278278 ZVAL_UNDEF(&R);
279279}
@@ -2091,27 +2091,78 @@ xx_call_parameter(R) ::= IDENTIFIER(I) COLON xx_common_expr(E) . {
20912091 xx_ret_call_parameter(&R, I, &E, status->scanner_state);
20922092}
20932093
2094- /** empty closure function () { } * */
2094+ /* empty closure function () { } */
20952095xx_common_expr(R) ::= FUNCTION PARENTHESES_OPEN PARENTHESES_CLOSE BRACKET_OPEN BRACKET_CLOSE . {
2096- xx_ret_expr(&R, "closure", NULL, NULL, NULL, status->scanner_state);
2096+ xx_ret_closure(&R, NULL, NULL, NULL, status->scanner_state);
2097+ }
2098+
2099+ /* empty closure with "use":
2100+ function () use (a, b, c) { } */
2101+ xx_common_expr(R) ::= FUNCTION PARENTHESES_OPEN PARENTHESES_CLOSE USE PARENTHESES_OPEN xx_use_parameter_list(U) PARENTHESES_CLOSE BRACKET_OPEN BRACKET_CLOSE . {
2102+ xx_ret_closure(&R, NULL, NULL, &U, status->scanner_state);
20972103}
20982104
2099- /** function() { ... }*/
2105+ /* function() { ... } */
21002106xx_common_expr(R) ::= FUNCTION PARENTHESES_OPEN PARENTHESES_CLOSE BRACKET_OPEN xx_statement_list(S) BRACKET_CLOSE . {
2101- xx_ret_expr(&R, "closure", NULL, &S, NULL, status->scanner_state);
2107+ xx_ret_closure(&R, NULL, &S, NULL, status->scanner_state);
2108+ }
2109+
2110+ /* function() use (a, b, c) { ... } */
2111+ xx_common_expr(R) ::= FUNCTION PARENTHESES_OPEN PARENTHESES_CLOSE USE PARENTHESES_OPEN xx_use_parameter_list(U) PARENTHESES_CLOSE BRACKET_OPEN xx_statement_list(S) BRACKET_CLOSE . {
2112+ xx_ret_closure(&R, NULL, &S, &U, status->scanner_state);
21022113}
21032114
2104- /** function(a, b, c) { }*/
2115+ /* function(a, b, c) { } */
21052116xx_common_expr(R) ::= FUNCTION PARENTHESES_OPEN xx_parameter_list(L) PARENTHESES_CLOSE BRACKET_OPEN BRACKET_CLOSE . {
2106- xx_ret_expr(&R, "closure", &L, NULL, NULL, status->scanner_state);
2117+ xx_ret_closure(&R, &L, NULL, NULL, status->scanner_state);
2118+ }
2119+
2120+ /* function(a, b, c) use (a, b, c) { } */
2121+ xx_common_expr(R) ::= FUNCTION PARENTHESES_OPEN xx_parameter_list(L) PARENTHESES_CLOSE USE PARENTHESES_OPEN xx_use_parameter_list(U) PARENTHESES_CLOSE BRACKET_OPEN BRACKET_CLOSE . {
2122+ xx_ret_closure(&R, &L, NULL, &U, status->scanner_state);
21072123}
21082124
2109- /** function(a, b, c) { ... }*/
2125+ /* function(a, b, c) { ... } */
21102126xx_common_expr(R) ::= FUNCTION PARENTHESES_OPEN xx_parameter_list(L) PARENTHESES_CLOSE BRACKET_OPEN xx_statement_list(S) BRACKET_CLOSE . {
2111- xx_ret_expr(&R, "closure", &L, &S, NULL, status->scanner_state);
2127+ xx_ret_closure(&R, &L, &S, NULL, status->scanner_state);
2128+ }
2129+
2130+ /* function(a, b, c) use (a, b, c) { ... } */
2131+ xx_common_expr(R) ::= FUNCTION PARENTHESES_OPEN xx_parameter_list(L) PARENTHESES_CLOSE USE PARENTHESES_OPEN xx_use_parameter_list(U) PARENTHESES_CLOSE BRACKET_OPEN xx_statement_list(S) BRACKET_CLOSE . {
2132+ xx_ret_closure(&R, &L, &S, &U, status->scanner_state);
2133+ }
2134+
2135+ /* xx_use_parameter_list */
2136+
2137+ xx_use_parameter_list(R) ::= xx_use_parameter_list(L) COMMA xx_use_parameter(P) . {
2138+ xx_ret_list(&R, &L, &P, status->scanner_state);
2139+ }
2140+
2141+ xx_use_parameter_list(R) ::= xx_use_parameter(P) . {
2142+ xx_ret_list(&R, NULL, &P, status->scanner_state);
2143+ }
2144+
2145+ // a
2146+ xx_use_parameter(R) ::= IDENTIFIER(I) . {
2147+ xx_ret_parameter(&R, 0, NULL, NULL, I, NULL, 0, 0, status->scanner_state);
2148+ }
2149+
2150+ // &a
2151+ xx_use_parameter(R) ::= BITWISE_AND IDENTIFIER(I) . {
2152+ xx_ret_parameter(&R, 0, NULL, NULL, I, NULL, 0, 1, status->scanner_state);
2153+ }
2154+
2155+ // const a
2156+ xx_use_parameter(R) ::= CONST IDENTIFIER(I) . {
2157+ xx_ret_parameter(&R, 1, NULL, NULL, I, NULL, 0, 0, status->scanner_state);
2158+ }
2159+
2160+ // const &a
2161+ xx_use_parameter(R) ::= CONST BITWISE_AND IDENTIFIER(I) . {
2162+ xx_ret_parameter(&R, 1, NULL, NULL, I, NULL, 0, 1, status->scanner_state);
21122163}
21132164
2114- /** x => x + 1 */
2165+ /* x => x + 1 */
21152166xx_common_expr(R) ::= IDENTIFIER(I) DOUBLEARROW xx_common_expr(E) . {
21162167 {
21172168 zval identifier;
0 commit comments