module BNFC.Backend.CPP.STL.STLUtils where
import Data.Char
import Data.Maybe (fromMaybe)
nsDefine :: Maybe String -> String -> String
nsDefine :: Maybe String -> String -> String
nsDefine Maybe String
inPackage String
h = String -> (String -> String) -> Maybe String -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
h (\String
ns -> (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper String
ns String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
h) Maybe String
inPackage
nsStart :: Maybe String -> String
nsStart :: Maybe String -> String
nsStart = String -> (String -> String) -> Maybe String -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"" (\String
ns -> String
"namespace " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
ns String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n{")
nsEnd :: Maybe String -> String
nsEnd :: Maybe String -> String
nsEnd = String -> (String -> String) -> Maybe String -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"" (String -> String -> String
forall a b. a -> b -> a
const String
"}")
nsScope :: Maybe String -> String
nsScope :: Maybe String -> String
nsScope = String -> (String -> String) -> Maybe String -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"" (String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"::")
nsString :: Maybe String -> String
nsString :: Maybe String -> String
nsString = String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe String
""