From 5e6f45e482f84f35c4c0d793c976f6a0c7980349 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 23 Jan 2017 12:37:12 -0500 Subject: [PATCH] Flatten the for statement patterns to the top level. --- src/Language/Go.hs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Language/Go.hs b/src/Language/Go.hs index 114a2629b..ad23f3f40 100644 --- a/src/Language/Go.hs +++ b/src/Language/Go.hs @@ -28,15 +28,9 @@ termAssignment source (range :. category :. sourceSpan :. Nil) children = Just $ (Function, _) -> withDefaultInfo $ case children of [id, params, block] -> S.Function id (toList $ unwrap params) (toList $ unwrap block) rest -> S.Error rest - (For, _) -> - withDefaultInfo $ case children of - [body] | Info.category (extract body) == Other "block" -> - S.For [] (toList $ unwrap body) - [forClause, body] | Info.category (extract forClause) == Other "for_clause" -> - S.For (toList $ unwrap forClause) (toList $ unwrap body) - [rangeClause, body] | Info.category (extract rangeClause) == Other "range_clause" -> - S.For (toList $ unwrap rangeClause) (toList $ unwrap body) - other -> S.Error other + (For, [body]) | Other "block" <- Info.category (extract body) -> withDefaultInfo $ S.For [] (toList (unwrap body)) + (For, [forClause, body]) | Other "for_clause" <- Info.category (extract forClause) -> withDefaultInfo $ S.For (toList (unwrap forClause)) (toList (unwrap body)) + (For, [rangeClause, body]) | Other "range_clause" <- Info.category (extract rangeClause) -> withDefaultInfo $ S.For (toList (unwrap rangeClause)) (toList (unwrap body)) (TypeDecl, _) -> toTypeDecl children (StructTy, _) -> toStructTy children (FieldDecl, _) -> toFieldDecl children