Created
September 16, 2012 15:17
-
-
Save arvidj/3732804 to your computer and use it in GitHub Desktop.
lex-pass transformer: Kill trailing comma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Transf.KillTrailingComma where | |
import Lang.Php | |
import TransfUtil | |
import qualified Data.Intercal as IC | |
transfs :: [Transf] | |
transfs = [ | |
"kill-trailing-comma" -:- ftype -?- | |
"Kills trailing commas from Arrays." | |
-=- argless (lexPass $ killTrailingComma)] | |
-- optionally pretend we changed something to make this file count and force | |
-- rewrite. | |
killTrailingComma :: Ast -> Transformed Ast | |
killTrailingComma = modAll $ \ cStmt -> case cStmt of | |
StmtExpr (ExprArray a (Right (b, Just ws))) c d -> | |
let b' = init b ++ [(last b) { wsCapPost = ws}] in | |
(pure $ StmtExpr (ExprArray a (Right (b', Nothing))) c d) | |
_ -> transfNothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment