rusty-ecma / RESSA

Rusty EcmaScript Syntax Analyzer
MIT License
111 stars 14 forks source link

Added optional chaining operator support #93

Open Fee0 opened 7 months ago

Fee0 commented 7 months ago

for normal indexing, computed indexing and function calls

Fee0 commented 7 months ago

moved some parsing code to extra functions to avoid duplicated code in case of parsing as optional or without optional operator

Fee0 commented 7 months ago

found some code that does not parse correctly:

function a(t){
    return 'normal' === t?.123:'fast' === t?.321:t
}

it seems this is a ternary operator + specification of a floating point number without the leading zero, which gets interpreted as the optional chaining operator now.

I wonder if we have to look ahead now for the matching ":" and then decide if its ternary or optional chaining operator.

FreeMasen commented 7 months ago

Good catch! I think we we might be able to get away with a check that the character after ?. is an ident_start. I can try and play around with that in ress this weekend

Fee0 commented 7 months ago

Ah, I thought its actually from my RESSA code. I gave it a try to fix this: https://github.com/rusty-ecma/RESS/pull/101