3 #define YYSTYPE HPHP::HPHP_PARSER_NS::Token
4 #define YYSTYPE_IS_TRIVIAL false
5 #define YYLTYPE HPHP::Location
6 #define YYLTYPE_IS_TRIVIAL true
7 #define YYERROR_VERBOSE
8 #define YYINITDEPTH 500
11 #include "hphp/compiler/parser/parser.h"
12 #include <folly/Conv.h>
13 #include "hphp/util/text-util.h"
14 #include "hphp/util/logger.h"
24 #define yyerror(loc,p,msg) p->parseFatal(loc,msg)
27 # undef YYLLOC_DEFAULT
29 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
30 #define YYLLOC_DEFAULT(Current, Rhs, N) \
33 (Current
).first
(YYRHSLOC
(Rhs
, 1)); \
34 (Current
).last
(YYRHSLOC
(Rhs
, N
)); \
36 (Current
).line0
= (Current
).line1
= YYRHSLOC
(Rhs
, 0).line1
;\
37 (Current
).char0
= (Current
).char1
= YYRHSLOC
(Rhs
, 0).char1
;\
40 _p
->setRuleLocation
(&Current
);
42 #define YYCOPY(To, From, Count) \
45 for
(yyi
= 0; yyi
< (Count
); yyi
++) { \
46 (To
)[yyi
] = (From
)[yyi
]; \
48 if
(From
!= From
## a) { \
49 YYSTACK_FREE
(From
); \
54 #define YYCOPY_RESET(To, From, Count) \
58 for
(yyi
= 0; yyi
< (Count
); yyi
++) { \
59 (To
)[yyi
] = (From
)[yyi
]; \
60 (From
)[yyi
].reset
(); \
62 if
(From
!= From
## a) { \
63 YYSTACK_FREE
(From
); \
68 #define YYTOKEN_RESET(From, Count) \
72 for
(yyi
= 0; yyi
< (Count
); yyi
++) { \
73 (From
)[yyi
].reset
(); \
75 if
(From
!= From
## a) { \
76 YYSTACK_FREE
(From
); \
81 # define YYSTACK_RELOCATE_RESET(Stack_alloc, Stack) \
84 YYSIZE_T yynewbytes
; \
85 YYCOPY_RESET
(&yyptr
->Stack_alloc
, Stack
, yysize
); \
86 Stack
= &yyptr
->Stack_alloc
; \
87 yynewbytes
= yystacksize
* sizeof
(*Stack
) + YYSTACK_GAP_MAXIMUM
; \
88 yyptr
+= yynewbytes
/ sizeof
(*yyptr
); \
92 #define YYSTACK_CLEANUP \
93 YYTOKEN_RESET
(yyvs
, yystacksize
); \
94 if
(yyvs
!= yyvsa
) { \
95 YYSTACK_FREE
(yyvs
); \
97 if
(yyls
!= yylsa
) { \
98 YYSTACK_FREE
(yyls
); \
103 #define BEXP(...) _p->onBinaryOpExp(__VA_ARGS__);
104 #define UEXP(...) _p->onUnaryOpExp(__VA_ARGS__);
106 using namespace HPHP
::HPHP_PARSER_NS
;
108 typedef HPHP
::ClosureType ClosureType
;
110 ///////////////////////////////////////////////////////////////////////////////
113 static void scalar_num
(Parser
*_p
, Token
&out
, const char *num
) {
116 _p
->onScalar
(out
, T_LNUMBER
, t
);
119 static void scalar_num
(Parser
*_p
, Token
&out
, int num
) {
121 t.setText
(folly
::to
<std
::string>(num
));
122 _p
->onScalar
(out
, T_LNUMBER
, t
);
125 static void scalar_null
(Parser
*_p
, Token
&out
) {
126 Token tnull
; tnull.setText
("null");
127 _p
->onConstantValue
(out
, tnull
);
130 static void scalar_file
(Parser
*_p
, Token
&out
) {
131 Token file
; file.setText
("__FILE__");
132 _p
->onScalar
(out
, T_FILE
, file
);
135 static void scalar_line
(Parser
*_p
, Token
&out
) {
136 Token line
; line.setText
("__LINE__");
137 _p
->onScalar
(out
, T_LINE
, line
);
140 ///////////////////////////////////////////////////////////////////////////////
142 static void constant_ae
(Parser
*_p
, Token
&out
, Token
&value
) {
143 const std
::string& valueStr
= value.text
();
144 if
(valueStr.size
() < 3 || valueStr.size
() > 5 ||
145 (strcasecmp
("true", valueStr.c_str
()) != 0 &&
146 strcasecmp
("false", valueStr.c_str
()) != 0 &&
147 strcasecmp
("null", valueStr.c_str
()) != 0 &&
148 strcasecmp
("inf", valueStr.c_str
()) != 0 &&
149 strcasecmp
("nan", valueStr.c_str
()) != 0)) {
150 HPHP_PARSER_ERROR
("User-defined constants are not allowed in user "
151 "attribute expressions", _p
);
153 _p
->onConstantValue
(out
, value
);
156 ///////////////////////////////////////////////////////////////////////////////
159 * XHP functions: They are defined here, so different parsers don't have to
160 * handle XHP rules at all.
163 static void xhp_tag
(Parser
*_p
, Token
&out
, Token
&label
, Token
&body
) {
164 if
(!body.text
().empty
() && body.text
() != label.text
()) {
165 HPHP_PARSER_ERROR
("XHP: mismatched tag: '%s' not the same as '%s'",
166 _p
, body.text
().c_str
(), label.text
().c_str
());
170 Token name
; _p
->onName
(name
, label
, Parser
::StringName
);
171 _p
->onNewObject
(out
, name
, body
);
174 static void xhp_attribute
(Parser
*_p
, Token
&out
, Token
&type
, Token
&label
,
175 Token
&def
, Token
&req
) {
177 * The bool, int, float, and string typenames are not given any special
178 * treatment by the parser and are treated the same as regular class names
179 * (which initially gets marked as type code 5). However, XHP wants to use
180 * different type codes for bool, int, float, and string, so we need to fix
181 * up the type code here to make XHP happy.
183 if
(type.num
() == 5) {
184 auto
* str
= type.text
().c_str
();
185 if
(_p
->scanner
().isHHSyntaxEnabled
()) {
186 switch
(type.text
().size
()) {
188 if
(!strcasecmp
(str
, "HH\\int")) {
189 type.reset
(); type.setNum
(3);
193 if
(!strcasecmp
(str
, "HH\\bool")) {
194 type.reset
(); type.setNum
(2);
198 if
(!strcasecmp
(str
, "HH\\float")) {
199 type.reset
(); type.setNum
(8);
200 } else if
(!strcasecmp
(str
, "HH\\mixed")) {
201 type.reset
(); type.setNum
(6);
205 if
(!strcasecmp
(str
, "HH\\string")) {
206 type.reset
(); type.setNum
(1);
213 switch
(type.text
().size
()) {
215 if
(!strcasecmp
(str
, "int")) {
216 type.reset
(); type.setNum
(3);
220 if
(!strcasecmp
(str
, "bool")) {
221 type.reset
(); type.setNum
(2);
222 } else if
(!strcasecmp
(str
, "real")) {
223 type.reset
(); type.setNum
(8);
227 if
(!strcasecmp
(str
, "float")) {
228 type.reset
(); type.setNum
(8);
229 } else if
(!strcasecmp
(str
, "mixed")) {
230 type.reset
(); type.setNum
(6);
234 if
(!strcasecmp
(str
, "string")) {
235 type.reset
(); type.setNum
(1);
236 } else if
(!strcasecmp
(str
, "double")) {
237 type.reset
(); type.setNum
(8);
241 if
(!strcasecmp
(str
, "integer")) {
242 type.reset
(); type.setNum
(3);
243 } else if
(!strcasecmp
(str
, "boolean")) {
244 type.reset
(); type.setNum
(2);
253 Token num
; scalar_num
(_p
, num
, type.num
());
254 Token arr1
; _p
->onArrayPair
(arr1
, 0, 0, num
, 0);
257 switch
(type.num
()) {
258 case
5: /* class */ {
259 Token cls
; _p
->onScalar
(cls
, T_CONSTANT_ENCAPSED_STRING
, type
);
260 _p
->onArrayPair
(arr2
, &arr1
, 0, cls
, 0);
264 Token arr
; _p
->onArray
(arr
, type
);
265 _p
->onArrayPair
(arr2
, &arr1
, 0, arr
, 0);
269 Token tnull
; scalar_null
(_p
, tnull
);
270 _p
->onArrayPair
(arr2
, &arr1
, 0, tnull
, 0);
275 Token arr3
; _p
->onArrayPair
(arr3
, &arr2
, 0, def
, 0);
276 Token arr4
; _p
->onArrayPair
(arr4
, &arr3
, 0, req
, 0);
277 _p
->onArray
(out
, arr4
);
281 static void xhp_attribute_list
(Parser
*_p
, Token
&out
, Token
*list
,
283 if
(decl.num
() == 0) {
287 out.setText
(list
->text
() + ":" + decl.text
()); // avoiding vector<string>
292 Token name
; _p
->onScalar
(name
, T_CONSTANT_ENCAPSED_STRING
, decl
);
293 _p
->onArrayPair
(out
, list
, &name
, decl
, 0);
295 out.setText
(list
->text
());
302 static void xhp_attribute_stmt
(Parser
*_p
, Token
&out
, Token
&attributes
) {
304 Token fname
; fname.setText
("__xhpAttributeDeclaration");
307 Token m1
; m1.setNum
(T_PROTECTED
); _p
->onMemberModifier
(m
, NULL
, m1
);
308 Token m2
; m2.setNum
(T_STATIC
); _p
->onMemberModifier
(modifiers
, &m
, m2
);
310 _p
->pushFuncLocation
();
311 _p
->onMethodStart
(fname
, modifiers
);
313 std
::vector
<std
::string> classes
;
314 HPHP
::split
(':', attributes.text
().c_str
(), classes
, true
);
315 Token arrAttributes
; _p
->onArray
(arrAttributes
, attributes
);
321 _p
->onStatementListStart
(stmts0
);
326 Token one
; scalar_num
(_p
, one
, "1");
327 Token mone
; UEXP
(mone
, one
, '-', 1);
328 Token var
; var.set
(T_VARIABLE
, "_");
329 Token decl
; _p
->onStaticVariable
(decl
, 0, var
, &mone
);
330 Token sdecl
; _p
->onStatic
(sdecl
, decl
);
331 _p
->addStatement
(stmts1
, stmts0
, sdecl
);
336 // $_ = array_merge(parent::__xhpAttributeDeclaration(),
339 Token parent
; parent.set
(T_STRING
, "parent");
340 Token cls
; _p
->onName
(cls
, parent
, Parser
::StringName
);
341 Token fname
; fname.setText
("__xhpAttributeDeclaration");
342 Token param1
; _p
->onCall
(param1
, 0, fname
, dummy
, &cls
);
343 Token params1
; _p
->onCallParam
(params1
, NULL
, param1
, false
, false
);
345 for
(unsigned int i
= 0; i
< classes.size
(); i
++) {
346 Token parent
; parent.set
(T_STRING
, classes
[i
]);
347 Token cls
; _p
->onName
(cls
, parent
, Parser
::StringName
);
348 Token fname
; fname.setText
("__xhpAttributeDeclaration");
349 Token param
; _p
->onCall
(param
, 0, fname
, dummy
, &cls
);
351 Token params
; _p
->onCallParam
(params
, ¶ms1
, param
, false
, false
);
355 Token params2
; _p
->onCallParam
(params2
, ¶ms1
, arrAttributes
,
358 Token name
; name.set
(T_STRING
, "array_merge");
359 Token call
; _p
->onCall
(call
, 0, name
, params2
, NULL
);
360 Token tvar
; tvar.set
(T_VARIABLE
, "_");
361 Token var
; _p
->onSimpleVariable
(var
, tvar
);
362 Token assign
; _p
->onAssign
(assign
, var
, call
, 0);
363 Token exp
; _p
->onExpStatement
(exp
, assign
);
364 Token block
; _p
->onBlock
(block
, exp
);
366 Token tvar2
; tvar2.set
(T_VARIABLE
, "_");
367 Token var2
; _p
->onSimpleVariable
(var2
, tvar2
);
368 Token one
; scalar_num
(_p
, one
, "1");
369 Token mone
; UEXP
(mone
, one
, '-', 1);
370 Token cond
; BEXP
(cond
, var2
, mone
, T_IS_IDENTICAL
);
371 Token dummy1
, dummy2
;
372 Token sif
; _p
->onIf
(sif
, cond
, block
, dummy1
, dummy2
);
373 _p
->addStatement
(stmts2
, stmts1
, sif
);
378 Token tvar
; tvar.set
(T_VARIABLE
, "_");
379 Token var
; _p
->onSimpleVariable
(var
, tvar
);
380 Token ret
; _p
->onReturn
(ret
, &var
);
381 _p
->addStatement
(stmts3
, stmts2
, ret
);
385 _p
->finishStatement
(stmt
, stmts3
);
389 Token params
, ret
, ref
; ref
= 1;
390 _p
->onMethod
(out
, modifiers
, ret
, ref
, fname
, params
, stmt
, nullptr
, false
);
394 static void xhp_collect_attributes
(Parser
*_p
, Token
&out
, Token
&stmts
) {
395 Token
*attr
= _p
->xhpGetAttributes
();
398 xhp_attribute_stmt
(_p
, stmt
, *attr
);
399 _p
->onClassStatement
(out
, stmts
, stmt
);
405 static void xhp_category_stmt
(Parser
*_p
, Token
&out
, Token
&categories
) {
406 Token fname
; fname.setText
("__xhpCategoryDeclaration");
407 Token m1
; m1.setNum
(T_PROTECTED
);
408 Token modifiers
; _p
->onMemberModifier
(modifiers
, 0, m1
);
409 _p
->pushFuncLocation
();
410 _p
->onMethodStart
(fname
, modifiers
);
414 _p
->onStatementListStart
(stmts0
);
418 // static $_ = categories;
419 Token arr
; _p
->onArray
(arr
, categories
);
420 Token var
; var.set
(T_VARIABLE
, "_");
421 Token decl
; _p
->onStaticVariable
(decl
, 0, var
, &arr
);
422 Token sdecl
; _p
->onStatic
(sdecl
, decl
);
423 _p
->addStatement
(stmts1
, stmts0
, sdecl
);
428 Token tvar
; tvar.set
(T_VARIABLE
, "_");
429 Token var
; _p
->onSimpleVariable
(var
, tvar
);
430 Token ret
; _p
->onReturn
(ret
, &var
);
431 _p
->addStatement
(stmts2
, stmts1
, ret
);
435 _p
->finishStatement
(stmt
, stmts2
);
439 Token params
, ret
, ref
; ref
= 1;
440 _p
->onMethod
(out
, modifiers
, ret
, ref
, fname
, params
, stmt
, nullptr
, false
);
444 static void xhp_children_decl_tag
(Parser
*_p
, Token
&arr
, Token
&tag
) {
445 Token num
; scalar_num
(_p
, num
, tag.num
());
446 Token arr1
; _p
->onArrayPair
(arr1
, &arr
, 0, num
, 0);
449 if
(tag.num
() == 3 || tag.num
() == 4) {
450 _p
->onScalar
(name
, T_CONSTANT_ENCAPSED_STRING
, tag
);
451 } else if
(tag.num
() >= 0) {
452 scalar_null
(_p
, name
);
454 HPHP_PARSER_ERROR
("XHP: unknown children declaration", _p
);
456 Token arr2
; _p
->onArrayPair
(arr2
, &arr1
, 0, name
, 0);
460 static void xhp_children_decl
(Parser
*_p
, Token
&out
, Token
&op1
, int op
,
462 Token num
; scalar_num
(_p
, num
, op
);
463 Token arr
; _p
->onArrayPair
(arr
, 0, 0, num
, 0);
466 Token arr1
; _p
->onArrayPair
(arr1
, &arr
, 0, op1
, 0);
467 Token arr2
; _p
->onArrayPair
(arr2
, &arr1
, 0, *op2
, 0);
468 _p
->onArray
(out
, arr2
);
470 xhp_children_decl_tag
(_p
, arr
, op1
);
471 _p
->onArray
(out
, arr
);
475 static void xhp_children_paren
(Parser
*_p
, Token
&out
, Token exp
, int op
) {
476 Token num
; scalar_num
(_p
, num
, op
);
477 Token arr1
; _p
->onArrayPair
(arr1
, 0, 0, num
, 0);
479 Token num5
; scalar_num
(_p
, num5
, 5);
480 Token arr2
; _p
->onArrayPair
(arr2
, &arr1
, 0, num5
, 0);
482 Token arr3
; _p
->onArrayPair
(arr3
, &arr2
, 0, exp
, 0);
483 _p
->onArray
(out
, arr3
);
486 static void xhp_children_stmt
(Parser
*_p
, Token
&out
, Token
&children
) {
487 Token fname
; fname.setText
("__xhpChildrenDeclaration");
488 Token m1
; m1.setNum
(T_PROTECTED
);
489 Token modifiers
; _p
->onMemberModifier
(modifiers
, 0, m1
);
490 _p
->pushFuncLocation
();
491 _p
->onMethodStart
(fname
, modifiers
);
495 _p
->onStatementListStart
(stmts0
);
499 // static $_ = children;
501 if
(children.num
() == 2) {
503 } else if
(children.num
() >= 0) {
504 scalar_num
(_p
, arr
, children.num
());
506 HPHP_PARSER_ERROR
("XHP: XHP unknown children declaration", _p
);
508 Token var
; var.set
(T_VARIABLE
, "_");
509 Token decl
; _p
->onStaticVariable
(decl
, 0, var
, &arr
);
510 Token sdecl
; _p
->onStatic
(sdecl
, decl
);
511 _p
->addStatement
(stmts1
, stmts0
, sdecl
);
516 Token tvar
; tvar.set
(T_VARIABLE
, "_");
517 Token var
; _p
->onSimpleVariable
(var
, tvar
);
518 Token ret
; _p
->onReturn
(ret
, &var
);
519 _p
->addStatement
(stmts2
, stmts1
, ret
);
523 _p
->finishStatement
(stmt
, stmts2
);
527 Token params
, ret
, ref
; ref
= 1;
528 _p
->onMethod
(out
, modifiers
, ret
, ref
, fname
, params
, stmt
, nullptr
, false
);
532 static void only_in_hh_syntax
(Parser
*_p
) {
533 if
(!_p
->scanner
().isHHSyntaxEnabled
()) {
535 "Syntax only allowed in Hack files (<?hh) or with -v "
536 "Eval.EnableHipHopSyntax=true",
541 static void validate_hh_variadic_variant
(Parser
* _p
,
542 Token
& userAttrs
, Token
& typehint
,
544 if
(!userAttrs.text
().empty
() ||
!typehint.text
().empty
() ||
545 (mod
&& !mod
->text
().empty
())) {
546 HPHP_PARSER_ERROR
("Variadic '...' should be followed by a '$variable'", _p
);
548 only_in_hh_syntax
(_p
);
551 // Shapes may not have leading integers in key names, considered as a
552 // parse time error. This is because at runtime they are currently
553 // hphp arrays, which will treat leading integer keys as numbers.
554 static void validate_shape_keyname
(Token
& tok
, Parser
* _p
) {
555 if
(tok.text
().empty
()) {
556 HPHP_PARSER_ERROR
("Shape key names may not be empty", _p
);
558 if
(isdigit
(tok.text
()[0])) {
559 HPHP_PARSER_ERROR
("Shape key names may not start with integers", _p
);
563 ///////////////////////////////////////////////////////////////////////////////
565 static int yylex(YYSTYPE *token
, HPHP
::Location
*loc
, Parser
*_p
) {
566 return _p
->scan
(token
, loc
);
572 %lex
-param
{HPHP
::HPHP_PARSER_NS
::Parser
*_p
}
573 %parse
-param
{HPHP
::HPHP_PARSER_NS
::Parser
*_p
}
575 %left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
576 %right T_LAMBDA_ARROW
583 %left
'=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL T_POW_EQUAL
584 %right T_AWAIT T_YIELD
592 %nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL
593 %nonassoc
'<' T_IS_SMALLER_OR_EQUAL
'>' T_IS_GREATER_OR_EQUAL T_SPACESHIP
598 %nonassoc T_INSTANCEOF
599 %right
'~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST
'@'
603 %nonassoc T_NEW T_CLONE
609 %token T_LNUMBER
/* long */
610 %token T_DNUMBER
/* double */
611 %token T_ONUMBER
/* overflowed decimal, might get parsed as long or double */
613 %token T_STRING_VARNAME
619 %token T_BAD_CHARACTER
620 %token T_ENCAPSED_AND_WHITESPACE
621 %token T_CONSTANT_ENCAPSED_STRING
649 %right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC
654 %token T_HALT_COMPILER
659 %token T_OBJECT_OPERATOR
660 %token T_NULLSAFE_OBJECT_OPERATOR
661 %token T_DOUBLE_ARROW
673 %token T_OPEN_TAG_WITH_ECHO
676 %token T_START_HEREDOC
678 %token T_DOLLAR_OPEN_CURLY_BRACES
680 %token T_DOUBLE_COLON
684 %token T_NS_SEPARATOR
688 %token T_XHP_ATTRIBUTE
689 %token T_XHP_CATEGORY
690 %token T_XHP_CATEGORY_LABEL
691 %token T_XHP_CHILDREN
693 %token T_XHP_REQUIRED
696 %token T_ELLIPSIS
"..."
697 %token T_COALESCE
"??"
708 %token T_UNRESOLVED_LT
713 %token T_UNRESOLVED_TYPE
715 %token T_UNRESOLVED_NEWTYPE
717 %token T_COMPILER_HALT_OFFSET
722 %token T_UNRESOLVED_OP
727 { _p
->onNewLabelScope
(true
);
728 _p
->initParseTree
();}
730 { _p
->popLabelInfo
();
732 _p
->onCompleteLabelScope
(true
);}
737 top_statement
{ _p
->addTopStatement
($2);}
741 statement
{ _p
->nns
($1.num
(), $1.text
()); $$
= $1;}
742 | function_declaration_statement
{ _p
->nns
(); $$
= $1;}
743 | class_declaration_statement
{ _p
->nns
(); $$
= $1;}
744 | enum_declaration_statement
{ _p
->nns
(); $$
= $1;}
745 | trait_declaration_statement
{ _p
->nns
(); $$
= $1;}
746 | hh_type_alias_statement
{ $$
= $1; }
747 | T_HALT_COMPILER
'(' ')' ';' { _p
->onHaltCompiler
();
750 | T_NAMESPACE namespace_name
';' { _p
->onNamespaceStart
($2.text
(), true
);
752 | T_NAMESPACE namespace_name
'{' { _p
->onNamespaceStart
($2.text
());}
753 top_statement_list
'}' { _p
->onNamespaceEnd
(); $$
= $5;}
754 | T_NAMESPACE
'{' { _p
->onNamespaceStart
("");}
755 top_statement_list
'}' { _p
->onNamespaceEnd
(); $$
= $4;}
756 | T_USE use_declarations
';' { _p
->nns
(); $$.reset
();}
758 use_fn_declarations
';' { _p
->nns
(); $$.reset
();}
760 use_const_declarations
';' { _p
->nns
(); $$.reset
();}
761 | constant_declaration
';' { _p
->nns
();
762 _p
->finishStatement
($$
, $1); $$
= 1;}
765 ident_no_semireserved:
767 | T_SUPER
{ $$
= $1;}
768 | T_XHP_ATTRIBUTE
{ $$
= $1;}
769 | T_XHP_CATEGORY
{ $$
= $1;}
770 | T_XHP_CHILDREN
{ $$
= $1;}
771 | T_XHP_REQUIRED
{ $$
= $1;}
775 ident_for_class_const:
776 ident_no_semireserved
838 /** The following must be made semi-reserved since they were keywords in HHVM
844 ident_for_class_const
851 | use_declaration
{ }
855 use_fn_declarations
','
856 use_fn_declaration
{ }
857 | use_fn_declaration
{ }
860 use_const_declarations:
861 use_const_declarations
','
862 use_const_declaration
{ }
863 | use_const_declaration
{ }
867 namespace_name
{ _p
->onUse
($1.text
(),"");}
868 | T_NS_SEPARATOR namespace_name
{ _p
->onUse
($2.text
(),"");}
869 | namespace_name T_AS ident_no_semireserved
{ _p
->onUse
($1.text
(),$3.text
());}
870 | T_NS_SEPARATOR namespace_name
871 T_AS ident_no_semireserved
{ _p
->onUse
($2.text
(),$4.text
());}
875 namespace_name
{ _p
->onUseFunction
($1.text
(),"");}
876 | T_NS_SEPARATOR namespace_name
{ _p
->onUseFunction
($2.text
(),"");}
877 | namespace_name T_AS ident_no_semireserved
{ _p
->onUseFunction
($1.text
(),$3.text
());}
878 | T_NS_SEPARATOR namespace_name
879 T_AS ident_no_semireserved
{ _p
->onUseFunction
($2.text
(),$4.text
());}
882 use_const_declaration:
883 namespace_name
{ _p
->onUseConst
($1.text
(),"");}
884 | T_NS_SEPARATOR namespace_name
{ _p
->onUseConst
($2.text
(),"");}
885 | namespace_name T_AS ident_no_semireserved
{ _p
->onUseConst
($1.text
(),$3.text
());}
886 | T_NS_SEPARATOR namespace_name
887 T_AS ident_no_semireserved
{ _p
->onUseConst
($2.text
(),$4.text
());}
891 ident_no_semireserved
{ $$
= $1;}
892 | namespace_name T_NS_SEPARATOR
893 ident_no_semireserved
{ $$
= $1 + $2 + $3; $$
= $1.num
() |
2;}
896 namespace_name
{ $$
= $1; $$
= $$.num
() |
1;}
897 | T_NAMESPACE T_NS_SEPARATOR
898 namespace_name
{ $$.set
($3.num
() |
2, _p
->nsDecl
($3.text
()));}
899 | T_NS_SEPARATOR namespace_name
{ $$
= $2; $$
= $$.num
() |
2;}
902 namespace_string_typeargs:
904 hh_typeargs_opt
{ if
($1.num
() & 1) {
905 $1.setText
(_p
->resolve
($1.text
(),0));
909 class_namespace_string_typeargs:
911 hh_typeargs_opt
{ if
($1.num
() & 1) {
912 $1.setText
(_p
->resolve
($1.text
(),1));
914 _p
->onTypeAnnotation
($$
, $1, $2);}
916 constant_declaration:
917 constant_declaration
','
919 '=' static_expr
{ $3.setText
(_p
->nsDecl
($3.text
()));
920 _p
->onConst
($$
,$3,$5);}
921 | T_CONST hh_name_with_type
'='
922 static_expr
{ $2.setText
(_p
->nsDecl
($2.text
()));
923 _p
->onConst
($$
,$2,$4);}
926 inner_statement_list:
928 inner_statement
{ _p
->addStatement
($$
,$1,$2);}
929 |
{ _p
->onStatementListStart
($$
);}
932 statement
{ $$
= $1;}
933 | function_declaration_statement
{ $$
= $1;}
934 | class_declaration_statement
{ $$
= $1;}
935 | trait_declaration_statement
{ $$
= $1;}
938 '{' inner_statement_list
'}' { _p
->onBlock
($$
, $2);}
939 | T_IF parenthesis_expr
942 else_single
{ _p
->onIf
($$
,$2,$3,$4,$5);}
943 | T_IF parenthesis_expr
':'
947 T_ENDIF
';' { _p
->onIf
($$
,$2,$4,$5,$6);}
948 | T_WHILE parenthesis_expr
{ _p
->onNewLabelScope
(false
);
949 _p
->pushLabelScope
();}
950 while_statement
{ _p
->popLabelScope
();
951 _p
->onWhile
($$
,$2,$4);
952 _p
->onCompleteLabelScope
(false
);}
954 | T_DO
{ _p
->onNewLabelScope
(false
);
955 _p
->pushLabelScope
();}
956 statement T_WHILE parenthesis_expr
957 ';' { _p
->popLabelScope
();
959 _p
->onCompleteLabelScope
(false
);}
960 | T_FOR
'(' for_expr
';'
961 for_expr
';' for_expr
')' { _p
->onNewLabelScope
(false
);
962 _p
->pushLabelScope
();}
963 for_statement
{ _p
->popLabelScope
();
964 _p
->onFor
($$
,$3,$5,$7,$10);
965 _p
->onCompleteLabelScope
(false
);}
966 | T_SWITCH parenthesis_expr
{ _p
->onNewLabelScope
(false
);
967 _p
->pushLabelScope
();}
968 switch_case_list
{ _p
->popLabelScope
();
969 _p
->onSwitch
($$
,$2,$4);
970 _p
->onCompleteLabelScope
(false
);}
971 | T_BREAK
';' { _p
->onBreakContinue
($$
, true
, NULL
);}
972 | T_BREAK expr
';' { _p
->onBreakContinue
($$
, true
, &$2);}
973 | T_CONTINUE
';' { _p
->onBreakContinue
($$
, false
, NULL
);}
974 | T_CONTINUE expr
';' { _p
->onBreakContinue
($$
, false
, &$2);}
975 | T_RETURN
';' { _p
->onReturn
($$
, NULL
);}
976 | T_RETURN expr
';' { _p
->onReturn
($$
, &$2);}
977 | T_YIELD T_BREAK
';' { _p
->onYieldBreak
($$
);}
978 | T_GLOBAL global_var_list
';' { _p
->onGlobal
($$
, $2);}
979 | T_STATIC static_var_list
';' { _p
->onStatic
($$
, $2);}
980 | T_ECHO expr_list
';' { _p
->onEcho
($$
, $2, 0);}
981 | T_OPEN_TAG_WITH_ECHO expr_list
';' { _p
->onEcho
($$
, $2, 0);}
982 | T_UNSET
'(' variable_list
')' ';' { _p
->onUnset
($$
, $3);}
983 |
';' { $$.reset
(); $$
= ';';}
984 | T_INLINE_HTML
{ _p
->onEcho
($$
, $1, 1);}
985 | T_HASHBANG
{ _p
->onHashBang
($$
, $1);
988 T_AS foreach_variable
989 foreach_optional_arg
')' { _p
->onNewLabelScope
(false
);
990 _p
->pushLabelScope
();}
991 foreach_statement
{ _p
->popLabelScope
();
992 _p
->onForEach
($$
,$3,$5,$6,$9, false
);
993 _p
->onCompleteLabelScope
(false
);}
995 T_AWAIT T_AS foreach_variable
996 foreach_optional_arg
')' { _p
->onNewLabelScope
(false
);
997 _p
->pushLabelScope
();}
998 foreach_statement
{ _p
->popLabelScope
();
999 _p
->onForEach
($$
,$3,$6,$7,$10, true
);
1000 _p
->onCompleteLabelScope
(false
);}
1001 | T_DECLARE
'(' declare_list
')'
1002 declare_statement
{ _p
->onBlock
($$
, $5); $$
= T_DECLARE
;}
1006 fully_qualified_class_name
1008 inner_statement_list
'}'
1009 additional_catches
{ _p
->onCompleteLabelScope
(false
);}
1010 optional_finally
{ _p
->onTry
($$
,$2,$5,$6,$9,$11,$13);}
1013 T_FINALLY
{ _p
->onCompleteLabelScope
(false
);}
1014 finally_statement_list
{ _p
->onTry
($$
, $2, $5);}
1015 | T_THROW expr
';' { _p
->onThrow
($$
, $2);}
1016 | T_GOTO ident_no_semireserved
';' { _p
->onGoto
($$
, $2, true
);
1017 _p
->addGoto
($2.text
(),
1020 | expr
';' { _p
->onExpStatement
($$
, $1);}
1021 | yield_expr
';' { _p
->onExpStatement
($$
, $1);}
1022 | yield_assign_expr
';' { _p
->onExpStatement
($$
, $1);}
1023 | yield_list_assign_expr
';' { _p
->onExpStatement
($$
, $1);}
1024 | await_expr
';' { _p
->onExpStatement
($$
, $1);}
1025 | await_assign_expr
';' { _p
->onExpStatement
($$
, $1);}
1026 | T_RETURN await_expr
';' { _p
->onReturn
($$
, &$2); }
1027 | await_list_assign_expr
';' { _p
->onExpStatement
($$
, $1);}
1028 | ident_no_semireserved
':' { _p
->onLabel
($$
, $1);
1029 _p
->addLabel
($1.text
(),
1032 _p
->onScopeLabel
($$
, $1);}
1036 '{' { _p
->onNewLabelScope
(false
);}
1037 inner_statement_list
'}' { $$
= $3;}
1043 fully_qualified_class_name
1046 inner_statement_list
'}' { _p
->onCatch
($$
, $1, $4, $5, $8);}
1050 finally_statement_list:
1051 '{' { _p
->onNewLabelScope
(false
);
1052 _p
->pushLabelScope
();}
1053 inner_statement_list
'}' { _p
->popLabelScope
();
1054 _p
->onFinally
($$
, $3);
1055 _p
->onCompleteLabelScope
(false
);}
1059 T_FINALLY finally_statement_list
{ $$
= $2;}
1069 T_FUNCTION
{ _p
->pushFuncLocation
(); }
1072 function_declaration_statement:
1075 hh_name_no_semireserved_with_typevar
{ $3.setText
(_p
->nsDecl
($3.text
()));
1076 _p
->onNewLabelScope
(true
);
1077 _p
->onFunctionStart
($3);
1078 _p
->pushLabelInfo
();}
1079 '(' parameter_list
')'
1081 function_body
{ _p
->onFunction
($$
,nullptr
,$8,$2,$3,$6,$9,nullptr
);
1084 _p
->onCompleteLabelScope
(true
);}
1085 | non_empty_member_modifiers
1088 hh_name_no_semireserved_with_typevar
{ $4.setText
(_p
->nsDecl
($4.text
()));
1089 _p
->onNewLabelScope
(true
);
1090 _p
->onFunctionStart
($4);
1091 _p
->pushLabelInfo
();}
1092 '(' parameter_list
')'
1094 function_body
{ _p
->onFunction
($$
,&$1,$9,$3,$4,$7,$10,nullptr
);
1097 _p
->onCompleteLabelScope
(true
);}
1098 | non_empty_user_attributes
1099 method_modifiers function_loc
1101 hh_name_no_semireserved_with_typevar
{ $5.setText
(_p
->nsDecl
($5.text
()));
1102 _p
->onNewLabelScope
(true
);
1103 _p
->onFunctionStart
($5);
1104 _p
->pushLabelInfo
();}
1105 '(' parameter_list
')'
1107 function_body
{ _p
->onFunction
($$
,&$2,$10,$4,$5,$8,$11,&$1);
1110 _p
->onCompleteLabelScope
(true
);}
1113 enum_declaration_statement:
1115 ident_no_semireserved
{ $2.setText
(_p
->nsClassDecl
($2.text
()));
1116 _p
->onClassStart
(T_ENUM
,$2);}
1119 '{' enum_statement_list
'}' { _p
->onEnum
($$
,$2,$5,$8,0); }
1121 | non_empty_user_attributes
1123 ident_no_semireserved
{ $3.setText
(_p
->nsClassDecl
($3.text
()));
1124 _p
->onClassStart
(T_ENUM
,$3);}
1127 '{' enum_statement_list
'}' { _p
->onEnum
($$
,$3,$6,$9,&$1); }
1131 class_declaration_statement:
1133 class_decl_name
{ $2.setText
(_p
->nsClassDecl
($2.text
()));
1134 _p
->onClassStart
($1.num
(),$2);}
1135 extends_from implements_list
'{'
1136 class_statement_list
'}' { Token stmts
;
1137 if
(_p
->peekClass
()) {
1138 xhp_collect_attributes
(_p
,stmts
,$7);
1142 _p
->onClass
($$
,$1.num
(),$2,$4,$5,
1144 if
(_p
->peekClass
()) {
1145 _p
->xhpResetAttributes
();
1148 _p
->popTypeScope
();}
1149 | non_empty_user_attributes
1151 class_decl_name
{ $3.setText
(_p
->nsClassDecl
($3.text
()));
1152 _p
->onClassStart
($2.num
(),$3);}
1153 extends_from implements_list
'{'
1154 class_statement_list
'}' { Token stmts
;
1155 if
(_p
->peekClass
()) {
1156 xhp_collect_attributes
(_p
,stmts
,$8);
1160 _p
->onClass
($$
,$2.num
(),$3,$5,$6,
1162 if
(_p
->peekClass
()) {
1163 _p
->xhpResetAttributes
();
1166 _p
->popTypeScope
();}
1168 interface_decl_name
{ $2.setText
(_p
->nsClassDecl
($2.text
()));
1169 _p
->onClassStart
(T_INTERFACE
,$2);}
1170 interface_extends_list
'{'
1171 class_statement_list
'}' { _p
->onInterface
($$
,$2,$4,$6,0);
1173 _p
->popTypeScope
();}
1174 | non_empty_user_attributes
1176 interface_decl_name
{ $3.setText
(_p
->nsClassDecl
($3.text
()));
1177 _p
->onClassStart
(T_INTERFACE
,$3);}
1178 interface_extends_list
'{'
1179 class_statement_list
'}' { _p
->onInterface
($$
,$3,$5,$7,&$1);
1181 _p
->popTypeScope
();}
1185 T_CLASS
{ _p
->onClassExpressionStart
(); }
1187 extends_from implements_list
'{'
1188 class_statement_list
'}' { _p
->onClassExpression
($$
, $3, $4, $5, $7); }
1190 trait_declaration_statement:
1192 trait_decl_name
{ $2.setText
(_p
->nsClassDecl
($2.text
()));
1193 _p
->onClassStart
(T_TRAIT
, $2);}
1195 '{' class_statement_list
'}' { Token t_ext
;
1197 _p
->onClass
($$
,T_TRAIT
,$2,t_ext
,$4,
1200 _p
->popTypeScope
();}
1201 | non_empty_user_attributes
1203 trait_decl_name
{ $3.setText
(_p
->nsClassDecl
($3.text
()));
1204 _p
->onClassStart
(T_TRAIT
, $3);}
1206 '{' class_statement_list
'}' { Token t_ext
;
1208 _p
->onClass
($$
,T_TRAIT
,$3,t_ext
,$5,
1211 _p
->popTypeScope
();}
1214 hh_name_no_semireserved_with_typevar
{ _p
->pushClass
(false
); $$
= $1;}
1215 | T_XHP_LABEL
{ $1.xhpLabel
(); _p
->pushTypeScope
();
1216 _p
->pushClass
(true
); $$
= $1;}
1218 interface_decl_name:
1219 hh_name_no_semireserved_with_typevar
{ _p
->pushClass
(false
); $$
= $1;}
1222 hh_name_no_semireserved_with_typevar
{ _p
->pushClass
(false
); $$
= $1;}
1225 T_CLASS
{ $$
= T_CLASS
;}
1226 | T_ABSTRACT T_CLASS
{ $$
= T_ABSTRACT
; }
1227 | T_ABSTRACT T_FINAL T_CLASS
{ only_in_hh_syntax
(_p
);
1228 /* hacky, but transforming to a single token is quite convenient */
1230 | T_FINAL T_ABSTRACT T_CLASS
{ only_in_hh_syntax
(_p
); $$
= T_STATIC
; }
1231 | T_FINAL T_CLASS
{ $$
= T_FINAL
;}
1235 fully_qualified_class_name
{ $$
= $2;}
1239 T_IMPLEMENTS interface_list
{ $$
= $2;}
1242 interface_extends_list:
1243 T_EXTENDS interface_list
{ $$
= $2;}
1247 fully_qualified_class_name
{ _p
->onInterfaceName
($$
, NULL
, $1);}
1248 | interface_list
','
1249 fully_qualified_class_name
{ _p
->onInterfaceName
($$
, &$1, $3);}
1252 fully_qualified_class_name
{ _p
->onTraitName
($$
, NULL
, $1);}
1254 fully_qualified_class_name
{ _p
->onTraitName
($$
, &$1, $3);}
1257 foreach_optional_arg:
1258 T_DOUBLE_ARROW foreach_variable
{ $$
= $2;}
1262 variable
{ $$
= $1; $$
= 0;}
1263 |
'&' variable
{ $$
= $2; $$
= 1;}
1264 | T_LIST
'(' assignment_list
')' { _p
->onListAssignment
($$
, $3, NULL
);}
1268 statement
{ $$
= $1;}
1269 |
':' inner_statement_list
1270 T_ENDFOR
';' { $$
= $2;}
1273 statement
{ $$
= $1;}
1274 |
':' inner_statement_list
1275 T_ENDFOREACH
';' { $$
= $2;}
1278 statement
{ $$
= $1;}
1279 |
':' inner_statement_list
1280 T_ENDWHILE
';' { $$
= $2;}
1283 statement
{ $$
= $1;}
1284 |
':' inner_statement_list
1285 T_ENDDECLARE
';' { $$
= $2;}
1289 ident_no_semireserved
'=' static_expr
1291 ident_no_semireserved
'=' static_expr
1295 '{' case_list
'}' { $$
= $2;}
1296 |
'{' ';' case_list
'}' { $$
= $3;}
1297 |
':' case_list T_ENDSWITCH
';' { $$
= $2;}
1298 |
':' ';' case_list T_ENDSWITCH
';' { $$
= $3;}
1301 case_list T_CASE expr
1303 inner_statement_list
{ _p
->onCase
($$
,$1,&$3,$5);}
1304 | case_list T_DEFAULT case_separator
1305 inner_statement_list
{ _p
->onCase
($$
,$1,NULL
,$4);}
1310 |
';' { $$.reset
();}
1314 elseif_list T_ELSEIF parenthesis_expr
1315 statement
{ _p
->onElseIf
($$
,$1,$3,$4);}
1319 new_elseif_list T_ELSEIF
1320 parenthesis_expr
':'
1321 inner_statement_list
{ _p
->onElseIf
($$
,$1,$3,$5);}
1325 T_ELSE statement
{ $$
= $2;}
1329 T_ELSE
':' inner_statement_list
{ $$
= $3;}
1333 method_parameter_list:
1334 non_empty_method_parameter_list
','
1335 optional_user_attributes
1337 hh_type_opt
"..." T_VARIABLE
1338 { _p
->onVariadicParam
($$
,&$1,$5,$7,false
,
1340 | non_empty_method_parameter_list
','
1341 optional_user_attributes
1343 hh_type_opt
'&' "..." T_VARIABLE
1344 { _p
->onVariadicParam
($$
,&$1,$5,$8,true
,
1346 | non_empty_method_parameter_list
','
1347 optional_user_attributes
1350 { validate_hh_variadic_variant
(
1353 | non_empty_method_parameter_list
1354 hh_possible_comma
{ $$
= $1;}
1355 | optional_user_attributes
1357 hh_type_opt
"..." T_VARIABLE
1358 { _p
->onVariadicParam
($$
,NULL
,$3,$5,false
,
1360 | optional_user_attributes
1362 hh_type_opt
'&' "..." T_VARIABLE
1363 { _p
->onVariadicParam
($$
,NULL
,$3,$6,true
,
1365 | optional_user_attributes
1368 { validate_hh_variadic_variant
(
1374 non_empty_method_parameter_list:
1375 optional_user_attributes
1377 hh_type_opt T_VARIABLE
{ _p
->onParam
($$
,NULL
,$3,$4,0,
1379 | optional_user_attributes
1381 hh_type_opt
'&' T_VARIABLE
{ _p
->onParam
($$
,NULL
,$3,$5,1,
1383 | optional_user_attributes
1385 hh_type_opt
'&' T_VARIABLE
1386 '=' expr
{ _p
->onParam
($$
,NULL
,$3,$5,1,
1388 | optional_user_attributes
1390 hh_type_opt T_VARIABLE
1391 '=' expr
{ _p
->onParam
($$
,NULL
,$3,$4,0,
1393 | non_empty_method_parameter_list
','
1394 optional_user_attributes
1396 hh_type_opt T_VARIABLE
{ _p
->onParam
($$
,&$1,$5,$6,0,
1398 | non_empty_method_parameter_list
','
1399 optional_user_attributes
1401 hh_type_opt
'&' T_VARIABLE
{ _p
->onParam
($$
,&$1,$5,$7,1,
1403 | non_empty_method_parameter_list
','
1404 optional_user_attributes
1406 hh_type_opt
'&' T_VARIABLE
1407 '=' expr
{ _p
->onParam
($$
,&$1,$5,$7,1,
1409 | non_empty_method_parameter_list
','
1410 optional_user_attributes
1412 hh_type_opt T_VARIABLE
1413 '=' expr
{ _p
->onParam
($$
,&$1,$5,$6,0,
1418 non_empty_parameter_list
','
1419 optional_user_attributes
1420 hh_type_opt
"..." T_VARIABLE
1421 { _p
->onVariadicParam
($$
,&$1,$4,$6,
1423 | non_empty_parameter_list
','
1424 optional_user_attributes
1425 hh_type_opt
'&' "..." T_VARIABLE
1426 { _p
->onVariadicParam
($$
,&$1,$4,$7,
1428 | non_empty_parameter_list
','
1429 optional_user_attributes
1431 { validate_hh_variadic_variant
(
1434 | non_empty_parameter_list
1435 hh_possible_comma
{ $$
= $1;}
1436 | optional_user_attributes
1437 hh_type_opt
"..." T_VARIABLE
1438 { _p
->onVariadicParam
($$
,NULL
,$2,$4,
1440 | optional_user_attributes
1441 hh_type_opt
'&' "..." T_VARIABLE
1442 { _p
->onVariadicParam
($$
,NULL
,$2,$5,
1444 | optional_user_attributes
1446 { validate_hh_variadic_variant
(
1452 non_empty_parameter_list:
1453 optional_user_attributes
1454 hh_type_opt T_VARIABLE
{ _p
->onParam
($$
,NULL
,$2,$3,false
,
1456 | optional_user_attributes
1457 hh_type_opt
'&' T_VARIABLE
{ _p
->onParam
($$
,NULL
,$2,$4,true
,
1459 | optional_user_attributes
1460 hh_type_opt
'&' T_VARIABLE
1461 '=' expr
{ _p
->onParam
($$
,NULL
,$2,$4,true
,
1463 | optional_user_attributes
1464 hh_type_opt T_VARIABLE
1465 '=' expr
{ _p
->onParam
($$
,NULL
,$2,$3,false
,
1467 | non_empty_parameter_list
','
1468 optional_user_attributes
1469 hh_type_opt T_VARIABLE
{ _p
->onParam
($$
,&$1,$4,$5,false
,
1471 | non_empty_parameter_list
','
1472 optional_user_attributes
1473 hh_type_opt
'&' T_VARIABLE
{ _p
->onParam
($$
,&$1,$4,$6,true
,
1475 | non_empty_parameter_list
','
1476 optional_user_attributes
1477 hh_type_opt
'&' T_VARIABLE
1478 '=' expr
{ _p
->onParam
($$
,&$1,$4,$6,true
,
1480 | non_empty_parameter_list
','
1481 optional_user_attributes
1482 hh_type_opt T_VARIABLE
1483 '=' expr
{ _p
->onParam
($$
,&$1,$4,$5,false
,
1487 function_call_parameter_list:
1488 non_empty_fcall_parameter_list
1489 hh_possible_comma
{ $$
= $1;}
1492 non_empty_fcall_parameter_list:
1493 expr
{ _p
->onCallParam
($$
,NULL
,$1,false
,false
);}
1494 |
'&' variable
{ _p
->onCallParam
($$
,NULL
,$2,true
,false
);}
1495 |
"..." expr
{ _p
->onCallParam
($$
,NULL
,$2,false
,true
);}
1496 | non_empty_fcall_parameter_list
1497 ',' expr
{ _p
->onCallParam
($$
,&$1,$3,false
, false
);}
1498 | non_empty_fcall_parameter_list
1499 ',' "..." expr
{ _p
->onCallParam
($$
,&$1,$4,false
,true
);}
1500 | non_empty_fcall_parameter_list
1501 ',' '&' variable
{ _p
->onCallParam
($$
,&$1,$4,true
, false
);}
1505 global_var_list
',' global_var
{ _p
->onGlobalVar
($$
, &$1, $3);}
1506 | global_var
{ _p
->onGlobalVar
($$
, NULL
, $1);}
1509 T_VARIABLE
{ $$
= $1;}
1510 |
'$' variable
{ $$
= $2; $$
= 1;}
1511 |
'$' '{' expr
'}' { $$
= $3; $$
= 1;}
1515 static_var_list
',' T_VARIABLE
{ _p
->onStaticVariable
($$
,&$1,$3,0);}
1516 | static_var_list
',' T_VARIABLE
1517 '=' static_expr
{ _p
->onStaticVariable
($$
,&$1,$3,&$5);}
1518 | T_VARIABLE
{ _p
->onStaticVariable
($$
,0,$1,0);}
1519 | T_VARIABLE
'=' static_expr
{ _p
->onStaticVariable
($$
,0,$1,&$3);}
1522 enum_statement_list:
1524 enum_statement
{ _p
->onClassStatement
($$
, $1, $2);}
1528 enum_constant_declaration
';' { _p
->onClassVariableStart
1531 enum_constant_declaration:
1532 hh_constname_with_type
'='
1533 static_expr
{ _p
->onClassConstant
($$
,0,$1,$3);}
1537 class_statement_list:
1538 class_statement_list
1539 class_statement
{ _p
->onClassStatement
($$
, $1, $2);}
1543 variable_modifiers
{ _p
->onClassVariableModifer
($1);}
1544 class_variable_declaration
';' { _p
->onClassVariableStart
1546 | non_empty_member_modifiers
1547 hh_type
{ _p
->onClassVariableModifer
($1);}
1548 class_variable_declaration
';' { _p
->onClassVariableStart
1550 | class_constant_declaration
';' { _p
->onClassVariableStart
1552 | class_abstract_constant_declaration
';'
1553 { _p
->onClassVariableStart
1554 ($$
,NULL
,$1,NULL
, true
);}
1555 | class_type_constant_declaration
';' { $$
= $1; }
1556 | method_modifiers function_loc
1557 is_reference hh_name_with_typevar
'('
1558 { _p
->onNewLabelScope
(true
);
1559 _p
->onMethodStart
($4, $1);
1560 _p
->pushLabelInfo
();}
1561 method_parameter_list
')'
1564 { _p
->onMethod
($$
,$1,$9,$3,$4,$7,$10,nullptr
);
1567 _p
->onCompleteLabelScope
(true
);}
1568 | non_empty_user_attributes
1569 method_modifiers function_loc
1571 hh_name_no_semireserved_with_typevar
'('
1572 { _p
->onNewLabelScope
(true
);
1573 _p
->onMethodStart
($5, $2);
1574 _p
->pushLabelInfo
();}
1575 method_parameter_list
')'
1578 { _p
->onMethod
($$
,$2,$10,$4,$5,$8,$11,&$1);
1581 _p
->onCompleteLabelScope
(true
);}
1583 xhp_attribute_stmt
';' { _p
->xhpSetAttributes
($2);}
1585 xhp_category_stmt
';' { xhp_category_stmt
(_p
,$$
,$2);}
1587 xhp_children_stmt
';' { xhp_children_stmt
(_p
,$$
,$2);}
1588 | T_REQUIRE T_EXTENDS fully_qualified_class_name
';'
1589 { _p
->onClassRequire
($$
, $3, true
); }
1590 | T_REQUIRE T_IMPLEMENTS fully_qualified_class_name
';'
1591 { _p
->onClassRequire
($$
, $3, false
); }
1592 | T_USE trait_list
';' { Token t
; t.reset
();
1593 _p
->onTraitUse
($$
,$2,t
); }
1594 | T_USE trait_list
'{'
1595 trait_rules
'}' { _p
->onTraitUse
($$
,$2,$4); }
1598 trait_rules trait_precedence_rule
{ _p
->onTraitRule
($$
,$1,$2); }
1599 | trait_rules trait_alias_rule
{ _p
->onTraitRule
($$
,$1,$2); }
1600 |
/* empty */ { $$.reset
(); }
1602 trait_precedence_rule:
1603 class_namespace_string_typeargs
1605 ident_no_semireserved
1606 T_INSTEADOF trait_list
';' { _p
->onTraitPrecRule
($$
,$1,$3,$5);}
1609 trait_alias_rule_method T_AS
1610 method_modifiers ident_no_semireserved
';'
1611 { _p
->onTraitAliasRuleModify
($$
,$1,$3,
1613 | trait_alias_rule_method T_AS
1614 non_empty_member_modifiers
';' { Token t
; t.reset
();
1615 _p
->onTraitAliasRuleModify
($$
,$1,$3,
1618 trait_alias_rule_method:
1619 class_namespace_string_typeargs
1621 ident_no_semireserved
{ _p
->onTraitAliasRuleStart
($$
,$1,$3);}
1622 | ident_no_semireserved
{ Token t
; t.reset
();
1623 _p
->onTraitAliasRuleStart
($$
,t
,$1);}
1627 xhp_attribute_decl
{ xhp_attribute_list
(_p
,$$
,
1628 _p
->xhpGetAttributes
(),$1);}
1629 | xhp_attribute_stmt
','
1630 xhp_attribute_decl
{ xhp_attribute_list
(_p
,$$
, &$1,$3);}
1634 xhp_nullable_attribute_decl_type
1636 xhp_attribute_default
1637 xhp_attribute_is_required
{ xhp_attribute
(_p
,$$
,$1,$2,$3,$4);
1639 | T_XHP_LABEL
{ $$
= $1; $$
= 0;}
1642 xhp_nullable_attribute_decl_type:
1643 '?' xhp_attribute_decl_type
{ $$
= $2;}
1644 | xhp_attribute_decl_type
1647 xhp_attribute_decl_type:
1649 | T_ARRAY T_TYPELIST_LT hh_type
1650 T_TYPELIST_GT
{ $$
= 4;}
1651 | T_ARRAY T_TYPELIST_LT hh_type
','
1652 hh_type T_TYPELIST_GT
{ $$
= 4;}
1653 | fully_qualified_class_name
{ /* This case handles all types other
1654 than "array", "var" and "enum".
1655 For now we just use type code 5;
1656 later xhp_attribute() will fix up
1657 the type code as appropriate. */
1658 $$
= 5; $$.setText
($1);}
1661 xhp_attribute_enum
'}' { $$
= $3; $$
= 7;}
1662 | T_CALLABLE
{ $$
= 9; }
1665 non_empty_xhp_attribute_enum:
1666 common_scalar
{ _p
->onArrayPair
($$
, 0,0,$1,0);}
1667 | non_empty_xhp_attribute_enum
','
1668 common_scalar
{ _p
->onArrayPair
($$
,&$1,0,$3,0);}
1672 non_empty_xhp_attribute_enum
1673 possible_comma
{ $$
= $1;}
1675 xhp_attribute_default:
1676 '=' static_expr
{ $$
= $2;}
1677 |
{ scalar_null
(_p
, $$
);}
1680 xhp_attribute_is_required:
1681 '@' T_XHP_REQUIRED
{ scalar_num
(_p
, $$
, "1");}
1682 |
{ scalar_num
(_p
, $$
, "0");}
1686 xhp_category_decl
{ Token t
; scalar_num
(_p
, t
, "1");
1687 _p
->onArrayPair
($$
,0,&$1,t
,0);}
1688 | xhp_category_stmt
','
1689 xhp_category_decl
{ Token t
; scalar_num
(_p
, t
, "1");
1690 _p
->onArrayPair
($$
,&$1,&$3,t
,0);}
1694 T_XHP_CATEGORY_LABEL
{ _p
->onScalar
($$
,
1695 T_CONSTANT_ENCAPSED_STRING
, $1);}
1699 xhp_children_paren_expr
{ $$
= $1; $$
= 2;}
1700 | ident_no_semireserved
{ $$
= -1;
1701 if
($1.same
("any")) $$
= 1;}
1702 | T_EMPTY
{ $$
= 0;}
1705 xhp_children_paren_expr:
1706 '(' xhp_children_decl_expr
')' { xhp_children_paren
(_p
, $$
, $2, 0);}
1707 |
'(' xhp_children_decl_expr
')' '*' { xhp_children_paren
(_p
, $$
, $2, 1);}
1708 |
'(' xhp_children_decl_expr
')' '?' { xhp_children_paren
(_p
, $$
, $2, 2);}
1709 |
'(' xhp_children_decl_expr
')' '+' { xhp_children_paren
(_p
, $$
, $2, 3);}
1712 xhp_children_decl_expr:
1713 xhp_children_paren_expr
{ $$
= $1;}
1714 | xhp_children_decl_tag
{ xhp_children_decl
(_p
,$$
,$1,0, 0);}
1715 | xhp_children_decl_tag
'*' { xhp_children_decl
(_p
,$$
,$1,1, 0);}
1716 | xhp_children_decl_tag
'?' { xhp_children_decl
(_p
,$$
,$1,2, 0);}
1717 | xhp_children_decl_tag
'+' { xhp_children_decl
(_p
,$$
,$1,3, 0);}
1718 | xhp_children_decl_expr
','
1719 xhp_children_decl_expr
{ xhp_children_decl
(_p
,$$
,$1,4,&$3);}
1720 | xhp_children_decl_expr
'|'
1721 xhp_children_decl_expr
{ xhp_children_decl
(_p
,$$
,$1,5,&$3);}
1724 xhp_children_decl_tag:
1725 ident_no_semireserved
{ $$
= -1;
1726 if
($1.same
("any")) $$
= 1; else
1727 if
($1.same
("pcdata")) $$
= 2;}
1728 | T_XHP_LABEL
{ $1.xhpLabel
(); $$
= $1; $$
= 3;}
1729 | T_XHP_CATEGORY_LABEL
{ $1.xhpLabel
(0); $$
= $1; $$
= 4;}
1734 |
'{' inner_statement_list
'}' { _p
->finishStatement
($$
, $2); $$
= 1;}
1739 |
'{' inner_statement_list
'}' { _p
->finishStatement
($$
, $2); $$
= 1;}
1742 non_empty_member_modifiers
{ $$
= $1;}
1743 | T_VAR
{ $$.reset
();}
1746 non_empty_member_modifiers
{ $$
= $1;}
1749 non_empty_member_modifiers:
1750 member_modifier
{ _p
->onMemberModifier
($$
,NULL
,$1);}
1751 | non_empty_member_modifiers
1752 member_modifier
{ _p
->onMemberModifier
($$
,&$1,$2);}
1755 T_PUBLIC
{ $$
= T_PUBLIC
;}
1756 | T_PROTECTED
{ $$
= T_PROTECTED
;}
1757 | T_PRIVATE
{ $$
= T_PRIVATE
;}
1758 | T_STATIC
{ $$
= T_STATIC
;}
1759 | T_ABSTRACT
{ $$
= T_ABSTRACT
;}
1760 | T_FINAL
{ $$
= T_FINAL
;}
1761 | T_ASYNC
{ $$
= T_ASYNC
;}
1764 parameter_modifiers:
1765 parameter_modifier
{ $$
= $1;}
1769 T_PUBLIC
{ $$
= T_PUBLIC
;}
1770 | T_PROTECTED
{ $$
= T_PROTECTED
;}
1771 | T_PRIVATE
{ $$
= T_PRIVATE
;}
1773 class_variable_declaration:
1774 class_variable_declaration
','
1775 T_VARIABLE
{ _p
->onClassVariable
($$
,&$1,$3,0);}
1776 | class_variable_declaration
','
1777 T_VARIABLE
'=' static_expr
{ _p
->onClassVariable
($$
,&$1,$3,&$5);}
1778 | T_VARIABLE
{ _p
->onClassVariable
($$
,0,$1,0);}
1779 | T_VARIABLE
'=' static_expr
{ _p
->onClassVariable
($$
,0,$1,&$3);}
1781 class_constant_declaration:
1782 class_constant_declaration
','
1783 hh_constname_with_type
'=' static_expr
{ _p
->onClassConstant
($$
,&$1,$3,$5);}
1784 | T_CONST hh_constname_with_type
'='
1785 static_expr
{ _p
->onClassConstant
($$
,0,$2,$4);}
1787 class_abstract_constant_declaration:
1788 class_abstract_constant_declaration
','
1789 hh_constname_with_type
{ _p
->onClassAbstractConstant
($$
,&$1,$3);}
1790 | T_ABSTRACT T_CONST hh_constname_with_type
1791 { _p
->onClassAbstractConstant
($$
,NULL
,$3);}
1793 class_type_constant_declaration:
1794 T_ABSTRACT class_type_constant
1795 hh_opt_constraint
{ Token t
;
1796 _p
->onClassTypeConstant
($$
, $2, t
);
1797 _p
->popTypeScope
(); }
1798 | class_type_constant
1799 hh_opt_constraint
'=' hh_type
{ _p
->onClassTypeConstant
($$
, $1, $4);
1800 _p
->popTypeScope
(); }
1801 class_type_constant:
1803 hh_name_no_semireserved_with_typevar
{ $$
= $3; }
1807 '(' expr_with_parens
')' { $$
= $2;}
1808 | T_NEW class_name_reference
1809 ctor_arguments
{ _p
->onNewObject
($$
, $2, $3);}
1810 | T_NEW class_expression
{ $$
= $2;}
1811 | T_CLONE expr
{ UEXP
($$
,$2,T_CLONE
,1);}
1812 | xhp_tag
{ $$
= $1;}
1813 | collection_literal
{ $$
= $1;}
1816 '(' expr
')' { $$
= $2;}
1820 expr_list
',' expr
{ _p
->onExprListElem
($$
, &$1, $3);}
1821 | expr
{ _p
->onExprListElem
($$
, NULL
, $1);}
1825 expr_list
{ $$
= $1;}
1830 T_YIELD
{ _p
->onYield
($$
, NULL
);}
1831 | T_YIELD expr
{ _p
->onYield
($$
, &$2);}
1832 | T_YIELD expr T_DOUBLE_ARROW expr
{ _p
->onYieldPair
($$
, &$2, &$4);}
1833 |
'(' yield_expr
')' { $$
= $2; }
1837 variable
'=' yield_expr
{ _p
->onAssign
($$
, $1, $3, 0, true
);}
1840 yield_list_assign_expr:
1841 T_LIST
'(' assignment_list
')'
1842 '=' yield_expr
{ _p
->onListAssignment
($$
, $3, &$6, true
);}
1846 T_AWAIT expr
{ _p
->onAwait
($$
, $2); }
1850 variable
'=' await_expr
{ _p
->onAssign
($$
, $1, $3, 0, true
);}
1853 await_list_assign_expr:
1854 T_LIST
'(' assignment_list
')'
1855 '=' await_expr
{ _p
->onListAssignment
($$
, $3, &$6, true
);}
1859 expr_no_variable
{ $$
= $1;}
1860 | variable
{ $$
= $1;}
1861 | expr_with_parens
{ $$
= $1;}
1862 | lambda_or_closure
{ $$
= $1;}
1863 | lambda_or_closure_with_parens
{ $$
= $1;}
1867 T_LIST
'(' assignment_list
')'
1868 '=' expr
{ _p
->onListAssignment
($$
, $3, &$6);}
1869 | variable
'=' expr
{ _p
->onAssign
($$
, $1, $3, 0);}
1870 | variable
'=' '&' variable
{ _p
->onAssign
($$
, $1, $4, 1);}
1871 | variable
'=' '&' T_NEW
1872 class_name_reference
1873 ctor_arguments
{ _p
->onAssignNew
($$
,$1,$5,$6);}
1874 | variable T_PLUS_EQUAL expr
{ BEXP
($$
,$1,$3,T_PLUS_EQUAL
);}
1875 | variable T_MINUS_EQUAL expr
{ BEXP
($$
,$1,$3,T_MINUS_EQUAL
);}
1876 | variable T_MUL_EQUAL expr
{ BEXP
($$
,$1,$3,T_MUL_EQUAL
);}
1877 | variable T_DIV_EQUAL expr
{ BEXP
($$
,$1,$3,T_DIV_EQUAL
);}
1878 | variable T_CONCAT_EQUAL expr
{ BEXP
($$
,$1,$3,T_CONCAT_EQUAL
);}
1879 | variable T_MOD_EQUAL expr
{ BEXP
($$
,$1,$3,T_MOD_EQUAL
);}
1880 | variable T_AND_EQUAL expr
{ BEXP
($$
,$1,$3,T_AND_EQUAL
);}
1881 | variable T_OR_EQUAL expr
{ BEXP
($$
,$1,$3,T_OR_EQUAL
);}
1882 | variable T_XOR_EQUAL expr
{ BEXP
($$
,$1,$3,T_XOR_EQUAL
);}
1883 | variable T_SL_EQUAL expr
{ BEXP
($$
,$1,$3,T_SL_EQUAL
);}
1884 | variable T_SR_EQUAL expr
{ BEXP
($$
,$1,$3,T_SR_EQUAL
);}
1885 | variable T_POW_EQUAL expr
{ BEXP
($$
,$1,$3,T_POW_EQUAL
);}
1886 | variable T_INC
{ UEXP
($$
,$1,T_INC
,0);}
1887 | T_INC variable
{ UEXP
($$
,$2,T_INC
,1);}
1888 | variable T_DEC
{ UEXP
($$
,$1,T_DEC
,0);}
1889 | T_DEC variable
{ UEXP
($$
,$2,T_DEC
,1);}
1890 | expr T_BOOLEAN_OR expr
{ BEXP
($$
,$1,$3,T_BOOLEAN_OR
);}
1891 | expr T_BOOLEAN_AND expr
{ BEXP
($$
,$1,$3,T_BOOLEAN_AND
);}
1892 | expr T_LOGICAL_OR expr
{ BEXP
($$
,$1,$3,T_LOGICAL_OR
);}
1893 | expr T_LOGICAL_AND expr
{ BEXP
($$
,$1,$3,T_LOGICAL_AND
);}
1894 | expr T_LOGICAL_XOR expr
{ BEXP
($$
,$1,$3,T_LOGICAL_XOR
);}
1895 | expr
'|' expr
{ BEXP
($$
,$1,$3,'|');}
1896 | expr
'&' expr
{ BEXP
($$
,$1,$3,'&');}
1897 | expr
'^' expr
{ BEXP
($$
,$1,$3,'^');}
1898 | expr
'.' expr
{ BEXP
($$
,$1,$3,'.');}
1899 | expr
'+' expr
{ BEXP
($$
,$1,$3,'+');}
1900 | expr
'-' expr
{ BEXP
($$
,$1,$3,'-');}
1901 | expr
'*' expr
{ BEXP
($$
,$1,$3,'*');}
1902 | expr
'/' expr
{ BEXP
($$
,$1,$3,'/');}
1903 | expr T_POW expr
{ BEXP
($$
,$1,$3,T_POW
);}
1904 | expr
'%' expr
{ BEXP
($$
,$1,$3,'%');}
1905 | expr T_SL expr
{ BEXP
($$
,$1,$3,T_SL
);}
1906 | expr T_SR expr
{ BEXP
($$
,$1,$3,T_SR
);}
1907 |
'+' expr %prec T_INC
{ UEXP
($$
,$2,'+',1);}
1908 |
'-' expr %prec T_INC
{ UEXP
($$
,$2,'-',1);}
1909 |
'!' expr
{ UEXP
($$
,$2,'!',1);}
1910 |
'~' expr
{ UEXP
($$
,$2,'~',1);}
1911 | expr T_IS_IDENTICAL expr
{ BEXP
($$
,$1,$3,T_IS_IDENTICAL
);}
1912 | expr T_IS_NOT_IDENTICAL expr
{ BEXP
($$
,$1,$3,T_IS_NOT_IDENTICAL
);}
1913 | expr T_IS_EQUAL expr
{ BEXP
($$
,$1,$3,T_IS_EQUAL
);}
1914 | expr T_IS_NOT_EQUAL expr
{ BEXP
($$
,$1,$3,T_IS_NOT_EQUAL
);}
1915 | expr
'<' expr
{ BEXP
($$
,$1,$3,'<');}
1916 | expr T_IS_SMALLER_OR_EQUAL expr
{ BEXP
($$
,$1,$3,
1917 T_IS_SMALLER_OR_EQUAL
);}
1918 | expr
'>' expr
{ BEXP
($$
,$1,$3,'>');}
1919 | expr T_IS_GREATER_OR_EQUAL expr
{ BEXP
($$
,$1,$3,
1920 T_IS_GREATER_OR_EQUAL
);}
1921 | expr T_SPACESHIP expr
{ BEXP
($$
,$1,$3,T_SPACESHIP
);}
1923 class_name_reference
{ BEXP
($$
,$1,$3,T_INSTANCEOF
);}
1924 |
'(' expr_no_variable
')' { $$
= $2;}
1925 | expr
'?' expr
':' expr
{ _p
->onQOp
($$
, $1, &$3, $5);}
1926 | expr
'?' ':' expr
{ _p
->onQOp
($$
, $1, 0, $4);}
1927 | expr T_COALESCE expr
{ _p
->onNullCoalesce
($$
, $1, $3);}
1928 | internal_functions
{ $$
= $1;}
1929 | T_INT_CAST expr
{ UEXP
($$
,$2,T_INT_CAST
,1);}
1930 | T_DOUBLE_CAST expr
{ UEXP
($$
,$2,T_DOUBLE_CAST
,1);}
1931 | T_STRING_CAST expr
{ UEXP
($$
,$2,T_STRING_CAST
,1);}
1932 | T_ARRAY_CAST expr
{ UEXP
($$
,$2,T_ARRAY_CAST
,1);}
1933 | T_OBJECT_CAST expr
{ UEXP
($$
,$2,T_OBJECT_CAST
,1);}
1934 | T_BOOL_CAST expr
{ UEXP
($$
,$2,T_BOOL_CAST
,1);}
1935 | T_UNSET_CAST expr
{ UEXP
($$
,$2,T_UNSET_CAST
,1);}
1936 | T_EXIT exit_expr
{ UEXP
($$
,$2,T_EXIT
,1);}
1937 |
'@' expr
{ UEXP
($$
,$2,'@',1);}
1938 | scalar
{ $$
= $1; }
1939 | array_literal
{ $$
= $1; }
1940 | shape_literal
{ $$
= $1; }
1941 |
'`' backticks_expr
'`' { _p
->onEncapsList
($$
,'`',$2);}
1942 | T_PRINT expr
{ UEXP
($$
,$2,T_PRINT
,1);}
1943 | dim_expr
{ $$
= $1;}
1956 is_reference
'(' { Token t
;
1957 _p
->onNewLabelScope
(true
);
1958 _p
->onClosureStart
(t
);
1959 _p
->pushLabelInfo
(); }
1961 hh_opt_return_type lambda_use_vars
1962 '{' inner_statement_list
'}' { _p
->finishStatement
($10, $10); $10 = 1;
1963 $$
= _p
->onClosure
(ClosureType
::Long
,
1967 _p
->onCompleteLabelScope
(true
);}
1968 | non_empty_member_modifiers
1970 is_reference
'(' { Token t
;
1971 _p
->onNewLabelScope
(true
);
1972 _p
->onClosureStart
(t
);
1973 _p
->pushLabelInfo
(); }
1975 hh_opt_return_type lambda_use_vars
1976 '{' inner_statement_list
'}' { _p
->finishStatement
($11, $11); $11 = 1;
1977 $$
= _p
->onClosure
(ClosureType
::Long
,
1981 _p
->onCompleteLabelScope
(true
);}
1986 T_VARIABLE
{ _p
->pushFuncLocation
();
1988 _p
->onNewLabelScope
(true
);
1989 _p
->onClosureStart
(t
);
1990 _p
->pushLabelInfo
();
1992 _p
->onParam
($2,NULL
,u
,$2,0,
1994 lambda_body
{ Token v
; Token w
; Token x
;
1996 _p
->onMemberModifier
($1, nullptr
, $1);
1997 _p
->finishStatement
($4, $4); $4 = 1;
1998 $$
= _p
->onClosure
(ClosureType
::Short
,
2002 _p
->onCompleteLabelScope
(true
);}
2004 T_LAMBDA_OP
{ _p
->pushFuncLocation
();
2006 _p
->onNewLabelScope
(true
);
2007 _p
->onClosureStart
(t
);
2008 _p
->pushLabelInfo
();}
2012 lambda_body
{ Token u
; Token v
;
2014 _p
->onMemberModifier
($1, nullptr
, $1);
2015 _p
->finishStatement
($7, $7); $7 = 1;
2016 $$
= _p
->onClosure
(ClosureType
::Short
,
2020 _p
->onCompleteLabelScope
(true
);}
2022 '{' { _p
->pushFuncLocation
();
2024 _p
->onNewLabelScope
(true
);
2025 _p
->onClosureStart
(t
);
2026 _p
->pushLabelInfo
();}
2027 inner_statement_list
2028 '}' { Token u
; Token v
; Token w
; Token x
;
2031 _p
->onMemberModifier
($1, nullptr
, $1);
2032 _p
->finishStatement
($4, $4); $4 = 1;
2033 $$
= _p
->onClosure
(ClosureType
::Short
,
2037 _p
->onCompleteLabelScope
(true
);
2038 _p
->onCall
($$
,1,$$
,y
,NULL
);}
2039 | T_VARIABLE
{ _p
->pushFuncLocation
();
2041 _p
->onNewLabelScope
(true
);
2042 _p
->onClosureStart
(t
);
2043 _p
->pushLabelInfo
();
2045 _p
->onParam
($1,NULL
,u
,$1,0,
2047 lambda_body
{ Token v
; Token w
; Token x
;
2048 _p
->finishStatement
($3, $3); $3 = 1;
2049 $$
= _p
->onClosure
(ClosureType
::Short
,
2053 _p
->onCompleteLabelScope
(true
);}
2054 | T_LAMBDA_OP
{ _p
->pushFuncLocation
();
2056 _p
->onNewLabelScope
(true
);
2057 _p
->onClosureStart
(t
);
2058 _p
->pushLabelInfo
();}
2062 lambda_body
{ Token u
; Token v
;
2063 _p
->finishStatement
($6, $6); $6 = 1;
2064 $$
= _p
->onClosure
(ClosureType
::Short
,
2068 _p
->onCompleteLabelScope
(true
);}
2072 T_LAMBDA_ARROW expr
{ $$
= _p
->onExprForLambda
($2);}
2073 | T_LAMBDA_ARROW await_expr
{ $$
= _p
->onExprForLambda
($2);}
2075 '{' inner_statement_list
'}' { $$
= $3; }
2079 T_CONSTANT_ENCAPSED_STRING
{ validate_shape_keyname
($1, _p
);
2080 _p
->onScalar
($$
, T_CONSTANT_ENCAPSED_STRING
, $1); }
2081 | class_constant
{ $$
= $1; }
2084 non_empty_shape_pair_list:
2085 non_empty_shape_pair_list
','
2088 expr
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0); }
2091 expr
{ _p
->onArrayPair
($$
, 0,&$1,$3,0); }
2094 non_empty_static_shape_pair_list:
2095 non_empty_static_shape_pair_list
','
2098 static_expr
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0); }
2101 static_expr
{ _p
->onArrayPair
($$
, 0,&$1,$3,0); }
2105 non_empty_shape_pair_list
2106 possible_comma
{ $$
= $1; }
2110 static_shape_pair_list:
2111 non_empty_static_shape_pair_list
2112 possible_comma
{ $$
= $1; }
2117 T_SHAPE
'(' shape_pair_list
')' { _p
->onArray
($$
, $3, T_ARRAY
);}
2121 T_ARRAY
'(' array_pair_list
')' { _p
->onArray
($$
,$3,T_ARRAY
);}
2122 |
'[' array_pair_list
']' { _p
->onArray
($$
,$2,T_ARRAY
);}
2126 fully_qualified_class_name
2127 '{' collection_init
'}' { Token t
;
2128 _p
->onName
(t
,$1,Parser
::StringName
);
2129 BEXP
($$
,t
,$3,T_COLLECTION
);}
2132 static_collection_literal:
2133 fully_qualified_class_name
2134 '{' static_collection_init
'}' { Token t
;
2135 _p
->onName
(t
,$1,Parser
::StringName
);
2136 BEXP
($$
,t
,$3,T_COLLECTION
);}
2141 '[' dim_offset
']' { _p
->onRefDim
($$
, $1, $3);}
2143 '[' dim_offset
']' { _p
->onRefDim
($$
, $1, $3);}
2147 array_literal
{ $$
= $1;}
2148 | class_constant
{ $$
= $1;}
2149 | lambda_or_closure_with_parens
{ $$
= $1;}
2150 | T_CONSTANT_ENCAPSED_STRING
{ _p
->onScalar
($$
,
2151 T_CONSTANT_ENCAPSED_STRING
, $1); }
2152 |
'(' expr_no_variable
')' { $$
= $2;}
2156 lexical_var_list
',' T_VARIABLE
{ _p
->onClosureParam
($$
,&$1,$3,0);}
2157 | lexical_var_list
',' '&'T_VARIABLE
{ _p
->onClosureParam
($$
,&$1,$4,1);}
2158 | T_VARIABLE
{ _p
->onClosureParam
($$
, 0,$1,0);}
2159 |
'&' T_VARIABLE
{ _p
->onClosureParam
($$
, 0,$2,1);}
2166 T_XHP_TAG_GT
{ xhp_tag
(_p
,$$
,$2,$3);}
2169 xhp_attributes
'/' { Token t1
; _p
->onArray
(t1
,$1);
2170 Token t2
; _p
->onArray
(t2
,$2);
2171 Token file
; scalar_file
(_p
, file
);
2172 Token line
; scalar_line
(_p
, line
);
2173 _p
->onCallParam
($1,NULL
,t1
,0,0);
2174 _p
->onCallParam
($$
, &$1,t2
,0,0);
2175 _p
->onCallParam
($1, &$1,file
,0,0);
2176 _p
->onCallParam
($1, &$1,line
,0,0);
2178 | xhp_attributes T_XHP_TAG_GT
2179 xhp_children T_XHP_TAG_LT
'/'
2180 xhp_opt_end_label
{ Token file
; scalar_file
(_p
, file
);
2181 Token line
; scalar_line
(_p
, line
);
2184 _p
->onCallParam
($2,NULL
,$4,0,0);
2185 _p
->onCallParam
($$
, &$2,$5,0,0);
2186 _p
->onCallParam
($2, &$2,file
,0,0);
2187 _p
->onCallParam
($2, &$2,line
,0,0);
2188 $$.setText
($6.text
());}
2191 { $$.reset
(); $$.setText
("");}
2192 | T_XHP_LABEL
{ $$.reset
(); $$.setText
($1);}
2196 xhp_attribute_name
'='
2197 xhp_attribute_value
{ _p
->onArrayPair
($$
,&$1,&$2,$4,0);}
2201 xhp_children xhp_child
{ _p
->onArrayPair
($$
,&$1,0,$2,0);}
2205 T_XHP_LABEL
{ _p
->onScalar
($$
,
2206 T_CONSTANT_ENCAPSED_STRING
, $1);}
2208 xhp_attribute_value:
2209 T_XHP_TEXT
{ $1.xhpDecode
();
2211 T_CONSTANT_ENCAPSED_STRING
, $1);}
2212 |
'{' expr
'}' { $$
= $2;}
2215 T_XHP_TEXT
{ $$.reset
();
2216 if
($1.htmlTrim
()) {
2219 T_CONSTANT_ENCAPSED_STRING
, $1);
2222 |
'{' expr
'}' { $$
= $2; }
2223 | xhp_tag
{ $$
= $1; }
2227 xhp_bareword
{ $$
= $1;}
2229 xhp_bareword
{ $$
= $1 + ":" + $3;}
2231 xhp_bareword
{ $$
= $1 + "-" + $3;}
2234 ident_no_semireserved
{ $$
= $1;}
2235 | T_EXIT
{ $$
= $1;}
2236 | T_FUNCTION
{ $$
= $1;}
2237 | T_CONST
{ $$
= $1;}
2238 | T_RETURN
{ $$
= $1;}
2239 | T_YIELD
{ $$
= $1;}
2240 | T_AWAIT
{ $$
= $1;}
2242 | T_CATCH
{ $$
= $1;}
2243 | T_FINALLY
{ $$
= $1;}
2244 | T_THROW
{ $$
= $1;}
2246 | T_ELSEIF
{ $$
= $1;}
2247 | T_ENDIF
{ $$
= $1;}
2248 | T_ELSE
{ $$
= $1;}
2249 | T_WHILE
{ $$
= $1;}
2250 | T_ENDWHILE
{ $$
= $1;}
2253 | T_ENDFOR
{ $$
= $1;}
2254 | T_FOREACH
{ $$
= $1;}
2255 | T_ENDFOREACH
{ $$
= $1;}
2256 | T_DECLARE
{ $$
= $1;}
2257 | T_ENDDECLARE
{ $$
= $1;}
2258 | T_INSTANCEOF
{ $$
= $1;}
2260 | T_SWITCH
{ $$
= $1;}
2261 | T_ENDSWITCH
{ $$
= $1;}
2262 | T_CASE
{ $$
= $1;}
2263 | T_DEFAULT
{ $$
= $1;}
2264 | T_BREAK
{ $$
= $1;}
2265 | T_CONTINUE
{ $$
= $1;}
2266 | T_GOTO
{ $$
= $1;}
2267 | T_ECHO
{ $$
= $1;}
2268 | T_PRINT
{ $$
= $1;}
2269 | T_CLASS
{ $$
= $1;}
2270 | T_INTERFACE
{ $$
= $1;}
2271 | T_EXTENDS
{ $$
= $1;}
2272 | T_IMPLEMENTS
{ $$
= $1;}
2274 | T_CLONE
{ $$
= $1;}
2276 | T_EVAL
{ $$
= $1;}
2277 | T_INCLUDE
{ $$
= $1;}
2278 | T_INCLUDE_ONCE
{ $$
= $1;}
2279 | T_REQUIRE
{ $$
= $1;}
2280 | T_REQUIRE_ONCE
{ $$
= $1;}
2281 | T_NAMESPACE
{ $$
= $1;}
2283 | T_GLOBAL
{ $$
= $1;}
2284 | T_ISSET
{ $$
= $1;}
2285 | T_EMPTY
{ $$
= $1;}
2286 | T_HALT_COMPILER
{ $$
= $1;}
2287 | T_STATIC
{ $$
= $1;}
2288 | T_ABSTRACT
{ $$
= $1;}
2289 | T_FINAL
{ $$
= $1;}
2290 | T_PRIVATE
{ $$
= $1;}
2291 | T_PROTECTED
{ $$
= $1;}
2292 | T_PUBLIC
{ $$
= $1;}
2293 | T_ASYNC
{ $$
= $1;}
2294 | T_UNSET
{ $$
= $1;}
2295 | T_LIST
{ $$
= $1;}
2296 | T_ARRAY
{ $$
= $1;}
2297 | T_LOGICAL_OR
{ $$
= $1;}
2298 | T_LOGICAL_AND
{ $$
= $1;}
2299 | T_LOGICAL_XOR
{ $$
= $1;}
2300 | T_CLASS_C
{ $$
= $1;}
2301 | T_FUNC_C
{ $$
= $1;}
2302 | T_METHOD_C
{ $$
= $1;}
2303 | T_LINE
{ $$
= $1;}
2304 | T_FILE
{ $$
= $1;}
2306 | T_NS_C
{ $$
= $1;}
2307 | T_COMPILER_HALT_OFFSET
{ $$
= $1;}
2308 | T_TRAIT
{ $$
= $1;}
2309 | T_TRAIT_C
{ $$
= $1;}
2310 | T_INSTEADOF
{ $$
= $1;}
2311 | T_TYPE
{ $$
= $1;}
2312 | T_NEWTYPE
{ $$
= $1;}
2313 | T_SHAPE
{ $$
= $1;}
2316 simple_function_call:
2317 namespace_string_typeargs
'('
2318 function_call_parameter_list
')' { _p
->onCall
($$
,0,$1,$3,NULL
);}
2321 fully_qualified_class_name:
2322 class_namespace_string_typeargs
{ $$
= $1;}
2323 | T_XHP_LABEL
{ $1.xhpLabel
(); $$
= $1;}
2326 static_class_name_base:
2327 fully_qualified_class_name
{ _p
->onName
($$
,$1,Parser
::StringName
);}
2328 | common_scalar
{ _p
->onName
($$
,$1,Parser
::StringName
);}
2329 | T_STATIC
{ _p
->onName
($$
,$1,Parser
::StaticName
);}
2330 | reference_variable
{ _p
->onName
($$
,$1,
2331 Parser
::StaticClassExprName
);}
2332 |
'(' expr_no_variable
')' { _p
->onName
($$
,$2,
2333 Parser
::StaticClassExprName
);}
2335 static_class_name_no_calls:
2336 static_class_name_base
{ $$
= $1; }
2337 | static_class_name_no_calls
2345 { _p
->onStaticMember
($$
,$1,$3);}
2348 static_class_name_base
{ $$
= $1; }
2349 | class_method_call
{ _p
->onName
($$
,$1,
2350 Parser
::StaticClassExprName
);}
2359 { _p
->onStaticMember
($$
,$1,$3);}
2362 class_name_reference:
2363 fully_qualified_class_name
{ _p
->onName
($$
,$1,Parser
::StringName
);}
2364 | T_STATIC
{ _p
->onName
($$
,$1,Parser
::StaticName
);}
2365 | variable_no_calls
{ _p
->onName
($$
,$1,Parser
::ExprName
);}
2369 '(' ')' { $$.reset
();}
2370 | parenthesis_expr
{ $$
= $1;}
2375 /* empty */ { $$.reset
();}
2376 | T_ENCAPSED_AND_WHITESPACE
{ _p
->addEncap
($$
, NULL
, $1, 0);}
2377 | encaps_list
{ $$
= $1;}
2381 function_call_parameter_list
')' { $$
= $2;}
2386 T_LNUMBER
{ _p
->onScalar
($$
, T_LNUMBER
, $1);}
2387 | T_DNUMBER
{ _p
->onScalar
($$
, T_DNUMBER
, $1);}
2388 | T_ONUMBER
{ _p
->onScalar
($$
, T_ONUMBER
, $1);}
2389 | T_CONSTANT_ENCAPSED_STRING
{ _p
->onScalar
($$
,
2390 T_CONSTANT_ENCAPSED_STRING
, $1);}
2391 | T_LINE
{ _p
->onScalar
($$
, T_LINE
, $1);}
2392 | T_FILE
{ _p
->onScalar
($$
, T_FILE
, $1);}
2393 | T_DIR
{ _p
->onScalar
($$
, T_DIR
, $1);}
2394 | T_CLASS_C
{ _p
->onScalar
($$
, T_CLASS_C
, $1);}
2395 | T_TRAIT_C
{ _p
->onScalar
($$
, T_TRAIT_C
, $1);}
2396 | T_METHOD_C
{ _p
->onScalar
($$
, T_METHOD_C
, $1);}
2397 | T_FUNC_C
{ _p
->onScalar
($$
, T_FUNC_C
, $1);}
2398 | T_NS_C
{ _p
->onScalar
($$
, T_NS_C
, $1);}
2399 | T_COMPILER_HALT_OFFSET
{ _p
->onScalar
($$
, T_COMPILER_HALT_OFFSET
, $1);}
2401 T_ENCAPSED_AND_WHITESPACE
2402 T_END_HEREDOC
{ _p
->onScalar
($$
, T_CONSTANT_ENCAPSED_STRING
, $2);}
2404 T_END_HEREDOC
{ $$.setText
(""); _p
->onScalar
($$
, T_CONSTANT_ENCAPSED_STRING
, $$
);}
2408 common_scalar
{ $$
= $1;}
2409 | namespace_string
{ _p
->onConstantValue
($$
, $1);}
2411 static_array_pair_list
')' { _p
->onArray
($$
,$3,T_ARRAY
); }
2412 |
'[' static_array_pair_list
']' { _p
->onArray
($$
,$2,T_ARRAY
); }
2414 static_shape_pair_list
')' { _p
->onArray
($$
,$3,T_ARRAY
); }
2415 | static_class_constant
{ $$
= $1;}
2416 | static_collection_literal
{ $$
= $1;}
2417 |
'(' static_expr
')' { $$
= $2;}
2418 | static_expr T_BOOLEAN_OR
2419 static_expr
{ BEXP
($$
,$1,$3,T_BOOLEAN_OR
);}
2420 | static_expr T_BOOLEAN_AND
2421 static_expr
{ BEXP
($$
,$1,$3,T_BOOLEAN_AND
);}
2422 | static_expr T_LOGICAL_OR
2423 static_expr
{ BEXP
($$
,$1,$3,T_LOGICAL_OR
);}
2424 | static_expr T_LOGICAL_AND
2425 static_expr
{ BEXP
($$
,$1,$3,T_LOGICAL_AND
);}
2426 | static_expr T_LOGICAL_XOR
2427 static_expr
{ BEXP
($$
,$1,$3,T_LOGICAL_XOR
);}
2428 | static_expr
'|' static_expr
{ BEXP
($$
,$1,$3,'|');}
2429 | static_expr
'&' static_expr
{ BEXP
($$
,$1,$3,'&');}
2430 | static_expr
'^' static_expr
{ BEXP
($$
,$1,$3,'^');}
2431 | static_expr
'.' static_expr
{ BEXP
($$
,$1,$3,'.');}
2432 | static_expr
'+' static_expr
{ BEXP
($$
,$1,$3,'+');}
2433 | static_expr
'-' static_expr
{ BEXP
($$
,$1,$3,'-');}
2434 | static_expr
'*' static_expr
{ BEXP
($$
,$1,$3,'*');}
2435 | static_expr
'/' static_expr
{ BEXP
($$
,$1,$3,'/');}
2436 | static_expr
'%' static_expr
{ BEXP
($$
,$1,$3,'%');}
2437 | static_expr T_SL static_expr
{ BEXP
($$
,$1,$3,T_SL
);}
2438 | static_expr T_SR static_expr
{ BEXP
($$
,$1,$3,T_SR
);}
2439 | static_expr T_POW static_expr
{ BEXP
($$
,$1,$3,T_POW
);}
2440 |
'!' static_expr
{ UEXP
($$
,$2,'!',1);}
2441 |
'~' static_expr
{ UEXP
($$
,$2,'~',1);}
2442 |
'+' static_expr
{ UEXP
($$
,$2,'+',1);}
2443 |
'-' static_expr
{ UEXP
($$
,$2,'-',1);}
2444 | static_expr T_IS_IDENTICAL
2445 static_expr
{ BEXP
($$
,$1,$3,T_IS_IDENTICAL
);}
2446 | static_expr T_IS_NOT_IDENTICAL
2447 static_expr
{ BEXP
($$
,$1,$3,T_IS_NOT_IDENTICAL
);}
2448 | static_expr T_IS_EQUAL
2449 static_expr
{ BEXP
($$
,$1,$3,T_IS_EQUAL
);}
2450 | static_expr T_IS_NOT_EQUAL
2451 static_expr
{ BEXP
($$
,$1,$3,T_IS_NOT_EQUAL
);}
2452 | static_expr
'<' static_expr
{ BEXP
($$
,$1,$3,'<');}
2453 | static_expr T_IS_SMALLER_OR_EQUAL
2454 static_expr
{ BEXP
($$
,$1,$3,
2455 T_IS_SMALLER_OR_EQUAL
);}
2456 | static_expr
'>' static_expr
{ BEXP
($$
,$1,$3,'>');}
2458 T_IS_GREATER_OR_EQUAL
2459 static_expr
{ BEXP
($$
,$1,$3,
2460 T_IS_GREATER_OR_EQUAL
);}
2463 static_expr
{ BEXP
($$
,$1,$3,T_SPACESHIP
);}
2465 | static_expr
'?' static_expr
':'
2466 static_expr
{ _p
->onQOp
($$
, $1, &$3, $5);}
2467 | static_expr
'?' ':' static_expr
{ _p
->onQOp
($$
, $1, 0, $4);}
2470 static_class_constant:
2471 class_namespace_string_typeargs
2473 ident_for_class_const
{ _p
->onClassConst
($$
, $1, $3, 1);}
2474 | T_XHP_LABEL T_DOUBLE_COLON
2475 ident_for_class_const
{ $1.xhpLabel
();
2476 _p
->onClassConst
($$
, $1, $3, 1);}
2477 | class_namespace_string_typeargs
2479 T_CLASS
{ _p
->onClassClass
($$
, $1, $3, 1);}
2483 namespace_string
{ _p
->onConstantValue
($$
, $1);}
2484 | T_STRING_VARNAME
{ _p
->onConstantValue
($$
, $1);}
2485 | class_constant
{ $$
= $1;}
2486 | common_scalar
{ $$
= $1;}
2487 |
'"' encaps_list
'"' { _p
->onEncapsList
($$
,'"',$2);}
2488 |
'\'' encaps_list
'\'' { _p
->onEncapsList
($$
,'\'',$2);}
2489 | T_START_HEREDOC encaps_list
2490 T_END_HEREDOC
{ _p
->onEncapsList
($$
,T_START_HEREDOC
,
2493 static_array_pair_list:
2494 non_empty_static_array_pair_list
2495 possible_comma
{ $$
= $1;}
2504 ',' { only_in_hh_syntax
(_p
); $$.reset
();}
2508 non_empty_static_array_pair_list:
2509 non_empty_static_array_pair_list
2510 ',' static_expr T_DOUBLE_ARROW
2511 static_expr
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0);}
2512 | non_empty_static_array_pair_list
2513 ',' static_expr
{ _p
->onArrayPair
($$
,&$1, 0,$3,0);}
2514 | static_expr T_DOUBLE_ARROW
2515 static_expr
{ _p
->onArrayPair
($$
, 0,&$1,$3,0);}
2516 | static_expr
{ _p
->onArrayPair
($$
, 0, 0,$1,0);}
2520 T_LNUMBER
{ _p
->onScalar
($$
, T_LNUMBER
, $1);}
2521 | T_DNUMBER
{ _p
->onScalar
($$
, T_DNUMBER
, $1);}
2522 | T_ONUMBER
{ _p
->onScalar
($$
, T_ONUMBER
, $1);}
2524 T_ENCAPSED_AND_WHITESPACE
2525 T_END_HEREDOC
{ _p
->onScalar
($$
, T_CONSTANT_ENCAPSED_STRING
, $2);}
2527 T_END_HEREDOC
{ $$.setText
(""); _p
->onScalar
($$
, T_CONSTANT_ENCAPSED_STRING
, $$
);}
2529 static_numeric_scalar_ae:
2530 T_LNUMBER
{ _p
->onScalar
($$
,T_LNUMBER
,$1);}
2531 | T_DNUMBER
{ _p
->onScalar
($$
,T_DNUMBER
,$1);}
2532 | T_ONUMBER
{ _p
->onScalar
($$
,T_ONUMBER
,$1);}
2533 | ident_no_semireserved
{ constant_ae
(_p
,$$
,$1);}
2536 static_string_expr_ae:
2537 T_CONSTANT_ENCAPSED_STRING
{ _p
->onScalar
($$
,
2538 T_CONSTANT_ENCAPSED_STRING
,$1);}
2539 | T_CONSTANT_ENCAPSED_STRING
'.' static_string_expr_ae
2541 T_CONSTANT_ENCAPSED_STRING
,
2547 | static_string_expr_ae
{ $$
= $1;}
2548 | ident_no_semireserved
{ constant_ae
(_p
,$$
,$1);}
2549 |
'+' static_numeric_scalar_ae
{ UEXP
($$
,$2,'+',1);}
2550 |
'-' static_numeric_scalar_ae
{ UEXP
($$
,$2,'-',1);}
2552 static_array_pair_list_ae
')' { _p
->onArray
($$
,$3,T_ARRAY
);}
2553 |
'[' static_array_pair_list_ae
']' { _p
->onArray
($$
,$2,T_ARRAY
);}
2555 static_shape_pair_list_ae
')' { _p
->onArray
($$
,$3,T_ARRAY
); }
2558 static_array_pair_list_ae:
2559 non_empty_static_array_pair_list_ae
2560 possible_comma
{ $$
= $1;}
2563 non_empty_static_array_pair_list_ae:
2564 non_empty_static_array_pair_list_ae
2565 ',' static_scalar_ae T_DOUBLE_ARROW
2566 static_scalar_ae
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0);}
2567 | non_empty_static_array_pair_list_ae
2568 ',' static_scalar_ae
{ _p
->onArrayPair
($$
,&$1, 0,$3,0);}
2569 | static_scalar_ae T_DOUBLE_ARROW
2570 static_scalar_ae
{ _p
->onArrayPair
($$
, 0,&$1,$3,0);}
2571 | static_scalar_ae
{ _p
->onArrayPair
($$
, 0, 0,$1,0);}
2573 non_empty_static_scalar_list_ae:
2574 non_empty_static_scalar_list_ae
2575 ',' static_scalar_ae
{ _p
->onArrayPair
($$
,&$1, 0,$3,0);}
2576 | static_scalar_ae
{ _p
->onArrayPair
($$
, 0, 0,$1,0);}
2579 static_shape_pair_list_ae:
2580 non_empty_static_shape_pair_list_ae
2581 possible_comma
{ $$
= $1; }
2584 non_empty_static_shape_pair_list_ae:
2585 non_empty_static_shape_pair_list_ae
2587 T_DOUBLE_ARROW static_scalar_ae
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0); }
2590 static_scalar_ae
{ _p
->onArrayPair
($$
, 0,&$1,$3,0); }
2593 static_scalar_list_ae:
2594 non_empty_static_scalar_list_ae
2595 possible_comma
{ $$
= $1;}
2598 attribute_static_scalar_list:
2599 '(' static_scalar_list_ae
')' { _p
->onArray
($$
,$2,T_ARRAY
);}
2600 |
{ Token t
; t.reset
();
2601 _p
->onArray
($$
,t
,T_ARRAY
);}
2604 non_empty_user_attribute_list:
2605 non_empty_user_attribute_list
2606 ',' ident_no_semireserved
2607 attribute_static_scalar_list
{ _p
->onUserAttribute
($$
,&$1,$3,$4);}
2608 | ident_no_semireserved
2609 attribute_static_scalar_list
{ _p
->onUserAttribute
($$
, 0,$1,$2);}
2611 user_attribute_list:
2612 { only_in_hh_syntax
(_p
);}
2613 non_empty_user_attribute_list
2614 possible_comma
{ $$
= $2;}
2616 non_empty_user_attributes:
2617 T_SL user_attribute_list T_SR
{ $$
= $2;}
2619 optional_user_attributes:
2620 non_empty_user_attributes
{ $$
= $1;}
2625 T_OBJECT_OPERATOR
{ $$
= $1; $$
= 0;}
2626 | T_NULLSAFE_OBJECT_OPERATOR
{ $$
= $1; $$
= 1;}
2629 object_property_name_no_variables:
2630 ident_no_semireserved
{ $$
= $1; $$
= HPHP
::ObjPropNormal
;}
2631 | T_XHP_LABEL
{ $$
= $1; $$
= HPHP
::ObjPropXhpAttr
;}
2632 |
'{' expr
'}' { $$
= $2; $$
= HPHP
::ObjPropNormal
;}
2635 object_property_name:
2636 object_property_name_no_variables
{ $$
= $1;}
2638 | variable_no_objects
{ $$
= $1; $$
= HPHP
::ObjPropNormal
;}
2641 | compound_variable
{ $$
= $1; $$
= HPHP
::ObjPropNormal
;}
2645 object_method_name_no_variables:
2646 ident_no_semireserved
{ $$
= $1;}
2647 |
'{' expr
'}' { $$
= $2;}
2651 object_method_name_no_variables
{ $$
= $1;}
2653 | variable_no_objects
{ $$
= $1;}
2656 | compound_variable
{ $$
= $1;}
2661 '[' dim_offset
']' { $$
= $2;}
2662 |
'{' expr
'}' { $$
= $2;}
2665 dimmable_variable_access:
2666 dimmable_variable array_access
{ _p
->onRefDim
($$
, $1, $2);}
2667 |
'(' expr_with_parens
')'
2668 array_access
{ _p
->onRefDim
($$
, $2, $4);}
2671 dimmable_variable_no_calls_access:
2672 dimmable_variable_no_calls
2673 array_access
{ _p
->onRefDim
($$
, $1, $2);}
2674 |
'(' expr_with_parens
')'
2675 array_access
{ _p
->onRefDim
($$
, $2, $4);}
2678 object_property_access_on_expr:
2679 '(' expr_with_parens
')'
2681 object_property_name
{ _p
->onObjectProperty
(
2685 ? HPHP
::PropAccessType
::Normal
2686 : HPHP
::PropAccessType
::NullSafe
,
2690 |
'(' expr_no_variable
')'
2692 object_property_name
{ _p
->onObjectProperty
(
2696 ? HPHP
::PropAccessType
::Normal
2697 : HPHP
::PropAccessType
::NullSafe
,
2703 object_property_access_on_expr_no_variables:
2704 '(' expr_with_parens
')'
2706 object_property_name_no_variables
2707 { _p
->onObjectProperty
(
2711 ? HPHP
::PropAccessType
::Normal
2712 : HPHP
::PropAccessType
::NullSafe
,
2716 |
'(' expr_no_variable
')'
2718 object_property_name_no_variables
2719 { _p
->onObjectProperty
(
2723 ? HPHP
::PropAccessType
::Normal
2724 : HPHP
::PropAccessType
::NullSafe
,
2731 variable_no_objects
{ $$
= $1;}
2732 | simple_function_call
{ $$
= $1;}
2733 | object_method_call
{ $$
= $1;}
2734 | class_method_call
{ $$
= $1;}
2735 | dimmable_variable_access
{ $$
= $1;}
2736 | object_property_access_on_expr
{ $$
= $1;}
2737 | variable object_operator
2738 object_property_name
{ _p
->onObjectProperty
(
2742 ? HPHP
::PropAccessType
::Normal
2743 : HPHP
::PropAccessType
::NullSafe
,
2755 { _p
->onStaticMember
($$
,$1,$3);}
2756 | callable_variable
'('
2757 function_call_parameter_list
')' { _p
->onCall
($$
,1,$1,$3,NULL
);}
2758 | lambda_or_closure_with_parens
'('
2759 function_call_parameter_list
')' { _p
->onCall
($$
,1,$1,$3,NULL
);}
2760 |
'(' variable
')' { $$
= $2;}
2764 simple_function_call
{ $$
= $1;}
2765 | object_method_call
{ $$
= $1;}
2766 | class_method_call
{ $$
= $1;}
2767 | dimmable_variable_access
{ $$
= $1;}
2768 | variable object_operator
2770 object_property_name_no_variables
2773 object_property_name
2775 { _p
->onObjectProperty
(
2779 ? HPHP
::PropAccessType
::Normal
2780 : HPHP
::PropAccessType
::NullSafe
,
2784 | object_property_access_on_expr_no_variables
{ $$
= $1;}
2785 | callable_variable
'('
2786 function_call_parameter_list
')' { _p
->onCall
($$
,1,$1,$3,NULL
);}
2787 |
'(' variable
')' { $$
= $2;}
2791 compound_variable
{ _p
->onStaticMember
($$
,$1,$3);}
2796 variable_no_objects
{ $$
= $1;}
2797 | dimmable_variable_access
{ $$
= $1;}
2798 | simple_function_call
{ $$
= $1;}
2799 | array_literal
{ $$
= $1;}
2800 | common_scalar
{ $$
= $1;}
2801 |
'(' variable
')' { $$
= $2;}
2802 |
'(' expr_no_variable
')' { $$
= $2;}
2803 | lambda_or_closure_with_parens
'('
2804 function_call_parameter_list
')' { _p
->onCall
($$
,1,$1,$3,NULL
);}
2805 | callable_variable
'('
2806 function_call_parameter_list
')' { _p
->onCall
($$
,1,$1,$3,NULL
);}
2809 lambda_or_closure_with_parens:
2810 '(' lambda_or_closure
')' { $$
= $2;}
2814 closure_expression
{ $$
= $1;}
2815 | lambda_expression
{ $$
= $1;}
2819 variable object_operator
2820 object_method_name hh_typeargs_opt
'('
2821 function_call_parameter_list
')' { _p
->onObjectMethodCall
($$
,$1,$2.num
(),$3,$6);}
2822 |
'(' expr_with_parens
')'
2824 object_method_name hh_typeargs_opt
'('
2825 function_call_parameter_list
')' { _p
->onObjectMethodCall
($$
,$2,$4.num
(),$5,$8);}
2831 ident hh_typeargs_opt
'('
2832 function_call_parameter_list
')' { _p
->onCall
($$
,0,$3,$6,&$1);}
2836 variable_no_objects
'('
2839 compound_variable
'('
2841 function_call_parameter_list
')' { _p
->onCall
($$
,1,$3,$5,&$1);}
2845 function_call_parameter_list
')' { _p
->onCall
($$
,1,$4,$7,&$1);}
2848 variable_no_objects:
2849 reference_variable
{ $$
= $1;}
2851 | simple_indirect_reference
2852 reference_variable
{ _p
->onIndirectRef
($$
,$1,$2);}
2858 '[' dim_offset
']' { _p
->onRefDim
($$
, $1, $3);}
2859 | reference_variable
'{' expr
'}' { _p
->onRefDim
($$
, $1, $3);}
2860 | compound_variable
{ $$
= $1;}
2864 T_VARIABLE
{ _p
->onSimpleVariable
($$
, $1);}
2865 |
'$' '{' expr
'}' { _p
->onDynamicVariable
($$
, $3, 0);}
2867 |
'$' compound_variable
{ $1 = 1; _p
->onIndirectRef
($$
, $1, $2);}
2877 simple_indirect_reference:
2879 | simple_indirect_reference
'$' { $$
++;}
2884 variable_no_objects
{ $$
= $1;}
2885 | dimmable_variable_no_calls_access
{ $$
= $1;}
2886 | object_property_access_on_expr
{ $$
= $1;}
2889 object_property_name
{ _p
->onObjectProperty
(
2893 ? HPHP
::PropAccessType
::Normal
2894 : HPHP
::PropAccessType
::NullSafe
,
2898 | static_class_name_no_calls
2900 variable_no_objects
{ _p
->onStaticMember
($$
,$1,$3);}
2901 |
'(' variable
')' { $$
= $2;}
2904 dimmable_variable_no_calls:
2905 | dimmable_variable_no_calls_access
{ $$
= $1;}
2906 | object_property_access_on_expr_no_variables
{ $$
= $1;}
2907 | variable_no_calls object_operator
2908 object_property_name_no_variables
2909 { _p
->onObjectProperty
(
2913 ? HPHP
::PropAccessType
::Normal
2914 : HPHP
::PropAccessType
::NullSafe
,
2918 |
'(' variable
')' { $$
= $2;}
2922 assignment_list
',' { _p
->onAListVar
($$
,&$1,NULL
);}
2923 | assignment_list
',' variable
{ _p
->onAListVar
($$
,&$1,&$3);}
2924 | assignment_list
','
2925 T_LIST
'(' assignment_list
')' { _p
->onAListSub
($$
,&$1,$5);}
2926 |
{ _p
->onAListVar
($$
,NULL
,NULL
);}
2927 | variable
{ _p
->onAListVar
($$
,NULL
,&$1);}
2928 | T_LIST
'(' assignment_list
')' { _p
->onAListSub
($$
,NULL
,$3);}
2932 non_empty_array_pair_list
2933 possible_comma
{ $$
= $1;}
2936 non_empty_array_pair_list:
2937 non_empty_array_pair_list
2938 ',' expr T_DOUBLE_ARROW expr
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0);}
2939 | non_empty_array_pair_list
',' expr
{ _p
->onArrayPair
($$
,&$1, 0,$3,0);}
2940 | expr T_DOUBLE_ARROW expr
{ _p
->onArrayPair
($$
, 0,&$1,$3,0);}
2941 | expr
{ _p
->onArrayPair
($$
, 0, 0,$1,0);}
2942 | non_empty_array_pair_list
2943 ',' expr T_DOUBLE_ARROW
2944 '&' variable
{ _p
->onArrayPair
($$
,&$1,&$3,$6,1);}
2945 | non_empty_array_pair_list
','
2946 '&' variable
{ _p
->onArrayPair
($$
,&$1, 0,$4,1);}
2947 | expr T_DOUBLE_ARROW
'&' variable
{ _p
->onArrayPair
($$
, 0,&$1,$4,1);}
2948 |
'&' variable
{ _p
->onArrayPair
($$
, 0, 0,$2,1);}
2952 non_empty_collection_init
2953 possible_comma
{ $$
= $1;}
2954 |
{ _p
->onEmptyCollection
($$
);}
2956 non_empty_collection_init:
2957 non_empty_collection_init
2958 ',' expr T_DOUBLE_ARROW expr
{ _p
->onCollectionPair
($$
,&$1,&$3,$5);}
2959 | non_empty_collection_init
',' expr
{ _p
->onCollectionPair
($$
,&$1, 0,$3);}
2960 | expr T_DOUBLE_ARROW expr
{ _p
->onCollectionPair
($$
, 0,&$1,$3);}
2961 | expr
{ _p
->onCollectionPair
($$
, 0, 0,$1);}
2964 static_collection_init:
2965 non_empty_static_collection_init
2966 possible_comma
{ $$
= $1;}
2967 |
{ _p
->onEmptyCollection
($$
);}
2969 non_empty_static_collection_init:
2970 non_empty_static_collection_init
2971 ',' static_expr T_DOUBLE_ARROW
2972 static_expr
{ _p
->onCollectionPair
($$
,&$1,&$3,$5);}
2973 | non_empty_static_collection_init
2974 ',' static_expr
{ _p
->onCollectionPair
($$
,&$1, 0,$3);}
2975 | static_expr T_DOUBLE_ARROW
2976 static_expr
{ _p
->onCollectionPair
($$
, 0,&$1,$3);}
2977 | static_expr
{ _p
->onCollectionPair
($$
, 0, 0,$1);}
2981 encaps_list encaps_var
{ _p
->addEncap
($$
, &$1, $2, -1);}
2983 T_ENCAPSED_AND_WHITESPACE
{ _p
->addEncap
($$
, &$1, $2, 0);}
2984 | encaps_var
{ _p
->addEncap
($$
, NULL
, $1, -1);}
2985 | T_ENCAPSED_AND_WHITESPACE
2986 encaps_var
{ _p
->addEncap
($$
, NULL
, $1, 0);
2987 _p
->addEncap
($$
, &$$
, $2, -1); }
2991 T_VARIABLE
{ _p
->onSimpleVariable
($$
, $1);}
2993 encaps_var_offset
']' { _p
->encapRefDim
($$
, $1, $3);}
2994 | T_VARIABLE object_operator
2995 ident_no_semireserved
{ _p
->encapObjProp
(
2999 ? HPHP
::PropAccessType
::Normal
3000 : HPHP
::PropAccessType
::NullSafe
,
3004 | T_DOLLAR_OPEN_CURLY_BRACES
3005 expr
'}' { _p
->onDynamicVariable
($$
, $2, 1);}
3006 | T_DOLLAR_OPEN_CURLY_BRACES
3007 T_STRING_VARNAME
'[' expr
']' '}' { _p
->encapArray
($$
, $2, $4);}
3008 | T_CURLY_OPEN variable
'}' { $$
= $2;}
3011 ident_no_semireserved
{ $$
= $1; $$
= T_STRING
;}
3012 | T_NUM_STRING
{ $$
= $1; $$
= T_NUM_STRING
;}
3013 | T_VARIABLE
{ $$
= $1; $$
= T_VARIABLE
;}
3017 T_ISSET
'(' expr_list
')' { UEXP
($$
,$3,T_ISSET
,1);}
3018 | T_EMPTY
'(' variable
')' { UEXP
($$
,$3,T_EMPTY
,1);}
3019 | T_EMPTY
'(' expr_no_variable
')' { UEXP
($$
,$3,'!',1);}
3020 | T_EMPTY
'(' lambda_or_closure
')' { UEXP
($$
,$3,'!',1);}
3021 | T_EMPTY
'(' lambda_or_closure_with_parens
')' { UEXP
($$
,$3,'!',1);}
3022 | T_EMPTY
'(' expr_with_parens
')' { UEXP
($$
,$3,'!',1);}
3023 | T_INCLUDE expr
{ UEXP
($$
,$2,T_INCLUDE
,1);}
3024 | T_INCLUDE_ONCE expr
{ UEXP
($$
,$2,T_INCLUDE_ONCE
,1);}
3025 | T_EVAL
'(' expr
')' { UEXP
($$
,$3,T_EVAL
,1);}
3026 | T_REQUIRE expr
{ UEXP
($$
,$2,T_REQUIRE
,1);}
3027 | T_REQUIRE_ONCE expr
{ UEXP
($$
,$2,T_REQUIRE_ONCE
,1);}
3031 variable
{ _p
->onExprListElem
($$
, NULL
, $1);}
3032 | variable_list
',' variable
{ _p
->onExprListElem
($$
, &$1, $3);}
3037 T_DOUBLE_COLON ident_for_class_const
{ _p
->onClassConst
($$
, $1, $3, 0);}
3039 T_DOUBLE_COLON T_CLASS
{ _p
->onClassClass
($$
, $1, $3, 0);}
3042 /* hack productions -- these allow some extra stuff in hack
3043 * mode, but simplify down to the original thing
3051 hh_type_alias_statement:
3052 T_TYPE hh_name_no_semireserved_with_typevar
3053 '=' hh_type
';' { $2.setText
(_p
->nsClassDecl
($2.text
()));
3054 _p
->onTypedef
($$
, $2, $4);
3055 _p
->popTypeScope
(); }
3056 | non_empty_user_attributes
3057 T_TYPE hh_name_no_semireserved_with_typevar
3058 '=' hh_type
';' { $3.setText
(_p
->nsClassDecl
($3.text
()));
3059 _p
->onTypedef
($$
, $3, $5, &$1);
3060 _p
->popTypeScope
(); }
3061 | T_NEWTYPE hh_name_no_semireserved_with_typevar
3062 hh_opt_constraint
'=' hh_type
';' { $2.setText
(_p
->nsClassDecl
($2.text
()));
3063 _p
->onTypedef
($$
, $2, $5);
3064 _p
->popTypeScope
(); }
3065 | non_empty_user_attributes
3066 T_NEWTYPE hh_name_no_semireserved_with_typevar
3067 hh_opt_constraint
'=' hh_type
';' { $3.setText
(_p
->nsClassDecl
($3.text
()));
3068 _p
->onTypedef
($$
, $3, $6, &$1);
3069 _p
->popTypeScope
(); }
3072 hh_name_with_type: /* foo -> int foo */
3074 | hh_type ident
{ only_in_hh_syntax
(_p
); $$
= $2; }
3077 hh_constname_with_type: /* foo -> int foo, but in class constants */
3078 ident_for_class_const
{ $$
= $1; }
3079 | hh_type ident_for_class_const
{ only_in_hh_syntax
(_p
); $$
= $2; }
3082 hh_name_with_typevar: /* foo -> foo<X,Y>; this adds a typevar
3083 * scope and must be followed by a call to
3085 ident
{ _p
->pushTypeScope
(); $$
= $1; }
3089 T_TYPELIST_GT
{ _p
->pushTypeScope
(); $$
= $1; }
3092 hh_name_no_semireserved_with_typevar: /* foo -> foo<X,Y>; this adds a typevar
3093 * scope and must be followed by a call
3094 * to popTypeScope() */
3095 ident_no_semireserved
{ _p
->pushTypeScope
(); $$
= $1; }
3096 | ident_no_semireserved
3099 T_TYPELIST_GT
{ Token t
; _p
->setTypeVars
(t
, $1);
3100 _p
->pushTypeScope
(); $$
= t
; }
3106 T_TYPELIST_GT
{ $$
= $2; }
3110 hh_non_empty_type_list:
3111 hh_type
{ Token t
; t.reset
();
3112 _p
->onTypeList
($1, t
);
3114 | hh_non_empty_type_list
',' hh_type
{ _p
->onTypeList
($1, $3);
3119 hh_non_empty_type_list
3120 possible_comma
{ $$
= $1; }
3124 hh_non_empty_type_list
3125 ',' T_ELLIPSIS
{ $$
= $1; }
3126 | hh_type_list
{ $$
= $1; }
3127 | T_ELLIPSIS
{ $$.reset
(); }
3133 |
':' hh_type
{ only_in_hh_syntax
(_p
); $$
= $2; }
3143 ident_no_semireserved
{ _p
->addTypeVar
($4.text
()); }
3144 | hh_typevar_variance
3145 ident_no_semireserved
{ _p
->addTypeVar
($2.text
()); }
3146 | hh_typevar_list
','
3148 ident_no_semireserved
3149 hh_constraint
{ _p
->addTypeVar
($4.text
()); }
3150 | hh_typevar_variance
3151 ident_no_semireserved
3152 hh_constraint
{ _p
->addTypeVar
($2.text
()); }
3155 hh_typevar_variance:
3161 hh_shape_member_type:
3162 T_CONSTANT_ENCAPSED_STRING
3164 hh_type
{ validate_shape_keyname
($1, _p
);
3165 _p
->onTypeAnnotation
($$
, $1, $3); }
3167 T_CONSTANT_ENCAPSED_STRING
3170 /* should not reach here as
3171 * optional shape fields are not
3172 * supported in strict mode */
3173 validate_shape_keyname
($2, _p
);
3174 _p
->onTypeAnnotation
($$
, $2, $4);
3176 | class_namespace_string_typeargs
3178 ident_no_semireserved
3180 hh_type
{ _p
->onClsCnsShapeField
($$
, $1, $3, $5); }
3183 hh_non_empty_shape_member_list:
3184 hh_non_empty_shape_member_list
','
3185 hh_shape_member_type
{ _p
->onTypeList
($$
, $3); }
3186 | hh_shape_member_type
{ }
3189 hh_shape_member_list:
3190 hh_non_empty_shape_member_list
3191 possible_comma
{ _p
->onShape
($$
, $1); }
3192 |
/* empty */ { Token t
; t.reset
();
3193 _p
->onShape
($$
, t
); }
3198 '(' hh_shape_member_list
')' { $$
= $3;
3199 $$.setText
("array"); }
3202 hh_access_type_start:
3203 class_namespace_string_typeargs
{ $$
= $1; }
3206 ident_no_semireserved
3208 hh_access_type
{ Token t
; t.reset
();
3209 _p
->onTypeAnnotation
($$
, $1, t
);
3210 _p
->onTypeList
($$
, $3); }
3211 | ident_no_semireserved
3212 hh_typeargs_opt
{ _p
->onTypeAnnotation
($$
, $1, $2); }
3215 /* extends non_empty_type_decl with some more types */
3217 /* double-optional types will be rejected by the typechecker; we
3218 * already allow plenty of nonsense types anyway */
3219 '?' hh_type
{ only_in_hh_syntax
(_p
);
3220 _p
->onTypeSpecialization
($2, '?');
3222 |
'@' hh_type
{ only_in_hh_syntax
(_p
);
3223 _p
->onTypeSpecialization
($2, '@');
3225 | class_namespace_string_typeargs
{ $$
= $1; }
3226 | T_ARRAY
{ Token t
; t.reset
();
3227 $1.setText
("array");
3228 _p
->onTypeAnnotation
($$
, $1, t
); }
3229 | T_CALLABLE
{ Token t
; t.reset
();
3230 $1.setText
("callable");
3231 _p
->onTypeAnnotation
($$
, $1, t
); }
3232 | hh_shape_type
{ $$
= $1; }
3233 | hh_access_type_start
3235 hh_access_type
{ only_in_hh_syntax
(_p
);
3236 _p
->onTypeAnnotation
($$
, $1, $3);
3237 _p
->onTypeSpecialization
($$
, 'a'); }
3238 | T_ARRAY T_TYPELIST_LT hh_type
3239 T_TYPELIST_GT
{ $1.setText
("array");
3240 _p
->onTypeAnnotation
($$
, $1, $3); }
3241 | T_ARRAY T_TYPELIST_LT hh_type
','
3242 hh_type T_TYPELIST_GT
{ _p
->onTypeList
($3, $5);
3243 $1.setText
("array");
3244 _p
->onTypeAnnotation
($$
, $1, $3); }
3245 | T_XHP_LABEL
{ $1.xhpLabel
();
3247 _p
->onTypeAnnotation
($$
, $1, t
);
3248 _p
->onTypeSpecialization
($$
, 'x'); }
3250 '(' hh_func_type_list
')'
3251 ':' hh_type
')' { only_in_hh_syntax
(_p
);
3252 _p
->onTypeList
($7, $4);
3253 _p
->onTypeAnnotation
($$
, $2, $7);
3254 _p
->onTypeSpecialization
($$
, 'f'); }
3256 hh_non_empty_type_list
3257 possible_comma
')' { only_in_hh_syntax
(_p
);
3258 _p
->onTypeList
($2, $4);
3259 Token t
; t.reset
(); t.setText
("array");
3260 _p
->onTypeAnnotation
($$
, t
, $2);
3261 _p
->onTypeSpecialization
($$
, 't'); }
3265 hh_type
{ $$
= $1; }
3271 bool Parser
::parseImpl5
() {
3274 bool Parser
::parseImpl7
() {
3276 return
yyparse(this
) == 0;