Skip to content

Commit

Permalink
xml-for-php explicit close tag correct handling; obscure error with &
Browse files Browse the repository at this point in the history
Summary: <a>..</> was becoming <a>..</a>

Reviewed By: marcel

Test Plan: id

Revert Plan: ok
  • Loading branch information
Daniel Corson committed Feb 10, 2010
1 parent bba46b0 commit 86c00e6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/Lang/Php/Ast/Expr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,9 @@ instance Unparse Xml where
maybe "" (\ (w, v) -> w2With tokEquals w ++
either unparse ((tokLBrace ++) . (++ tokRBrace) . unparse) v) vMb)
attrs ++
maybe tokDiv (\ c -> tokGT ++ concatMap unparse c ++ tokLT ++
tokDiv ++ tag) content ++
maybe tokDiv (\ (c, hasExplicitCloseTag) ->
tokGT ++ concatMap unparse c ++ tokLT ++ tokDiv ++
if hasExplicitCloseTag then tag else "") content ++
tokGT

instance Unparse XmlLitOrExpr where
Expand Down Expand Up @@ -571,9 +572,10 @@ instance Parse Xml where
Left <$> parse) <|>
return Nothing
content <- (tokDivP >> tokGTP >> return Nothing) <|>
Just <$> (tokGTP >>
many (Right <$> try parse <|> Left <$> parse) <*
tokLTP <* tokDivP <* optional (string tag) <* tokGTP)
Just <$> liftM2 (,)
(tokGTP >> many (Right <$> try parse <|> Left <$> parse))
(tokLTP >> tokDivP >> ((string tag >> return True) <|> return False))
<* tokGTP
return $ Xml tag attrs content

instance Parse XmlLitOrExpr where
Expand Down
2 changes: 1 addition & 1 deletion src/Lang/Php/Ast/ExprTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ data Expr =

data Xml = Xml String
(IC.Intercal WS (String, Maybe (WS2, Either StrLit (WSCap Expr))))
(Maybe [Either XmlLitOrExpr Xml])
(Maybe ([Either XmlLitOrExpr Xml], Bool))
deriving (Eq, Show, Typeable, Data)

data XmlLitOrExpr = XmlLit String | XmlExpr (WSCap Expr)
Expand Down
2 changes: 1 addition & 1 deletion src/Lang/Php/Ast/Stmt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ cStmtConstUnparser vars = tokConst ++

instance Unparse AbstrFunc where
unparse (AbstrFunc pre ref name args ws end) = concat [unparsePre pre,
tokFunction, maybe "" ((tokAmp ++) . unparse) ref, unparse name, tokLParen,
tokFunction, maybe "" ((++ tokAmp) . unparse) ref, unparse name, tokLParen,
either unparse (intercalate tokComma . map unparse) args, tokRParen,
unparse ws, unparse end]

Expand Down
2 changes: 1 addition & 1 deletion src/Transf/FuncManip.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ transfs = [
-=- (\ [f, n] -> lexPass . killFuncArg f $ read n),
"make-public-explicit" -:- ftype -?-
"Add \"public\" to class functions without an explicit access keyword."
-=- (\ [] -> lexPass $ makePublicExplicit)]
-=- (\ [] -> lexPass makePublicExplicit)]

renameFunc :: String -> String -> Ast -> Transformed Ast
renameFunc oldF newF = modAll $ \ a -> case a of
Expand Down

0 comments on commit 86c00e6

Please sign in to comment.