diff options
Diffstat (limited to 'Omni/Bild/Meta.hs')
-rw-r--r-- | Omni/Bild/Meta.hs | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/Omni/Bild/Meta.hs b/Omni/Bild/Meta.hs index 44bcff0..a5f722e 100644 --- a/Omni/Bild/Meta.hs +++ b/Omni/Bild/Meta.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE NoImplicitPrelude #-} @@ -6,7 +5,6 @@ module Omni.Bild.Meta where import Alpha -import qualified Data.Aeson as Aeson import qualified Data.Char as Char import qualified Data.Set as Set import qualified Data.Text as Text @@ -29,15 +27,7 @@ type Run = String -- command. Should be used sparingly, and not all builds will support this. type Arg = String -data Out = Lib String | Bin String | None - deriving (Show, Eq) - -instance Aeson.ToJSON Out where - toJSON = - Aeson.String <. Text.pack <. \case - Bin a -> a - Lib a -> a - None -> "" +type Out = Maybe String data Parsed = Parsed { pdep :: Set Dep, @@ -56,19 +46,24 @@ detect m cl = |> Set.fromList -- | 'Out' is always singular, so it gets a special function -detectOut :: Regex.RE Char Out -> [Text] -> Out +detectOut :: Regex.RE Char String -> [Text] -> Out detectOut m cl = cl /> Text.unpack /> Regex.match m |> catMaybes |> head - |> fromMaybe None -detectAll :: [Char] -> [Text] -> Parsed +-- | Detect all metadata +detectAll :: + -- | The comment character(s) to match on + [Char] -> + -- | Lines of text to parse + [Text] -> + Parsed detectAll m cl = Parsed {..} where - pout = detectOut (out m <|> lib m) cl + pout = detectOut (out m) cl detect_ re = detect (re m) cl pdep = detect_ dep psys = detect_ sys @@ -85,17 +80,10 @@ sys comment = Regex.string (comment ++ " : sys ") *> Regex.many (Regex.psym (not <. Char.isSpace)) -out :: [Char] -> Regex.RE Char Out +out :: [Char] -> Regex.RE Char String out comment = Regex.string (comment ++ " : out ") *> Regex.many (Regex.psym (/= ' ')) - /> Bin - -lib :: [Char] -> Regex.RE Char Out -lib comment = - Regex.string (comment ++ " : lib ") - *> Regex.many (Regex.psym (/= ' ')) - /> Lib arg :: [Char] -> Regex.RE Char Arg arg comment = |