diff --git a/src/Language/JavaScript.hs b/src/Language/JavaScript.hs index e036d2162..88e78d292 100644 --- a/src/Language/JavaScript.hs +++ b/src/Language/JavaScript.hs @@ -16,7 +16,7 @@ functions :: [Text] functions = [ "arrow_function", "generator_function", "function" ] forStatements :: [Text] -forStatements = [ "for_statement", "for_of_statement", "for_in_statement" ] +forStatements = [ "for_statement", "for_of_statement", "for_in_statement", "trailing_for_statement", "trailing_for_of_statement", "trailing_for_in_statement" ] termConstructor :: Source Char -- ^ The source that the term occurs within. @@ -29,6 +29,7 @@ termConstructor source sourceSpan name range children | name == "ERROR" = withDefaultInfo (S.Error children) | otherwise = withDefaultInfo $ case (name, children) of ("return_statement", _) -> S.Return (listToMaybe children) + ("trailing_return_statement", _) -> S.Return (listToMaybe children) ("assignment", [ identifier, value ]) -> S.Assignment identifier value ("assignment", _ ) -> S.Error children ("math_assignment", [ identifier, value ]) -> S.MathAssignment identifier value @@ -52,6 +53,7 @@ termConstructor source sourceSpan name range children ("var_assignment", [ x, y ]) -> S.VarAssignment x y ("var_assignment", _ ) -> S.Error children ("var_declaration", _) -> S.Indexed $ toVarDecl <$> children + ("trailing_var_declaration", _) -> S.Indexed $ toVarDecl <$> children ("switch_statement", expr : rest) -> S.Switch expr rest ("switch_statement", _ ) -> S.Error children ("case", [ expr, body ]) -> S.Case expr [body] @@ -60,13 +62,21 @@ termConstructor source sourceSpan name range children ("pair", _) -> S.Fixed children ("comment", _) -> S.Comment . toText $ slice range source ("if_statement", expr : rest ) -> S.If expr rest + ("trailing_if_statement", expr : rest ) -> S.If expr rest ("if_statement", _ ) -> S.Error children + ("trailing_if_statement", _ ) -> S.Error children ("while_statement", expr : rest ) -> S.While expr rest + ("trailing_while_statement", expr : rest ) -> S.While expr rest ("while_statement", _ ) -> S.Error children + ("trailing_while_statement", _ ) -> S.Error children ("do_statement", [ expr, body ]) -> S.DoWhile expr body + ("trailing_do_statement", [ expr, body ]) -> S.DoWhile expr body ("do_statement", _ ) -> S.Error children + ("trailing_do_statement", _ ) -> S.Error children ("throw_statement", [ expr ]) -> S.Throw expr + ("trailing_throw_statement", [ expr ]) -> S.Throw expr ("throw_statment", _ ) -> S.Error children + ("trailing_throw_statment", _ ) -> S.Error children ("new_expression", [ expr ]) -> S.Constructor expr ("new_expression", _ ) -> S.Error children ("try_statement", _) -> case children of @@ -114,6 +124,7 @@ categoryForJavaScriptProductionName :: Text -> Category categoryForJavaScriptProductionName name = case name of "object" -> Object "expression_statement" -> ExpressionStatements + "trailing_expression_statement" -> ExpressionStatements "this_expression" -> Identifier "null" -> Identifier "undefined" -> Identifier @@ -125,13 +136,18 @@ categoryForJavaScriptProductionName name = case name of "delete_op" -> Operator -- delete operator, e.g. delete x[2]. "type_op" -> Operator -- type operator, e.g. typeof Object. "void_op" -> Operator -- void operator, e.g. void 2. + "for_statement" -> For + "trailing_for_statement" -> For "for_in_statement" -> For + "trailing_for_in_statement" -> For "for_of_statement" -> For + "trailing_for_of_statement" -> For "new_expression" -> Constructor "class" -> Class "catch" -> Catch "finally" -> Finally "if_statement" -> If + "trailing_if_statement" -> If "empty_statement" -> Empty "program" -> Program "ERROR" -> Error @@ -155,17 +171,21 @@ categoryForJavaScriptProductionName name = case name of "template_string" -> TemplateString "var_assignment" -> VarAssignment "var_declaration" -> VarDecl + "trailing_var_declaration" -> VarDecl "switch_statement" -> Switch "math_assignment" -> MathAssignment "case" -> Case "true" -> Boolean "false" -> Boolean "ternary" -> Ternary - "for_statement" -> For "while_statement" -> While + "trailing_while_statement" -> While "do_statement" -> DoWhile + "trailing_do_statement" -> DoWhile "return_statement" -> Return + "trailing_return_statement" -> Return "throw_statement" -> Throw + "trailing_throw_statement" -> Throw "try_statement" -> Try "method_definition" -> Method "comment" -> Comment