3 /* By default this grammar is set up to be used by HPHP's compile parser.
4 * However, it can be used to make parsers for different purposes by
5 * making a Parser implementation with the same interface as
6 * HPHP::Compiler::Parser in a header file specified by
7 * PARSER_DEFINITIONS_HEADER, and specifying an alternate namespace with
12 #define YYSTYPE HPHP::HPHP_PARSER_NS::Token
13 #define YYSTYPE_IS_TRIVIAL false
14 #define YYLTYPE HPHP::Location
15 #define YYLTYPE_IS_TRIVIAL true
16 #define YYERROR_VERBOSE
17 #define YYINITDEPTH 500
18 #define YYLEX_PARAM _p
20 #ifdef PARSER_DEFINITIONS_HEADER
21 #include PARSER_DEFINITIONS_HEADER
23 #include "hphp/compiler/parser/parser.h"
26 #include <folly/Conv.h>
27 #include <folly/String.h>
29 #include "hphp/util/logger.h"
39 #define yyerror(loc,p,msg) p->parseFatal(loc,msg)
42 # undef YYLLOC_DEFAULT
44 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
45 #define YYLLOC_DEFAULT(Current, Rhs, N) \
48 (Current
).first
(YYRHSLOC
(Rhs
, 1)); \
49 (Current
).last
(YYRHSLOC
(Rhs
, N
)); \
51 (Current
).line0
= (Current
).line1
= YYRHSLOC
(Rhs
, 0).line1
;\
52 (Current
).char0
= (Current
).char1
= YYRHSLOC
(Rhs
, 0).char1
;\
55 _p
->setRuleLocation
(&Current
);
57 #define YYCOPY(To, From, Count) \
60 for
(yyi
= 0; yyi
< (Count
); yyi
++) { \
61 (To
)[yyi
] = (From
)[yyi
]; \
63 if
(From
!= From
## a) { \
64 YYSTACK_FREE
(From
); \
69 #define YYCOPY_RESET(To, From, Count) \
73 for
(yyi
= 0; yyi
< (Count
); yyi
++) { \
74 (To
)[yyi
] = (From
)[yyi
]; \
75 (From
)[yyi
].reset
(); \
77 if
(From
!= From
## a) { \
78 YYSTACK_FREE
(From
); \
83 #define YYTOKEN_RESET(From, Count) \
87 for
(yyi
= 0; yyi
< (Count
); yyi
++) { \
88 (From
)[yyi
].reset
(); \
90 if
(From
!= From
## a) { \
91 YYSTACK_FREE
(From
); \
96 # define YYSTACK_RELOCATE_RESET(Stack_alloc, Stack) \
99 YYSIZE_T yynewbytes
; \
100 YYCOPY_RESET
(&yyptr
->Stack_alloc
, Stack
, yysize
); \
101 Stack
= &yyptr
->Stack_alloc
; \
102 yynewbytes
= yystacksize
* sizeof
(*Stack
) + YYSTACK_GAP_MAXIMUM
; \
103 yyptr
+= yynewbytes
/ sizeof
(*yyptr
); \
107 #define YYSTACK_CLEANUP \
108 YYTOKEN_RESET
(yyvs
, yystacksize
); \
109 if
(yyvs
!= yyvsa
) { \
110 YYSTACK_FREE
(yyvs
); \
112 if
(yyls
!= yylsa
) { \
113 YYSTACK_FREE
(yyls
); \
118 #define BEXP(...) _p->onBinaryOpExp(__VA_ARGS__);
119 #define UEXP(...) _p->onUnaryOpExp(__VA_ARGS__);
121 using namespace HPHP
::HPHP_PARSER_NS
;
123 typedef HPHP
::ClosureType ClosureType
;
125 ///////////////////////////////////////////////////////////////////////////////
128 static void scalar_num
(Parser
*_p
, Token
&out
, const char *num
) {
131 _p
->onScalar
(out
, T_LNUMBER
, t
);
134 static void scalar_num
(Parser
*_p
, Token
&out
, int num
) {
136 t.setText
(folly
::to
<std
::string>(num
));
137 _p
->onScalar
(out
, T_LNUMBER
, t
);
140 static void scalar_null
(Parser
*_p
, Token
&out
) {
141 Token tnull
; tnull.setText
("null");
142 _p
->onConstantValue
(out
, tnull
);
145 static void scalar_file
(Parser
*_p
, Token
&out
) {
146 Token file
; file.setText
("__FILE__");
147 _p
->onScalar
(out
, T_FILE
, file
);
150 static void scalar_line
(Parser
*_p
, Token
&out
) {
151 Token line
; line.setText
("__LINE__");
152 _p
->onScalar
(out
, T_LINE
, line
);
155 ///////////////////////////////////////////////////////////////////////////////
157 static void constant_ae
(Parser
*_p
, Token
&out
, Token
&value
) {
158 const std
::string& valueStr
= value.text
();
159 if
(valueStr.size
() < 3 || valueStr.size
() > 5 ||
160 (strcasecmp
("true", valueStr.c_str
()) != 0 &&
161 strcasecmp
("false", valueStr.c_str
()) != 0 &&
162 strcasecmp
("null", valueStr.c_str
()) != 0 &&
163 strcasecmp
("inf", valueStr.c_str
()) != 0 &&
164 strcasecmp
("nan", valueStr.c_str
()) != 0)) {
165 HPHP_PARSER_ERROR
("User-defined constants are not allowed in user "
166 "attribute expressions", _p
);
168 _p
->onConstantValue
(out
, value
);
171 ///////////////////////////////////////////////////////////////////////////////
174 * XHP functions: They are defined here, so different parsers don't have to
175 * handle XHP rules at all.
178 static void xhp_tag
(Parser
*_p
, Token
&out
, Token
&label
, Token
&body
) {
179 if
(!body.text
().empty
() && body.text
() != label.text
()) {
180 HPHP_PARSER_ERROR
("XHP: mismatched tag: '%s' not the same as '%s'",
181 _p
, body.text
().c_str
(), label.text
().c_str
());
185 Token name
; _p
->onName
(name
, label
, Parser
::StringName
);
186 _p
->onNewObject
(out
, name
, body
);
189 static void xhp_attribute
(Parser
*_p
, Token
&out
, Token
&type
, Token
&label
,
190 Token
&def
, Token
&req
) {
192 * The bool, int, float, and string typenames are not given any special
193 * treatment by the parser and are treated the same as regular class names
194 * (which initially gets marked as type code 5). However, XHP wants to use
195 * different type codes for bool, int, float, and string, so we need to fix
196 * up the type code here to make XHP happy.
198 if
(type.num
() == 5) {
199 auto
* str
= type.text
().c_str
();
200 if
(_p
->scanner
().isHHSyntaxEnabled
()) {
201 switch
(type.text
().size
()) {
203 if
(!strcasecmp
(str
, "HH\\int")) {
204 type.reset
(); type.setNum
(3);
208 if
(!strcasecmp
(str
, "HH\\bool")) {
209 type.reset
(); type.setNum
(2);
213 if
(!strcasecmp
(str
, "HH\\float")) {
214 type.reset
(); type.setNum
(8);
215 } else if
(!strcasecmp
(str
, "HH\\mixed")) {
216 type.reset
(); type.setNum
(6);
220 if
(!strcasecmp
(str
, "HH\\string")) {
221 type.reset
(); type.setNum
(1);
228 switch
(type.text
().size
()) {
230 if
(!strcasecmp
(str
, "int")) {
231 type.reset
(); type.setNum
(3);
235 if
(!strcasecmp
(str
, "bool")) {
236 type.reset
(); type.setNum
(2);
237 } else if
(!strcasecmp
(str
, "real")) {
238 type.reset
(); type.setNum
(8);
242 if
(!strcasecmp
(str
, "float")) {
243 type.reset
(); type.setNum
(8);
244 } else if
(!strcasecmp
(str
, "mixed")) {
245 type.reset
(); type.setNum
(6);
249 if
(!strcasecmp
(str
, "string")) {
250 type.reset
(); type.setNum
(1);
251 } else if
(!strcasecmp
(str
, "double")) {
252 type.reset
(); type.setNum
(8);
256 if
(!strcasecmp
(str
, "integer")) {
257 type.reset
(); type.setNum
(3);
258 } else if
(!strcasecmp
(str
, "boolean")) {
259 type.reset
(); type.setNum
(2);
268 Token num
; scalar_num
(_p
, num
, type.num
());
269 Token arr1
; _p
->onArrayPair
(arr1
, 0, 0, num
, 0);
272 switch
(type.num
()) {
273 case
5: /* class */ {
274 Token cls
; _p
->onScalar
(cls
, T_CONSTANT_ENCAPSED_STRING
, type
);
275 _p
->onArrayPair
(arr2
, &arr1
, 0, cls
, 0);
279 Token arr
; _p
->onArray
(arr
, type
);
280 _p
->onArrayPair
(arr2
, &arr1
, 0, arr
, 0);
284 Token tnull
; scalar_null
(_p
, tnull
);
285 _p
->onArrayPair
(arr2
, &arr1
, 0, tnull
, 0);
290 Token arr3
; _p
->onArrayPair
(arr3
, &arr2
, 0, def
, 0);
291 Token arr4
; _p
->onArrayPair
(arr4
, &arr3
, 0, req
, 0);
292 _p
->onArray
(out
, arr4
);
296 static void xhp_attribute_list
(Parser
*_p
, Token
&out
, Token
*list
,
298 if
(decl.num
() == 0) {
302 out.setText
(list
->text
() + ":" + decl.text
()); // avoiding vector<string>
307 Token name
; _p
->onScalar
(name
, T_CONSTANT_ENCAPSED_STRING
, decl
);
308 _p
->onArrayPair
(out
, list
, &name
, decl
, 0);
310 out.setText
(list
->text
());
317 static void xhp_attribute_stmt
(Parser
*_p
, Token
&out
, Token
&attributes
) {
319 Token fname
; fname.setText
("__xhpAttributeDeclaration");
322 Token m1
; m1.setNum
(T_PROTECTED
); _p
->onMemberModifier
(m
, NULL
, m1
);
323 Token m2
; m2.setNum
(T_STATIC
); _p
->onMemberModifier
(modifiers
, &m
, m2
);
325 _p
->pushFuncLocation
();
326 _p
->onMethodStart
(fname
, modifiers
);
328 std
::vector
<std
::string> classes
;
329 folly
::split
(':', attributes.text
(), classes
, true
);
330 Token arrAttributes
; _p
->onArray
(arrAttributes
, attributes
);
336 _p
->onStatementListStart
(stmts0
);
341 Token one
; scalar_num
(_p
, one
, "1");
342 Token mone
; UEXP
(mone
, one
, '-', 1);
343 Token var
; var.set
(T_VARIABLE
, "_");
344 Token decl
; _p
->onStaticVariable
(decl
, 0, var
, &mone
);
345 Token sdecl
; _p
->onStatic
(sdecl
, decl
);
346 _p
->addStatement
(stmts1
, stmts0
, sdecl
);
351 // $_ = array_merge(parent::__xhpAttributeDeclaration(),
354 Token parent
; parent.set
(T_STRING
, "parent");
355 Token cls
; _p
->onName
(cls
, parent
, Parser
::StringName
);
356 Token fname
; fname.setText
("__xhpAttributeDeclaration");
357 Token param1
; _p
->onCall
(param1
, 0, fname
, dummy
, &cls
);
358 Token params1
; _p
->onCallParam
(params1
, NULL
, param1
, false
, false
);
360 for
(unsigned int i
= 0; i
< classes.size
(); i
++) {
361 Token parent
; parent.set
(T_STRING
, classes
[i
]);
362 Token cls
; _p
->onName
(cls
, parent
, Parser
::StringName
);
363 Token fname
; fname.setText
("__xhpAttributeDeclaration");
364 Token param
; _p
->onCall
(param
, 0, fname
, dummy
, &cls
);
366 Token params
; _p
->onCallParam
(params
, ¶ms1
, param
, false
, false
);
370 Token params2
; _p
->onCallParam
(params2
, ¶ms1
, arrAttributes
,
373 Token name
; name.set
(T_STRING
, "array_merge");
374 Token call
; _p
->onCall
(call
, 0, name
, params2
, NULL
);
375 Token tvar
; tvar.set
(T_VARIABLE
, "_");
376 Token var
; _p
->onSimpleVariable
(var
, tvar
);
377 Token assign
; _p
->onAssign
(assign
, var
, call
, 0);
378 Token exp
; _p
->onExpStatement
(exp
, assign
);
379 Token block
; _p
->onBlock
(block
, exp
);
381 Token tvar2
; tvar2.set
(T_VARIABLE
, "_");
382 Token var2
; _p
->onSimpleVariable
(var2
, tvar2
);
383 Token one
; scalar_num
(_p
, one
, "1");
384 Token mone
; UEXP
(mone
, one
, '-', 1);
385 Token cond
; BEXP
(cond
, var2
, mone
, T_IS_IDENTICAL
);
386 Token dummy1
, dummy2
;
387 Token sif
; _p
->onIf
(sif
, cond
, block
, dummy1
, dummy2
);
388 _p
->addStatement
(stmts2
, stmts1
, sif
);
393 Token tvar
; tvar.set
(T_VARIABLE
, "_");
394 Token var
; _p
->onSimpleVariable
(var
, tvar
);
395 Token ret
; _p
->onReturn
(ret
, &var
);
396 _p
->addStatement
(stmts3
, stmts2
, ret
);
400 _p
->finishStatement
(stmt
, stmts3
);
404 Token params
, ret
, ref
; ref
= 0;
405 _p
->onMethod
(out
, modifiers
, ret
, ref
, fname
, params
, stmt
, nullptr
, false
);
409 static void xhp_collect_attributes
(Parser
*_p
, Token
&out
, Token
&stmts
) {
410 Token
*attr
= _p
->xhpGetAttributes
();
413 xhp_attribute_stmt
(_p
, stmt
, *attr
);
414 _p
->onClassStatement
(out
, stmts
, stmt
);
420 static void xhp_category_stmt
(Parser
*_p
, Token
&out
, Token
&categories
) {
421 Token fname
; fname.setText
("__xhpCategoryDeclaration");
422 Token m1
; m1.setNum
(T_PROTECTED
);
423 Token modifiers
; _p
->onMemberModifier
(modifiers
, 0, m1
);
424 _p
->pushFuncLocation
();
425 _p
->onMethodStart
(fname
, modifiers
);
429 _p
->onStatementListStart
(stmts0
);
433 // static $_ = categories;
434 Token arr
; _p
->onArray
(arr
, categories
);
435 Token var
; var.set
(T_VARIABLE
, "_");
436 Token decl
; _p
->onStaticVariable
(decl
, 0, var
, &arr
);
437 Token sdecl
; _p
->onStatic
(sdecl
, decl
);
438 _p
->addStatement
(stmts1
, stmts0
, sdecl
);
443 Token tvar
; tvar.set
(T_VARIABLE
, "_");
444 Token var
; _p
->onSimpleVariable
(var
, tvar
);
445 Token ret
; _p
->onReturn
(ret
, &var
);
446 _p
->addStatement
(stmts2
, stmts1
, ret
);
450 _p
->finishStatement
(stmt
, stmts2
);
454 Token params
, ret
, ref
; ref
= 0;
455 _p
->onMethod
(out
, modifiers
, ret
, ref
, fname
, params
, stmt
, nullptr
, false
);
459 static void xhp_children_decl_tag
(Parser
*_p
, Token
&arr
, Token
&tag
) {
460 Token num
; scalar_num
(_p
, num
, tag.num
());
461 Token arr1
; _p
->onArrayPair
(arr1
, &arr
, 0, num
, 0);
464 if
(tag.num
() == 3 || tag.num
() == 4) {
465 _p
->onScalar
(name
, T_CONSTANT_ENCAPSED_STRING
, tag
);
466 } else if
(tag.num
() >= 0) {
467 scalar_null
(_p
, name
);
469 HPHP_PARSER_ERROR
("XHP: unknown children declaration", _p
);
471 Token arr2
; _p
->onArrayPair
(arr2
, &arr1
, 0, name
, 0);
475 static void xhp_children_decl
(Parser
*_p
, Token
&out
, Token
&op1
, int op
,
477 Token num
; scalar_num
(_p
, num
, op
);
478 Token arr
; _p
->onArrayPair
(arr
, 0, 0, num
, 0);
481 Token arr1
; _p
->onArrayPair
(arr1
, &arr
, 0, op1
, 0);
482 Token arr2
; _p
->onArrayPair
(arr2
, &arr1
, 0, *op2
, 0);
483 _p
->onArray
(out
, arr2
);
485 xhp_children_decl_tag
(_p
, arr
, op1
);
486 _p
->onArray
(out
, arr
);
490 static void xhp_children_paren
(Parser
*_p
, Token
&out
, Token exp
, int op
) {
491 Token num
; scalar_num
(_p
, num
, op
);
492 Token arr1
; _p
->onArrayPair
(arr1
, 0, 0, num
, 0);
494 Token num5
; scalar_num
(_p
, num5
, 5);
495 Token arr2
; _p
->onArrayPair
(arr2
, &arr1
, 0, num5
, 0);
497 Token arr3
; _p
->onArrayPair
(arr3
, &arr2
, 0, exp
, 0);
498 _p
->onArray
(out
, arr3
);
501 static void xhp_children_stmt
(Parser
*_p
, Token
&out
, Token
&children
) {
502 Token fname
; fname.setText
("__xhpChildrenDeclaration");
503 Token m1
; m1.setNum
(T_PROTECTED
);
504 Token modifiers
; _p
->onMemberModifier
(modifiers
, 0, m1
);
505 _p
->pushFuncLocation
();
506 _p
->onMethodStart
(fname
, modifiers
);
510 _p
->onStatementListStart
(stmts0
);
514 // static $_ = children;
516 if
(children.num
() == 2) {
518 } else if
(children.num
() >= 0) {
519 scalar_num
(_p
, arr
, children.num
());
521 HPHP_PARSER_ERROR
("XHP: XHP unknown children declaration", _p
);
523 Token var
; var.set
(T_VARIABLE
, "_");
524 Token decl
; _p
->onStaticVariable
(decl
, 0, var
, &arr
);
525 Token sdecl
; _p
->onStatic
(sdecl
, decl
);
526 _p
->addStatement
(stmts1
, stmts0
, sdecl
);
531 Token tvar
; tvar.set
(T_VARIABLE
, "_");
532 Token var
; _p
->onSimpleVariable
(var
, tvar
);
533 Token ret
; _p
->onReturn
(ret
, &var
);
534 _p
->addStatement
(stmts2
, stmts1
, ret
);
538 _p
->finishStatement
(stmt
, stmts2
);
542 Token params
, ret
, ref
; ref
= 0;
543 _p
->onMethod
(out
, modifiers
, ret
, ref
, fname
, params
, stmt
, nullptr
, false
);
547 static void only_in_hh_syntax
(Parser
*_p
) {
548 if
(!_p
->scanner
().isHHSyntaxEnabled
()) {
550 "Syntax only allowed in Hack files (<?hh) or with -v "
551 "Eval.EnableHipHopSyntax=true",
556 static void validate_hh_variadic_variant
(Parser
* _p
,
557 Token
& userAttrs
, Token
& typehint
,
559 if
(!userAttrs.text
().empty
() ||
!typehint.text
().empty
() ||
560 (mod
&& !mod
->text
().empty
())) {
561 HPHP_PARSER_ERROR
("Variadic '...' should be followed by a '$variable'", _p
);
563 only_in_hh_syntax
(_p
);
566 // Shapes may not have leading integers in key names, considered as a
567 // parse time error. This is because at runtime they are currently
568 // hphp arrays, which will treat leading integer keys as numbers.
569 static void validate_shape_keyname
(Token
& tok
, Parser
* _p
) {
570 if
(tok.text
().empty
()) {
571 HPHP_PARSER_ERROR
("Shape key names may not be empty", _p
);
573 if
(isdigit
(tok.text
()[0])) {
574 HPHP_PARSER_ERROR
("Shape key names may not start with integers", _p
);
578 ///////////////////////////////////////////////////////////////////////////////
580 static int yylex(YYSTYPE* token
, HPHP
::Location
* loc
, Parser
* _p
) {
581 return _p
->scan
(token
, loc
);
587 %lex
-param
{HPHP
::HPHP_PARSER_NS
::Parser
*_p
}
588 %parse
-param
{HPHP
::HPHP_PARSER_NS
::Parser
*_p
}
590 %left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
591 %right T_LAMBDA_ARROW
598 %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
599 %right T_AWAIT T_YIELD
609 %nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL
610 %nonassoc
'<' T_IS_SMALLER_OR_EQUAL
'>' T_IS_GREATER_OR_EQUAL T_SPACESHIP
615 %nonassoc T_INSTANCEOF
616 %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
'@'
620 %nonassoc T_NEW T_CLONE
626 %token T_LNUMBER
/* long */
627 %token T_DNUMBER
/* double */
628 %token T_ONUMBER
/* overflowed decimal, might get parsed as long or double */
630 %token T_STRING_VARNAME
637 %token T_BAD_CHARACTER
638 %token T_ENCAPSED_AND_WHITESPACE
639 %token T_CONSTANT_ENCAPSED_STRING
667 %right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC
672 %token T_HALT_COMPILER
677 %token T_OBJECT_OPERATOR
678 %token T_NULLSAFE_OBJECT_OPERATOR
679 %token T_DOUBLE_ARROW
694 %token T_OPEN_TAG_WITH_ECHO
697 %token T_START_HEREDOC
699 %token T_DOLLAR_OPEN_CURLY_BRACES
701 %token T_DOUBLE_COLON
705 %token T_NS_SEPARATOR
709 %token T_XHP_ATTRIBUTE
710 %token T_XHP_CATEGORY
711 %token T_XHP_CATEGORY_LABEL
712 %token T_XHP_CHILDREN
714 %token T_XHP_REQUIRED
717 %token T_ELLIPSIS
"..."
718 %token T_COALESCE
"??"
729 %token T_UNRESOLVED_LT
734 %token T_UNRESOLVED_TYPE
736 %token T_UNRESOLVED_NEWTYPE
738 %token T_COMPILER_HALT_OFFSET
743 %token T_UNRESOLVED_OP
749 { _p
->onNewLabelScope
(true
);
750 _p
->initParseTree
();}
752 { _p
->popLabelInfo
();
754 _p
->onCompleteLabelScope
(true
);}
759 top_statement
{ _p
->addTopStatement
($2);}
763 statement
{ _p
->nns
($1.num
(), $1.text
()); $$
= $1;}
764 | function_declaration_statement
{ _p
->nns
(); $$
= $1;}
765 | class_declaration_statement
{ _p
->nns
(); $$
= $1;}
766 | enum_declaration_statement
{ _p
->nns
(); $$
= $1;}
767 | trait_declaration_statement
{ _p
->nns
(); $$
= $1;}
768 | hh_type_alias_statement
{ $$
= $1; }
769 | T_HALT_COMPILER
'(' ')' ';' { _p
->onHaltCompiler
();
772 | T_NAMESPACE namespace_name
';' { _p
->onNamespaceStart
($2.text
(), true
);
774 | T_NAMESPACE namespace_name
'{' { _p
->onNamespaceStart
($2.text
());}
775 top_statement_list
'}' { _p
->onNamespaceEnd
(); $$
= $5;}
776 | T_NAMESPACE
'{' { _p
->onNamespaceStart
("");}
777 top_statement_list
'}' { _p
->onNamespaceEnd
(); $$
= $4;}
778 | T_USE use_declarations
';' { _p
->onUse
($2, &Parser
::useClass
);
779 _p
->nns
(T_USE
); $$.reset
();}
781 use_declarations
';' { _p
->onUse
($3, &Parser
::useFunction
);
782 _p
->nns
(T_USE
); $$.reset
();}
784 use_declarations
';' { _p
->onUse
($3, &Parser
::useConst
);
785 _p
->nns
(T_USE
); $$.reset
();}
786 | T_USE group_use_prefix
787 '{' mixed_use_declarations
'}' ';' { _p
->onGroupUse
($2.text
(), $4,
789 _p
->nns
(T_USE
); $$.reset
();}
790 | T_USE T_FUNCTION group_use_prefix
791 '{' use_declarations
'}' ';' { _p
->onGroupUse
($3.text
(), $5,
792 &Parser
::useFunction
);
793 _p
->nns
(T_USE
); $$.reset
();}
794 | T_USE T_CONST group_use_prefix
795 '{' use_declarations
'}' ';' { _p
->onGroupUse
($3.text
(), $5,
797 _p
->nns
(T_USE
); $$.reset
();}
798 | constant_declaration
';' { _p
->nns
();
799 _p
->finishStatement
($$
, $1); $$
= 1;}
802 ident_no_semireserved:
804 | T_SUPER
{ $$
= $1;}
805 | T_WHERE
{ $$
= $1;}
806 | T_XHP_ATTRIBUTE
{ $$
= $1;}
807 | T_XHP_CATEGORY
{ $$
= $1;}
808 | T_XHP_CHILDREN
{ $$
= $1;}
809 | T_XHP_REQUIRED
{ $$
= $1;}
813 | T_KEYSET
{ $$
= $1;}
816 ident_for_class_const:
817 ident_no_semireserved
881 /** The following must be made semi-reserved since they were keywords in HHVM
887 ident_for_class_const
892 namespace_name T_NS_SEPARATOR
{ $$
= $1;}
894 namespace_name T_NS_SEPARATOR
{ $$
= $2;}
897 non_empty_use_declarations:
898 non_empty_use_declarations
','
899 use_declaration
{ _p
->addStatement
($$
,$1,$3);}
900 | use_declaration
{ $$.reset
();
901 _p
->addStatement
($$
,$$
,$1);}
905 non_empty_use_declarations
906 hh_possible_comma
{ $$
= $1;}
910 namespace_name
{ _p
->onUseDeclaration
($$
, $1.text
(),"");}
911 | T_NS_SEPARATOR namespace_name
{ _p
->onUseDeclaration
($$
, $2.text
(),"");}
913 T_AS ident_no_semireserved
{ _p
->onUseDeclaration
($$
, $1.text
(),$3.text
());}
914 | T_NS_SEPARATOR namespace_name
915 T_AS ident_no_semireserved
{ _p
->onUseDeclaration
($$
, $2.text
(),$4.text
());}
918 non_empty_mixed_use_declarations:
919 non_empty_mixed_use_declarations
','
920 mixed_use_declaration
{ _p
->addStatement
($$
,$1,$3);}
921 | mixed_use_declaration
{ $$.reset
();
922 _p
->addStatement
($$
,$$
,$1);}
925 mixed_use_declarations:
926 non_empty_mixed_use_declarations
927 hh_possible_comma
{ $$
= $1;}
930 mixed_use_declaration:
931 use_declaration
{ _p
->onMixedUseDeclaration
($$
, $1,
933 | T_FUNCTION use_declaration
{ _p
->onMixedUseDeclaration
($$
, $2,
934 &Parser
::useFunction
);}
935 | T_CONST use_declaration
{ _p
->onMixedUseDeclaration
($$
, $2,
940 ident_no_semireserved
{ $$
= $1;}
941 | namespace_name T_NS_SEPARATOR
942 ident_no_semireserved
{ $$
= $1 + $2 + $3; $$
= $1.num
() |
2;}
945 namespace_name
{ $$
= $1; $$
= $$.num
() |
1;}
946 | T_NAMESPACE T_NS_SEPARATOR
947 namespace_name
{ $$.set
($3.num
() |
2, _p
->nsDecl
($3.text
()));}
948 | T_NS_SEPARATOR namespace_name
{ $$
= $2; $$
= $$.num
() |
2;}
951 namespace_string_typeargs:
953 hh_typeargs_opt
{ if
($1.num
() & 1) {
954 $1.setText
(_p
->resolve
($1.text
(),0));
958 class_namespace_string_typeargs:
960 hh_typeargs_opt
{ if
($1.num
() & 1) {
961 $1.setText
(_p
->resolve
($1.text
(),1));
963 _p
->onTypeAnnotation
($$
, $1, $2);}
965 constant_declaration:
966 constant_declaration
','
968 '=' static_expr
{ $3.setText
(_p
->nsDecl
($3.text
()));
969 _p
->onConst
($$
,$3,$5);}
970 | T_CONST hh_name_with_type
'='
971 static_expr
{ $2.setText
(_p
->nsDecl
($2.text
()));
972 _p
->onConst
($$
,$2,$4);}
975 inner_statement_list:
977 inner_statement
{ _p
->addStatement
($$
,$1,$2);}
978 |
{ _p
->onStatementListStart
($$
);}
981 statement
{ $$
= $1;}
982 | function_declaration_statement
{ $$
= $1;}
983 | class_declaration_statement
{ $$
= $1;}
984 | trait_declaration_statement
{ $$
= $1;}
987 '{' inner_statement_list
'}' { _p
->onBlock
($$
, $2);}
988 | T_IF parenthesis_expr
991 else_single
{ _p
->onIf
($$
,$2,$3,$4,$5);}
992 | T_IF parenthesis_expr
':'
996 T_ENDIF
';' { _p
->onIf
($$
,$2,$4,$5,$6);}
997 | T_WHILE parenthesis_expr
{ _p
->onNewLabelScope
(false
);
998 _p
->pushLabelScope
();}
999 while_statement
{ _p
->popLabelScope
();
1000 _p
->onWhile
($$
,$2,$4);
1001 _p
->onCompleteLabelScope
(false
);}
1003 | T_DO
{ _p
->onNewLabelScope
(false
);
1004 _p
->pushLabelScope
();}
1005 statement T_WHILE parenthesis_expr
1006 ';' { _p
->popLabelScope
();
1008 _p
->onCompleteLabelScope
(false
);}
1009 | T_FOR
'(' for_expr
';'
1010 for_expr
';' for_expr
')' { _p
->onNewLabelScope
(false
);
1011 _p
->pushLabelScope
();}
1012 for_statement
{ _p
->popLabelScope
();
1013 _p
->onFor
($$
,$3,$5,$7,$10);
1014 _p
->onCompleteLabelScope
(false
);}
1015 | T_SWITCH parenthesis_expr
{ _p
->onNewLabelScope
(false
);
1016 _p
->pushLabelScope
();}
1017 switch_case_list
{ _p
->popLabelScope
();
1018 _p
->onSwitch
($$
,$2,$4);
1019 _p
->onCompleteLabelScope
(false
);}
1020 | T_BREAK
';' { _p
->onBreakContinue
($$
, true
, NULL
);}
1021 | T_BREAK expr
';' { _p
->onBreakContinue
($$
, true
, &$2);}
1022 | T_CONTINUE
';' { _p
->onBreakContinue
($$
, false
, NULL
);}
1023 | T_CONTINUE expr
';' { _p
->onBreakContinue
($$
, false
, &$2);}
1024 | T_RETURN
';' { _p
->onReturn
($$
, NULL
);}
1025 | T_RETURN expr
';' { _p
->onReturn
($$
, &$2);}
1026 | T_YIELD T_BREAK
';' { _p
->onYieldBreak
($$
);}
1027 | T_GLOBAL global_var_list
';' { _p
->onGlobal
($$
, $2);}
1028 | T_STATIC static_var_list
';' { _p
->onStatic
($$
, $2);}
1029 | T_ECHO expr_list
';' { _p
->onEcho
($$
, $2, 0);}
1030 | T_OPEN_TAG_WITH_ECHO expr_list
';' { _p
->onEcho
($$
, $2, 0);}
1031 | T_UNSET
'(' variable_list
')' ';' { _p
->onUnset
($$
, $3);}
1032 |
';' { $$.reset
(); $$
= ';';}
1033 | T_INLINE_HTML
{ _p
->onEcho
($$
, $1, 1);}
1034 | T_HASHBANG
{ _p
->onHashBang
($$
, $1);
1036 | T_FOREACH
'(' expr
1037 T_AS foreach_variable
1038 foreach_optional_arg
')' { _p
->onNewLabelScope
(false
);
1039 _p
->pushLabelScope
();}
1040 foreach_statement
{ _p
->popLabelScope
();
1041 _p
->onForEach
($$
,$3,$5,$6,$9, false
);
1042 _p
->onCompleteLabelScope
(false
);}
1043 | T_FOREACH
'(' expr
1044 T_AWAIT T_AS foreach_variable
1045 foreach_optional_arg
')' { _p
->onNewLabelScope
(false
);
1046 _p
->pushLabelScope
();}
1047 foreach_statement
{ _p
->popLabelScope
();
1048 _p
->onForEach
($$
,$3,$6,$7,$10, true
);
1049 _p
->onCompleteLabelScope
(false
);}
1050 | T_DECLARE
'(' declare_list
')'
1051 declare_statement
{ _p
->onDeclare
($3, $5);
1057 fully_qualified_class_name
1059 inner_statement_list
'}'
1060 additional_catches
{ _p
->onCompleteLabelScope
(false
);}
1061 optional_finally
{ _p
->onTry
($$
,$2,$5,$6,$9,$11,$13);}
1064 T_FINALLY
{ _p
->onCompleteLabelScope
(false
);}
1065 finally_statement_list
{ _p
->onTry
($$
, $2, $5);}
1066 | T_THROW expr
';' { _p
->onThrow
($$
, $2);}
1067 | T_GOTO ident_no_semireserved
';' { _p
->onGoto
($$
, $2, true
);
1068 _p
->addGoto
($2.text
(),
1071 | expr
';' { _p
->onExpStatement
($$
, $1);}
1072 | yield_expr
';' { _p
->onExpStatement
($$
, $1);}
1073 | yield_assign_expr
';' { _p
->onExpStatement
($$
, $1);}
1074 | yield_list_assign_expr
';' { _p
->onExpStatement
($$
, $1);}
1075 | yield_from_expr
';' { _p
->onExpStatement
($$
, $1);}
1076 | yield_from_assign_expr
';' { _p
->onExpStatement
($$
, $1);}
1077 | T_RETURN yield_from_expr
';' { _p
->onReturn
($$
, &$2);}
1078 | await_expr
';' { _p
->onExpStatement
($$
, $1);}
1079 | await_assign_expr
';' { _p
->onExpStatement
($$
, $1);}
1080 | T_RETURN await_expr
';' { _p
->onReturn
($$
, &$2); }
1081 | await_list_assign_expr
';' { _p
->onExpStatement
($$
, $1);}
1082 | ident_no_semireserved
':' { _p
->onLabel
($$
, $1);
1083 _p
->addLabel
($1.text
(),
1086 _p
->onScopeLabel
($$
, $1);}
1090 '{' { _p
->onNewLabelScope
(false
);}
1091 inner_statement_list
'}' { $$
= $3;}
1097 fully_qualified_class_name
1100 inner_statement_list
'}' { _p
->onCatch
($$
, $1, $4, $5, $8);}
1104 finally_statement_list:
1105 '{' { _p
->onNewLabelScope
(false
);
1106 _p
->pushLabelScope
();}
1107 inner_statement_list
'}' { _p
->popLabelScope
();
1108 _p
->onFinally
($$
, $3);
1109 _p
->onCompleteLabelScope
(false
);}
1113 T_FINALLY finally_statement_list
{ $$
= $2;}
1123 T_FUNCTION
{ _p
->pushFuncLocation
(); }
1126 function_declaration_statement:
1129 hh_name_no_semireserved_with_typevar
{ $3.setText
(_p
->nsDecl
($3.text
()));
1130 _p
->onNewLabelScope
(true
);
1131 _p
->onFunctionStart
($3);
1132 _p
->pushLabelInfo
();}
1133 '(' parameter_list
')'
1135 function_body
{ _p
->onFunction
($$
,nullptr
,$8,$2,$3,$6,$9,nullptr
);
1138 _p
->onCompleteLabelScope
(true
);}
1139 | non_empty_member_modifiers
1142 hh_name_no_semireserved_with_typevar
{ $4.setText
(_p
->nsDecl
($4.text
()));
1143 _p
->onNewLabelScope
(true
);
1144 _p
->onFunctionStart
($4);
1145 _p
->pushLabelInfo
();}
1146 '(' parameter_list
')'
1148 function_body
{ _p
->onFunction
($$
,&$1,$9,$3,$4,$7,$10,nullptr
);
1151 _p
->onCompleteLabelScope
(true
);}
1152 | non_empty_user_attributes
1153 method_modifiers function_loc
1155 hh_name_no_semireserved_with_typevar
{ $5.setText
(_p
->nsDecl
($5.text
()));
1156 _p
->onNewLabelScope
(true
);
1157 _p
->onFunctionStart
($5);
1158 _p
->pushLabelInfo
();}
1159 '(' parameter_list
')'
1161 function_body
{ _p
->onFunction
($$
,&$2,$10,$4,$5,$8,$11,&$1);
1164 _p
->onCompleteLabelScope
(true
);}
1167 enum_declaration_statement:
1169 ident_no_semireserved
{ $2.setText
(_p
->nsClassDecl
($2.text
()));
1170 _p
->onClassStart
(T_ENUM
,$2);}
1173 '{' enum_statement_list
'}' { _p
->onEnum
($$
,$2,$5,$8,0); }
1175 | non_empty_user_attributes
1177 ident_no_semireserved
{ $3.setText
(_p
->nsClassDecl
($3.text
()));
1178 _p
->onClassStart
(T_ENUM
,$3);}
1181 '{' enum_statement_list
'}' { _p
->onEnum
($$
,$3,$6,$9,&$1); }
1185 class_declaration_statement:
1187 class_decl_name
{ $2.setText
(_p
->nsClassDecl
($2.text
()));
1188 _p
->onClassStart
($1.num
(),$2);}
1189 extends_from implements_list
'{'
1190 class_statement_list
'}' { Token stmts
;
1191 if
(_p
->peekClass
()) {
1192 xhp_collect_attributes
(_p
,stmts
,$7);
1196 _p
->onClass
($$
,$1.num
(),$2,$4,$5,
1198 if
(_p
->peekClass
()) {
1199 _p
->xhpResetAttributes
();
1202 _p
->popTypeScope
();}
1203 | non_empty_user_attributes
1205 class_decl_name
{ $3.setText
(_p
->nsClassDecl
($3.text
()));
1206 _p
->onClassStart
($2.num
(),$3);}
1207 extends_from implements_list
'{'
1208 class_statement_list
'}' { Token stmts
;
1209 if
(_p
->peekClass
()) {
1210 xhp_collect_attributes
(_p
,stmts
,$8);
1214 _p
->onClass
($$
,$2.num
(),$3,$5,$6,
1216 if
(_p
->peekClass
()) {
1217 _p
->xhpResetAttributes
();
1220 _p
->popTypeScope
();}
1222 interface_decl_name
{ $2.setText
(_p
->nsClassDecl
($2.text
()));
1223 _p
->onClassStart
(T_INTERFACE
,$2);}
1224 interface_extends_list
'{'
1225 class_statement_list
'}' { _p
->onInterface
($$
,$2,$4,$6,0);
1227 _p
->popTypeScope
();}
1228 | non_empty_user_attributes
1230 interface_decl_name
{ $3.setText
(_p
->nsClassDecl
($3.text
()));
1231 _p
->onClassStart
(T_INTERFACE
,$3);}
1232 interface_extends_list
'{'
1233 class_statement_list
'}' { _p
->onInterface
($$
,$3,$5,$7,&$1);
1235 _p
->popTypeScope
();}
1239 T_CLASS
{ _p
->onClassExpressionStart
(); }
1241 extends_from implements_list
'{'
1242 class_statement_list
'}' { _p
->onClassExpression
($$
, $3, $4, $5, $7); }
1244 trait_declaration_statement:
1246 trait_decl_name
{ $2.setText
(_p
->nsClassDecl
($2.text
()));
1247 _p
->onClassStart
(T_TRAIT
, $2);}
1249 '{' class_statement_list
'}' { Token t_ext
;
1251 _p
->onClass
($$
,T_TRAIT
,$2,t_ext
,$4,
1254 _p
->popTypeScope
();}
1255 | non_empty_user_attributes
1257 trait_decl_name
{ $3.setText
(_p
->nsClassDecl
($3.text
()));
1258 _p
->onClassStart
(T_TRAIT
, $3);}
1260 '{' class_statement_list
'}' { Token t_ext
;
1262 _p
->onClass
($$
,T_TRAIT
,$3,t_ext
,$5,
1265 _p
->popTypeScope
();}
1268 hh_name_no_semireserved_with_typevar
{ _p
->pushClass
(false
); $$
= $1;}
1269 | T_XHP_LABEL
{ $1.xhpLabel
(); _p
->pushTypeScope
();
1270 _p
->pushClass
(true
); $$
= $1;}
1272 interface_decl_name:
1273 hh_name_no_semireserved_with_typevar
{ _p
->pushClass
(false
); $$
= $1;}
1276 hh_name_no_semireserved_with_typevar
{ _p
->pushClass
(false
); $$
= $1;}
1279 T_CLASS
{ $$
= T_CLASS
;}
1280 | T_ABSTRACT T_CLASS
{ $$
= T_ABSTRACT
; }
1281 | T_ABSTRACT T_FINAL T_CLASS
{ only_in_hh_syntax
(_p
);
1282 /* hacky, but transforming to a single token is quite convenient */
1284 | T_FINAL T_ABSTRACT T_CLASS
{ only_in_hh_syntax
(_p
); $$
= T_STATIC
; }
1285 | T_FINAL T_CLASS
{ $$
= T_FINAL
;}
1289 fully_qualified_class_name
{ $$
= $2;}
1293 T_IMPLEMENTS interface_list
{ $$
= $2;}
1296 interface_extends_list:
1297 T_EXTENDS interface_list
{ $$
= $2;}
1301 fully_qualified_class_name
{ _p
->onInterfaceName
($$
, NULL
, $1);}
1302 | interface_list
','
1303 fully_qualified_class_name
{ _p
->onInterfaceName
($$
, &$1, $3);}
1306 fully_qualified_class_name
{ _p
->onTraitName
($$
, NULL
, $1);}
1308 fully_qualified_class_name
{ _p
->onTraitName
($$
, &$1, $3);}
1311 foreach_optional_arg:
1312 T_DOUBLE_ARROW foreach_variable
{ $$
= $2;}
1316 variable
{ $$
= $1; $$
= 0;}
1317 |
'&' variable
{ $$
= $2; $$
= 1;}
1318 | T_LIST
'(' assignment_list
')' { _p
->onListAssignment
($$
, $3, NULL
);}
1322 statement
{ $$
= $1;}
1323 |
':' inner_statement_list
1324 T_ENDFOR
';' { $$
= $2;}
1327 statement
{ $$
= $1;}
1328 |
':' inner_statement_list
1329 T_ENDFOREACH
';' { $$
= $2;}
1332 statement
{ $$
= $1;}
1333 |
':' inner_statement_list
1334 T_ENDWHILE
';' { $$
= $2;}
1337 statement
{ _p
->onBlock
($$
, $1);}
1338 |
':' inner_statement_list
1339 T_ENDDECLARE
';' { _p
->onBlock
($$
, $2);}
1343 ident_no_semireserved
'=' static_expr
{_p
->onDeclareList
($$
, $1, $3);}
1345 ident_no_semireserved
'=' static_expr
{_p
->onDeclareList
($1, $3, $5);
1350 '{' case_list
'}' { $$
= $2;}
1351 |
'{' ';' case_list
'}' { $$
= $3;}
1352 |
':' case_list T_ENDSWITCH
';' { $$
= $2;}
1353 |
':' ';' case_list T_ENDSWITCH
';' { $$
= $3;}
1356 case_list T_CASE expr
1358 inner_statement_list
{ _p
->onCase
($$
,$1,&$3,$5);}
1359 | case_list T_DEFAULT case_separator
1360 inner_statement_list
{ _p
->onCase
($$
,$1,NULL
,$4);}
1365 |
';' { $$.reset
();}
1369 elseif_list T_ELSEIF parenthesis_expr
1370 statement
{ _p
->onElseIf
($$
,$1,$3,$4);}
1374 new_elseif_list T_ELSEIF
1375 parenthesis_expr
':'
1376 inner_statement_list
{ _p
->onElseIf
($$
,$1,$3,$5);}
1380 T_ELSE statement
{ $$
= $2;}
1384 T_ELSE
':' inner_statement_list
{ $$
= $3;}
1388 method_parameter_list:
1389 non_empty_method_parameter_list
','
1390 optional_user_attributes
1392 hh_type_opt
"..." T_VARIABLE
1393 { _p
->onVariadicParam
($$
,&$1,$5,$7,false
,
1395 | non_empty_method_parameter_list
','
1396 optional_user_attributes
1398 hh_type_opt
'&' "..." T_VARIABLE
1399 { _p
->onVariadicParam
($$
,&$1,$5,$8,true
,
1401 | non_empty_method_parameter_list
','
1402 optional_user_attributes
1405 { validate_hh_variadic_variant
(
1408 | non_empty_method_parameter_list
1409 hh_possible_comma
{ $$
= $1;}
1410 | optional_user_attributes
1412 hh_type_opt
"..." T_VARIABLE
1413 { _p
->onVariadicParam
($$
,NULL
,$3,$5,false
,
1415 | optional_user_attributes
1417 hh_type_opt
'&' "..." T_VARIABLE
1418 { _p
->onVariadicParam
($$
,NULL
,$3,$6,true
,
1420 | optional_user_attributes
1423 { validate_hh_variadic_variant
(
1429 non_empty_method_parameter_list:
1430 optional_user_attributes
1432 hh_type_opt T_VARIABLE
{ _p
->onParam
($$
,NULL
,$3,$4,0,
1434 | optional_user_attributes
1436 hh_type_opt
'&' T_VARIABLE
{ _p
->onParam
($$
,NULL
,$3,$5,1,
1438 | optional_user_attributes
1440 hh_type_opt
'&' T_VARIABLE
1441 '=' expr
{ _p
->onParam
($$
,NULL
,$3,$5,1,
1443 | optional_user_attributes
1445 hh_type_opt T_VARIABLE
1446 '=' expr
{ _p
->onParam
($$
,NULL
,$3,$4,0,
1448 | non_empty_method_parameter_list
','
1449 optional_user_attributes
1451 hh_type_opt T_VARIABLE
{ _p
->onParam
($$
,&$1,$5,$6,0,
1453 | non_empty_method_parameter_list
','
1454 optional_user_attributes
1456 hh_type_opt
'&' T_VARIABLE
{ _p
->onParam
($$
,&$1,$5,$7,1,
1458 | non_empty_method_parameter_list
','
1459 optional_user_attributes
1461 hh_type_opt
'&' T_VARIABLE
1462 '=' expr
{ _p
->onParam
($$
,&$1,$5,$7,1,
1464 | non_empty_method_parameter_list
','
1465 optional_user_attributes
1467 hh_type_opt T_VARIABLE
1468 '=' expr
{ _p
->onParam
($$
,&$1,$5,$6,0,
1473 non_empty_parameter_list
','
1474 optional_user_attributes
1475 hh_type_opt
"..." T_VARIABLE
1476 { _p
->onVariadicParam
($$
,&$1,$4,$6,
1478 | non_empty_parameter_list
','
1479 optional_user_attributes
1480 hh_type_opt
'&' "..." T_VARIABLE
1481 { _p
->onVariadicParam
($$
,&$1,$4,$7,
1483 | non_empty_parameter_list
','
1484 optional_user_attributes
1486 { validate_hh_variadic_variant
(
1489 | non_empty_parameter_list
1490 hh_possible_comma
{ $$
= $1;}
1491 | optional_user_attributes
1492 hh_type_opt
"..." T_VARIABLE
1493 { _p
->onVariadicParam
($$
,NULL
,$2,$4,
1495 | optional_user_attributes
1496 hh_type_opt
'&' "..." T_VARIABLE
1497 { _p
->onVariadicParam
($$
,NULL
,$2,$5,
1499 | optional_user_attributes
1501 { validate_hh_variadic_variant
(
1507 non_empty_parameter_list:
1508 optional_user_attributes
1509 hh_type_opt T_VARIABLE
{ _p
->onParam
($$
,NULL
,$2,$3,false
,
1511 | optional_user_attributes
1512 hh_type_opt
'&' T_VARIABLE
{ _p
->onParam
($$
,NULL
,$2,$4,true
,
1514 | optional_user_attributes
1515 hh_type_opt
'&' T_VARIABLE
1516 '=' expr
{ _p
->onParam
($$
,NULL
,$2,$4,true
,
1518 | optional_user_attributes
1519 hh_type_opt T_VARIABLE
1520 '=' expr
{ _p
->onParam
($$
,NULL
,$2,$3,false
,
1522 | non_empty_parameter_list
','
1523 optional_user_attributes
1524 hh_type_opt T_VARIABLE
{ _p
->onParam
($$
,&$1,$4,$5,false
,
1526 | non_empty_parameter_list
','
1527 optional_user_attributes
1528 hh_type_opt
'&' T_VARIABLE
{ _p
->onParam
($$
,&$1,$4,$6,true
,
1530 | non_empty_parameter_list
','
1531 optional_user_attributes
1532 hh_type_opt
'&' T_VARIABLE
1533 '=' expr
{ _p
->onParam
($$
,&$1,$4,$6,true
,
1535 | non_empty_parameter_list
','
1536 optional_user_attributes
1537 hh_type_opt T_VARIABLE
1538 '=' expr
{ _p
->onParam
($$
,&$1,$4,$5,false
,
1542 function_call_parameter_list:
1543 non_empty_fcall_parameter_list
1544 hh_possible_comma
{ $$
= $1;}
1547 non_empty_fcall_parameter_list:
1548 expr
{ _p
->onCallParam
($$
,NULL
,$1,false
,false
);}
1549 |
'&' variable
{ _p
->onCallParam
($$
,NULL
,$2,true
,false
);}
1550 |
"..." expr
{ _p
->onCallParam
($$
,NULL
,$2,false
,true
);}
1551 | non_empty_fcall_parameter_list
1552 ',' expr
{ _p
->onCallParam
($$
,&$1,$3,false
, false
);}
1553 | non_empty_fcall_parameter_list
1554 ',' "..." expr
{ _p
->onCallParam
($$
,&$1,$4,false
,true
);}
1555 | non_empty_fcall_parameter_list
1556 ',' '&' variable
{ _p
->onCallParam
($$
,&$1,$4,true
, false
);}
1560 global_var_list
',' global_var
{ _p
->onGlobalVar
($$
, &$1, $3);}
1561 | global_var
{ _p
->onGlobalVar
($$
, NULL
, $1);}
1564 T_VARIABLE
{ $$
= $1;}
1565 |
'$' variable
{ $$
= $2; $$
= 1;}
1566 |
'$' '{' expr
'}' { $$
= $3; $$
= 1;}
1570 static_var_list
',' T_VARIABLE
{ _p
->onStaticVariable
($$
,&$1,$3,0);}
1571 | static_var_list
',' T_VARIABLE
1572 '=' static_expr
{ _p
->onStaticVariable
($$
,&$1,$3,&$5);}
1573 | T_VARIABLE
{ _p
->onStaticVariable
($$
,0,$1,0);}
1574 | T_VARIABLE
'=' static_expr
{ _p
->onStaticVariable
($$
,0,$1,&$3);}
1577 enum_statement_list:
1579 enum_statement
{ _p
->onClassStatement
($$
, $1, $2);}
1583 enum_constant_declaration
';' { _p
->onClassVariableStart
1586 enum_constant_declaration:
1587 hh_constname_with_type
'='
1588 static_expr
{ _p
->onClassConstant
($$
,0,$1,$3);}
1592 class_statement_list:
1593 class_statement_list
1594 class_statement
{ _p
->onClassStatement
($$
, $1, $2);}
1598 variable_modifiers
{ _p
->onClassVariableModifer
($1);}
1599 class_variable_declaration
';' { _p
->onClassVariableStart
1601 | non_empty_member_modifiers
1602 hh_type
{ _p
->onClassVariableModifer
($1);}
1603 class_variable_declaration
';' { _p
->onClassVariableStart
1605 | class_constant_declaration
';' { _p
->onClassVariableStart
1607 | class_abstract_constant_declaration
';'
1608 { _p
->onClassVariableStart
1609 ($$
,NULL
,$1,NULL
, true
);}
1610 | class_type_constant_declaration
';' { $$
= $1; }
1611 | method_modifiers function_loc
1612 is_reference hh_name_with_typevar
'('
1613 { _p
->onNewLabelScope
(true
);
1614 _p
->onMethodStart
($4, $1);
1615 _p
->pushLabelInfo
();}
1616 method_parameter_list
')'
1618 opt_type_constraint_where_clause
1620 { _p
->onMethod
($$
,$1,$9,$3,$4,$7,$11,nullptr
);
1623 _p
->onCompleteLabelScope
(true
);}
1624 | non_empty_user_attributes
1625 method_modifiers function_loc
1627 hh_name_no_semireserved_with_typevar
'('
1628 { _p
->onNewLabelScope
(true
);
1629 _p
->onMethodStart
($5, $2);
1630 _p
->pushLabelInfo
();}
1631 method_parameter_list
')'
1633 opt_type_constraint_where_clause
1635 { _p
->onMethod
($$
,$2,$10,$4,$5,$8,$12,&$1);
1638 _p
->onCompleteLabelScope
(true
);}
1640 xhp_attribute_stmt
';' { _p
->xhpSetAttributes
($2);}
1642 xhp_category_stmt
';' { xhp_category_stmt
(_p
,$$
,$2);}
1644 xhp_children_stmt
';' { xhp_children_stmt
(_p
,$$
,$2);}
1645 | T_REQUIRE T_EXTENDS fully_qualified_class_name
';'
1646 { _p
->onClassRequire
($$
, $3, true
); }
1647 | T_REQUIRE T_IMPLEMENTS fully_qualified_class_name
';'
1648 { _p
->onClassRequire
($$
, $3, false
); }
1649 | T_USE trait_list
';' { Token t
; t.reset
();
1650 _p
->onTraitUse
($$
,$2,t
); }
1651 | T_USE trait_list
'{'
1652 trait_rules
'}' { _p
->onTraitUse
($$
,$2,$4); }
1655 trait_rules trait_precedence_rule
{ _p
->onTraitRule
($$
,$1,$2); }
1656 | trait_rules trait_alias_rule
{ _p
->onTraitRule
($$
,$1,$2); }
1657 |
/* empty */ { $$.reset
(); }
1659 trait_precedence_rule:
1660 class_namespace_string_typeargs
1662 ident_no_semireserved
1663 T_INSTEADOF trait_list
';' { _p
->onTraitPrecRule
($$
,$1,$3,$5);}
1666 trait_alias_rule_method T_AS
1667 method_modifiers ident_no_semireserved
';'
1668 { _p
->onTraitAliasRuleModify
($$
,$1,$3,
1670 | trait_alias_rule_method T_AS
1671 non_empty_member_modifiers
';' { Token t
; t.reset
();
1672 _p
->onTraitAliasRuleModify
($$
,$1,$3,
1675 trait_alias_rule_method:
1676 class_namespace_string_typeargs
1678 ident_no_semireserved
{ _p
->onTraitAliasRuleStart
($$
,$1,$3);}
1679 | ident_no_semireserved
{ Token t
; t.reset
();
1680 _p
->onTraitAliasRuleStart
($$
,t
,$1);}
1684 xhp_attribute_decl
{ xhp_attribute_list
(_p
,$$
,
1685 _p
->xhpGetAttributes
(),$1);}
1686 | xhp_attribute_stmt
','
1687 xhp_attribute_decl
{ xhp_attribute_list
(_p
,$$
, &$1,$3);}
1691 xhp_nullable_attribute_decl_type
1693 xhp_attribute_default
1694 xhp_attribute_is_required
{ xhp_attribute
(_p
,$$
,$1,$2,$3,$4);
1696 | T_XHP_LABEL
{ $$
= $1; $$
= 0;}
1699 xhp_nullable_attribute_decl_type:
1700 '?' xhp_attribute_decl_type
{ $$
= $2;}
1701 | xhp_attribute_decl_type
1704 xhp_attribute_decl_type:
1706 | T_ARRAY T_TYPELIST_LT hh_type
1707 possible_comma T_TYPELIST_GT
{ $$
= 4;}
1708 | T_ARRAY T_TYPELIST_LT hh_type
','
1709 hh_type T_TYPELIST_GT
{ $$
= 4;}
1710 | fully_qualified_class_name
{ /* This case handles all types other
1711 than "array", "var" and "enum".
1712 For now we just use type code 5;
1713 later xhp_attribute() will fix up
1714 the type code as appropriate. */
1715 $$
= 5; $$.setText
($1);}
1718 xhp_attribute_enum
'}' { $$
= $3; $$
= 7;}
1719 | T_CALLABLE
{ $$
= 9; }
1722 non_empty_xhp_attribute_enum:
1723 common_scalar
{ _p
->onArrayPair
($$
, 0,0,$1,0);}
1724 | non_empty_xhp_attribute_enum
','
1725 common_scalar
{ _p
->onArrayPair
($$
,&$1,0,$3,0);}
1729 non_empty_xhp_attribute_enum
1730 possible_comma
{ $$
= $1;}
1732 xhp_attribute_default:
1733 '=' static_expr
{ $$
= $2;}
1734 |
{ scalar_null
(_p
, $$
);}
1737 xhp_attribute_is_required:
1738 '@' T_XHP_REQUIRED
{ scalar_num
(_p
, $$
, "1");}
1739 |
{ scalar_num
(_p
, $$
, "0");}
1743 xhp_category_decl
{ Token t
; scalar_num
(_p
, t
, "1");
1744 _p
->onArrayPair
($$
,0,&$1,t
,0);}
1745 | xhp_category_stmt
','
1746 xhp_category_decl
{ Token t
; scalar_num
(_p
, t
, "1");
1747 _p
->onArrayPair
($$
,&$1,&$3,t
,0);}
1751 T_XHP_CATEGORY_LABEL
{ _p
->onScalar
($$
,
1752 T_CONSTANT_ENCAPSED_STRING
, $1);}
1756 xhp_children_paren_expr
{ $$
= $1; $$
= 2;}
1757 | ident_no_semireserved
{ $$
= -1;
1758 if
($1.same
("any")) $$
= 1;}
1759 | T_EMPTY
{ $$
= 0;}
1762 xhp_children_paren_expr:
1763 '(' xhp_children_decl_expr
')' { xhp_children_paren
(_p
, $$
, $2, 0);}
1764 |
'(' xhp_children_decl_expr
')' '*' { xhp_children_paren
(_p
, $$
, $2, 1);}
1765 |
'(' xhp_children_decl_expr
')' '?' { xhp_children_paren
(_p
, $$
, $2, 2);}
1766 |
'(' xhp_children_decl_expr
')' '+' { xhp_children_paren
(_p
, $$
, $2, 3);}
1769 xhp_children_decl_expr:
1770 xhp_children_paren_expr
{ $$
= $1;}
1771 | xhp_children_decl_tag
{ xhp_children_decl
(_p
,$$
,$1,0, 0);}
1772 | xhp_children_decl_tag
'*' { xhp_children_decl
(_p
,$$
,$1,1, 0);}
1773 | xhp_children_decl_tag
'?' { xhp_children_decl
(_p
,$$
,$1,2, 0);}
1774 | xhp_children_decl_tag
'+' { xhp_children_decl
(_p
,$$
,$1,3, 0);}
1775 | xhp_children_decl_expr
','
1776 xhp_children_decl_expr
{ xhp_children_decl
(_p
,$$
,$1,4,&$3);}
1777 | xhp_children_decl_expr
'|'
1778 xhp_children_decl_expr
{ xhp_children_decl
(_p
,$$
,$1,5,&$3);}
1781 xhp_children_decl_tag:
1782 ident_no_semireserved
{ $$
= -1;
1783 if
($1.same
("any")) $$
= 1; else
1784 if
($1.same
("pcdata")) $$
= 2;}
1785 | T_XHP_LABEL
{ $1.xhpLabel
(); $$
= $1; $$
= 3;}
1786 | T_XHP_CATEGORY_LABEL
{ $1.xhpLabel
(0); $$
= $1; $$
= 4;}
1791 |
'{' inner_statement_list
'}' { _p
->finishStatement
($$
, $2); $$
= 1;}
1796 |
'{' inner_statement_list
'}' { _p
->finishStatement
($$
, $2); $$
= 1;}
1799 non_empty_member_modifiers
{ $$
= $1;}
1800 | T_VAR
{ $$.reset
();}
1803 non_empty_member_modifiers
{ $$
= $1;}
1806 non_empty_member_modifiers:
1807 member_modifier
{ _p
->onMemberModifier
($$
,NULL
,$1);}
1808 | non_empty_member_modifiers
1809 member_modifier
{ _p
->onMemberModifier
($$
,&$1,$2);}
1812 T_PUBLIC
{ $$
= T_PUBLIC
;}
1813 | T_PROTECTED
{ $$
= T_PROTECTED
;}
1814 | T_PRIVATE
{ $$
= T_PRIVATE
;}
1815 | T_STATIC
{ $$
= T_STATIC
;}
1816 | T_ABSTRACT
{ $$
= T_ABSTRACT
;}
1817 | T_FINAL
{ $$
= T_FINAL
;}
1818 | T_ASYNC
{ $$
= T_ASYNC
;}
1821 parameter_modifiers:
1822 parameter_modifier
{ $$
= $1;}
1826 T_PUBLIC
{ $$
= T_PUBLIC
;}
1827 | T_PROTECTED
{ $$
= T_PROTECTED
;}
1828 | T_PRIVATE
{ $$
= T_PRIVATE
;}
1830 class_variable_declaration:
1831 class_variable_declaration
','
1832 T_VARIABLE
{ _p
->onClassVariable
($$
,&$1,$3,0);}
1833 | class_variable_declaration
','
1834 T_VARIABLE
'=' static_expr
{ _p
->onClassVariable
($$
,&$1,$3,&$5);}
1835 | T_VARIABLE
{ _p
->onClassVariable
($$
,0,$1,0);}
1836 | T_VARIABLE
'=' static_expr
{ _p
->onClassVariable
($$
,0,$1,&$3);}
1838 class_constant_declaration:
1839 class_constant_declaration
','
1840 hh_constname_with_type
'=' static_expr
{ _p
->onClassConstant
($$
,&$1,$3,$5);}
1841 | T_CONST hh_constname_with_type
'='
1842 static_expr
{ _p
->onClassConstant
($$
,0,$2,$4);}
1844 class_abstract_constant_declaration:
1845 class_abstract_constant_declaration
','
1846 hh_constname_with_type
{ _p
->onClassAbstractConstant
($$
,&$1,$3);}
1847 | T_ABSTRACT T_CONST hh_constname_with_type
1848 { _p
->onClassAbstractConstant
($$
,NULL
,$3);}
1850 class_type_constant_declaration:
1851 T_ABSTRACT class_type_constant
1852 hh_opt_constraint
{ Token t
;
1853 _p
->onClassTypeConstant
($$
, $2, t
);
1854 _p
->popTypeScope
(); }
1855 | class_type_constant
1856 hh_opt_constraint
'=' hh_type
{ _p
->onClassTypeConstant
($$
, $1, $4);
1857 _p
->popTypeScope
(); }
1858 class_type_constant:
1860 hh_name_no_semireserved_with_typevar
{ $$
= $3; }
1864 '(' expr_with_parens
')' { $$
= $2;}
1865 | T_NEW class_name_reference
1866 ctor_arguments
{ _p
->onNewObject
($$
, $2, $3);}
1867 | T_NEW class_expression
{ $$
= $2;}
1868 | T_CLONE expr
{ UEXP
($$
,$2,T_CLONE
,1);}
1869 | xhp_tag
{ $$
= $1;}
1870 | collection_literal
{ $$
= $1;}
1873 '(' expr
')' { $$
= $2;}
1877 expr_list
',' expr
{ _p
->onExprListElem
($$
, &$1, $3);}
1878 | expr
{ _p
->onExprListElem
($$
, NULL
, $1);}
1882 expr_list
{ $$
= $1;}
1887 T_YIELD
{ _p
->onYield
($$
, NULL
);}
1888 | T_YIELD expr
{ _p
->onYield
($$
, &$2);}
1889 | T_YIELD expr T_DOUBLE_ARROW expr
{ _p
->onYieldPair
($$
, &$2, &$4);}
1890 |
'(' yield_expr
')' { $$
= $2; }
1894 variable
'=' yield_expr
{ _p
->onAssign
($$
, $1, $3, 0, true
);}
1897 yield_list_assign_expr:
1898 T_LIST
'(' assignment_list
')'
1899 '=' yield_expr
{ _p
->onListAssignment
($$
, $3, &$6, true
);}
1903 T_YIELD_FROM expr
{ _p
->onYieldFrom
($$
,&$2);}
1906 yield_from_assign_expr:
1907 variable
'=' yield_from_expr
{ _p
->onAssign
($$
, $1, $3, 0, true
);}
1911 T_AWAIT expr
{ _p
->onAwait
($$
, $2); }
1915 variable
'=' await_expr
{ _p
->onAssign
($$
, $1, $3, 0, true
);}
1918 await_list_assign_expr:
1919 T_LIST
'(' assignment_list
')'
1920 '=' await_expr
{ _p
->onListAssignment
($$
, $3, &$6, true
);}
1924 expr_no_variable
{ $$
= $1;}
1925 | variable
{ $$
= $1;}
1926 | expr_with_parens
{ $$
= $1;}
1927 | lambda_or_closure
{ $$
= $1;}
1928 | lambda_or_closure_with_parens
{ $$
= $1;}
1932 T_LIST
'(' assignment_list
')'
1933 '=' expr
{ _p
->onListAssignment
($$
, $3, &$6);}
1934 | variable
'=' expr
{ _p
->onAssign
($$
, $1, $3, 0);}
1935 | variable
'=' '&' variable
{ _p
->onAssign
($$
, $1, $4, 1);}
1936 | variable
'=' '&' T_NEW
1937 class_name_reference
1938 ctor_arguments
{ _p
->onAssignNew
($$
,$1,$5,$6);}
1939 | variable T_PLUS_EQUAL expr
{ BEXP
($$
,$1,$3,T_PLUS_EQUAL
);}
1940 | variable T_MINUS_EQUAL expr
{ BEXP
($$
,$1,$3,T_MINUS_EQUAL
);}
1941 | variable T_MUL_EQUAL expr
{ BEXP
($$
,$1,$3,T_MUL_EQUAL
);}
1942 | variable T_DIV_EQUAL expr
{ BEXP
($$
,$1,$3,T_DIV_EQUAL
);}
1943 | variable T_CONCAT_EQUAL expr
{ BEXP
($$
,$1,$3,T_CONCAT_EQUAL
);}
1944 | variable T_MOD_EQUAL expr
{ BEXP
($$
,$1,$3,T_MOD_EQUAL
);}
1945 | variable T_AND_EQUAL expr
{ BEXP
($$
,$1,$3,T_AND_EQUAL
);}
1946 | variable T_OR_EQUAL expr
{ BEXP
($$
,$1,$3,T_OR_EQUAL
);}
1947 | variable T_XOR_EQUAL expr
{ BEXP
($$
,$1,$3,T_XOR_EQUAL
);}
1948 | variable T_SL_EQUAL expr
{ BEXP
($$
,$1,$3,T_SL_EQUAL
);}
1949 | variable T_SR_EQUAL expr
{ BEXP
($$
,$1,$3,T_SR_EQUAL
);}
1950 | variable T_POW_EQUAL expr
{ BEXP
($$
,$1,$3,T_POW_EQUAL
);}
1951 | variable T_INC
{ UEXP
($$
,$1,T_INC
,0);}
1952 | T_INC variable
{ UEXP
($$
,$2,T_INC
,1);}
1953 | variable T_DEC
{ UEXP
($$
,$1,T_DEC
,0);}
1954 | T_DEC variable
{ UEXP
($$
,$2,T_DEC
,1);}
1955 | expr T_BOOLEAN_OR expr
{ BEXP
($$
,$1,$3,T_BOOLEAN_OR
);}
1956 | expr T_BOOLEAN_AND expr
{ BEXP
($$
,$1,$3,T_BOOLEAN_AND
);}
1957 | expr T_LOGICAL_OR expr
{ BEXP
($$
,$1,$3,T_LOGICAL_OR
);}
1958 | expr T_LOGICAL_AND expr
{ BEXP
($$
,$1,$3,T_LOGICAL_AND
);}
1959 | expr T_LOGICAL_XOR expr
{ BEXP
($$
,$1,$3,T_LOGICAL_XOR
);}
1960 | expr
'|' expr
{ BEXP
($$
,$1,$3,'|');}
1961 | expr
'&' expr
{ BEXP
($$
,$1,$3,'&');}
1962 | expr
'^' expr
{ BEXP
($$
,$1,$3,'^');}
1963 | expr
'.' expr
{ BEXP
($$
,$1,$3,'.');}
1964 | expr
'+' expr
{ BEXP
($$
,$1,$3,'+');}
1965 | expr
'-' expr
{ BEXP
($$
,$1,$3,'-');}
1966 | expr
'*' expr
{ BEXP
($$
,$1,$3,'*');}
1967 | expr
'/' expr
{ BEXP
($$
,$1,$3,'/');}
1968 | expr T_POW expr
{ BEXP
($$
,$1,$3,T_POW
);}
1969 | expr
'%' expr
{ BEXP
($$
,$1,$3,'%');}
1970 | expr T_PIPE expr
{ BEXP
($$
,$1,$3,T_PIPE
);}
1971 | expr T_SL expr
{ BEXP
($$
,$1,$3,T_SL
);}
1972 | expr T_SR expr
{ BEXP
($$
,$1,$3,T_SR
);}
1973 |
'+' expr %prec T_INC
{ UEXP
($$
,$2,'+',1);}
1974 |
'-' expr %prec T_INC
{ UEXP
($$
,$2,'-',1);}
1975 |
'!' expr
{ UEXP
($$
,$2,'!',1);}
1976 |
'~' expr
{ UEXP
($$
,$2,'~',1);}
1977 | expr T_IS_IDENTICAL expr
{ BEXP
($$
,$1,$3,T_IS_IDENTICAL
);}
1978 | expr T_IS_NOT_IDENTICAL expr
{ BEXP
($$
,$1,$3,T_IS_NOT_IDENTICAL
);}
1979 | expr T_IS_EQUAL expr
{ BEXP
($$
,$1,$3,T_IS_EQUAL
);}
1980 | expr T_IS_NOT_EQUAL expr
{ BEXP
($$
,$1,$3,T_IS_NOT_EQUAL
);}
1981 | expr
'<' expr
{ BEXP
($$
,$1,$3,'<');}
1982 | expr T_IS_SMALLER_OR_EQUAL expr
{ BEXP
($$
,$1,$3,
1983 T_IS_SMALLER_OR_EQUAL
);}
1984 | expr
'>' expr
{ BEXP
($$
,$1,$3,'>');}
1985 | expr T_IS_GREATER_OR_EQUAL expr
{ BEXP
($$
,$1,$3,
1986 T_IS_GREATER_OR_EQUAL
);}
1987 | expr T_SPACESHIP expr
{ BEXP
($$
,$1,$3,T_SPACESHIP
);}
1989 class_name_reference
{ BEXP
($$
,$1,$3,T_INSTANCEOF
);}
1990 |
'(' expr_no_variable
')' { $$
= $2;}
1991 | expr
'?' expr
':' expr
{ _p
->onQOp
($$
, $1, &$3, $5);}
1992 | expr
'?' ':' expr
{ _p
->onQOp
($$
, $1, 0, $4);}
1993 | expr T_COALESCE expr
{ _p
->onNullCoalesce
($$
, $1, $3);}
1994 | internal_functions
{ $$
= $1;}
1995 | T_INT_CAST expr
{ UEXP
($$
,$2,T_INT_CAST
,1);}
1996 | T_DOUBLE_CAST expr
{ UEXP
($$
,$2,T_DOUBLE_CAST
,1);}
1997 | T_STRING_CAST expr
{ UEXP
($$
,$2,T_STRING_CAST
,1);}
1998 | T_ARRAY_CAST expr
{ UEXP
($$
,$2,T_ARRAY_CAST
,1);}
1999 | T_OBJECT_CAST expr
{ UEXP
($$
,$2,T_OBJECT_CAST
,1);}
2000 | T_BOOL_CAST expr
{ UEXP
($$
,$2,T_BOOL_CAST
,1);}
2001 | T_UNSET_CAST expr
{ UEXP
($$
,$2,T_UNSET_CAST
,1);}
2002 | T_EXIT exit_expr
{ UEXP
($$
,$2,T_EXIT
,1);}
2003 |
'@' expr
{ UEXP
($$
,$2,'@',1);}
2004 | scalar
{ $$
= $1; }
2005 | array_literal
{ $$
= $1; }
2006 | dict_literal
{ $$
= $1; }
2007 | vec_literal
{ $$
= $1; }
2008 | keyset_literal
{ $$
= $1; }
2009 | shape_literal
{ $$
= $1; }
2010 |
'`' backticks_expr
'`' { _p
->onEncapsList
($$
,'`',$2);}
2011 | T_PRINT expr
{ UEXP
($$
,$2,T_PRINT
,1);}
2012 | dim_expr
{ $$
= $1;}
2025 is_reference
'(' { Token t
;
2026 _p
->onNewLabelScope
(true
);
2027 _p
->onClosureStart
(t
);
2028 _p
->pushLabelInfo
(); }
2030 opt_return_type lambda_use_vars opt_return_type
2031 '{' inner_statement_list
'}' { _p
->finishStatement
($11, $11); $11 = 1;
2033 ClosureType
::Long
, nullptr
,
2034 $2,$5,$8,$11,$7,&$9);
2036 _p
->onCompleteLabelScope
(true
);}
2037 | non_empty_member_modifiers
2039 is_reference
'(' { Token t
;
2040 _p
->onNewLabelScope
(true
);
2041 _p
->onClosureStart
(t
);
2042 _p
->pushLabelInfo
(); }
2044 opt_return_type lambda_use_vars opt_return_type
2045 '{' inner_statement_list
'}' { _p
->finishStatement
($12, $12); $12 = 1;
2047 ClosureType
::Long
, &$1,
2048 $3,$6,$9,$12,$8,&$10);
2050 _p
->onCompleteLabelScope
(true
);}
2055 T_VARIABLE
{ _p
->pushFuncLocation
();
2057 _p
->onNewLabelScope
(true
);
2058 _p
->onClosureStart
(t
);
2059 _p
->pushLabelInfo
();
2061 _p
->onParam
($2,NULL
,u
,$2,0,
2063 lambda_body
{ Token v
; Token w
; Token x
;
2065 _p
->onMemberModifier
($1, nullptr
, $1);
2066 _p
->finishStatement
($4, $4); $4 = 1;
2067 $$
= _p
->onClosure
(ClosureType
::Short
,
2071 _p
->onCompleteLabelScope
(true
);}
2073 T_LAMBDA_OP
{ _p
->pushFuncLocation
();
2075 _p
->onNewLabelScope
(true
);
2076 _p
->onClosureStart
(t
);
2077 _p
->pushLabelInfo
();}
2081 lambda_body
{ Token u
; Token v
;
2083 _p
->onMemberModifier
($1, nullptr
, $1);
2084 _p
->finishStatement
($7, $7); $7 = 1;
2085 $$
= _p
->onClosure
(ClosureType
::Short
,
2089 _p
->onCompleteLabelScope
(true
);}
2091 '{' { _p
->pushFuncLocation
();
2093 _p
->onNewLabelScope
(true
);
2094 _p
->onClosureStart
(t
);
2095 _p
->pushLabelInfo
();}
2096 inner_statement_list
2097 '}' { Token u
; Token v
; Token w
; Token x
;
2100 _p
->onMemberModifier
($1, nullptr
, $1);
2101 _p
->finishStatement
($4, $4); $4 = 1;
2102 $$
= _p
->onClosure
(ClosureType
::Short
,
2106 _p
->onCompleteLabelScope
(true
);
2107 _p
->onCall
($$
,1,$$
,y
,NULL
);}
2108 | T_VARIABLE
{ _p
->pushFuncLocation
();
2110 _p
->onNewLabelScope
(true
);
2111 _p
->onClosureStart
(t
);
2112 _p
->pushLabelInfo
();
2114 _p
->onParam
($1,NULL
,u
,$1,0,
2116 lambda_body
{ Token v
; Token w
; Token x
;
2117 _p
->finishStatement
($3, $3); $3 = 1;
2118 $$
= _p
->onClosure
(ClosureType
::Short
,
2122 _p
->onCompleteLabelScope
(true
);}
2123 | T_LAMBDA_OP
{ _p
->pushFuncLocation
();
2125 _p
->onNewLabelScope
(true
);
2126 _p
->onClosureStart
(t
);
2127 _p
->pushLabelInfo
();}
2131 lambda_body
{ Token u
; Token v
;
2132 _p
->finishStatement
($6, $6); $6 = 1;
2133 $$
= _p
->onClosure
(ClosureType
::Short
,
2137 _p
->onCompleteLabelScope
(true
);}
2141 T_LAMBDA_ARROW expr
{ $$
= _p
->onExprForLambda
($2);}
2142 | T_LAMBDA_ARROW await_expr
{ $$
= _p
->onExprForLambda
($2);}
2144 '{' inner_statement_list
'}' { $$
= $3; }
2148 T_CONSTANT_ENCAPSED_STRING
{ validate_shape_keyname
($1, _p
);
2149 _p
->onScalar
($$
, T_CONSTANT_ENCAPSED_STRING
, $1); }
2150 | class_constant
{ $$
= $1; }
2153 non_empty_shape_pair_list:
2154 non_empty_shape_pair_list
','
2157 expr
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0); }
2160 expr
{ _p
->onArrayPair
($$
, 0,&$1,$3,0); }
2163 non_empty_static_shape_pair_list:
2164 non_empty_static_shape_pair_list
','
2167 static_expr
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0); }
2170 static_expr
{ _p
->onArrayPair
($$
, 0,&$1,$3,0); }
2174 non_empty_shape_pair_list
2175 possible_comma
{ $$
= $1; }
2179 static_shape_pair_list:
2180 non_empty_static_shape_pair_list
2181 possible_comma
{ $$
= $1; }
2186 T_SHAPE
'(' shape_pair_list
')' { _p
->onArray
($$
, $3, T_ARRAY
);}
2190 T_ARRAY
'(' array_pair_list
')' { _p
->onArray
($$
,$3,T_ARRAY
);}
2191 |
'[' array_pair_list
']' { _p
->onArray
($$
,$2,T_ARRAY
);}
2195 non_empty_dict_pair_list
2196 possible_comma
{ $$
= $1;}
2200 non_empty_dict_pair_list:
2201 non_empty_dict_pair_list
2202 ',' expr T_DOUBLE_ARROW expr
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0);}
2203 | expr T_DOUBLE_ARROW expr
{ _p
->onArrayPair
($$
, 0,&$1,$3,0);}
2204 | non_empty_dict_pair_list
2205 ',' expr T_DOUBLE_ARROW
2206 '&' variable
{ _p
->onArrayPair
($$
,&$1,&$3,$6,1);}
2207 | expr T_DOUBLE_ARROW
'&' variable
{ _p
->onArrayPair
($$
, 0,&$1,$4,1);}
2210 static_dict_pair_list:
2211 non_empty_static_dict_pair_list
2212 possible_comma
{ $$
= $1;}
2216 non_empty_static_dict_pair_list:
2217 non_empty_static_dict_pair_list
2218 ',' static_expr T_DOUBLE_ARROW
2219 static_expr
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0);}
2220 | static_expr T_DOUBLE_ARROW
2221 static_expr
{ _p
->onArrayPair
($$
, 0,&$1,$3,0);}
2224 static_dict_pair_list_ae:
2225 non_empty_static_dict_pair_list_ae
2226 possible_comma
{ $$
= $1;}
2230 non_empty_static_dict_pair_list_ae:
2231 non_empty_static_dict_pair_list_ae
2232 ',' static_scalar_ae T_DOUBLE_ARROW
2233 static_scalar_ae
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0);}
2234 | static_scalar_ae T_DOUBLE_ARROW
2235 static_scalar_ae
{ _p
->onArrayPair
($$
, 0,&$1,$3,0);}
2239 T_DICT
'[' dict_pair_list
']' { _p
->onDict
($$
, $3); }
2242 static_dict_literal:
2243 T_DICT
'[' static_dict_pair_list
']' { _p
->onDict
($$
, $3); }
2246 static_dict_literal_ae:
2247 T_DICT
'[' static_dict_pair_list_ae
']' { _p
->onDict
($$
, $3); }
2251 T_VEC
'[' vec_ks_expr_list
']' { _p
->onVec
($$
, $3); }
2255 T_VEC
'[' static_vec_ks_expr_list
']' { _p
->onVec
($$
, $3); }
2258 static_vec_literal_ae:
2259 T_VEC
'[' static_vec_ks_expr_list_ae
']' { _p
->onVec
($$
, $3); }
2263 T_KEYSET
'[' vec_ks_expr_list
']' { _p
->onKeyset
($$
, $3); }
2266 static_keyset_literal:
2267 T_KEYSET
'[' static_vec_ks_expr_list
']' { _p
->onKeyset
($$
, $3); }
2270 static_keyset_literal_ae:
2271 T_KEYSET
'[' static_vec_ks_expr_list_ae
']' { _p
->onKeyset
($$
, $3); }
2276 possible_comma
{ $$
= $1;}
2280 static_vec_ks_expr_list:
2282 possible_comma
{ $$
= $1;}
2286 static_vec_ks_expr_list_ae:
2287 static_scalar_ae_list
2288 possible_comma
{ $$
= $1;}
2293 fully_qualified_class_name
2294 '{' collection_init
'}' { Token t
;
2295 _p
->onName
(t
,$1,Parser
::StringName
);
2296 BEXP
($$
,t
,$3,T_COLLECTION
);}
2299 static_collection_literal:
2300 fully_qualified_class_name
2301 '{' static_collection_init
'}' { Token t
;
2302 _p
->onName
(t
,$1,Parser
::StringName
);
2303 BEXP
($$
,t
,$3,T_COLLECTION
);}
2308 '[' dim_offset
']' { _p
->onRefDim
($$
, $1, $3);}
2310 '[' dim_offset
']' { _p
->onRefDim
($$
, $1, $3);}
2314 array_literal
{ $$
= $1;}
2315 | dict_literal
{ $$
= $1;}
2316 | vec_literal
{ $$
= $1;}
2317 | keyset_literal
{ $$
= $1;}
2318 | class_constant
{ $$
= $1;}
2319 | lambda_or_closure_with_parens
{ $$
= $1;}
2320 | T_CONSTANT_ENCAPSED_STRING
{ _p
->onScalar
($$
,
2321 T_CONSTANT_ENCAPSED_STRING
, $1); }
2322 |
'(' expr_no_variable
')' { $$
= $2;}
2323 | T_STRING
{ $$
= $1;}
2327 lexical_var_list
',' T_VARIABLE
{ _p
->onClosureParam
($$
,&$1,$3,0);}
2328 | lexical_var_list
',' '&'T_VARIABLE
{ _p
->onClosureParam
($$
,&$1,$4,1);}
2329 | T_VARIABLE
{ _p
->onClosureParam
($$
, 0,$1,0);}
2330 |
'&' T_VARIABLE
{ _p
->onClosureParam
($$
, 0,$2,1);}
2337 T_XHP_TAG_GT
{ xhp_tag
(_p
,$$
,$2,$3);}
2340 xhp_attributes
'/' { Token t1
; _p
->onArray
(t1
,$1);
2341 Token t2
; _p
->onArray
(t2
,$2);
2342 Token file
; scalar_file
(_p
, file
);
2343 Token line
; scalar_line
(_p
, line
);
2344 _p
->onCallParam
($1,NULL
,t1
,0,0);
2345 _p
->onCallParam
($$
, &$1,t2
,0,0);
2346 _p
->onCallParam
($1, &$1,file
,0,0);
2347 _p
->onCallParam
($1, &$1,line
,0,0);
2349 | xhp_attributes T_XHP_TAG_GT
2350 xhp_children T_XHP_TAG_LT
'/'
2351 xhp_opt_end_label
{ Token file
; scalar_file
(_p
, file
);
2352 Token line
; scalar_line
(_p
, line
);
2355 _p
->onCallParam
($2,NULL
,$4,0,0);
2356 _p
->onCallParam
($$
, &$2,$5,0,0);
2357 _p
->onCallParam
($2, &$2,file
,0,0);
2358 _p
->onCallParam
($2, &$2,line
,0,0);
2359 $$.setText
($6.text
());}
2362 { $$.reset
(); $$.setText
("");}
2363 | T_XHP_LABEL
{ $$.reset
(); $$.setText
($1);}
2367 xhp_attribute_name
'='
2368 xhp_attribute_value
{ _p
->onArrayPair
($$
,&$1,&$2,$4,0);}
2372 xhp_children xhp_child
{ _p
->onArrayPair
($$
,&$1,0,$2,0);}
2376 T_XHP_LABEL
{ _p
->onScalar
($$
,
2377 T_CONSTANT_ENCAPSED_STRING
, $1);}
2379 xhp_attribute_value:
2380 T_XHP_TEXT
{ $1.xhpDecode
();
2382 T_CONSTANT_ENCAPSED_STRING
, $1);}
2383 |
'{' expr
'}' { $$
= $2;}
2386 T_XHP_TEXT
{ $$.reset
();
2387 if
($1.htmlTrim
()) {
2390 T_CONSTANT_ENCAPSED_STRING
, $1);
2393 |
'{' expr
'}' { $$
= $2; }
2394 | xhp_tag
{ $$
= $1; }
2398 xhp_bareword
{ $$
= $1;}
2400 xhp_bareword
{ $$
= $1 + ":" + $3;}
2402 xhp_bareword
{ $$
= $1 + "-" + $3;}
2406 ident_no_semireserved
{ $$
= $1;}
2407 | T_EXIT
{ $$
= $1;}
2408 | T_FUNCTION
{ $$
= $1;}
2409 | T_CONST
{ $$
= $1;}
2410 | T_RETURN
{ $$
= $1;}
2411 | T_YIELD
{ $$
= $1;}
2412 | T_YIELD_FROM
{ $$
= $1;}
2413 | T_AWAIT
{ $$
= $1;}
2415 | T_CATCH
{ $$
= $1;}
2416 | T_FINALLY
{ $$
= $1;}
2417 | T_THROW
{ $$
= $1;}
2419 | T_ELSEIF
{ $$
= $1;}
2420 | T_ENDIF
{ $$
= $1;}
2421 | T_ELSE
{ $$
= $1;}
2422 | T_WHILE
{ $$
= $1;}
2423 | T_ENDWHILE
{ $$
= $1;}
2426 | T_ENDFOR
{ $$
= $1;}
2427 | T_FOREACH
{ $$
= $1;}
2428 | T_ENDFOREACH
{ $$
= $1;}
2429 | T_DECLARE
{ $$
= $1;}
2430 | T_ENDDECLARE
{ $$
= $1;}
2431 | T_INSTANCEOF
{ $$
= $1;}
2433 | T_SWITCH
{ $$
= $1;}
2434 | T_ENDSWITCH
{ $$
= $1;}
2435 | T_CASE
{ $$
= $1;}
2436 | T_DEFAULT
{ $$
= $1;}
2437 | T_BREAK
{ $$
= $1;}
2438 | T_CONTINUE
{ $$
= $1;}
2439 | T_GOTO
{ $$
= $1;}
2440 | T_ECHO
{ $$
= $1;}
2441 | T_PRINT
{ $$
= $1;}
2442 | T_CLASS
{ $$
= $1;}
2443 | T_INTERFACE
{ $$
= $1;}
2444 | T_EXTENDS
{ $$
= $1;}
2445 | T_IMPLEMENTS
{ $$
= $1;}
2447 | T_CLONE
{ $$
= $1;}
2449 | T_EVAL
{ $$
= $1;}
2450 | T_INCLUDE
{ $$
= $1;}
2451 | T_INCLUDE_ONCE
{ $$
= $1;}
2452 | T_REQUIRE
{ $$
= $1;}
2453 | T_REQUIRE_ONCE
{ $$
= $1;}
2454 | T_NAMESPACE
{ $$
= $1;}
2456 | T_GLOBAL
{ $$
= $1;}
2457 | T_ISSET
{ $$
= $1;}
2458 | T_EMPTY
{ $$
= $1;}
2459 | T_HALT_COMPILER
{ $$
= $1;}
2460 | T_STATIC
{ $$
= $1;}
2461 | T_ABSTRACT
{ $$
= $1;}
2462 | T_FINAL
{ $$
= $1;}
2463 | T_PRIVATE
{ $$
= $1;}
2464 | T_PROTECTED
{ $$
= $1;}
2465 | T_PUBLIC
{ $$
= $1;}
2466 | T_ASYNC
{ $$
= $1;}
2467 | T_UNSET
{ $$
= $1;}
2468 | T_LIST
{ $$
= $1;}
2469 | T_ARRAY
{ $$
= $1;}
2470 | T_LOGICAL_OR
{ $$
= $1;}
2471 | T_LOGICAL_AND
{ $$
= $1;}
2472 | T_LOGICAL_XOR
{ $$
= $1;}
2473 | T_CLASS_C
{ $$
= $1;}
2474 | T_FUNC_C
{ $$
= $1;}
2475 | T_METHOD_C
{ $$
= $1;}
2476 | T_LINE
{ $$
= $1;}
2477 | T_FILE
{ $$
= $1;}
2479 | T_NS_C
{ $$
= $1;}
2480 | T_COMPILER_HALT_OFFSET
{ $$
= $1;}
2481 | T_TRAIT
{ $$
= $1;}
2482 | T_TRAIT_C
{ $$
= $1;}
2483 | T_INSTEADOF
{ $$
= $1;}
2484 | T_TYPE
{ $$
= $1;}
2485 | T_NEWTYPE
{ $$
= $1;}
2486 | T_SHAPE
{ $$
= $1;}
2489 simple_function_call:
2490 namespace_string_typeargs
'('
2491 function_call_parameter_list
')' { _p
->onCall
($$
,0,$1,$3,NULL
);}
2494 fully_qualified_class_name:
2495 class_namespace_string_typeargs
{ $$
= $1;}
2496 | T_XHP_LABEL
{ $1.xhpLabel
(); $$
= $1;}
2499 static_class_name_base:
2500 fully_qualified_class_name
{ _p
->onName
($$
,$1,Parser
::StringName
);}
2501 | common_scalar
{ _p
->onName
($$
,$1,Parser
::StringName
);}
2502 | T_STATIC
{ _p
->onName
($$
,$1,Parser
::StaticName
);}
2503 | reference_variable
{ _p
->onName
($$
,$1,
2504 Parser
::StaticClassExprName
);}
2505 |
'(' expr_no_variable
')' { _p
->onName
($$
,$2,
2506 Parser
::StaticClassExprName
);}
2508 static_class_name_no_calls:
2509 static_class_name_base
{ $$
= $1; }
2510 | static_class_name_no_calls
2518 { _p
->onStaticMember
($$
,$1,$3);}
2521 static_class_name_base
{ $$
= $1; }
2522 | class_method_call
{ _p
->onName
($$
,$1,
2523 Parser
::StaticClassExprName
);}
2532 { _p
->onStaticMember
($$
,$1,$3);}
2535 class_name_reference:
2536 fully_qualified_class_name
{ _p
->onName
($$
,$1,Parser
::StringName
);}
2537 | T_STATIC
{ _p
->onName
($$
,$1,Parser
::StaticName
);}
2538 | variable_no_calls
{ _p
->onName
($$
,$1,Parser
::ExprName
);}
2542 '(' ')' { $$.reset
();}
2543 | parenthesis_expr
{ $$
= $1;}
2548 /* empty */ { $$.reset
();}
2549 | T_ENCAPSED_AND_WHITESPACE
{ _p
->addEncap
($$
, NULL
, $1, 0);}
2550 | encaps_list
{ $$
= $1;}
2554 function_call_parameter_list
')' { $$
= $2;}
2559 T_LNUMBER
{ _p
->onScalar
($$
, T_LNUMBER
, $1);}
2560 | T_DNUMBER
{ _p
->onScalar
($$
, T_DNUMBER
, $1);}
2561 | T_ONUMBER
{ _p
->onScalar
($$
, T_ONUMBER
, $1);}
2562 | T_CONSTANT_ENCAPSED_STRING
{ _p
->onScalar
($$
,
2563 T_CONSTANT_ENCAPSED_STRING
, $1);}
2564 | T_LINE
{ _p
->onScalar
($$
, T_LINE
, $1);}
2565 | T_FILE
{ _p
->onScalar
($$
, T_FILE
, $1);}
2566 | T_DIR
{ _p
->onScalar
($$
, T_DIR
, $1);}
2567 | T_CLASS_C
{ _p
->onScalar
($$
, T_CLASS_C
, $1);}
2568 | T_TRAIT_C
{ _p
->onScalar
($$
, T_TRAIT_C
, $1);}
2569 | T_METHOD_C
{ _p
->onScalar
($$
, T_METHOD_C
, $1);}
2570 | T_FUNC_C
{ _p
->onScalar
($$
, T_FUNC_C
, $1);}
2571 | T_NS_C
{ _p
->onScalar
($$
, T_NS_C
, $1);}
2572 | T_COMPILER_HALT_OFFSET
{ _p
->onScalar
($$
, T_COMPILER_HALT_OFFSET
, $1);}
2574 T_ENCAPSED_AND_WHITESPACE
2575 T_END_HEREDOC
{ _p
->onScalar
($$
, T_CONSTANT_ENCAPSED_STRING
, $2);}
2577 T_END_HEREDOC
{ $$.setText
(""); _p
->onScalar
($$
, T_CONSTANT_ENCAPSED_STRING
, $$
);}
2581 common_scalar
{ $$
= $1;}
2582 | namespace_string
{ _p
->onConstantValue
($$
, $1);}
2584 static_array_pair_list
')' { _p
->onArray
($$
,$3,T_ARRAY
); }
2585 |
'[' static_array_pair_list
']' { _p
->onArray
($$
,$2,T_ARRAY
); }
2587 static_shape_pair_list
')' { _p
->onArray
($$
,$3,T_ARRAY
); }
2588 | static_dict_literal
{ $$
= $1;}
2589 | static_vec_literal
{ $$
= $1;}
2590 | static_keyset_literal
{ $$
= $1;}
2591 | static_class_constant
{ $$
= $1;}
2592 | static_collection_literal
{ $$
= $1;}
2593 |
'(' static_expr
')' { $$
= $2;}
2594 | static_expr T_BOOLEAN_OR
2595 static_expr
{ BEXP
($$
,$1,$3,T_BOOLEAN_OR
);}
2596 | static_expr T_BOOLEAN_AND
2597 static_expr
{ BEXP
($$
,$1,$3,T_BOOLEAN_AND
);}
2598 | static_expr T_LOGICAL_OR
2599 static_expr
{ BEXP
($$
,$1,$3,T_LOGICAL_OR
);}
2600 | static_expr T_LOGICAL_AND
2601 static_expr
{ BEXP
($$
,$1,$3,T_LOGICAL_AND
);}
2602 | static_expr T_LOGICAL_XOR
2603 static_expr
{ BEXP
($$
,$1,$3,T_LOGICAL_XOR
);}
2604 | static_expr
'|' static_expr
{ BEXP
($$
,$1,$3,'|');}
2605 | static_expr
'&' static_expr
{ BEXP
($$
,$1,$3,'&');}
2606 | static_expr
'^' static_expr
{ BEXP
($$
,$1,$3,'^');}
2607 | static_expr
'.' static_expr
{ BEXP
($$
,$1,$3,'.');}
2608 | static_expr
'+' static_expr
{ BEXP
($$
,$1,$3,'+');}
2609 | static_expr
'-' static_expr
{ BEXP
($$
,$1,$3,'-');}
2610 | static_expr
'*' static_expr
{ BEXP
($$
,$1,$3,'*');}
2611 | static_expr
'/' static_expr
{ BEXP
($$
,$1,$3,'/');}
2612 | static_expr
'%' static_expr
{ BEXP
($$
,$1,$3,'%');}
2613 | static_expr T_SL static_expr
{ BEXP
($$
,$1,$3,T_SL
);}
2614 | static_expr T_SR static_expr
{ BEXP
($$
,$1,$3,T_SR
);}
2615 | static_expr T_POW static_expr
{ BEXP
($$
,$1,$3,T_POW
);}
2616 |
'!' static_expr
{ UEXP
($$
,$2,'!',1);}
2617 |
'~' static_expr
{ UEXP
($$
,$2,'~',1);}
2618 |
'+' static_expr
{ UEXP
($$
,$2,'+',1);}
2619 |
'-' static_expr
{ UEXP
($$
,$2,'-',1);}
2620 | static_expr T_IS_IDENTICAL
2621 static_expr
{ BEXP
($$
,$1,$3,T_IS_IDENTICAL
);}
2622 | static_expr T_IS_NOT_IDENTICAL
2623 static_expr
{ BEXP
($$
,$1,$3,T_IS_NOT_IDENTICAL
);}
2624 | static_expr T_IS_EQUAL
2625 static_expr
{ BEXP
($$
,$1,$3,T_IS_EQUAL
);}
2626 | static_expr T_IS_NOT_EQUAL
2627 static_expr
{ BEXP
($$
,$1,$3,T_IS_NOT_EQUAL
);}
2628 | static_expr
'<' static_expr
{ BEXP
($$
,$1,$3,'<');}
2629 | static_expr T_IS_SMALLER_OR_EQUAL
2630 static_expr
{ BEXP
($$
,$1,$3,
2631 T_IS_SMALLER_OR_EQUAL
);}
2632 | static_expr
'>' static_expr
{ BEXP
($$
,$1,$3,'>');}
2634 T_IS_GREATER_OR_EQUAL
2635 static_expr
{ BEXP
($$
,$1,$3,
2636 T_IS_GREATER_OR_EQUAL
);}
2639 static_expr
{ BEXP
($$
,$1,$3,T_SPACESHIP
);}
2641 | static_expr
'?' static_expr
':'
2642 static_expr
{ _p
->onQOp
($$
, $1, &$3, $5);}
2643 | static_expr
'?' ':' static_expr
{ _p
->onQOp
($$
, $1, 0, $4);}
2647 static_expr_list
',' static_expr
{ _p
->onExprListElem
($$
, &$1, $3);}
2648 | static_expr
{ _p
->onExprListElem
($$
, NULL
, $1);}
2651 static_class_class_constant:
2652 fully_qualified_class_name
2654 T_CLASS
{ _p
->onClassClass
($$
, $1, $3, 1);}
2657 static_class_constant:
2658 fully_qualified_class_name
2660 ident_for_class_const
{ _p
->onClassConst
($$
, $1, $3, 1);}
2661 | static_class_class_constant
{ $$
= $1;}
2665 namespace_string
{ _p
->onConstantValue
($$
, $1);}
2666 | T_STRING_VARNAME
{ _p
->onConstantValue
($$
, $1);}
2667 | class_constant
{ $$
= $1;}
2668 | common_scalar
{ $$
= $1;}
2669 |
'"' encaps_list
'"' { _p
->onEncapsList
($$
,'"',$2);}
2670 |
'\'' encaps_list
'\'' { _p
->onEncapsList
($$
,'\'',$2);}
2671 | T_START_HEREDOC encaps_list
2672 T_END_HEREDOC
{ _p
->onEncapsList
($$
,T_START_HEREDOC
,
2675 static_array_pair_list:
2676 non_empty_static_array_pair_list
2677 possible_comma
{ $$
= $1;}
2686 ',' { only_in_hh_syntax
(_p
); $$.reset
();}
2690 non_empty_static_array_pair_list:
2691 non_empty_static_array_pair_list
2692 ',' static_expr T_DOUBLE_ARROW
2693 static_expr
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0);}
2694 | non_empty_static_array_pair_list
2695 ',' static_expr
{ _p
->onArrayPair
($$
,&$1, 0,$3,0);}
2696 | static_expr T_DOUBLE_ARROW
2697 static_expr
{ _p
->onArrayPair
($$
, 0,&$1,$3,0);}
2698 | static_expr
{ _p
->onArrayPair
($$
, 0, 0,$1,0);}
2702 T_LNUMBER
{ _p
->onScalar
($$
, T_LNUMBER
, $1);}
2703 | T_DNUMBER
{ _p
->onScalar
($$
, T_DNUMBER
, $1);}
2704 | T_ONUMBER
{ _p
->onScalar
($$
, T_ONUMBER
, $1);}
2706 T_ENCAPSED_AND_WHITESPACE
2707 T_END_HEREDOC
{ _p
->onScalar
($$
, T_CONSTANT_ENCAPSED_STRING
, $2);}
2709 T_END_HEREDOC
{ $$.setText
(""); _p
->onScalar
($$
, T_CONSTANT_ENCAPSED_STRING
, $$
);}
2711 static_numeric_scalar_ae:
2712 T_LNUMBER
{ _p
->onScalar
($$
,T_LNUMBER
,$1);}
2713 | T_DNUMBER
{ _p
->onScalar
($$
,T_DNUMBER
,$1);}
2714 | T_ONUMBER
{ _p
->onScalar
($$
,T_ONUMBER
,$1);}
2715 | ident_no_semireserved
{ constant_ae
(_p
,$$
,$1);}
2718 static_string_expr_ae:
2719 T_CONSTANT_ENCAPSED_STRING
{ _p
->onScalar
($$
,
2720 T_CONSTANT_ENCAPSED_STRING
,$1);}
2721 | T_CONSTANT_ENCAPSED_STRING
'.' static_string_expr_ae
2723 T_CONSTANT_ENCAPSED_STRING
,
2729 | static_string_expr_ae
{ $$
= $1;}
2730 | static_class_class_constant
{ $$
= $1;}
2731 | fully_qualified_class_name
2733 T_STRING
{ HPHP_PARSER_ERROR
("User-defined "
2734 "constants are not allowed in "
2735 "user attribute expressions", _p
);}
2736 | ident_no_semireserved
{ constant_ae
(_p
,$$
,$1);}
2737 |
'+' static_numeric_scalar_ae
{ UEXP
($$
,$2,'+',1);}
2738 |
'-' static_numeric_scalar_ae
{ UEXP
($$
,$2,'-',1);}
2740 static_array_pair_list_ae
')' { _p
->onArray
($$
,$3,T_ARRAY
);}
2741 |
'[' static_array_pair_list_ae
']' { _p
->onArray
($$
,$2,T_ARRAY
);}
2743 static_shape_pair_list_ae
')' { _p
->onArray
($$
,$3,T_ARRAY
); }
2744 | static_dict_literal_ae
{ $$
= $1;}
2745 | static_vec_literal_ae
{ $$
= $1;}
2746 | static_keyset_literal_ae
{ $$
= $1;}
2749 static_scalar_ae_list:
2750 static_scalar_ae_list
','
2751 static_scalar_ae
{ _p
->onExprListElem
($$
, &$1, $3);}
2752 | static_scalar_ae
{ _p
->onExprListElem
($$
, NULL
, $1);}
2755 static_array_pair_list_ae:
2756 non_empty_static_array_pair_list_ae
2757 possible_comma
{ $$
= $1;}
2760 non_empty_static_array_pair_list_ae:
2761 non_empty_static_array_pair_list_ae
2762 ',' static_scalar_ae T_DOUBLE_ARROW
2763 static_scalar_ae
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0);}
2764 | non_empty_static_array_pair_list_ae
2765 ',' static_scalar_ae
{ _p
->onArrayPair
($$
,&$1, 0,$3,0);}
2766 | static_scalar_ae T_DOUBLE_ARROW
2767 static_scalar_ae
{ _p
->onArrayPair
($$
, 0,&$1,$3,0);}
2768 | static_scalar_ae
{ _p
->onArrayPair
($$
, 0, 0,$1,0);}
2770 non_empty_static_scalar_list_ae:
2771 non_empty_static_scalar_list_ae
2772 ',' static_scalar_ae
{ _p
->onArrayPair
($$
,&$1, 0,$3,0);}
2773 | static_scalar_ae
{ _p
->onArrayPair
($$
, 0, 0,$1,0);}
2776 static_shape_pair_list_ae:
2777 non_empty_static_shape_pair_list_ae
2778 possible_comma
{ $$
= $1; }
2781 non_empty_static_shape_pair_list_ae:
2782 non_empty_static_shape_pair_list_ae
2784 T_DOUBLE_ARROW static_scalar_ae
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0); }
2787 static_scalar_ae
{ _p
->onArrayPair
($$
, 0,&$1,$3,0); }
2790 static_scalar_list_ae:
2791 non_empty_static_scalar_list_ae
2792 possible_comma
{ $$
= $1;}
2795 attribute_static_scalar_list:
2796 '(' static_scalar_list_ae
')' { _p
->onArray
($$
,$2,T_ARRAY
);}
2797 |
{ Token t
; t.reset
();
2798 _p
->onArray
($$
,t
,T_ARRAY
);}
2801 non_empty_user_attribute_list:
2802 non_empty_user_attribute_list
2803 ',' ident_no_semireserved
2804 attribute_static_scalar_list
{ _p
->onUserAttribute
($$
,&$1,$3,$4);}
2805 | ident_no_semireserved
2806 attribute_static_scalar_list
{ _p
->onUserAttribute
($$
, 0,$1,$2);}
2808 user_attribute_list:
2809 { only_in_hh_syntax
(_p
);}
2810 non_empty_user_attribute_list
2811 possible_comma
{ $$
= $2;}
2813 non_empty_user_attributes:
2814 T_SL user_attribute_list T_SR
{ $$
= $2;}
2816 optional_user_attributes:
2817 non_empty_user_attributes
{ $$
= $1;}
2822 T_OBJECT_OPERATOR
{ $$
= $1; $$
= 0;}
2823 | T_NULLSAFE_OBJECT_OPERATOR
{ $$
= $1; $$
= 1;}
2826 object_property_name_no_variables:
2827 ident_no_semireserved
{ $$
= $1; $$
= HPHP
::ObjPropNormal
;}
2828 | T_XHP_LABEL
{ $$
= $1; $$
= HPHP
::ObjPropXhpAttr
;}
2829 |
'{' expr
'}' { $$
= $2; $$
= HPHP
::ObjPropNormal
;}
2832 object_property_name:
2833 object_property_name_no_variables
{ $$
= $1;}
2835 | variable_no_objects
{ $$
= $1; $$
= HPHP
::ObjPropNormal
;}
2838 | compound_variable
{ $$
= $1; $$
= HPHP
::ObjPropNormal
;}
2842 object_method_name_no_variables:
2843 ident_no_semireserved
{ $$
= $1;}
2844 |
'{' expr
'}' { $$
= $2;}
2848 object_method_name_no_variables
{ $$
= $1;}
2850 | variable_no_objects
{ $$
= $1;}
2853 | compound_variable
{ $$
= $1;}
2858 '[' dim_offset
']' { $$
= $2;}
2859 |
'{' expr
'}' { $$
= $2;}
2862 dimmable_variable_access:
2863 dimmable_variable array_access
{ _p
->onRefDim
($$
, $1, $2);}
2864 |
'(' expr_with_parens
')'
2865 array_access
{ _p
->onRefDim
($$
, $2, $4);}
2868 dimmable_variable_no_calls_access:
2869 dimmable_variable_no_calls
2870 array_access
{ _p
->onRefDim
($$
, $1, $2);}
2871 |
'(' expr_with_parens
')'
2872 array_access
{ _p
->onRefDim
($$
, $2, $4);}
2875 object_property_access_on_expr:
2876 '(' expr_with_parens
')'
2878 object_property_name
{ _p
->onObjectProperty
(
2882 ? HPHP
::PropAccessType
::Normal
2883 : HPHP
::PropAccessType
::NullSafe
,
2887 |
'(' expr_no_variable
')'
2889 object_property_name
{ _p
->onObjectProperty
(
2893 ? HPHP
::PropAccessType
::Normal
2894 : HPHP
::PropAccessType
::NullSafe
,
2900 object_property_access_on_expr_no_variables:
2901 '(' expr_with_parens
')'
2903 object_property_name_no_variables
2904 { _p
->onObjectProperty
(
2908 ? HPHP
::PropAccessType
::Normal
2909 : HPHP
::PropAccessType
::NullSafe
,
2913 |
'(' expr_no_variable
')'
2915 object_property_name_no_variables
2916 { _p
->onObjectProperty
(
2920 ? HPHP
::PropAccessType
::Normal
2921 : HPHP
::PropAccessType
::NullSafe
,
2928 variable_no_objects
{ $$
= $1;}
2929 | simple_function_call
{ $$
= $1;}
2930 | object_method_call
{ $$
= $1;}
2931 | class_method_call
{ $$
= $1;}
2932 | dimmable_variable_access
{ $$
= $1;}
2933 | object_property_access_on_expr
{ $$
= $1;}
2934 | variable object_operator
2935 object_property_name
{ _p
->onObjectProperty
(
2939 ? HPHP
::PropAccessType
::Normal
2940 : HPHP
::PropAccessType
::NullSafe
,
2952 { _p
->onStaticMember
($$
,$1,$3);}
2953 | callable_variable
'('
2954 function_call_parameter_list
')' { _p
->onCall
($$
,1,$1,$3,NULL
);}
2955 | lambda_or_closure_with_parens
'('
2956 function_call_parameter_list
')' { _p
->onCall
($$
,1,$1,$3,NULL
);}
2957 |
'(' variable
')' { $$
= $2;}
2961 simple_function_call
{ $$
= $1;}
2962 | object_method_call
{ $$
= $1;}
2963 | class_method_call
{ $$
= $1;}
2964 | dimmable_variable_access
{ $$
= $1;}
2965 | variable object_operator
2967 object_property_name_no_variables
2970 object_property_name
2972 { _p
->onObjectProperty
(
2976 ? HPHP
::PropAccessType
::Normal
2977 : HPHP
::PropAccessType
::NullSafe
,
2981 | object_property_access_on_expr_no_variables
{ $$
= $1;}
2982 | callable_variable
'('
2983 function_call_parameter_list
')' { _p
->onCall
($$
,1,$1,$3,NULL
);}
2984 |
'(' variable
')' { $$
= $2;}
2988 compound_variable
{ _p
->onStaticMember
($$
,$1,$3);}
2993 variable_no_objects
{ $$
= $1;}
2994 | dimmable_variable_access
{ $$
= $1;}
2995 | simple_function_call
{ $$
= $1;}
2996 | array_literal
{ $$
= $1;}
2997 | common_scalar
{ $$
= $1;}
2998 |
'(' variable
')' { $$
= $2;}
2999 |
'(' expr_no_variable
')' { $$
= $2;}
3000 | lambda_or_closure_with_parens
'('
3001 function_call_parameter_list
')' { _p
->onCall
($$
,1,$1,$3,NULL
);}
3002 | callable_variable
'('
3003 function_call_parameter_list
')' { _p
->onCall
($$
,1,$1,$3,NULL
);}
3006 lambda_or_closure_with_parens:
3007 '(' lambda_or_closure
')' { $$
= $2;}
3011 closure_expression
{ $$
= $1;}
3012 | lambda_expression
{ $$
= $1;}
3016 variable object_operator
3017 object_method_name hh_typeargs_opt
'('
3018 function_call_parameter_list
')' { _p
->onObjectMethodCall
($$
,$1,$2.num
(),$3,$6);}
3019 |
'(' expr_with_parens
')'
3021 object_method_name hh_typeargs_opt
'('
3022 function_call_parameter_list
')' { _p
->onObjectMethodCall
($$
,$2,$4.num
(),$5,$8);}
3028 ident hh_typeargs_opt
'('
3029 function_call_parameter_list
')' { _p
->onCall
($$
,0,$3,$6,&$1);}
3033 variable_no_objects
'('
3036 compound_variable
'('
3038 function_call_parameter_list
')' { _p
->onCall
($$
,1,$3,$5,&$1);}
3042 function_call_parameter_list
')' { _p
->onCall
($$
,1,$4,$7,&$1);}
3045 variable_no_objects:
3046 reference_variable
{ $$
= $1;}
3048 | simple_indirect_reference
3049 reference_variable
{ _p
->onIndirectRef
($$
,$1,$2);}
3055 '[' dim_offset
']' { _p
->onRefDim
($$
, $1, $3);}
3056 | reference_variable
'{' expr
'}' { _p
->onRefDim
($$
, $1, $3);}
3057 | compound_variable
{ $$
= $1;}
3061 T_VARIABLE
{ _p
->onSimpleVariable
($$
, $1);}
3062 | T_PIPE_VAR
{ _p
->onPipeVariable
($$
);}
3063 |
'$' '{' expr
'}' { _p
->onDynamicVariable
($$
, $3, 0);}
3065 |
'$' compound_variable
{ $1 = 1; _p
->onIndirectRef
($$
, $1, $2);}
3075 simple_indirect_reference:
3077 | simple_indirect_reference
'$' { $$
++;}
3082 variable_no_objects
{ $$
= $1;}
3083 | dimmable_variable_no_calls_access
{ $$
= $1;}
3084 | object_property_access_on_expr
{ $$
= $1;}
3087 object_property_name
{ _p
->onObjectProperty
(
3091 ? HPHP
::PropAccessType
::Normal
3092 : HPHP
::PropAccessType
::NullSafe
,
3096 | static_class_name_no_calls
3098 variable_no_objects
{ _p
->onStaticMember
($$
,$1,$3);}
3099 |
'(' variable
')' { $$
= $2;}
3102 dimmable_variable_no_calls:
3103 | dimmable_variable_no_calls_access
{ $$
= $1;}
3104 | object_property_access_on_expr_no_variables
{ $$
= $1;}
3105 | variable_no_calls object_operator
3106 object_property_name_no_variables
3107 { _p
->onObjectProperty
(
3111 ? HPHP
::PropAccessType
::Normal
3112 : HPHP
::PropAccessType
::NullSafe
,
3116 |
'(' variable
')' { $$
= $2;}
3120 assignment_list
',' { _p
->onAListVar
($$
,&$1,NULL
);}
3121 | assignment_list
',' variable
{ _p
->onAListVar
($$
,&$1,&$3);}
3122 | assignment_list
','
3123 T_LIST
'(' assignment_list
')' { _p
->onAListSub
($$
,&$1,$5);}
3124 |
{ _p
->onAListVar
($$
,NULL
,NULL
);}
3125 | variable
{ _p
->onAListVar
($$
,NULL
,&$1);}
3126 | T_LIST
'(' assignment_list
')' { _p
->onAListSub
($$
,NULL
,$3);}
3130 non_empty_array_pair_list
3131 possible_comma
{ $$
= $1;}
3134 non_empty_array_pair_list:
3135 non_empty_array_pair_list
3136 ',' expr T_DOUBLE_ARROW expr
{ _p
->onArrayPair
($$
,&$1,&$3,$5,0);}
3137 | non_empty_array_pair_list
',' expr
{ _p
->onArrayPair
($$
,&$1, 0,$3,0);}
3138 | expr T_DOUBLE_ARROW expr
{ _p
->onArrayPair
($$
, 0,&$1,$3,0);}
3139 | expr
{ _p
->onArrayPair
($$
, 0, 0,$1,0);}
3140 | non_empty_array_pair_list
3141 ',' expr T_DOUBLE_ARROW
3142 '&' variable
{ _p
->onArrayPair
($$
,&$1,&$3,$6,1);}
3143 | non_empty_array_pair_list
','
3144 '&' variable
{ _p
->onArrayPair
($$
,&$1, 0,$4,1);}
3145 | expr T_DOUBLE_ARROW
'&' variable
{ _p
->onArrayPair
($$
, 0,&$1,$4,1);}
3146 |
'&' variable
{ _p
->onArrayPair
($$
, 0, 0,$2,1);}
3150 non_empty_collection_init
3151 possible_comma
{ $$
= $1;}
3152 |
{ _p
->onEmptyCollection
($$
);}
3154 non_empty_collection_init:
3155 non_empty_collection_init
3156 ',' expr T_DOUBLE_ARROW expr
{ _p
->onCollectionPair
($$
,&$1,&$3,$5);}
3157 | non_empty_collection_init
',' expr
{ _p
->onCollectionPair
($$
,&$1, 0,$3);}
3158 | expr T_DOUBLE_ARROW expr
{ _p
->onCollectionPair
($$
, 0,&$1,$3);}
3159 | expr
{ _p
->onCollectionPair
($$
, 0, 0,$1);}
3162 static_collection_init:
3163 non_empty_static_collection_init
3164 possible_comma
{ $$
= $1;}
3165 |
{ _p
->onEmptyCollection
($$
);}
3167 non_empty_static_collection_init:
3168 non_empty_static_collection_init
3169 ',' static_expr T_DOUBLE_ARROW
3170 static_expr
{ _p
->onCollectionPair
($$
,&$1,&$3,$5);}
3171 | non_empty_static_collection_init
3172 ',' static_expr
{ _p
->onCollectionPair
($$
,&$1, 0,$3);}
3173 | static_expr T_DOUBLE_ARROW
3174 static_expr
{ _p
->onCollectionPair
($$
, 0,&$1,$3);}
3175 | static_expr
{ _p
->onCollectionPair
($$
, 0, 0,$1);}
3179 encaps_list encaps_var
{ _p
->addEncap
($$
, &$1, $2, -1);}
3181 T_ENCAPSED_AND_WHITESPACE
{ _p
->addEncap
($$
, &$1, $2, 0);}
3182 | encaps_var
{ _p
->addEncap
($$
, NULL
, $1, -1);}
3183 | T_ENCAPSED_AND_WHITESPACE
3184 encaps_var
{ _p
->addEncap
($$
, NULL
, $1, 0);
3185 _p
->addEncap
($$
, &$$
, $2, -1); }
3189 T_VARIABLE
{ _p
->onSimpleVariable
($$
, $1);}
3191 encaps_var_offset
']' { _p
->encapRefDim
($$
, $1, $3);}
3192 | T_VARIABLE object_operator
3193 ident_no_semireserved
{ _p
->encapObjProp
(
3197 ? HPHP
::PropAccessType
::Normal
3198 : HPHP
::PropAccessType
::NullSafe
,
3202 | T_DOLLAR_OPEN_CURLY_BRACES
3203 expr
'}' { _p
->onDynamicVariable
($$
, $2, 1);}
3204 | T_DOLLAR_OPEN_CURLY_BRACES
3205 T_STRING_VARNAME
'[' expr
']' '}' { _p
->encapArray
($$
, $2, $4);}
3206 | T_CURLY_OPEN variable
'}' { $$
= $2;}
3209 ident_no_semireserved
{ $$
= $1; $$
= T_STRING
;}
3210 | T_NUM_STRING
{ $$
= $1; $$
= T_NUM_STRING
;}
3211 | T_VARIABLE
{ $$
= $1; $$
= T_VARIABLE
;}
3215 T_ISSET
'(' expr_list
')' { UEXP
($$
,$3,T_ISSET
,1);}
3216 | T_EMPTY
'(' variable
')' { UEXP
($$
,$3,T_EMPTY
,1);}
3217 | T_EMPTY
'(' expr_no_variable
')' { UEXP
($$
,$3,'!',1);}
3218 | T_EMPTY
'(' lambda_or_closure
')' { UEXP
($$
,$3,'!',1);}
3219 | T_EMPTY
'(' lambda_or_closure_with_parens
')' { UEXP
($$
,$3,'!',1);}
3220 | T_EMPTY
'(' expr_with_parens
')' { UEXP
($$
,$3,'!',1);}
3221 | T_INCLUDE expr
{ UEXP
($$
,$2,T_INCLUDE
,1);}
3222 | T_INCLUDE_ONCE expr
{ UEXP
($$
,$2,T_INCLUDE_ONCE
,1);}
3223 | T_EVAL
'(' expr
')' { UEXP
($$
,$3,T_EVAL
,1);}
3224 | T_REQUIRE expr
{ UEXP
($$
,$2,T_REQUIRE
,1);}
3225 | T_REQUIRE_ONCE expr
{ UEXP
($$
,$2,T_REQUIRE_ONCE
,1);}
3229 variable
{ _p
->onExprListElem
($$
, NULL
, $1);}
3230 | variable_list
',' variable
{ _p
->onExprListElem
($$
, &$1, $3);}
3235 T_DOUBLE_COLON ident_for_class_const
{ _p
->onClassConst
($$
, $1, $3, 0);}
3237 T_DOUBLE_COLON T_CLASS
{ _p
->onClassClass
($$
, $1, $3, 0);}
3240 /* hack productions -- these allow some extra stuff in hack
3241 * mode, but simplify down to the original thing
3249 hh_type_alias_statement:
3250 T_TYPE hh_name_no_semireserved_with_typevar
3251 '=' hh_type
';' { $2.setText
(_p
->nsClassDecl
($2.text
()));
3252 _p
->onTypedef
($$
, $2, $4);
3253 _p
->popTypeScope
(); }
3254 | non_empty_user_attributes
3255 T_TYPE hh_name_no_semireserved_with_typevar
3256 '=' hh_type
';' { $3.setText
(_p
->nsClassDecl
($3.text
()));
3257 _p
->onTypedef
($$
, $3, $5, &$1);
3258 _p
->popTypeScope
(); }
3259 | T_NEWTYPE hh_name_no_semireserved_with_typevar
3260 hh_opt_constraint
'=' hh_type
';' { $2.setText
(_p
->nsClassDecl
($2.text
()));
3261 _p
->onTypedef
($$
, $2, $5);
3262 _p
->popTypeScope
(); }
3263 | non_empty_user_attributes
3264 T_NEWTYPE hh_name_no_semireserved_with_typevar
3265 hh_opt_constraint
'=' hh_type
';' { $3.setText
(_p
->nsClassDecl
($3.text
()));
3266 _p
->onTypedef
($$
, $3, $6, &$1);
3267 _p
->popTypeScope
(); }
3270 hh_name_with_type: /* foo -> int foo */
3272 | hh_type ident
{ only_in_hh_syntax
(_p
); $$
= $2; }
3275 hh_constname_with_type: /* foo -> int foo, but in class constants */
3276 ident_for_class_const
{ $$
= $1; }
3277 | hh_type ident_for_class_const
{ only_in_hh_syntax
(_p
); $$
= $2; }
3280 hh_name_with_typevar: /* foo -> foo<X,Y>; this adds a typevar
3281 * scope and must be followed by a call to
3283 ident
{ _p
->pushTypeScope
(); $$
= $1; }
3287 T_TYPELIST_GT
{ _p
->pushTypeScope
(); $$
= $1; }
3290 hh_name_no_semireserved_with_typevar: /* foo -> foo<X,Y>; this adds a typevar
3291 * scope and must be followed by a call
3292 * to popTypeScope() */
3293 ident_no_semireserved
{ _p
->pushTypeScope
(); $$
= $1; }
3294 | ident_no_semireserved
3297 T_TYPELIST_GT
{ Token t
; _p
->setTypeVars
(t
, $1);
3298 _p
->pushTypeScope
(); $$
= t
; }
3304 T_TYPELIST_GT
{ $$
= $2; }
3308 hh_non_empty_type_list:
3309 hh_type
{ Token t
; t.reset
();
3310 _p
->onTypeList
($1, t
);
3312 | hh_non_empty_type_list
',' hh_type
{ _p
->onTypeList
($1, $3);
3317 hh_non_empty_type_list
3318 possible_comma
{ $$
= $1; }
3322 hh_non_empty_type_list
3323 ',' T_ELLIPSIS
{ $$
= $1; }
3324 | hh_type_list
{ $$
= $1; }
3325 | T_ELLIPSIS
{ $$.reset
(); }
3329 opt_type_constraint_where_clause:
3332 non_empty_constraint_list
3336 non_empty_constraint_list:
3337 hh_generalised_constraint
3338 | non_empty_constraint_list
',' hh_generalised_constraint
3341 hh_generalised_constraint:
3343 | hh_type hh_constraint
3348 |
':' hh_type
{ $$
= $2; $$
= 1; }
3356 hh_non_empty_typevar_list
3357 possible_comma
{ $$
= $1; }
3360 hh_non_empty_constraint_list:
3362 | hh_non_empty_constraint_list hh_constraint
3365 hh_non_empty_typevar_list:
3366 hh_non_empty_typevar_list
','
3368 ident_no_semireserved
{ _p
->addTypeVar
($4.text
()); }
3369 | hh_typevar_variance
3370 ident_no_semireserved
{ _p
->addTypeVar
($2.text
()); }
3371 | hh_non_empty_typevar_list
','
3373 ident_no_semireserved
3374 hh_non_empty_constraint_list
{ _p
->addTypeVar
($4.text
()); }
3375 | hh_typevar_variance
3376 ident_no_semireserved
3377 hh_non_empty_constraint_list
{ _p
->addTypeVar
($2.text
()); }
3380 hh_typevar_variance:
3386 hh_shape_member_type:
3387 T_CONSTANT_ENCAPSED_STRING
3389 hh_type
{ validate_shape_keyname
($1, _p
);
3390 _p
->onTypeAnnotation
($$
, $1, $3); }
3392 T_CONSTANT_ENCAPSED_STRING
3395 /* should not reach here as
3396 * optional shape fields are not
3397 * supported in strict mode */
3398 validate_shape_keyname
($2, _p
);
3399 _p
->onTypeAnnotation
($$
, $2, $4);
3401 | class_namespace_string_typeargs
3403 ident_no_semireserved
3405 hh_type
{ _p
->onClsCnsShapeField
($$
, $1, $3, $5); }
3408 hh_non_empty_shape_member_list:
3409 hh_non_empty_shape_member_list
','
3410 hh_shape_member_type
{ _p
->onTypeList
($$
, $3); }
3411 | hh_shape_member_type
{ }
3414 hh_shape_member_list:
3415 hh_non_empty_shape_member_list
3416 possible_comma
{ _p
->onShape
($$
, $1); }
3417 |
/* empty */ { Token t
; t.reset
();
3418 _p
->onShape
($$
, t
); }
3423 '(' hh_shape_member_list
')' { $$
= $3;
3424 $$.setText
("array"); }
3427 hh_access_type_start:
3428 class_namespace_string_typeargs
{ $$
= $1; }
3431 ident_no_semireserved
3433 hh_access_type
{ Token t
; t.reset
();
3434 _p
->onTypeAnnotation
($$
, $1, t
);
3435 _p
->onTypeList
($$
, $3); }
3436 | ident_no_semireserved
3437 hh_typeargs_opt
{ _p
->onTypeAnnotation
($$
, $1, $2); }
3441 T_TYPELIST_LT hh_type
3442 possible_comma T_TYPELIST_GT
{ $$
= $2;}
3443 | T_TYPELIST_LT hh_type
','
3444 hh_type T_TYPELIST_GT
{ _p
->onTypeList
($2, $4); $$
= $2;}
3446 /* extends non_empty_type_decl with some more types */
3448 /* double-optional types will be rejected by the typechecker; we
3449 * already allow plenty of nonsense types anyway */
3450 '?' hh_type
{ only_in_hh_syntax
(_p
);
3451 _p
->onTypeSpecialization
($2, '?');
3453 |
'@' hh_type
{ only_in_hh_syntax
(_p
);
3454 _p
->onTypeSpecialization
($2, '@');
3456 | class_namespace_string_typeargs
{ $$
= $1; }
3457 | T_ARRAY
{ Token t
; t.reset
();
3458 $1.setText
("array");
3459 _p
->onTypeAnnotation
($$
, $1, t
); }
3460 | T_CALLABLE
{ Token t
; t.reset
();
3461 $1.setText
("callable");
3462 _p
->onTypeAnnotation
($$
, $1, t
); }
3463 | hh_shape_type
{ $$
= $1; }
3464 | hh_access_type_start
3466 hh_access_type
{ only_in_hh_syntax
(_p
);
3467 _p
->onTypeAnnotation
($$
, $1, $3);
3468 _p
->onTypeSpecialization
($$
, 'a'); }
3469 | T_ARRAY array_typelist
{ $1.setText
("array");
3470 _p
->onTypeAnnotation
($$
, $1, $2); }
3471 | T_XHP_LABEL
{ $1.xhpLabel
();
3473 _p
->onTypeAnnotation
($$
, $1, t
);
3474 _p
->onTypeSpecialization
($$
, 'x'); }
3476 '(' hh_func_type_list
')'
3477 ':' hh_type
')' { only_in_hh_syntax
(_p
);
3478 _p
->onTypeList
($7, $4);
3479 _p
->onTypeAnnotation
($$
, $2, $7);
3480 _p
->onTypeSpecialization
($$
, 'f'); }
3482 hh_non_empty_type_list
3483 possible_comma
')' { only_in_hh_syntax
(_p
);
3484 _p
->onTypeList
($2, $4);
3485 Token t
; t.reset
(); t.setText
("array");
3486 _p
->onTypeAnnotation
($$
, t
, $2);
3487 _p
->onTypeSpecialization
($$
, 't'); }
3491 hh_type
{ $$
= $1; }
3497 bool Parser
::parseImpl5
() {
3500 bool Parser
::parseImpl7
() {
3502 return
yyparse(this
) == 0;