Skip to content

Remove all function expression allocations when speculatively parsing or looking ahead.#1368

Merged
CyrusNajmabadi merged 6 commits into
masterfrom
parseErrors
Dec 4, 2014
Merged

Remove all function expression allocations when speculatively parsing or looking ahead.#1368
CyrusNajmabadi merged 6 commits into
masterfrom
parseErrors

Conversation

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Also, make speculative parsing much more flexible. It now no longer always rewinds just because an error was encountered during parsing. Instead, the speculative method has full control over deciding if rewinding is necessary or not. (Note: this flexibility was necessary to be able to remove the function expression allocations).

We now no longer fail a speculative parse just because an error was encountered at any point while
speculating.  instead, we allow the speculative function that is being called to determine if the
parse was successful or not.  Only if it decides it was not successful is parsing rewound.

This improves our error recovery in several cases (esp. around arrow functions).  it will also
help in a followup refactoring to prevent lookahead/speculative parsing from causing lambda
allocations.
…ooking ahead.

Also, remove unnecessary grammar check now that the previous hack to insert a
missing type argument node has been removed.
Comment thread src/compiler/parser.ts Outdated
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

er. will fix comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are no longer thrown off by the errant token after the comma. Instead, we still properly recognize this as a generic function call.

@JsonFreeman JsonFreeman changed the title Reduce all function expression allocations when speculatively parsing or looking ahead. Remove all function expression allocations when speculatively parsing or looking ahead. Dec 4, 2014
@JsonFreeman
Copy link
Copy Markdown
Contributor

👍

Comment thread src/compiler/parser.ts Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flags

CyrusNajmabadi added a commit that referenced this pull request Dec 4, 2014
Remove all function expression allocations when speculatively parsing or looking ahead.
@CyrusNajmabadi CyrusNajmabadi merged commit 824edea into master Dec 4, 2014
@CyrusNajmabadi CyrusNajmabadi deleted the parseErrors branch December 4, 2014 20:35
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants