Currently in the process of developing a JavaScript/ECMAScript 5.1 parser using JavaCC and encountering challenges with the ArrayLiteral production.
ArrayLiteral :
[ Elision_opt ]
[ ElementList ]
[ ElementList , Elision_opt ]
ElementList :
Elision_opt AssignmentExpression
ElementList , Elision_opt AssignmentExpression
Elision :
,
Elision ,
Three questions will be addressed individually:
An attempt was made to simplify/rewrite the ArrayLiteral
production as shown below (pseudo-grammar):
ArrayLiteral:
"[" ("," | AssignmentExpression ",") * AssignmentExpression ? "]"
Question 1: Is this rewriting accurate?
Other inquiries include:
- LOOKAHEADs for the JavaScript/ECMAScript array literal production
- How to implement a negative LOOKAHEAD check for a token in JavaCC?