Changeset View
Changeset View
Standalone View
Standalone View
support/xhpast/parser.y
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | static void yyerror(void* yyscanner, void* _, const char* error) { | ||||
yyextra->error = error; | yyextra->error = error; | ||||
} | } | ||||
%} | %} | ||||
%expect 5 | %expect 5 | ||||
// 2: PHP's if/else grammar | // 2: PHP's if/else grammar | ||||
// 7: expr '[' dim_offset ']' -- shift will default to first grammar | // 7: expr '[' dim_offset ']' -- shift will default to first grammar | ||||
%name-prefix "xhpast" | |||||
%pure-parser | %pure-parser | ||||
%parse-param { void* yyscanner } | %parse-param { void* yyscanner } | ||||
%parse-param { xhpast::Node** root } | %parse-param { xhpast::Node** root } | ||||
%lex-param { void* yyscanner } | %lex-param { void* yyscanner } | ||||
%error-verbose | %error-verbose | ||||
%precedence T_INCLUDE T_INCLUDE_ONCE | %left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE | ||||
%token T_EVAL | %left ',' | ||||
%precedence T_REQUIRE T_REQUIRE_ONCE | |||||
%token ',' | |||||
%left T_LOGICAL_OR | %left T_LOGICAL_OR | ||||
%left T_LOGICAL_XOR | %left T_LOGICAL_XOR | ||||
%left T_LOGICAL_AND | %left T_LOGICAL_AND | ||||
%precedence T_PRINT | %right T_PRINT | ||||
%precedence '=' T_PLUS_EQUAL | %left '=' T_PLUS_EQUAL | ||||
T_MINUS_EQUAL | T_MINUS_EQUAL | ||||
T_MUL_EQUAL | T_MUL_EQUAL | ||||
T_DIV_EQUAL | T_DIV_EQUAL | ||||
T_CONCAT_EQUAL | T_CONCAT_EQUAL | ||||
T_MOD_EQUAL | T_MOD_EQUAL | ||||
T_AND_EQUAL | T_AND_EQUAL | ||||
T_OR_EQUAL | T_OR_EQUAL | ||||
T_XOR_EQUAL | T_XOR_EQUAL | ||||
T_SL_EQUAL | T_SL_EQUAL | ||||
T_SR_EQUAL | T_SR_EQUAL | ||||
%left '?' ':' | %left '?' ':' | ||||
%right T_COALESCE | %right T_COALESCE | ||||
%left T_BOOLEAN_OR | %left T_BOOLEAN_OR | ||||
%left T_BOOLEAN_AND | %left T_BOOLEAN_AND | ||||
%left '|' | %left '|' | ||||
%left '^' | %left '^' | ||||
%left '&' | %left '&' | ||||
%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL | %nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL | ||||
T_SPACESHIP | T_SPACESHIP | ||||
%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL | %nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL | ||||
%left T_SL T_SR | %left T_SL T_SR | ||||
%left '+' '-' '.' | %left '+' '-' '.' | ||||
%left '*' '/' '%' | %left '*' '/' '%' | ||||
%precedence '!' | %right '!' | ||||
%precedence T_INSTANCEOF | %nonassoc T_INSTANCEOF | ||||
%precedence '~' T_INC | %right '~' T_INC | ||||
%token T_DEC | T_DEC | ||||
%precedence T_INT_CAST T_DOUBLE_CAST T_STRING_CAST | T_INT_CAST | ||||
%token T_UNICODE_CAST | T_DOUBLE_CAST | ||||
%token T_BINARY_CAST | T_STRING_CAST | ||||
%precedence T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@' | T_UNICODE_CAST | ||||
%token '[' | T_BINARY_CAST | ||||
%token T_NEW | T_ARRAY_CAST | ||||
%precedence T_CLONE | T_OBJECT_CAST | ||||
T_BOOL_CAST | |||||
T_UNSET_CAST | |||||
'@' | |||||
%right '[' | |||||
%nonassoc T_NEW T_CLONE | |||||
%token T_EXIT | %token T_EXIT | ||||
%token T_IF | %token T_IF | ||||
%token T_ELSEIF | %left T_ELSEIF | ||||
%token T_ELSE | %left T_ELSE | ||||
%token T_ENDIF | %left T_ENDIF | ||||
%token T_LNUMBER | %token T_LNUMBER | ||||
%token T_DNUMBER | %token T_DNUMBER | ||||
%token T_STRING | %token T_STRING | ||||
%token T_STRING_VARNAME /* unused in XHP: `foo` in `"$foo"` */ | %token T_STRING_VARNAME /* unused in XHP: `foo` in `"$foo"` */ | ||||
%token T_VARIABLE | %token T_VARIABLE | ||||
%token T_NUM_STRING /* unused in XHP: `0` in `"$foo[0]"` */ | %token T_NUM_STRING /* unused in XHP: `0` in `"$foo[0]"` */ | ||||
%token T_INLINE_HTML | %token T_INLINE_HTML | ||||
Show All 24 Lines | |||||
%token T_FUNCTION | %token T_FUNCTION | ||||
%token T_CONST | %token T_CONST | ||||
%token T_RETURN | %token T_RETURN | ||||
%token T_TRY | %token T_TRY | ||||
%token T_CATCH | %token T_CATCH | ||||
%token T_THROW | %token T_THROW | ||||
%token T_USE | %token T_USE | ||||
%token T_GLOBAL | %token T_GLOBAL | ||||
%token T_STATIC | %right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC | ||||
%token T_ABSTRACT | |||||
%token T_FINAL | |||||
%token T_PRIVATE | |||||
%token T_PROTECTED | |||||
%token T_PUBLIC | |||||
%token T_VAR | %token T_VAR | ||||
%token T_UNSET | %token T_UNSET | ||||
%token T_ISSET | %token T_ISSET | ||||
%token T_EMPTY | %token T_EMPTY | ||||
%token T_HALT_COMPILER | %token T_HALT_COMPILER | ||||
%token T_CLASS | %token T_CLASS | ||||
%token T_INTERFACE | %token T_INTERFACE | ||||
%token T_EXTENDS | %token T_EXTENDS | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | top_statement_list { | ||||
*root = NNEW(n_PROGRAM)->appendChild($1); | *root = NNEW(n_PROGRAM)->appendChild($1); | ||||
} | } | ||||
; | ; | ||||
top_statement_list: | top_statement_list: | ||||
top_statement_list top_statement { | top_statement_list top_statement { | ||||
$$ = $1->appendChild($2); | $$ = $1->appendChild($2); | ||||
} | } | ||||
| %empty { | | /* empty */ { | ||||
$$ = NNEW(n_STATEMENT_LIST); | $$ = NNEW(n_STATEMENT_LIST); | ||||
} | } | ||||
; | ; | ||||
namespace_name: | namespace_name: | ||||
T_STRING { | T_STRING { | ||||
$$ = NTYPE($1, n_SYMBOL_NAME); | $$ = NTYPE($1, n_SYMBOL_NAME); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | $$->appendChild( | ||||
->appendChild($4)); | ->appendChild($4)); | ||||
} | } | ||||
; | ; | ||||
inner_statement_list: | inner_statement_list: | ||||
inner_statement_list inner_statement { | inner_statement_list inner_statement { | ||||
$$ = $1->appendChild($2); | $$ = $1->appendChild($2); | ||||
} | } | ||||
| %empty { | | /* empty */ { | ||||
$$ = NNEW(n_STATEMENT_LIST); | $$ = NNEW(n_STATEMENT_LIST); | ||||
} | } | ||||
; | ; | ||||
inner_statement: | inner_statement: | ||||
statement | statement | ||||
| function_declaration_statement | | function_declaration_statement | ||||
| class_declaration_statement | | class_declaration_statement | ||||
▲ Show 20 Lines • Show All 292 Lines • ▼ Show 20 Lines | '{' inner_statement_list '}' { | ||||
$1->appendChild(NTYPE($4, n_VARIABLE)); | $1->appendChild(NTYPE($4, n_VARIABLE)); | ||||
$1->appendChild(NEXPAND($6, $7, $8)); | $1->appendChild(NEXPAND($6, $7, $8)); | ||||
NMORE($1, $8); | NMORE($1, $8); | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
; | ; | ||||
finally_statement: | finally_statement: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| non_empty_finally_statement | | non_empty_finally_statement | ||||
; | ; | ||||
non_empty_finally_statement: | non_empty_finally_statement: | ||||
T_FINALLY '{' inner_statement_list '}' { | T_FINALLY '{' inner_statement_list '}' { | ||||
NTYPE($1, n_FINALLY); | NTYPE($1, n_FINALLY); | ||||
Show All 22 Lines | function_declaration_statement: | ||||
unticked_function_declaration_statement | unticked_function_declaration_statement | ||||
; | ; | ||||
class_declaration_statement: | class_declaration_statement: | ||||
unticked_class_declaration_statement | unticked_class_declaration_statement | ||||
; | ; | ||||
is_reference: | is_reference: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| '&' { | | '&' { | ||||
$$ = NTYPE($1, n_REFERENCE); | $$ = NTYPE($1, n_REFERENCE); | ||||
} | } | ||||
; | ; | ||||
unticked_function_declaration_statement: | unticked_function_declaration_statement: | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | | T_FINAL T_CLASS { | ||||
} | } | ||||
| T_TRAIT { | | T_TRAIT { | ||||
$$ = NNEW(n_CLASS_ATTRIBUTES); | $$ = NNEW(n_CLASS_ATTRIBUTES); | ||||
$$->appendChild(NTYPE($1, n_STRING)); | $$->appendChild(NTYPE($1, n_STRING)); | ||||
} | } | ||||
; | ; | ||||
extends_from: | extends_from: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| T_EXTENDS fully_qualified_class_name { | | T_EXTENDS fully_qualified_class_name { | ||||
$$ = NTYPE($1, n_EXTENDS_LIST)->appendChild($2); | $$ = NTYPE($1, n_EXTENDS_LIST)->appendChild($2); | ||||
} | } | ||||
; | ; | ||||
interface_entry: | interface_entry: | ||||
T_INTERFACE | T_INTERFACE | ||||
; | ; | ||||
interface_extends_list: | interface_extends_list: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| T_EXTENDS interface_list { | | T_EXTENDS interface_list { | ||||
NTYPE($1, n_EXTENDS_LIST); | NTYPE($1, n_EXTENDS_LIST); | ||||
$1->appendChildren($2); | $1->appendChildren($2); | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
; | ; | ||||
implements_list: | implements_list: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| T_IMPLEMENTS interface_list { | | T_IMPLEMENTS interface_list { | ||||
NTYPE($1, n_IMPLEMENTS_LIST); | NTYPE($1, n_IMPLEMENTS_LIST); | ||||
$1->appendChildren($2); | $1->appendChildren($2); | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
; | ; | ||||
interface_list: | interface_list: | ||||
fully_qualified_class_name { | fully_qualified_class_name { | ||||
$$ = NNEW(n_IMPLEMENTS_LIST)->appendChild($1); | $$ = NNEW(n_IMPLEMENTS_LIST)->appendChild($1); | ||||
} | } | ||||
| interface_list ',' fully_qualified_class_name { | | interface_list ',' fully_qualified_class_name { | ||||
$$ = $1->appendChild($3); | $$ = $1->appendChild($3); | ||||
} | } | ||||
; | ; | ||||
foreach_optional_arg: | foreach_optional_arg: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| T_DOUBLE_ARROW foreach_variable { | | T_DOUBLE_ARROW foreach_variable { | ||||
$$ = $2; | $$ = $2; | ||||
} | } | ||||
; | ; | ||||
foreach_variable: | foreach_variable: | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | | ':' ';' case_list T_ENDSWITCH ';' { | ||||
$$ = NNEW(n_STATEMENT_LIST)->appendChild($2); | $$ = NNEW(n_STATEMENT_LIST)->appendChild($2); | ||||
$$->appendChildren($3); | $$->appendChildren($3); | ||||
NMORE($$, $5); | NMORE($$, $5); | ||||
NMORE($$, $1); | NMORE($$, $1); | ||||
} | } | ||||
; | ; | ||||
case_list: | case_list: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_STATEMENT_LIST); | $$ = NNEW(n_STATEMENT_LIST); | ||||
} | } | ||||
| case_list T_CASE expr case_separator inner_statement_list { | | case_list T_CASE expr case_separator inner_statement_list { | ||||
NTYPE($2, n_CASE); | NTYPE($2, n_CASE); | ||||
$2->appendChild($3); | $2->appendChild($3); | ||||
$2->appendChild($5); | $2->appendChild($5); | ||||
$1->appendChild($2); | $1->appendChild($2); | ||||
Show All 18 Lines | |||||
| ':' inner_statement_list T_ENDWHILE ';' { | | ':' inner_statement_list T_ENDWHILE ';' { | ||||
NMORE($2, $4); | NMORE($2, $4); | ||||
NMORE($2, $1); | NMORE($2, $1); | ||||
$$ = $2; | $$ = $2; | ||||
} | } | ||||
; | ; | ||||
elseif_list: | elseif_list: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_CONDITION_LIST); | $$ = NNEW(n_CONDITION_LIST); | ||||
} | } | ||||
| elseif_list T_ELSEIF '(' expr ')' statement { | | elseif_list T_ELSEIF '(' expr ')' statement { | ||||
NTYPE($2, n_ELSEIF); | NTYPE($2, n_ELSEIF); | ||||
$2->appendChild(NSPAN($3, n_CONTROL_CONDITION, $5)->appendChild($4)); | $2->appendChild(NSPAN($3, n_CONTROL_CONDITION, $5)->appendChild($4)); | ||||
$2->appendChild($6); | $2->appendChild($6); | ||||
$$ = $1->appendChild($2); | $$ = $1->appendChild($2); | ||||
} | } | ||||
; | ; | ||||
new_elseif_list: | new_elseif_list: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_CONDITION_LIST); | $$ = NNEW(n_CONDITION_LIST); | ||||
} | } | ||||
| new_elseif_list T_ELSEIF '(' expr ')' ':' inner_statement_list { | | new_elseif_list T_ELSEIF '(' expr ')' ':' inner_statement_list { | ||||
NTYPE($2, n_ELSEIF); | NTYPE($2, n_ELSEIF); | ||||
$2->appendChild($4); | $2->appendChild($4); | ||||
$2->appendChild($7); | $2->appendChild($7); | ||||
$$ = $1->appendChild($2); | $$ = $1->appendChild($2); | ||||
} | } | ||||
; | ; | ||||
else_single: | else_single: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| T_ELSE statement { | | T_ELSE statement { | ||||
NTYPE($1, n_ELSE); | NTYPE($1, n_ELSE); | ||||
$1->appendChild($2); | $1->appendChild($2); | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
; | ; | ||||
new_else_single: | new_else_single: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| T_ELSE ':' inner_statement_list { | | T_ELSE ':' inner_statement_list { | ||||
NTYPE($1, n_ELSE); | NTYPE($1, n_ELSE); | ||||
$1->appendChild($3); | $1->appendChild($3); | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
; | ; | ||||
parameter_list: | parameter_list: | ||||
non_empty_parameter_list | non_empty_parameter_list | ||||
| %empty { | | /* empty */ { | ||||
$$ = NNEW(n_DECLARATION_PARAMETER_LIST); | $$ = NNEW(n_DECLARATION_PARAMETER_LIST); | ||||
} | } | ||||
; | ; | ||||
non_empty_parameter_list: | non_empty_parameter_list: | ||||
optional_type parameter { | optional_type parameter { | ||||
$$ = NNEW(n_DECLARATION_PARAMETER); | $$ = NNEW(n_DECLARATION_PARAMETER); | ||||
$$->appendChild($1); | $$->appendChild($1); | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | T_ELLIPSIS T_VARIABLE { | ||||
$$->appendChild(NTYPE($2, n_VARIABLE)); | $$->appendChild(NTYPE($2, n_VARIABLE)); | ||||
} | } | ||||
| T_VARIABLE { | | T_VARIABLE { | ||||
$$ = NTYPE($1, n_VARIABLE); | $$ = NTYPE($1, n_VARIABLE); | ||||
} | } | ||||
; | ; | ||||
optional_type: | optional_type: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| type | | type | ||||
| '?' type { | | '?' type { | ||||
$$ = NNEW(n_NULLABLE_TYPE); | $$ = NNEW(n_NULLABLE_TYPE); | ||||
$$->appendChild($2); | $$->appendChild($2); | ||||
} | } | ||||
; | ; | ||||
type: | type: | ||||
fully_qualified_class_name { | fully_qualified_class_name { | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
| T_ARRAY { | | T_ARRAY { | ||||
$$ = NTYPE($1, n_TYPE_NAME); | $$ = NTYPE($1, n_TYPE_NAME); | ||||
} | } | ||||
| T_CALLABLE { | | T_CALLABLE { | ||||
$$ = NTYPE($1, n_TYPE_NAME); | $$ = NTYPE($1, n_TYPE_NAME); | ||||
} | } | ||||
; | ; | ||||
return_type: | return_type: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| ':' optional_type { | | ':' optional_type { | ||||
$$ = NNEW(n_DECLARATION_RETURN); | $$ = NNEW(n_DECLARATION_RETURN); | ||||
$$->appendChild($2); | $$->appendChild($2); | ||||
} | } | ||||
; | ; | ||||
function_call_parameter_list: | function_call_parameter_list: | ||||
non_empty_function_call_parameter_list | non_empty_function_call_parameter_list | ||||
| %empty { | | /* empty */ { | ||||
$$ = NNEW(n_CALL_PARAMETER_LIST); | $$ = NNEW(n_CALL_PARAMETER_LIST); | ||||
} | } | ||||
; | ; | ||||
non_empty_function_call_parameter_list: | non_empty_function_call_parameter_list: | ||||
argument { | argument { | ||||
$$ = NNEW(n_CALL_PARAMETER_LIST)->appendChild($1); | $$ = NNEW(n_CALL_PARAMETER_LIST)->appendChild($1); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | | T_VARIABLE '=' static_scalar { | ||||
$$ = NNEW(n_STATIC_DECLARATION_LIST)->appendChild($$); | $$ = NNEW(n_STATIC_DECLARATION_LIST)->appendChild($$); | ||||
} | } | ||||
; | ; | ||||
class_statement_list: | class_statement_list: | ||||
class_statement_list class_statement { | class_statement_list class_statement { | ||||
$$ = $1->appendChild($2); | $$ = $1->appendChild($2); | ||||
} | } | ||||
| %empty { | | /* empty */ { | ||||
$$ = NNEW(n_STATEMENT_LIST); | $$ = NNEW(n_STATEMENT_LIST); | ||||
} | } | ||||
; | ; | ||||
class_statement: | class_statement: | ||||
variable_modifiers class_variable_declaration ';' { | variable_modifiers class_variable_declaration ';' { | ||||
$$ = NNEW(n_CLASS_MEMBER_DECLARATION_LIST); | $$ = NNEW(n_CLASS_MEMBER_DECLARATION_LIST); | ||||
$$->appendChild($1); | $$->appendChild($1); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | ';' { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| '{' trait_adaptation_list '}' { | | '{' trait_adaptation_list '}' { | ||||
$$ = NEXPAND($1, $2, $3); | $$ = NEXPAND($1, $2, $3); | ||||
} | } | ||||
; | ; | ||||
trait_adaptation_list: | trait_adaptation_list: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_TRAIT_ADAPTATION_LIST); | $$ = NNEW(n_TRAIT_ADAPTATION_LIST); | ||||
} | } | ||||
| non_empty_trait_adaptation_list { | | non_empty_trait_adaptation_list { | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
; | ; | ||||
non_empty_trait_adaptation_list: | non_empty_trait_adaptation_list: | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | | trait_method_reference T_AS member_modifier { | ||||
$$ = NNEW(n_TRAIT_AS); | $$ = NNEW(n_TRAIT_AS); | ||||
$$->appendChild($1); | $$->appendChild($1); | ||||
$$->appendChild($3); | $$->appendChild($3); | ||||
$$->appendChild(NNEW(n_EMPTY)); | $$->appendChild(NNEW(n_EMPTY)); | ||||
} | } | ||||
; | ; | ||||
trait_modifiers: | trait_modifiers: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| member_modifier { | | member_modifier { | ||||
$$ = NNEW(n_METHOD_MODIFIER_LIST); | $$ = NNEW(n_METHOD_MODIFIER_LIST); | ||||
$$->appendChild(NTYPE($1, n_STRING)); | $$->appendChild(NTYPE($1, n_STRING)); | ||||
} | } | ||||
; | ; | ||||
Show All 11 Lines | variable_modifiers: | ||||
non_empty_member_modifiers | non_empty_member_modifiers | ||||
| T_VAR { | | T_VAR { | ||||
$$ = NNEW(n_CLASS_MEMBER_MODIFIER_LIST); | $$ = NNEW(n_CLASS_MEMBER_MODIFIER_LIST); | ||||
$$->appendChild(NTYPE($1, n_STRING)); | $$->appendChild(NTYPE($1, n_STRING)); | ||||
} | } | ||||
; | ; | ||||
method_modifiers: | method_modifiers: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_METHOD_MODIFIER_LIST); | $$ = NNEW(n_METHOD_MODIFIER_LIST); | ||||
} | } | ||||
| non_empty_member_modifiers { | | non_empty_member_modifiers { | ||||
NTYPE($1, n_METHOD_MODIFIER_LIST); | NTYPE($1, n_METHOD_MODIFIER_LIST); | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
; | ; | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | echo_expr_list: | ||||
} | } | ||||
| expr { | | expr { | ||||
$$ = NNEW(n_ECHO_LIST); | $$ = NNEW(n_ECHO_LIST); | ||||
$$->appendChild($1); | $$->appendChild($1); | ||||
} | } | ||||
; | ; | ||||
for_expr: | for_expr: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| non_empty_for_expr | | non_empty_for_expr | ||||
; | ; | ||||
non_empty_for_expr: | non_empty_for_expr: | ||||
non_empty_for_expr ',' expr { | non_empty_for_expr ',' expr { | ||||
▲ Show 20 Lines • Show All 484 Lines • ▼ Show 20 Lines | | T_YIELD expr T_DOUBLE_ARROW variable { | ||||
} | } | ||||
; | ; | ||||
function: | function: | ||||
T_FUNCTION | T_FUNCTION | ||||
; | ; | ||||
lexical_vars: | lexical_vars: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| T_USE '(' lexical_var_list ')' { | | T_USE '(' lexical_var_list ')' { | ||||
NTYPE($1, n_LEXICAL_VARIABLE_LIST); | NTYPE($1, n_LEXICAL_VARIABLE_LIST); | ||||
$1->appendChildren($3); | $1->appendChildren($3); | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
; | ; | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | dynamic_class_name_reference: | ||||
} | } | ||||
| base_variable | | base_variable | ||||
; | ; | ||||
dynamic_class_name_variable_properties: | dynamic_class_name_variable_properties: | ||||
dynamic_class_name_variable_properties dynamic_class_name_variable_property { | dynamic_class_name_variable_properties dynamic_class_name_variable_property { | ||||
$$ = $1->appendChild($2); | $$ = $1->appendChild($2); | ||||
} | } | ||||
| %empty { | | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
; | ; | ||||
dynamic_class_name_variable_property: | dynamic_class_name_variable_property: | ||||
T_OBJECT_OPERATOR object_property { | T_OBJECT_OPERATOR object_property { | ||||
$$ = $2; | $$ = $2; | ||||
} | } | ||||
; | ; | ||||
exit_expr: | exit_expr: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| '(' ')' { | | '(' ')' { | ||||
NSPAN($1, n_EMPTY, $2); | NSPAN($1, n_EMPTY, $2); | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
| '(' expr ')' { | | '(' expr ')' { | ||||
NSPAN($1, n_PARENTHETICAL_EXPRESSION, $3); | NSPAN($1, n_PARENTHETICAL_EXPRESSION, $3); | ||||
$1->appendChild($2); | $1->appendChild($2); | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
; | ; | ||||
ctor_arguments: | ctor_arguments: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| '(' function_call_parameter_list ')' { | | '(' function_call_parameter_list ')' { | ||||
$$ = NEXPAND($1, $2, $3); | $$ = NEXPAND($1, $2, $3); | ||||
} | } | ||||
; | ; | ||||
common_scalar: | common_scalar: | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | | T_NAMESPACE T_NS_SEPARATOR namespace_name { | ||||
} | } | ||||
| T_NS_SEPARATOR namespace_name { | | T_NS_SEPARATOR namespace_name { | ||||
$$ = NMORE($2, $1); | $$ = NMORE($2, $1); | ||||
} | } | ||||
| common_scalar | | common_scalar | ||||
; | ; | ||||
static_array_pair_list: | static_array_pair_list: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_ARRAY_VALUE_LIST); | $$ = NNEW(n_ARRAY_VALUE_LIST); | ||||
} | } | ||||
| non_empty_static_array_pair_list possible_comma { | | non_empty_static_array_pair_list possible_comma { | ||||
$$ = NMORE($1, $2); | $$ = NMORE($1, $2); | ||||
} | } | ||||
; | ; | ||||
possible_comma: | possible_comma: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| ',' | | ',' | ||||
; | ; | ||||
non_empty_static_array_pair_list: | non_empty_static_array_pair_list: | ||||
non_empty_static_array_pair_list | non_empty_static_array_pair_list | ||||
',' | ',' | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | variable: | ||||
} | } | ||||
| base_variable_with_function_calls | | base_variable_with_function_calls | ||||
; | ; | ||||
variable_properties: | variable_properties: | ||||
variable_properties variable_property { | variable_properties variable_property { | ||||
$$ = $1->appendChildren($2); | $$ = $1->appendChildren($2); | ||||
} | } | ||||
| %empty { | | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
; | ; | ||||
variable_property: | variable_property: | ||||
T_OBJECT_OPERATOR object_property method_or_not { | T_OBJECT_OPERATOR object_property method_or_not { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
$$->appendChild($2); | $$->appendChild($2); | ||||
Show All 22 Lines | method: | ||||
'(' function_call_parameter_list ')' { | '(' function_call_parameter_list ')' { | ||||
$$ = NEXPAND($1, $2, $3); | $$ = NEXPAND($1, $2, $3); | ||||
} | } | ||||
; | ; | ||||
method_or_not: | method_or_not: | ||||
method | method | ||||
| array_method_dereference | | array_method_dereference | ||||
| %empty { | | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
; | ; | ||||
variable_without_objects: | variable_without_objects: | ||||
reference_variable | reference_variable | ||||
| simple_indirect_reference reference_variable { | | simple_indirect_reference reference_variable { | ||||
xhpast::Node *last = $1; | xhpast::Node *last = $1; | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | |||||
| '$' '{' expr '}' { | | '$' '{' expr '}' { | ||||
NSPAN($1, n_VARIABLE_EXPRESSION, $4); | NSPAN($1, n_VARIABLE_EXPRESSION, $4); | ||||
$1->appendChild($3); | $1->appendChild($3); | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
; | ; | ||||
dim_offset: | dim_offset: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
| expr { | | expr { | ||||
$$ = $1; | $$ = $1; | ||||
} | } | ||||
; | ; | ||||
object_property: | object_property: | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
; | ; | ||||
assignment_list_element: | assignment_list_element: | ||||
variable | variable | ||||
| T_LIST '(' assignment_list ')' { | | T_LIST '(' assignment_list ')' { | ||||
$$ = NNEW(n_LIST); | $$ = NNEW(n_LIST); | ||||
$$->appendChild(NEXPAND($2, $3, $4)); | $$->appendChild(NEXPAND($2, $3, $4)); | ||||
} | } | ||||
| %empty { | | /* empty */ { | ||||
$$ = NNEW(n_EMPTY); | $$ = NNEW(n_EMPTY); | ||||
} | } | ||||
; | ; | ||||
array_pair_list: | array_pair_list: | ||||
%empty { | /* empty */ { | ||||
$$ = NNEW(n_ARRAY_VALUE_LIST); | $$ = NNEW(n_ARRAY_VALUE_LIST); | ||||
} | } | ||||
| non_empty_array_pair_list possible_comma { | | non_empty_array_pair_list possible_comma { | ||||
$$ = NMORE($1, $2); | $$ = NMORE($1, $2); | ||||
} | } | ||||
; | ; | ||||
non_empty_array_pair_list: | non_empty_array_pair_list: | ||||
▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines |