Closed sisshiki1969 closed 5 years ago
Since https://github.com/maekawatoshiki/rapidus/commit/6092927c3b6e979cfb646f745cf68a5580e5c769,
let i = 1 + (x) => x
causes error. The other one doesn't, though.
Since https://github.com/maekawatoshiki/rapidus/commit/ae3ef536659533a1a4bba99e7fdb3d7f35b77454, all the examples you show cause syntax error. In addition: since 747e4e43357568d5293da533659170468902e0ea, test error fixed.
However my code looks so horrible. Do you have any idea to simplify my code?
Maybe u can use my parser, but not finished yet:D https://github.com/LuoZijun/es/tree/master/src/parser
@LuoZijun It seems I can get some hints from your code. Thank you.
@maekawatoshiki
It's not easy to implement a complete ECMAScript language parser, and there's too much work to do:)
The syntax of arrow function "(a, b, c) => {}" is very similar to that of ParenthesizedExpression with comma operator "(a, b, c)", which is a variant of PrimaryExpression. Thus, a backtracking in parser is inevitable. I am trying to modify the lexer to suit backtracking.
https://tc39.github.io/ecma262/#prod-CoverParenthesizedExpressionAndArrowParameterList https://tc39.github.io/ecma262/#prod-ArrowParameters
In ECMA spec, an ArrowFunction is a variant of an AssignmentExpression. But in rapidus, an arrow function is parsed as a variant of a primary expression. Thus, the parser can not detect a syntax error in such a code as follows.