@@ -22,6 +22,7 @@ module Language.JavaScript.Parser.AST
22
22
, JSArrayElement (.. )
23
23
, JSCommaList (.. )
24
24
, JSCommaTrailingList (.. )
25
+ , JSArrowParameterList (.. )
25
26
26
27
-- Modules
27
28
, JSModuleItem (.. )
@@ -175,7 +176,7 @@ data JSExpression
175
176
| JSExpressionParen ! JSAnnot ! JSExpression ! JSAnnot -- ^ lb,expression,rb
176
177
| JSExpressionPostfix ! JSExpression ! JSUnaryOp -- ^ expression, operator
177
178
| JSExpressionTernary ! JSExpression ! JSAnnot ! JSExpression ! JSAnnot ! JSExpression -- ^ cond, ?, trueval, :, falseval
178
- | JSArrowExpression ! JSAnnot ! ( JSCommaList JSIdent ) ! JSAnnot ! JSAnnot ! JSStatement -- ^ parameter list,arrow,block`
179
+ | JSArrowExpression ! JSArrowParameterList ! JSAnnot ! JSStatement -- ^ parameter list,arrow,block`
179
180
| JSFunctionExpression ! JSAnnot ! JSIdent ! JSAnnot ! (JSCommaList JSIdent ) ! JSAnnot ! JSBlock -- ^ fn,name,lb, parameter list,rb,block`
180
181
| JSMemberDot ! JSExpression ! JSAnnot ! JSExpression -- ^ firstpart, dot, name
181
182
| JSMemberExpression ! JSExpression ! JSAnnot ! (JSCommaList JSExpression ) ! JSAnnot -- expr, lb, args, rb
@@ -188,6 +189,11 @@ data JSExpression
188
189
| JSVarInitExpression ! JSExpression ! JSVarInitializer -- ^ identifier, initializer
189
190
deriving (Data , Eq , Show , Typeable )
190
191
192
+ data JSArrowParameterList
193
+ = JSUnparenthesizedArrowParameter ! JSIdent
194
+ | JSParenthesizedArrowParameterList ! JSAnnot ! (JSCommaList JSIdent ) ! JSAnnot
195
+ deriving (Data , Eq , Show , Typeable )
196
+
191
197
data JSBinOp
192
198
= JSBinOpAnd ! JSAnnot
193
199
| JSBinOpBitAnd ! JSAnnot
@@ -373,7 +379,7 @@ instance ShowStripped JSExpression where
373
379
ss (JSExpressionParen _lp x _rp) = " JSExpressionParen (" ++ ss x ++ " )"
374
380
ss (JSExpressionPostfix xs op) = " JSExpressionPostfix (" ++ ss op ++ " ," ++ ss xs ++ " )"
375
381
ss (JSExpressionTernary x1 _q x2 _c x3) = " JSExpressionTernary (" ++ ss x1 ++ " ," ++ ss x2 ++ " ," ++ ss x3 ++ " )"
376
- ss (JSArrowExpression _ n _ _ e) = " JSArrowExpression (" ++ ss n ++ " ) => " ++ ss e
382
+ ss (JSArrowExpression ps _ e) = " JSArrowExpression (" ++ ss ps ++ " ) => " ++ ss e
377
383
ss (JSFunctionExpression _ n _lb pl _rb x3) = " JSFunctionExpression " ++ ssid n ++ " " ++ ss pl ++ " (" ++ ss x3 ++ " ))"
378
384
ss (JSHexInteger _ s) = " JSHexInteger " ++ singleQuote s
379
385
ss (JSOctal _ s) = " JSOctal " ++ singleQuote s
@@ -392,6 +398,10 @@ instance ShowStripped JSExpression where
392
398
ss (JSVarInitExpression x1 x2) = " JSVarInitExpression (" ++ ss x1 ++ " ) " ++ ss x2
393
399
ss (JSSpreadExpression _ x1) = " JSSpreadExpression (" ++ ss x1 ++ " )"
394
400
401
+ instance ShowStripped JSArrowParameterList where
402
+ ss (JSUnparenthesizedArrowParameter x) = ss x
403
+ ss (JSParenthesizedArrowParameterList _ xs _) = ss xs
404
+
395
405
instance ShowStripped JSModuleItem where
396
406
ss (JSModuleExportDeclaration _ x1) = " JSModuleExportDeclaration (" ++ ss x1 ++ " )"
397
407
ss (JSModuleImportDeclaration _ x1) = " JSModuleImportDeclaration (" ++ ss x1 ++ " )"
0 commit comments