parser and codegen changes for XHP spread operator
commit4897137505f864c7d8d30d5449a49f541282b4b4
authorNick Gavalas <njg@fb.com>
Fri, 17 Nov 2017 20:53:37 +0000 (17 12:53 -0800)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Fri, 17 Nov 2017 21:13:44 +0000 (17 13:13 -0800)
tree0454323a6aa6ee492dac409c323f14f512e11a5b
parente693551c0387eb2c15be5b741ad205d074df2ce4
parser and codegen changes for XHP spread operator

Summary:
HHVM parses XHP creation as if it were actually a `new xhp__foo_bar(...)` call. We need to augment the attribute array to include consecutively numbered spreads (so the array keys are unique and the runtime can properly expand each spread), which requires a small stack of ints every time we descend into a new XHP while parsing an attribute list. In practice, it doesn't really offer much value to spread an XHP literal, because one could have just written the attributes manually in the first place, but there's no reason to disallow such constructs.

There is some very special cases in the lexer state machine to figure out if we are in an XHP tag or not (which triggers different token emission), so I had to allow for `{` as the next token for identifying XHP state.

Reviewed By: paulbiss

Differential Revision: D6326686

fbshipit-source-id: e146097f317bb711ff157a3201908e12328f097f
15 files changed:
hphp/compiler/parser/parser.cpp
hphp/compiler/parser/parser.h
hphp/parser/hphp.5.tab.cpp
hphp/parser/hphp.7.tab.cpp
hphp/parser/hphp.ll
hphp/parser/hphp.y
hphp/parser/lex.yy.cpp
hphp/runtime/ext/factparse/parser.cpp
hphp/runtime/ext/factparse/parser.h
hphp/test/slow/xhp/xhp_spread.php [new file with mode: 0644]
hphp/test/slow/xhp/xhp_spread.php.expectf [new file with mode: 0644]
hphp/test/slow/xhp/xhp_spread_default.php [new file with mode: 0644]
hphp/test/slow/xhp/xhp_spread_default.php.expectf [new file with mode: 0644]
hphp/test/slow/xhp/xhp_spread_nested.php [new file with mode: 0644]
hphp/test/slow/xhp/xhp_spread_nested.php.expectf [new file with mode: 0644]