Skip to content

fixed state handling in lexer #972

Merged
merged 5 commits into from Apr 9, 2013

3 participants

@guyzmo
guyzmo commented Mar 28, 2013

When looking ahead with a peek loop, the parser calls lexer.token() and pushes the result in a stack, that gets unstacked when using advance().

But the lexer also checks the environment using the state global to raise environment dependent lexing warnings or errors.

That's where there is a design flaw: if the parser peek()s to determine whether the upcoming expression or statements has to change or not the environment, but the lexer needs the environment to be updated in order to trigger correct checks, some warnings/erros will always be raised and others will never be.

That has been a problem with jsonMode, and {/[ syntax determination in destructuringAssignOrJsonValue() and again with fat arrow support.

That's why here is an implementation of trigger_async, that updates an array of function checks that gets tied to the current token, and ran by the parser in the advance() function.

guyzmo added some commits Mar 22, 2013
@guyzmo guyzmo added A LOT of tests
renamed isMozOrESNext to isAfterESNext;
added isAfterES5;
refactored ESnext/Moz support to raise errors on future features;
fixed several parsing issues

Signed-off-by: Bernard `Guyzmo` Pratz <guyzmo+github@m0g.net>
e9e8186
@guyzmo guyzmo updated automatic comma insertion support (cf #950) 2980237
@guyzmo guyzmo added line breaking error on 'return' statement with and without asi …
…option (when it's broken, fix it).
38d14b4
@guyzmo guyzmo added es3 config option and updated tests to match es3 ;
made es5 the default and updated tests to remove es5 ;
added info message to tell about es5 being default ;
added functions to encapsulate management of current version state

Signed-off-by: Bernard `Guyzmo` Pratz <guyzmo+github@m0g.net>
c001e7c
@guyzmo guyzmo added support for asynchronous triggers defined in the lexer, but lau…
…nched in the parser for correct state context handling.

removed jsonMode/jsonWarnings hacks for JSON parsing

Signed-off-by: Bernard `Guyzmo` Pratz <guyzmo+github@m0g.net>
86e32f1
@valueof valueof merged commit 86e32f1 into jshint:master Apr 9, 2013

1 check passed

Details default The Travis build passed
@guyzmo guyzmo deleted the guyzmo:trigger_async branch Apr 10, 2013
@mishoo

This line fails when you have custom methods added to the Array.prototype. Could we change it to a plain for (instead of for-in?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.