mirror of https://github.com/zachjs/sv2v.git
minor codegen cleanup
This commit is contained in:
parent
d2a18e01f2
commit
ecaaec9c00
|
|
@ -126,7 +126,7 @@ data Args
|
||||||
deriving (Eq, Ord)
|
deriving (Eq, Ord)
|
||||||
|
|
||||||
instance Show Args where
|
instance Show Args where
|
||||||
show (Args pnArgs kwArgs) = "(" ++ (commas strs) ++ ")"
|
show (Args pnArgs kwArgs) = '(' : commas strs ++ ")"
|
||||||
where
|
where
|
||||||
strs = (map show pnArgs) ++ (map showKwArg kwArgs)
|
strs = (map show pnArgs) ++ (map showKwArg kwArgs)
|
||||||
showKwArg (x, e) = printf ".%s(%s)" x (show e)
|
showKwArg (x, e) = printf ".%s(%s)" x (show e)
|
||||||
|
|
@ -177,10 +177,10 @@ showAssignment val = " = " ++ show val
|
||||||
|
|
||||||
showRanges :: [Range] -> String
|
showRanges :: [Range] -> String
|
||||||
showRanges [] = ""
|
showRanges [] = ""
|
||||||
showRanges l = " " ++ (concatMap showRange l)
|
showRanges l = ' ' : concatMap showRange l
|
||||||
|
|
||||||
showRange :: Range -> String
|
showRange :: Range -> String
|
||||||
showRange (h, l) = printf "[%s:%s]" (show h) (show l)
|
showRange (h, l) = '[' : show h ++ ':' : show l ++ "]"
|
||||||
|
|
||||||
showUniOpPrec :: Expr -> ShowS
|
showUniOpPrec :: Expr -> ShowS
|
||||||
showUniOpPrec (e @ UniOp{}) = (showParen True . shows) e
|
showUniOpPrec (e @ UniOp{}) = (showParen True . shows) e
|
||||||
|
|
@ -198,6 +198,5 @@ showParams params = indentedParenList $ map showParam params
|
||||||
|
|
||||||
showParam :: ParamBinding -> String
|
showParam :: ParamBinding -> String
|
||||||
showParam ("*", Right Nil) = ".*"
|
showParam ("*", Right Nil) = ".*"
|
||||||
showParam (i, arg) =
|
showParam ("", arg) = showEither arg
|
||||||
printf fmt i (either show show arg)
|
showParam (i, arg) = printf ".%s(%s)" i (showEither arg)
|
||||||
where fmt = if i == "" then "%s%s" else ".%s(%s)"
|
|
||||||
|
|
|
||||||
|
|
@ -57,4 +57,4 @@ showEither (Right v) = show v
|
||||||
showBlock :: (Show a, Show b) => [a] -> [b] -> String
|
showBlock :: (Show a, Show b) => [a] -> [b] -> String
|
||||||
showBlock a [] = indent $ show a
|
showBlock a [] = indent $ show a
|
||||||
showBlock [] b = indent $ show b
|
showBlock [] b = indent $ show b
|
||||||
showBlock a b = indent $ show a ++ "\n" ++ show b
|
showBlock a b = indent $ show a ++ '\n' : show b
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue