Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange code in JavaScript - PredictionContext.js line 191 #1280

Closed
shds86 opened this issue Sep 14, 2016 · 2 comments
Closed

Strange code in JavaScript - PredictionContext.js line 191 #1280

shds86 opened this issue Sep 14, 2016 · 2 comments

Comments

@shds86
Copy link
Contributor

shds86 commented Sep 14, 2016

Hi.
I searched some ways for optimization in ANTLR for JavaScript and found one strange line in code:

if (this.returnState === this.EMPTY_RETURN_STATE) {

I researched like SingletonPredictionContext class implemented. I don't sure but SingletonPredictionContext doesn't have property EMPTY_RETURN_STATE always because PredictionContext.call(this, hashString); (
PredictionContext.call(this, hashString);
) doesn't give this property to SingletonPredictionContext. .call(this,...) doesn't translate properties from prototype to children. Need to use Object.create or PredictionContext.EMPTY_RETURN_STATE in line 191 for this.

Does it a bug or mistake or typo?

@ericvergnaud
Copy link
Contributor

Indeed this is a typo, the code should read PredictionContext.EMPTY_RETURN_STATE
Thanks for pointing this, however Not sure it has any impact on performance

Envoyé de mon iPhone

Le 14 sept. 2016 à 15:34, DimKO notifications@github.com a écrit :

Hi.
I searched some ways for optimization in ANTLR for JavaScript and found one strange line in code:

if (this.returnState === this.EMPTY_RETURN_STATE) {

I researched like SingletonPredictionContext class implemented. I don't sure but SingletonPredictionContext doesn't have property EMPTY_RETURN_STATE always because PredictionContext.call(this, hashString); (
PredictionContext.call(this, hashString);
) doesn't give this property to SingletonPredictionContext. .call(this,...) doesn't translate properties from prototype to children. Need to use Object.create or PredictionContext.EMPTY_RETURN_STATE in line 191 for this.

Does it a bug or mistake or typo?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@shds86
Copy link
Contributor Author

shds86 commented Sep 14, 2016

You are right, it has not impact on performance. I just found the typo. But it can have impact on algorithm and logic. Not sure, need more research.
Thanks.

Live long and prosper //

@parrt parrt added this to the 4.6 milestone Nov 22, 2016
@parrt parrt closed this as completed in ace7758 Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants