Remove syntax node introspection from the parser after it was parsed
commit120e028a84056279b9b6cdb9365e92dbb88bf924
authorRuslan Sakevych <ruslans@fb.com>
Mon, 12 Feb 2018 13:23:13 +0000 (12 05:23 -0800)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Mon, 12 Feb 2018 13:27:09 +0000 (12 05:27 -0800)
treef08f002b1e77c6da5ea0e26b49f0c9ddb1b79e59
parent3a44e3dcab6a298b2d304bda242137bde1ae17d0
Remove syntax node introspection from the parser after it was parsed

Summary:
We are using "hacky" tricks to remove inspection of the node after it was created. Some of the cases were trivial like returning additional `Token.t` along with `Syntax.t` so that we can make some decision based on the former one.

Changing `PrefixUnaryExpression` was the hardest one. I had to store(cache) necessary information in the module state each time `make_prefix_unary_expression` was called, so that functions afterwards could inspect it.

Better datastructure for caching prefix unary expressions would be map/hashtable, but in our case is simple enough to just use list and iterate.

Differential Revision: D6890521

fbshipit-source-id: 4b6a130819a141d7699765ff2eed6f615834b7c2
hphp/hack/src/parser/full_fidelity_declaration_parser.ml
hphp/hack/src/parser/full_fidelity_expression_parser.ml
hphp/hack/src/parser/full_fidelity_parser_helpers.ml
hphp/hack/src/parser/full_fidelity_precedence_parser.ml
hphp/hack/src/parser/full_fidelity_statement_parser.ml
hphp/hack/src/parser/full_fidelity_statement_parser_type.ml