Closed sebmck closed 9 years ago
Ping @RReverser
Why? I think it can be adapted to new tokenizer as well.
Probably, the history is messed up so it'd be easier to just create another PR.
Not sure what to do as the new JSX implementation breaks var identity: <T>(x: T, ...y:T[]) => T
and many more, <T>
is parsing as a JSX tag.
You have to inject into the place where JSX expression is being started (https://github.com/RReverser/acorn-jsx/blob/master/acorn.js#L707) and change it to conditionally start either JSX expression or type generic based on previous token / parent context / whatever needed.
@RReverser I see that _lt
and _gt
was changed to a general _relational
, how do I determine which is which?
Nevermind. tokVal
, duh.
It was relational
initially, now it's just back to it in contexts where relational operator is allowed, or jsxTagStart
/ jsxTagEnd
when should be tag boundary. This is the main benefit of new approach - any disambiguation is performed on tokenizer level, so 1) you can use it independently when needed (i.e. for highlighting) and 2) in parser funcs you get valid tokens for each given context and ready to be consumed.
Most of this is a 1:1 mapping from esprima-fb. There are only two things that I haven't implemented due to not knowing the best way, this is types within arrow function parameters and the postfix for paranthesized primary types.
Apologies if the code is a bit janky, let me know if you want me to make any revisions.