@@ -352,13 +352,48 @@ pSection = pWhite *> (
352352 <|< Section <$> pKeyWordNC " library" <*> libName <*> pFields
353353 <|< Section <$> pKeyWordNC " foreign-library" <*> pName <*> pFields
354354 <|< Section <$> pKeyWordNC " executable" <*> pName <*> pFields
355- <|< Section <$> pKeyWordNC " source-repository" <*> pName <*> pFields
356- <|< Section <$> pKeyWordNC " flag" <*> pName <*> pFields
355+ <|< Section <$> pKeyWordNC " source-repository" <*> pName <*> pSourceRepositoryFields
356+ <|< Section <$> pKeyWordNC " flag" <*> pName <*> pFlagFields
357357 <|< Section <$> pKeyWordNC " test-suite" <*> pName <*> pFields
358358 <|< Section <$> pKeyWordNC " benchmark" <*> pName <*> pFields
359359 )
360360 where libName = pName <|< pure " "
361361
362+ pSourceRepositoryFields :: P [Field ]
363+ pSourceRepositoryFields = pSpaces *> pNewLine *> emany pSourceRepositoryField
364+ where
365+ pSourceRepositoryField = do
366+ pWhite
367+ pushColumn
368+ fn <- lower <$> pFieldName
369+ pColon
370+ v <- case fn of
371+ " type" -> VItem <$> pItem
372+ " location" -> VItem <$> pItem
373+ " module" -> VItem <$> pItem
374+ " branch" -> VItem <$> pItem
375+ " tag" -> VItem <$> pItem
376+ " subdir" -> VItem <$> pItem
377+ _ -> error $ " Unknown source-repository field: " ++ fn
378+ pFieldSep
379+ pure $ Field fn v
380+
381+ pFlagFields :: P [Field ]
382+ pFlagFields = pSpaces *> pNewLine *> emany pFlagField
383+ where
384+ pFlagField = do
385+ pWhite
386+ pushColumn
387+ fn <- lower <$> pFieldName
388+ pColon
389+ v <- case fn of
390+ " description" -> pFreeText
391+ " default" -> VBool <$> pBoolNL
392+ " manual" -> VBool <$> pBoolNL
393+ _ -> error $ " Unknown flag field: " ++ fn
394+ pFieldSep
395+ pure $ Field fn v
396+
362397getParser :: FieldName -> P Value
363398getParser f =
364399 if " x-" `isPrefixOf` f then pFreeTextX else
@@ -448,12 +483,6 @@ parsers =
448483 , " main-is" # (VItem <$> pItem)
449484 , " test-module" # (VItem <$> pItem)
450485 , " type" # (VItem <$> pItem)
451- -- source-repository fields
452- , " location" # (VItem <$> pItem)
453- -- flag fields
454- , " manual" # (VBool <$> pBoolNL)
455- , " default" # (VBool <$> pBoolNL)
456- , " tag" # pFreeText
457486 ]
458487 where ( # ) = (,)
459488 -- XXX use local fixity
0 commit comments